Menu

#33 CMYK jpeg

open
nobody
5
2005-06-05
2005-06-05
Anonymous
No

Please correct me, but I have problem with CMYK (and
YCC) jpeg decoding
I'm solved this by adding decodeCMYK() into
pljpegdec.h and pljpegdec.cpp

1. pljpegdec.h:

added declaration
void decodeCMYK
( PLBmpBase * pBmp);

2. pljpegdec.cpp:
after
#include <jmorecfg.h>
added
// CMYK->RGB in DecodeCMYK()
#define CMYK_C 0
#define CMYK_M 1
#define CMYK_Y 2
#define CMYK_K 3
#define CMYK_PIXELSIZE 4

in
void PLJPEGDecoder::GetImage (PLBmpBase & Bmp)
before
else
decodeRGB (&Bmp);
added
else if (cinfo.out_color_space == JCS_CMYK)
decodeCMYK (&Bmp);

added function:
void PLJPEGDecoder::decodeCMYK
( PLBmpBase * pBmp)
// Assumes IJPEG decoder is already set up.
{
int CurLine = 0;

PLBYTE * pBuf;
JSAMPARRAY ppBuf = &pBuf;
pBuf = new PLBYTE[GetWidth()*sizeof (PLPixel32)];

int read = 0;
while (CurLine < GetHeight())
{
// CMYK->RGB
PLPixel32 ** pLineArray = pBmp->GetLineArray32();
jpeg_read_scanlines (&cinfo, ppBuf, 1);
int i;
BYTE k;
for (i=0; i<GetWidth(); i++)
{
PLBYTE * pSrcPixel = pBuf+i*CMYK_PIXELSIZE;
PLPixel32 * pDestPixel = pLineArray[CurLine]+i;
k = pSrcPixel[CMYK_K]; //
pDestPixel->SetR ((k * pSrcPixel[CMYK_C])/255);
pDestPixel->SetG ((k * pSrcPixel[CMYK_M])/255);
pDestPixel->SetB ((k * pSrcPixel[CMYK_Y])/255);
}
CurLine++;
}
delete[] pBuf;

}

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.