我想用这将在下文中提到德尔福DLL映像stretchdraw错误
{ to resize the image }
function ResizeImg(maxWidth,maxHeight: integer;thumbnail : TBitmap): TBitmap;
var
thumbRect : TRect;
begin
thumbRect.Left := 0;
thumbRect.Top := 0;
if thumbnail.Width > maxWidth then
begin
thumbRect.Right := maxWidth;
end
else
begin
thumbRect.Right := thumbnail.Width;;
end;
if thumbnail.Height > maxHeight then
begin
thumbRect.Bottom := maxHeight;
end
else
begin
thumbRect.Bottom := thumbnail.Height;
end;
thumbnail.Canvas.StretchDraw(thumbRect, thumbnail) ;
//resize image
thumbnail.Width := thumbRect.Right;
thumbnail.Height := thumbRect.Bottom;
//display in a TImage control
Result:= thumbnail;
end;
当我使用这个应用程序调用它正常工作,一个DLL函数(养活所有的图像调整大小(规模)的位图图像我的列表视图):
//bs:TStream; btmap:TBitmap;
bs := CreateBlobstream(fieldbyname('Picture'),bmRead);
bs.postion := 0;
btmap.Loadfromstream(bs);
ListView1.Items[i].ImageIndex := ImageList1.Add(ResizeImg(60,55,btmap), nil);
但是当我尝试此应用程序调用(以获得单个图像到我的TImage组件):
bs := CreateBlobstream(fieldbyname('Picture'),bmRead);
bs.postion := 0;
btmap.Loadfromstream(bs);
Image1.Picture.Bitmap := ResizeImg(250,190,btmap);
它给了我一个错误的:
thumbnail.Canvas.StretchDraw(thumbRect, thumbnail) ;
说:
AV at address 00350422 in module 'mydll.dll' Read of Address 20000027
当我结束我的可执行文件,我得到这样的:
runtime error 216 at 0101C4BA
如果我定义和使用相同的函数(ResizeImg
)在我的EXE pas文件里面,它工作得很好,没有任何错误。
该函数意味着给出完全不同的TBitmap,但它只是返回输入TBitmap。我建议将这个例程重构成一个过程。 – NGLN
我不能使用它的过程,因为我将函数的结果分配给其他组件 – Shirish11