var
encoderClsid: TGUID;
stat: TStatus;
image: TGPImage;
begin
image := TGPImage.Create('a.bmp');
GetEncoderClsid('image/jpeg', encoderClsid);
stat := image.save('a.jpg', encoderClsid, nil);
if ( stat= OK ) then
memo1.lines.add('Save Successfully!')
else
memo1.lines.add( format( 'Failure: stat = %s',[GetStatus(stat)]));
image.free;
end;
编译时提示GetEncoderClsid没有定义,不知道这个应该怎么写,请知道的大侠赐教
// unit Winapi.GDIPUTIL;
function GetEncoderClsid(format: String; out pClsid: TGUID): integer;
var
num, size, j: UINT;
ImageCodecInfo: PImageCodecInfo;
Type
ArrIMgInf = array of TImageCodecInfo;
begin
num := 0; // number of image encoders
size := 0; // size of the image encoder array in bytes
result := -1;
GetImageEncodersSize(num, size);
if (size = 0) then exit;
GetMem(ImageCodecInfo, size);
if(ImageCodecInfo = nil) then exit;
GetImageEncoders(num, size, ImageCodecInfo);
for j := 0 to num - 1 do
begin
if( ArrIMgInf(ImageCodecInfo)[j].MimeType = format) then
begin
pClsid := ArrIMgInf(ImageCodecInfo)[j].Clsid;
result := j; // Success
end;
end;
FreeMem(ImageCodecInfo, size);
end;