Board index » delphi » Bitmap to JPEG
Asko Korpela
![]() Delphi Developer |
Asko Korpela
![]() Delphi Developer |
Bitmap to JPEG2006-10-09 06:56:32 AM delphi259 How to load or assign a bitmap to jpg in Delphi 2006? What is wrong in this? (Access violation) ScanFotoImage.Picture.SaveToFile(ApuDir+'\Scan02.bmp'); jpg := TJPEGImage.Create; jpg.DIBNeeded; jpg.LoadFromFile(ApuDir+'\Scan02.bmp'); // jpg.Assign(ScanFotoImage.Picture.Graphic); -- Asko Korpela www.askokorpela.fi/ +358(0)50 529 9539 |
Nicholas Sherlock
![]() Delphi Developer |
2006-10-09 07:42:38 AM
Re:Bitmap to JPEG
Asko Korpela writes:
QuoteHow to load or assign a bitmap to jpg in Delphi 2006? I seem to remember that setting 'graphic' will free the old graphic for you. In that case, you can use something like: var jpg:TJpegImage; jpg:=TJpegImage.create; jpg.assign(ScanFotoImage.picture.graphic); ScanFotoImage.picture:=jpg; QuoteWhat is wrong in this? (Access violation) Nicholas Sherlock -- www.sherlocksoftware.org |
JD
![]() Delphi Developer |
2006-10-09 10:24:02 AM
Re:Bitmap to JPEG
Nicholas Sherlock <XXXX@XXXXX.COM>writes:
Quote
jpg.assign( the name of the TBitmap ); ~ JD |
Asko Korpela
![]() Delphi Developer |
2006-10-09 06:11:00 PM
Re:Bitmap to JPEG
Thank you. Did I understand correct
jpg := TJPEGImage.Create; jpg.Assign(ApuDir+'\Scan01.bmp'); This follows: [Pascal Error] Unit1.pas(122): E2010 Incompatible types: 'TPersistent' and 'string' -- Asko Korpela www.askokorpela.fi/ +358(0)50 529 9539 "JD" <XXXX@XXXXX.COM>kirjoitti viestiss?4529b2c2$XXXX@XXXXX.COM... Quote
|
willem van deursen
![]() Delphi Developer |
2006-10-09 06:17:47 PM
Re:Bitmap to JPEG
See
www.scalabium.com/faq/dct0042.htm for an example For more examples: google on 'Delphi bitmap jpeg' Willem Asko Korpela writes: QuoteThank you. Did I understand correct XXXX@XXXXX.COM replace _nospam@nospam_ for @ to get a valid email address www.carthago.nl |
Asko Korpela
![]() Delphi Developer |
2006-10-09 06:45:25 PM
Re:Bitmap to JPEG
Thank you very much.
The following really seems to work: ApuBitmap.SaveToFile(ApuDir+'\Scan01.bmp'); ApuBitmap.Free; ScanFotoImage.Picture.LoadFromFile(ApuDir+'\Scan01.bmp'); jpg := TJPEGImage.Create; jpg.assign(ScanFotoImage.picture.graphic); jpg.SaveToFile(ApuDir+'\Scan01.jpg'); ScanFotoImage.Picture.LoadFromFile(ApuDir+'\Scan01.jpg'); -- Asko Korpela www.askokorpela.fi/ +358(0)50 529 9539 "Nicholas Sherlock" <XXXX@XXXXX.COM>kirjoitti viestiss?XXXX@XXXXX.COM... QuoteAsko Korpela writes: |
Dennis Passmore
![]() Delphi Developer |
2006-10-09 06:51:23 PM
Re:Bitmap to JPEG |
willem van deursen
![]() Delphi Developer |
2006-10-09 06:54:03 PM
Re:Bitmap to JPEG
Make sure to free your jpg afterwards, (and add a try..finally block) to
avoid memory leaks. ... ScanFotoImage.Picture.LoadFromFile(ApuDir+'\Scan01.bmp'); jpg := TJPEGImage.Create; try jpg.assign(ScanFotoImage.picture.graphic); jpg.SaveToFile(ApuDir+'\Scan01.jpg'); finally jpg.Free; end; ScanFotoImage.Picture.LoadFromFile(ApuDir+'\Scan01.jpg'); ... Willem Asko Korpela writes: QuoteThank you very much. XXXX@XXXXX.COM replace _nospam@nospam_ for @ to get a valid email address www.carthago.nl |
Nicholas Sherlock
![]() Delphi Developer |
2006-10-10 03:10:33 AM
Re:Bitmap to JPEG
Asko Korpela writes:
QuoteThank you very much. disk, and want to show the jpeg in your picture afterwards, use: ApuBitmap.SaveToFile(ApuDir+'\Scan01.bmp'); jpg := TJPEGImage.Create; jpg.assign(ApuBitmap); ApuBitmap.Free; jpg.SaveToFile(ApuDir+'\Scan01.jpg'); ScanFotoImage.Picture.Graphic:=jpg; If you don't really need the bitmap, you can use: jpg := TJPEGImage.Create; jpg.assign(ApuBitmap); ApuBitmap.Free; jpg.SaveToFile(ApuDir+'\Scan01.jpg'); ScanFotoImage.Picture.Graphic:=jpg; Cheers, Nicholas Sherlock -- www.sherlocksoftware.org |