Use graphicex to convert BMP to PNG. After transfer, it is still in BMP format. I do not know how to write it? Delphi/Windows SDK/API
Http://www.delphi2007.net/DelphiMultimedia/html/delphi_20061008142348265.html
PNG: = tpnggraphic. Create;
Try
Image1.picture. loadfromfile (sbmpname );
If image1.picture. Graphic is tbitmap then
PNG. Assign (image1.picture. Graphic)
Else
Begin
PNG. pixelformat: = pf16bit;
PNG. Width: = image1.picture. width;
PNG. Height: = image1.picture. height;
PNG. Canvas. Draw (0, 0, image1.picture. Graphic );
End;
PNG. savetofile (ssavename );
Finally
PNG. Free;
End;
Use GDI +
Function tmainform. savefiletopng (savebmp: tbitmap32; filename: string): Boolean;
VaR
B: tbitmap32;
Encoderclsid: tguid;
Tempgbitmap: tgpbitmap;
I, J: integer;
Color: Cardinal;
Stat: tstatus;
Begin
Result: = false;
B: = tbitmap32.create;
B. drawmode: = dmblend;
B. Assign (savebmp );
Tempgbitmap: = tgpbitmap. Create (B. Width, B. Height, pixelformat32bppargb );
For I: = 0 to B. Width-1 do
For J: = 0 to B. Height-1 do
Begin
Color: = B. pixel [I, j];
Tempgbitmap. setpixel (I, j, color );
End;
Getencoderclsid ('image/PNG ', encoderclsid );
Stat: = tempgbitmap. Save (filename, encoderclsid, nil );
If stat = OK then
Result: = true;
End;
See my reply in the following post:
Http://community.csdn.net/Expert/topic/5172/5172039.xml? Temp =. 6034052.