From 5aee7c7744005d11a9cc060e99b840749b671cfa Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Tue, 13 Nov 2012 14:28:45 +0000 Subject: [PATCH] Correction to YCCK and CNYK jpeg images loading into blender There was incorrect formula applied on color components, used the same as gimp uses. It makes image looking nicer in blender, however it's still not 100% correct. Seems lots of software are handling profiles from jpeg file nicely. But that's another topic. --- source/blender/imbuf/intern/jpeg.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/source/blender/imbuf/intern/jpeg.c b/source/blender/imbuf/intern/jpeg.c index d96a01d7093..758617bdd48 100644 --- a/source/blender/imbuf/intern/jpeg.c +++ b/source/blender/imbuf/intern/jpeg.c @@ -348,25 +348,12 @@ static ImBuf *ibJpegImageFromCinfo(struct jpeg_decompress_struct *cinfo, int fla g = *buffer++; b = *buffer++; k = *buffer++; - - k = 255 - k; - r -= k; - if (r & 0xffffff00) { - if (r < 0) r = 0; - else r = 255; - } - g -= k; - if (g & 0xffffff00) { - if (g < 0) g = 0; - else g = 255; - } - b -= k; - if (b & 0xffffff00) { - if (b < 0) b = 0; - else b = 255; - } - - rect[3] = 255 - k; + + r = (r * k) / 255; + g = (g * k) / 255; + b = (b * k) / 255; + + rect[3] = 255; rect[2] = b; rect[1] = g; rect[0] = r;