uses ....,
Vcl.Graphics,
Winapi.Wincodec
procedure TForm24.Button1Click(Sender: TObject);
var
myOriginal : TWICImage;
myRotate : IWICBitmap;
iDecoder : IWICBitmapDecoder;
iDecoderFrame: IWICBitmapFrameDecode;
iFlipRotator : IWICBitmapFlipRotator;
hres : HRESULT;
myFile :
string;
begin
myFile := '
..\..\testpilot-header.png';
myOriginal := TWICImage.Create;
try
myOriginal.LoadFromFile(myFile);
hres := myOriginal.ImagingFactory.CreateDecoderFromFilename(PWideChar(myFile), GUID_NULL, GENERIC_READ,
WICDecodeMetadataCacheOnDemand, iDecoder);
if Succeeded(hres)
then
begin
hres := iDecoder.GetFrame(0, iDecoderFrame);
if Succeeded(hres)
then
begin
hres := myOriginal.ImagingFactory.CreateBitmapFlipRotator(iFlipRotator);
if Succeeded(hres)
then
begin
hres := iFlipRotator.Initialize(iDecoderFrame, WICBitmapTransformRotate90);
if Succeeded(hres)
then
begin
myOriginal.ImagingFactory.CreateBitmapFromSource(iFlipRotator, WICBitmapCacheOnDemand, myRotate);
if Assigned(myRotate)
then
begin
myOriginal.Handle := myRotate;
myOriginal.SaveToFile('
../../rotated.png');
end;
end;
end;
end;
end;
finally
myOriginal.Free;
end;
end;