头部定义:
encoderClsid: TGUID; encoderParameters: TEncoderParameters; Stream:TStreamAdapter; MemStream :TMemoryStream; quality:Cardinal;
程序体:
FPreviewBMP := TGPImage.Create(filename); if GetEncoderClsid('image/png', encoderClsid) = -1 then exit; encoderParameters.Count := 1; encoderParameters.Parameter[0].Guid := EncoderQuality; encoderParameters.Parameter[0].Type_ := EncoderParameterValueTypeLong; encoderParameters.Parameter[0].NumberOfValues := 1; quality := 50; encoderParameters.Parameter[0].Value := @quality; MemStream := TMemoryStream.Create; Stream := TStreamAdapter.Create(MemStream); IStream(Stream)._AddRef; FPreviewBMP.Save(Stream,encoderClsid,@encoderParameters); FPreImage := TGPImage.Create(Stream);