// Es wird
festgestellt, welches Grafikformat sich gerade in einem
//
TWICImage befindet.
// Getestet mit RS 10.4 unter Win11
// uses Vcl.Graphics;
var
GUID_ContainerFormatIco: TGUID = '{a3a860c4-338f-4c17-919a-fba4b5628f21}';
WICImg: TWICImage;
function WICImageFormat(const WIC: TWICImage): Byte;
begin
If WIC.Empty then
Result := 0
else
begin
Result := 255;
case WIC.ImageFormat of
wifBmp:
Result := 1;
wifPng:
Result := 2;
wifJpeg:
Result := 3;
wifGif:
Result := 4;
wifTiff:
Result := 5;
wifWMPhoto:
Result := 6;
wifOther:
if WIC.EncoderContainerFormat = GUID_ContainerFormatIco then
Result := 7;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
WICImg := TWICImage.Create;
WICImg.loadfromfile('D:\Icons\Icon4.ico'); // z.B.
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FreeAndNil(WICImg);
end;
// Beispielaufruf
procedure TForm1.Button1Click(Sender: TObject);
var
s: string;
begin
case WICImageFormat(WICImg) of
0:
s := 'Keine Grafik gefunden';
1:
s := 'Bitmap';
2:
s := 'PNG';
3:
s := 'JPEG';
4:
s := 'GIF';
5:
s := 'TIFF';
6:
s := 'JPEG XR';
7:
s := 'Icon';
else
s := 'Unklar';
end;
showmessage(s);
end;
|