下記のdll関数を使用してビットマップ画像のサイズを変更(拡大縮小)しようとしています
{ 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;
このアプリケーション呼び出しを使用すると(リストビュー内のすべての画像をフィードするために)正常に機能します。
//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
exe pasファイル内で同じ関数(ResizeImg
)を定義して使用すると、エラーなしで完全に正常に動作します。