Tjpegscale = (jsfullsize, jshalf, Jsquarter, jseighth);//Picture size (all, 1/2,1/4,1/8)
tbitmap.pixelformat:=pf8bit;//number of pictures (8,24)
To provide you with a few commonly used image format conversion method and its conversion function
I hope I can help you.
1. ico icon to convert BMP format
2.32x32 BMP format image converted to ICO format
3. Convert bmp->jpeg file format
4.JPEG conversion to BMP function
5.BMP convert to JPEG file Format function
------------------------------------------------------------------------------------------
1.chinese:ico icon Conversion BMP format
中文版:(Conversion from ICO to BMP)
--------------------------------------------------------
Procedure Tform1.button1click (Sender:tobject);
var windc, SRCDC, DESTDC:HDC;
Oldbitmap:hbitmap;
Iinfo:ticoninfo;
Begin
Geticoninfo (Image1.Picture.Icon.Handle, iinfo);
WINDC: = GetDC (handle);
SRCDC: = CreateCompatibleDC (WINDC);
DESTDC: = CreateCompatibleDC (WINDC);
Oldbitmap: = SelectObject (DESTDC, Iinfo.hbmcolor);
Oldbitmap: = SelectObject (SRCDC, Iinfo.hbmmask);
BitBlt (destdc, 0, 0, Image1.picture.icon.width,
Image1.picture.icon.height,
SRCDC, 0, 0, srcpaint);
Image2.picture.bitmap.handle: = SelectObject (DESTDC, Oldbitmap);
DeleteDC (DESTDC);
DeleteDC (SRCDC);
DeleteDC (WINDC);
Image2. Picture.Bitmap.savetofile (Extractfilepath (Application.exename)
+ ' myfile.bmp ');
End
Procedure Tform1.formcreate (Sender:tobject);
Begin
Image1.picture.icon.loadfromfile (' C:\myicon.ico ');
End
End.
==================================================================
3. Chinese: Convert bmp->jpeg file format
Englsh:convert the bitmap into a JPEG file format
------------------------------------------------------------------
Var
Myjpeg:tjpegimage;
Image1:timage;
Begin
Image1:= timage.create;
Myjpeg:= tjpegimage.create;
Image1.loadfromfile (' testimage.bmp '); Read Bitmap file
Myjpeg.assign (IMAGE1.PICTURE.BITMAP);
Object
Myjpeg.savetofile (' myjpegimage.jpg '); Save JPEG
End
--------------------------------------------------------------------
4.JPEG conversion to BMP function
procedure jpg2bmp (const source,dest:string);
var
Myjpeg:tjpegimage;
Bmp:tbitmap;
Begin
Bmp:=tbitmap. Create;
myjpeg:= tjpegimage.create;
Try
myjpeg. LoadFromFile (source);
BMP. Assign (Myjpeg);
BMP. SaveToFile (dest);
finally
Bmp.free;
Myjpeg. Free;
End;
End;
----------------------------------------------------------
5.BMP convert to JPEG file Format function
----------------------------------------------------------
Procedure bmp2jpg (const source,dest:string;const scale:byte);
Var
Myjpeg:tjpegimage;
Image1:timage;
Begin
image1:= timage.create (application);
Myjpeg:= tjpegimage.create;
Try
Image1.Picture.Bitmap.LoadFromFile (source);
Myjpeg.assign (IMAGE1.PICTURE.BITMAP);
Myjpeg.compressionquality:=scale;
myjpeg.compress;
Myjpeg.savetofile (dest);
Finally
Image1.free;
Myjpeg. Free;
End
End
-----------------------------------------------------------------------
[Delphi Technology] Delphi Common Image Format conversion technology