Add std/tga package

This is just a placeholder decoder implementation  (and all of the
required plumbing) that produces a 1x1 reddish-purple image. Follow-up
commits will add flesh to the metaphorical bones.

TGA has no magic identifier, so MIME sniffers have to use heuristics.
The test/data/cbor-rfc-7049-examples.cbor file (which is CBOR binary
data, not a TGA image) is mistakenly sniffed as TGA. The /usr/bin/file
program makes the same classification (a false positive).

$ file test/data/cbor-rfc-7049-examples.cbor
test/data/cbor-rfc-7049-examples.cbor: Targa image data - Map 59395 x 26
x 15 +6169 +6500 - 2-bit alpha - interleave "@\033"

Some test/3pdata/tgasuite/*.tga test files, which are invalid TGA
images, are also false positives for now.

Updates #67
This commit is contained in:
Nigel Tao committed 2022-01-14 22:53:20 +11:00
1 parent db0a5a4f3a
commit 4c09c77bb9
10 files changed
+1280

No files matched your search

+12
View File
@@ -66,6 +66,7 @@ https://skia-review.googlesource.com/c/skia/+/290618
#define WUFFS_CONFIG__MODULE__LZW
#define WUFFS_CONFIG__MODULE__NIE
#define WUFFS_CONFIG__MODULE__PNG
#define WUFFS_CONFIG__MODULE__TGA
#define WUFFS_CONFIG__MODULE__WBMP
#define WUFFS_CONFIG__MODULE__ZLIB
@@ -138,6 +139,7 @@ union {
wuffs_gif__decoder gif;
wuffs_nie__decoder nie;
wuffs_png__decoder png;
wuffs_tga__decoder tga;
wuffs_wbmp__decoder wbmp;
} g_potential_decoders;
@@ -300,6 +302,16 @@ initialize_image_decoder() {
&g_potential_decoders.png);
return NULL;
case WUFFS_BASE__FOURCC__TGA:
status = wuffs_tga__decoder__initialize(
&g_potential_decoders.tga, sizeof g_potential_decoders.tga,
WUFFS_VERSION, WUFFS_INITIALIZE__DEFAULT_OPTIONS);
TRY(wuffs_base__status__message(&status));
g_image_decoder =
wuffs_tga__decoder__upcast_as__wuffs_base__image_decoder(
&g_potential_decoders.tga);
return NULL;
case WUFFS_BASE__FOURCC__WBMP:
status = wuffs_wbmp__decoder__initialize(
&g_potential_decoders.wbmp, sizeof g_potential_decoders.wbmp,
+1
View File
@@ -80,6 +80,7 @@ The Escape key quits.
#define WUFFS_CONFIG__MODULE__LZW
#define WUFFS_CONFIG__MODULE__NIE
#define WUFFS_CONFIG__MODULE__PNG
#define WUFFS_CONFIG__MODULE__TGA
#define WUFFS_CONFIG__MODULE__WBMP
#define WUFFS_CONFIG__MODULE__ZLIB