GraphicsMagick: coders/tga.c Monochromatic uncompressed TGA coul...
GraphicsMagick Commits <[email protected]>
| Newsgroups | gmane.comp.video.graphicsmagick.cvs |
|---|---|
| Message-ID | <mailman.10209.1664488559.1826.graphicsmagick-commit@lists.sourceforge.net> |
changeset ef5c8ffaadcc in /hg/GraphicsMagick details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=ef5c8ffaadcc summary: coders/tga.c Monochromatic uncompressed TGA could be read. diffstat: ChangeLog | 4 ++++ coders/tga.c | 35 +++++++++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 8 deletions(-) diffs (93 lines): diff -r 37d9ed8a5ea7 -r ef5c8ffaadcc ChangeLog --- a/ChangeLog Wed Sep 28 20:15:59 2022 +0200 +++ b/ChangeLog Thu Sep 29 23:55:14 2022 +0200 @@ -1,3 +1,7 @@ +2022-09-29 Fojtik Jaroslav <[email protected]> + + * coders/tga.c Monochromatic TGA could be read. + 2022-09-28 Fojtik Jaroslav <[email protected]> * PerlMagick/t/input_mono.tga Added monochromatic TGA sample generated diff -r 37d9ed8a5ea7 -r ef5c8ffaadcc coders/tga.c --- a/coders/tga.c Wed Sep 28 20:15:59 2022 +0200 +++ b/coders/tga.c Thu Sep 29 23:55:14 2022 +0200 @@ -325,8 +325,8 @@ Validate depth. */ if (!(((tga_info.bits_per_pixel > 1) && (tga_info.bits_per_pixel < 17)) || - (tga_info.bits_per_pixel == 24 ) || - (tga_info.bits_per_pixel == 32 ))) + (tga_info.bits_per_pixel == 24 ) || (tga_info.bits_per_pixel == 32) || + (tga_info.bits_per_pixel == 1 && tga_info.image_type == TGAMonochrome) )) ThrowReaderException(CoderError,DataStorageTypeIsNotSupported,image); /* @@ -509,11 +509,11 @@ if (q == (PixelPacket *) NULL) break; indexes=AccessMutableIndexes(image); - for (x=0; x < (long) image->columns; x++) + for (x=0; x < (long)image->columns; x++) { if ((tga_info.image_type == TGARLEColormap) || (tga_info.image_type == TGARLERGB) || - (tga_info.image_type == TGARLEMonochrome)) + (tga_info.image_type == TGARLEMonochrome)) /* J.F. THIS WILLL NOT WORK! Some image sample should be obtained. */ { if (runlength != 0) { @@ -536,17 +536,32 @@ if (!skip) switch (tga_info.bits_per_pixel) { + case 1:if((x&7) == 0) // Read byte every 8th bit. + index = ReadBlobByte(image); + else + index <<= 1; + if(image->storage_class == PseudoClass) + { + pixel = image->colormap[indexes[x] = ((index & 128) ? 1 : 0)]; + } + else + { + pixel.blue=pixel.green=pixel.red = (index & 128)?MaxRGB:0; + } + break; + case 8: default: { /* Gray scale. */ - index=ReadBlobByte(image); + index = ReadBlobByte(image); if (image->storage_class == PseudoClass) { VerifyColormapIndex(image,index); pixel=image->colormap[index]; + indexes[x] = index; } else { @@ -625,12 +640,16 @@ break; } } + else /* skip==true - Duplicate index on RLE repeat. */ + { + if(image->storage_class == PseudoClass) + indexes[x] = index; + } + if (EOFBlob(image)) status = MagickFail; if (status == MagickFail) - ThrowReaderException(CorruptImageError,UnableToReadImageData,image); - if (image->storage_class == PseudoClass) - indexes[x]=index; + ThrowReaderException(CorruptImageError,UnableToReadImageData,image); *q++=pixel; } /*