全部博文(788)
分类:
2009-03-13 10:34:44
用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;
请参见下面帖中我的回复: