Debian Codegraph @

examples/images_videos/image_identify/image_identify.dpr

raw
1 {
2 Copyright 2009-2021 Michalis Kamburelis.
3
4 This file is part of "Castle Game Engine".
5
6 "Castle Game Engine" is free software; see the file COPYING.txt,
7 included in this distribution, for details about the copyright.
8
9 "Castle Game Engine" is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 ----------------------------------------------------------------------------
14 }
15
16 { Write basic information about the image.
17 See README.md for details. }
18 program image_identify;
19
20 uses SysUtils, CastleUtils, CastleImages, CastleParameters;
21
22 var
23 I: Integer;
24 Img: TEncodedImage;
25 AlphaChannel: string;
26 begin
27 if Parameters.High = 0 then
28 raise EInvalidParams.Create('No parameters supplied, nothing to do');
29 for I := 1 to Parameters.High do
30 begin
31 try
32 Img := LoadEncodedImage(Parameters[I]);
33 except
34 on E: EImageLoadError do
35 begin
36 Writeln(Parameters[I], ': load error: ', E.Message);
37 Continue;
38 end;
39 on E: EImageFormatNotSupported do
40 begin
41 Writeln(Parameters[I], ': image format not supported: ', E.Message);
42 Continue;
43 end;
44 end;
45 try
46 AlphaChannel := AlphaToString[Img.AlphaChannel];
47 case Img.AlphaChannel of
48 acTest : AlphaChannel := AlphaChannel + ' (only fully transparent / fully opaque parts)';
49 acBlending: AlphaChannel := AlphaChannel + ' (partially transparent parts)';
50 end;
51
52 Writeln(Parameters[I], ': ', Img.Width, ' x ', Img.Height,
53 ', type: ', Img.ClassName, ', alpha: ' + AlphaChannel);
54 finally FreeAndNil(Img) end;
55 end;
56 end.