![]() |
BMP in JPG Umwandlung funktioniert nicht
Ich habe ein grosses Problem. Wenn ich das Programm ausführe, wird ein runtime error erzeugt.
Hier der Code:
Delphi-Quellcode:
Was ist da dran falsch?????
var
Bmp: TBitmap; Jpg: TJpegImage; begin Bmp := TBitmap.Create; Jpg := TJpegImage.Create; try Bmp:=form1.Image1.Picture.Bitmap; Jpg.CompressionQuality:=spinedit1.Value; Jpg.Assign(Bmp); Jpg.SaveToFile(form1.SaveDialog1.FileName + '.jpg'); finally Jpg.Free; Bmp.Free; end; Close; end; mfg Gauggi |
Re: BMP in JPG Umwandlung funktioniert nicht
Ganz klar. Du erzeugst ein Bitmap, weißt dem Bmp aber die Referenz eines anderen Bitmaps zu und gibst dann dieses Bitmap frei.
Dann hast Du eine Speicherlücke sund form1.Image1 steht ohne gültiges Bitmap da. |
Re: BMP in JPG Umwandlung funktioniert nicht
Zitat:
|
Re: BMP in JPG Umwandlung funktioniert nicht
Delphi-Quellcode:
//bmp holen
Bmp.Assign(Image1.Picture.Bitmap); //bmp manipulieren ... //bmp zurückschreiben Image1.Picture.Bitmap.Assign(bmp); //puffer freigeben bmp.Free; |
Re: BMP in JPG Umwandlung funktioniert nicht
Das
Delphi-Quellcode:
kannst du dir in deinem Fall sparen
//bmp zurückschreiben
Image1.Picture.Bitmap.Assign(bmp); |
Re: BMP in JPG Umwandlung funktioniert nicht
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:41 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz