How can I make a thumbnail from a JPG or PNG and load that thumbnail into a TImage
control?
I've tried stuff like this, but the TImage
does not look like is loading something.
Image2
is a TImage
control.
function resize2(source: string): TBitmap;
var
BMPFile, ScreenBMP: TBitmap;
begin
BMPFile := TBitmap.Create;
try
BMPFile.LoadFromFile(source);
ScreenBMP := TBitmap.Create;
ScreenBMP.PixelFormat := BMPFile.PixelFormat;
ScreenBMP.Width := 10;
ScreenBMP.Height := 10;
ScreenBMP.Canvas.StretchDraw(Rect(0,0, ScreenBMP.Width, ScreenBMP.Height), BMPFile);
Result := ScreenBMP;
finally
BMPFile.Free;
end;
end;
procedure TAlpha.dbeditTextBoxChange(Sender: TObject);
var
pic1: string;
mimapa: TBitmap;
begin
try
pic1 := dm.TableNotes.FieldByName('PathPic').AsVariant;
mimapa := resize2(pic1);
//all of these are not working
Image2.Assign(mimapa);
image2.Picture.Bitmap := mimapa;