tjLoadImage(): return TJPF_GRAY for grayscale BMPs
... if *pixelFormat=TJPF_UNKNOWN is passed to the function.
This commit is contained in:
3
rdbmp.c
3
rdbmp.c
@@ -133,6 +133,9 @@ read_colormap (bmp_source_ptr sinfo, int cmaplen, int mapentrysize)
|
||||
break;
|
||||
}
|
||||
|
||||
if (sinfo->cinfo->in_color_space == JCS_UNKNOWN && gray)
|
||||
sinfo->cinfo->in_color_space = JCS_GRAYSCALE;
|
||||
|
||||
if (sinfo->cinfo->in_color_space == JCS_GRAYSCALE && !gray)
|
||||
ERREXIT(sinfo->cinfo, JERR_BAD_IN_COLORSPACE);
|
||||
}
|
||||
|
||||
18
tjunittest.c
18
tjunittest.c
@@ -792,7 +792,7 @@ int doBmpTest(const char *ext, int width, int align, int height, int pf,
|
||||
{
|
||||
char filename[80], *md5sum, md5buf[65];
|
||||
int ps=tjPixelSize[pf], pitch=PAD(width*ps, align),
|
||||
loadWidth=0, loadHeight=0, retval=0;
|
||||
loadWidth=0, loadHeight=0, retval=0, pixelFormat=pf;
|
||||
unsigned char *buf=NULL;
|
||||
char *md5ref;
|
||||
|
||||
@@ -858,6 +858,22 @@ int doBmpTest(const char *ext, int width, int align, int height, int pf,
|
||||
retval=-1; goto bailout;
|
||||
}
|
||||
}
|
||||
/* Verify that tjLoadImage() returns the proper "preferred" pixel format for
|
||||
the file type. */
|
||||
tjFree(buf); buf=NULL;
|
||||
pf=pixelFormat;
|
||||
pixelFormat=TJPF_UNKNOWN;
|
||||
if((buf=tjLoadImage(filename, &loadWidth, align, &loadHeight, &pixelFormat,
|
||||
flags))==NULL)
|
||||
_throwtj();
|
||||
if((pf==TJPF_GRAY && pixelFormat!=TJPF_GRAY) ||
|
||||
(pf!=TJPF_GRAY && !strcasecmp(ext, "bmp") && pixelFormat!=TJPF_BGR) ||
|
||||
(pf!=TJPF_GRAY && !strcasecmp(ext, "ppm") && pixelFormat!=TJPF_RGB))
|
||||
{
|
||||
printf("\n tjLoadImage() returned unexpected pixel format: %s\n",
|
||||
pixFormatStr[pixelFormat]);
|
||||
retval=-1;
|
||||
}
|
||||
unlink(filename);
|
||||
|
||||
bailout:
|
||||
|
||||
Reference in New Issue
Block a user