diff options
author | dcommander <dcommander@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2010-11-04 22:39:59 +0000 |
---|---|---|
committer | dcommander <dcommander@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2010-11-04 22:39:59 +0000 |
commit | f64bd97c0f3cd5da992d7bb30d518dac1c3ef30c (patch) | |
tree | 369fe09756ea00c017b610a5433177f7deed3123 /trunk/turbojpegl.c | |
parent | 3765257823ed5ef9647dccc4fcce7aaa4bce1447 (diff) |
Grayscale bitmap support in TurboJPEG/OSS
git-svn-id: https://libjpeg-turbo.svn.sourceforge.net/svnroot/libjpeg-turbo@288 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'trunk/turbojpegl.c')
-rw-r--r-- | trunk/turbojpegl.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/trunk/turbojpegl.c b/trunk/turbojpegl.c index c3694c8..03833c5 100644 --- a/trunk/turbojpegl.c +++ b/trunk/turbojpegl.c @@ -1,6 +1,6 @@ /* Copyright (C)2004 Landmark Graphics Corporation * Copyright (C)2005 Sun Microsystems, Inc. - * Copyright (C)2009 D. R. Commander + * Copyright (C)2009-2010 D. R. Commander * * This library is free software and may be redistributed and/or modified under * the terms of the wxWindows Library License, Version 3.1 or (at your option) @@ -124,7 +124,8 @@ DLLEXPORT int DLLCALL tjCompress(tjhandle h, || dstbuf==NULL || size==NULL || jpegsub<0 || jpegsub>=NUMSUBOPT || qual<0 || qual>100) _throw("Invalid argument in tjCompress()"); - if(ps!=3 && ps!=4) _throw("This compressor can only take 24-bit or 32-bit RGB input"); + if(ps!=3 && ps!=4 && ps!=1) + _throw("This compressor can only handle 24-bit and 32-bit RGB or 8-bit grayscale input"); if(!j->initc) _throw("Instance has not been initialized for compression"); if(pitch==0) pitch=width*ps; @@ -133,8 +134,9 @@ DLLEXPORT int DLLCALL tjCompress(tjhandle h, j->cinfo.image_height = height; j->cinfo.input_components = ps; + if(ps==1) j->cinfo.in_color_space = JCS_GRAYSCALE; #if JCS_EXTENSIONS==1 - j->cinfo.in_color_space = JCS_EXT_RGB; + else j->cinfo.in_color_space = JCS_EXT_RGB; if(ps==3 && (flags&TJ_BGR)) j->cinfo.in_color_space = JCS_EXT_BGR; else if(ps==4 && !(flags&TJ_BGR) && !(flags&TJ_ALPHAFIRST)) @@ -287,7 +289,8 @@ DLLEXPORT int DLLCALL tjDecompress(tjhandle h, if(srcbuf==NULL || size<=0 || dstbuf==NULL || width<=0 || pitch<0 || height<=0) _throw("Invalid argument in tjDecompress()"); - if(ps!=3 && ps!=4) _throw("This compressor can only take 24-bit or 32-bit RGB input"); + if(ps!=3 && ps!=4 && ps!=1) + _throw("This decompressor can only handle 24-bit and 32-bit RGB or 8-bit grayscale output"); if(!j->initd) _throw("Instance has not been initialized for decompression"); if(pitch==0) pitch=width*ps; @@ -315,8 +318,9 @@ DLLEXPORT int DLLCALL tjDecompress(tjhandle h, else row_pointer[i]= &dstbuf[i*pitch]; } + if(ps==1) j->dinfo.out_color_space = JCS_GRAYSCALE; #if JCS_EXTENSIONS==1 - j->dinfo.out_color_space = JCS_EXT_RGB; + else j->dinfo.out_color_space = JCS_EXT_RGB; if(ps==3 && (flags&TJ_BGR)) j->dinfo.out_color_space = JCS_EXT_BGR; else if(ps==4 && !(flags&TJ_BGR) && !(flags&TJ_ALPHAFIRST)) |