如何能让图像显示的快一些?

gioc 2006-08-26 01:01:40
程序中有一个500*500的二维数组,存放的是一个500*500像素,颜色为16位的图像。

我现在用如下方法来作:
for (int i=0;i<500;i++)
{
for (int j=0;j<500;j++)
{
Image1->Canvas->Pixels[i][j]=a[i][j];
}
}
感觉速度慢,有没有什么方法能更快一些?

另:16位的颜色如何转化成32位颜色?

刚接触图像编程,请大家不吝赐教!!
...全文
297 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
gioc 2006-08-29
  • 打赏
  • 举报
回复
楼上说的是!今天看了一些书,懂了一些,今晚上试一试,估计就有结果了!
hsn1982 2006-08-29
  • 打赏
  • 举报
回复
HDC hdc,// handle to device context
在bcb中就是image1->Canvas->Handle
Joininthefun 2006-08-28
  • 打赏
  • 举报
回复
guanzhu
gioc 2006-08-28
  • 打赏
  • 举报
回复
BOOL BitBlt(
HDC hdcDest, // handle to destination device context
int nXDest, // x-coordinate of destination rectangle's upper-left
// corner
int nYDest, // y-coordinate of destination rectangle's upper-left
// corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
HDC hdcSrc, // handle to source device context
int nXSrc, // x-coordinate of source rectangle's upper-left
// corner
int nYSrc, // y-coordinate of source rectangle's upper-left
// corner
DWORD dwRop // raster operation code
);

int SetDIBitsToDevice(
HDC hdc, // handle to device context
int XDest, // x-coordinate of upper-left corner of
// dest. rect.
int YDest, // y-coordinate of upper-left corner of
// dest. rect.
DWORD dwWidth, // source rectangle width
DWORD dwHeight, // source rectangle height
int XSrc, // x-coordinate of lower-left corner of
// source rect.
int YSrc, // y-coordinate of lower-left corner of
// source rect.
UINT uStartScan, // first scan line in array
UINT cScanLines, // number of scan lines
CONST VOID *lpvBits, // address of array with DIB bits
CONST BITMAPINFO *lpbmi, // address of structure with bitmap info.
UINT fuColorUse // RGB or palette indexes
);

我在VC里用StretchBlt实现了,挺快的!

可是这些API函数,都有HDC hdc,// handle to device context这样的参数,在CB中这个参数怎么赋值,怎么调用呢?
tanlim 2006-08-28
  • 打赏
  • 举报
回复
使用PIXELS只是对于BMP格式类型的文件有效,
对于显示加速的方法还是有很多知识点的,我记得BCB5版本的有一本书详细讲解了类似于ACDSEE的一样的加速方法,当然进行内存预读是加速显示的通用方法。
yinxu 2006-08-28
  • 打赏
  • 举报
回复
可以这样,你在内存里面建立一块画布,然后通过:
for (int i=0;i<500;i++)
{
for (int j=0;j<500;j++)
{
MemObj->Canvas->Pixels[i][j]=a[i][j];
}
}
画上去,在需要的时候,比如:响应WM_PAINT,通过bitblt等函数拷到屏幕.
gioc 2006-08-27
  • 打赏
  • 举报
回复
那么16位的颜色如何转化成32位颜色?文件里没有提供调色板。
gioc 2006-08-27
  • 打赏
  • 举报
回复
SetDIBitsToDevice怎么用,最好给个例子程序!

还有16位的颜色如何转换成24位的真彩?系统不是设置成16位色的吗?可怎么没用讲16位色的呢?到处都是讲256色或16色。
cczlp 2006-08-27
  • 打赏
  • 举报
回复
用SetDIBitsToDevice
gioc 2006-08-27
  • 打赏
  • 举报
回复
iec(冰冰凉) ( ) 信誉:88 Blog 2006-8-26 1:33:49 得分: 0
BYTE *lpbitmap=(BYTE*) new BYTE[500*500*2];
SetBitmapBits(Image1->Picture->Bitmap->Handle,500*500*2,lpbitmap);
Image1->Refresh();

-------------------------------------------------
iec(冰冰凉) ,你的方法我试了,SetBitmapBits函数返回的总是0,是失败的。所以不起作用!

到底怎么用?





zwh202342 2006-08-26
  • 打赏
  • 举报
回复
9494!楼上的不错!楼主可参考以下!
iec 2006-08-26
  • 打赏
  • 举报
回复
delete lpbitmap;
SetBitmapBits 这个函数很快的.
iec 2006-08-26
  • 打赏
  • 举报
回复
BYTE *lpbitmap=(BYTE*) new BYTE[500*500*2];
SetBitmapBits(Image1->Picture->Bitmap->Handle,500*500*2,lpbitmap);
Image1->Refresh();

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧