![]() ![]() Note that the TBitmap employs a LoadFromFile method that can load a file, say Handshak.bmp, into the bitmap, but you must use the SaveToStream method from the TJPEGImage to save the JPEG image to a file stream again. Using that information, you can write a simple CONSOLE application to convert a given BMP file to a JPEG file. You assign an instance of a TBitmap containing a picture in BMP format to an instance of a TJPEGImage, converting the picture from BMP to JPEG along the way. The TJPEGImage component is derived from TGraphic, so it’s Assign-compatible with a TBitmap (also derived form TGraphic). (Don’t tell me you never look at the Info directory of your Delphi CD-it contains many goodies.) If you’re looking for the source code, check out the Info\Extras\JPEG directory of your Delphi CD-ROM. ![]() The LoadFromFile and SaveToFile methods from the TImage component can load a BMP file, but if you save it to a file with the JPG extension, you will still get the BMP format inside.įortunately, Delphi 3 also added a hidden component not present on the component palette called TJPEGImage, which is declared and implemented in the JPEG unit (and the VCLJPG package). However, being able to display a format is not the same as being able to transform one format to another. For a little background info on graphics formats, check out this sidebar.Īs of Delphi 3, the regular TImage component from the Additional tab of the Delphi component palette can display files in different formats, such as BMP, ICO, WMF/EMF, and JPEG. I will walk you through the code that converts BMPs to JPEGs and then converts them back to BMPs. I store the original BMP files on CDs and use a Delphi application to convert them to JPEG files. I frequently need two versions of images-JPEGs for my Web site and BMPs for my magazine articles. Thanks to a hidden component, it's not as hard as you might think. Delphi’s TJPEGImage lets you transform BMPs to JPEGsĭelphi guru Bob Swart shares a trick for programmatically transforming BMPs to JPEGs and vice versa. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |