aboutsummaryrefslogtreecommitdiff
path: root/tjunittest.c
diff options
context:
space:
mode:
authordcommander <dcommander@632fc199-4ca6-4c93-a231-07263d6284db>2011-09-08 23:54:40 +0000
committerdcommander <dcommander@632fc199-4ca6-4c93-a231-07263d6284db>2011-09-08 23:54:40 +0000
commit742398873f5343e75b64f479ee185ced54f59c21 (patch)
tree18e059fbd9cf97fff155accbaaa1a505bd452942 /tjunittest.c
parentca178369524df9e21a93d647da50d6da6156a85c (diff)
When decompressing to a 4-byte RGB buffer, set the unused byte to 0xFF so it can be interpreted as an opaque alpha channel.
git-svn-id: svn://svn.code.sf.net/p/libjpeg-turbo/code/trunk@699 632fc199-4ca6-4c93-a231-07263d6284db
Diffstat (limited to 'tjunittest.c')
-rw-r--r--tjunittest.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/tjunittest.c b/tjunittest.c
index 08d8fe2..3a57347 100644
--- a/tjunittest.c
+++ b/tjunittest.c
@@ -68,6 +68,8 @@ const char *pixFormatStr[TJ_NUMPF]=
"RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "Grayscale"
};
+const int alphaOffset[TJ_NUMPF] = {-1, -1, 3, 3, 0, 0, -1};
+
const int _3byteFormats[]={TJPF_RGB, TJPF_BGR};
const int _4byteFormats[]={TJPF_RGBX, TJPF_BGRX, TJPF_XBGR, TJPF_XRGB};
const int _onlyGray[]={TJPF_GRAY};
@@ -156,6 +158,7 @@ int checkBuf(unsigned char *buf, int w, int h, int pf, int subsamp,
int roffset=tjRedOffset[pf];
int goffset=tjGreenOffset[pf];
int boffset=tjBlueOffset[pf];
+ int aoffset=alphaOffset[pf];
int ps=tjPixelSize[pf];
int index, row, col, retval=1;
int halfway=16*sf.num/sf.denom;
@@ -165,12 +168,13 @@ int checkBuf(unsigned char *buf, int w, int h, int pf, int subsamp,
{
for(col=0; col<w; col++)
{
- unsigned char r, g, b;
+ unsigned char r, g, b, a;
if(flags&TJFLAG_BOTTOMUP) index=(h-row-1)*w+col;
else index=row*w+col;
r=buf[index*ps+roffset];
g=buf[index*ps+goffset];
b=buf[index*ps+boffset];
+ a=aoffset>=0? buf[index*ps+aoffset]:0xFF;
if(((row/blocksize)+(col/blocksize))%2==0)
{
if(row<halfway)
@@ -207,6 +211,7 @@ int checkBuf(unsigned char *buf, int w, int h, int pf, int subsamp,
}
}
}
+ checkval255(a);
}
}