Skip to content

Commit

Permalink
ecere/gfx/bitmaps/JPEG: Added support for CMYK JPEGs
Browse files Browse the repository at this point in the history
  • Loading branch information
jerstlouis committed Apr 23, 2014
1 parent 62a41b6 commit 9368375
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ecere/src/gfx/bitmaps/JPEGFormat.ec
Expand Up @@ -214,7 +214,16 @@ class JPGFormat : BitmapFormat
jpeg_read_scanlines(&cinfo, buffer, 1);
for(c = 0; c<cinfo.image_width; c++)
{
if(cinfo.output_components == 1)
if(cinfo.out_color_space == JCS_CMYK && cinfo.output_components == 4)
{
int cyan = 255-buffer[0][c*4+0];
int m = 255-buffer[0][c*4+1];
int y = 255-buffer[0][c*4+2];
int k = 255-buffer[0][c*4+3];
//picture[c] = ColorAlpha { 255, { cinfo.sample_range_limit[(255 - (cyan + k))], cinfo.sample_range_limit[(255 - (m + k))], cinfo.sample_range_limit[(255 - (y + k))] } };
picture[c] = ColorCMYK { cyan * 100.0f / 255, m * 100.0f / 255, y * 100.0f / 255, k * 100.0f / 255 };
}
else if(cinfo.output_components == 1)
picture[c] = ColorAlpha { 255, { buffer[0][c], buffer[0][c], buffer[0][c] } };
else
picture[c] = ColorAlpha { 255, { buffer[0][c*3], buffer[0][c*3+1], buffer[0][c*3+2] } };
Expand Down

0 comments on commit 9368375

Please sign in to comment.