Convert BMP to jpeg jpg to BMP in Delphi

Source: Internet
Author: User
Convert BMP to jpeg jpg to BMP in Delphi

Transferred from

Xjq2003 Column


Thank you

; ---- Convert BMP to JPEG -----


Uses JPEG;
Procedure tform1.button1click (Sender: tobject );
VaR
JPG: tsf-image;
BMP: tbitmap;
Begin
JPG: = tsf-image. Create;
BMP: = tbitmap. Create;
BMP. loadfromfile ('H:/Avi _ fig _ WAV/ .bmp ');
JPG. Assign (BMP );
JPG. savetofile ('H:/Avi _ fig _ WAV/. jpg ');
BMP. Free;
JPG. Free;
End;


// --------------- Convert JPG to BMP -----------------

Procedure tform1.button1click (Sender: tobject );
VaR
Myjpeg: tsf-image;
Mybmp: tbitmap;
Begin
Myjpeg: = tsf-image. Create;
With myjpeg do begin
Loadfromfile ('wwhier. JPEG ');
Mybmp: = tbitmap. Create;
With mybmp do begin
Width: = myjpeg. width;
Height: = myjpeg. height;
Canvas. Draw (0, 0, myjpeg );
Savetofile ('uwbmphier. BMP ');
Free;
End;
Free;
End;
End;
========================================================== ==============================
// JPEG and bitmaps
VaR
Myjpeg: tsf-image;
Image1: timage;
Begin
Image1: = timage. Create;
Myjpeg: = tsf-image. Create;
Image1.loadfromfile ('testimage. BMP '); // load the bitmap from a file
Myjpeg. Assign (image1.picture. Bitmap); // assign the bitmap to myjpeg
Object
Myjpeg. savetofile ('myphoto image. jpg '); // Save the JPEG to disk
End;
----------------------------------------
Convert JPG to BMP
... Convert JPG to BMP?

VaR
JPEG: tsf-image;
BMP: tbitmap;
Begin
JPEG: = tsf-image. Create;
Try
JPEG. loadfromfile (filename );
BMP: = tbitmap. Create;
Try
BMP. Assign (JPEG );
BMP. savetofile (changefileext (filename, '. BMP '));
Finally
BMP. Free
End;
Finally
JPEG. Free
End;
End;
-------------------------------------------
Procedure tform1.button1click (Sender: tobject );
VaR
BMP: tbitmap;
JPG: tsf-image;
Begin
BMP: = tbitmap. Create;
JPG: = tsf-image. Create;
JPG. loadfromfile ('G:/VCL/menu_directory/Color panel/river. jpg ');
BMP. Assign (JPG );
BMP. savetofile ('G:/VCL/menu_directory/Color panel/river.bmp ');
JPG. Free;
BMP. Free;
End;
---------------------------------
Convert JPG to BMP?
VaR JPEG: tsf-image;
BMP: tbitmap;
Begin
JPEG: = tsf-image. Create;
Try jpeg. loadfromfile (filename );
BMP: = tbitmap. Create;
Try BMP. Assign (JPEG );
BMP. savetofile (changefileext (filename, '. BMP '));
Finally
BMP. Free
End; finally
JPEG. Free
End;
End;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.