Hi. I have some problem with converting jpg to TBitmap.
I'l try that code:
function JpegToBitmap(jpeg: string):TBitmap;
var
jpg:TJpegImage;
bmp:TBitmap;
begin
bmp := TBitmap.Create;
jpg:=TJpegImage.Create;
try
jpg.LoadFromFile(jpeg);
Bmp.Height := jpg.Height;
Bmp.Width := jpg.Width;
Bmp.PixelFormat := pf24bit;
Bmp.Canvas.Draw(0, 0, jpg);
bmp.Assign(jpg);
result:=bmp;
finally
jpg.Free;
bmp.Free;
end;
end;
but that give me error in Picture.inc in function
procedure TPicture.SetGraphic(Value: TGraphic);
var
NewGraphic: TGraphic;
ok: boolean;
begin
if (Value=FGraphic) then exit;
NewGraphic := nil;
ok := False;
try
if Value <> nil then
begin
NewGraphic := TGraphicClass(Value.ClassType).Create;
NewGraphic.Assign(Value);
NewGraphic.OnChange := @Changed;
NewGraphic.OnProgress := @Progress;
end;
FGraphic.Free;
FGraphic := NewGraphic;
Changed(Self);
ok := True;
finally
// this try..finally construction will in case of an exception
// not alter the error backtrace output
if not ok then
NewGraphic.Free;
end;
in line NewGraphic.Assign(Value). How i can convert jpg to TBitmap?
PS: Win7 32, lazarus 0.9.30.4 + fpc 2.6.0.