개발자료/Delphi
GDI+ Image Encoders and Decoders
구룡포과메기
2013. 10. 23. 20:31
Saving an image in a certain format (such as JPEG or PNG) takes a couple of steps in the C++ version. You would have to enumerate all encoders that are installed on the system to find the encoder you are interested in. This enumeration would also take a couple of steps. For standard formats like BMP, GIF, JPEG, PNG and TIFF, this library allows you the specify the format directly without any encoder enumeration:
var
Bitmap: IGPBitmap;
begin
Bitmap := TGPBitmap.Create(200, 100);
Bitmap.Save('Output.png', TGPImageFormat.Png);
end;
You can still enumerate encoders if you need to. This has been simplified too since the class function TGPImageCodecInfo.GetImageEncoders returns an array of all installed encoders:
var
Bitmap: IGPBitmap;
Codec: IGPImageCodecInfo;
begin
Bitmap := TGPBitmap.Create(200, 100);
for Codec in TGPImageCodecInfo.GetImageEncoders do
if SameText(Codec.MimeType, 'image/targa') then
begin
Bitmap.Save('Output.tga', Codec);
Break;
end;
end;
출처 : http://www.bilsen.com/gdiplus/index.shtml