TBitmap.ScanLine[] 执行时间过长
我正在与德尔福合作。我在代码中使用 bmp.ScanLine[]
。我的代码如下:
bmp := TBitmap.Create;
bmp.Height := imgMain.Height;
bmp.Width := imgMain.Width;
for i := 0 to imgMain.Height - 1 do begin
prgb := bmp.ScanLine[i];
p1 := imgMain.ScanLine[i];
for j := 0 to imgMain.Width - 1 do begin
//Some code
end;
end;
这里,imgMain 是 TBitmap 类型。我的问题是,当我执行这段代码时,它花费了太多时间
prgb := bmp.ScanLine[i];
p1 := imgMain.ScanLine[i];
,请告诉我哪里错了?
I am working with Delphi. I am using bmp.ScanLine[]
in my code. My code is as follows :
bmp := TBitmap.Create;
bmp.Height := imgMain.Height;
bmp.Width := imgMain.Width;
for i := 0 to imgMain.Height - 1 do begin
prgb := bmp.ScanLine[i];
p1 := imgMain.ScanLine[i];
for j := 0 to imgMain.Width - 1 do begin
//Some code
end;
end;
Here, imgMain is of TBitmap type. My problem is when I execute this code, it takes too much time on the lines
prgb := bmp.ScanLine[i];
p1 := imgMain.ScanLine[i];
Please, tell me where I am wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,可以获得一些东西(介绍 rowpitch,见下文),但这并不算太多。可能将 for 循环更改为 while 循环,该循环执行指针增量并与最后一个像素的指针值进行比较
另请参阅旋转位图。在代码中,例程执行类似的操作以快速旋转图像。
一直分配 bmp 也可能很昂贵,特别是如果它们很大,请使用池来避免重复分配。
Hmm, something can be gained (introducing rowpitch, see below) but that is not too much. Probably changing the for loop to a while loop that does pointer increment and compares with a pointer value of the last pixel
See also rotating bitmaps. In code for a routine that does things like this to rotate an image fast.
Allocating bmps all the time can be expensive too, specially if they are large, use pools to avoid repeated allocation.