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;