From 4a3caeb25fde2e02455b847c2c82173e191b42a9 Mon Sep 17 00:00:00 2001 From: Mark Cochran Date: Thu, 30 Aug 2012 14:57:13 -0700 Subject: [PATCH] Adding support for grayscale JPEG. --- examples/grayscale-image.js | 22 ++++++++++++++++++++++ examples/images/grayscaleImage.jpg | Bin 0 -> 25251 bytes src/Image.cc | 20 ++++++++++++++------ 3 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 examples/grayscale-image.js create mode 100644 examples/images/grayscaleImage.jpg diff --git a/examples/grayscale-image.js b/examples/grayscale-image.js new file mode 100644 index 0000000..5c37657 --- /dev/null +++ b/examples/grayscale-image.js @@ -0,0 +1,22 @@ +/** + * Passing grayscale image through canvas. Image should remain a gray square. + * If image is distorted with lines, then grayscale images are being distorted. + */ +var Canvas = require('../lib/canvas') + , Image = Canvas.Image + , canvas = new Canvas(288, 288) + , ctx = canvas.getContext('2d') + , fs = require('fs'); + +var grayScaleImage = fs.readFileSync(__dirname + '/images/grayscaleImage.jpg'); +img = new Image; +img.src = grayScaleImage; + +ctx.drawImage(img, 0, 0); + +var out = fs.createWriteStream(__dirname + '/passedThroughGrayscale.jpg') + , stream = canvas.createJPEGStream(); + +stream.on('data', function(chunk){ + out.write(chunk); +}); \ No newline at end of file diff --git a/examples/images/grayscaleImage.jpg b/examples/images/grayscaleImage.jpg new file mode 100644 index 0000000000000000000000000000000000000000..672c2a0fa2a622b954b7b9869cc4fe5afe6adbb1 GIT binary patch literal 25251 zcmeIZeOwf0nl4<>DjE|z#tiHZ9EwpV&g_Wf6T}6|k2vT$rW2EyxPfB_kueS*%~ujg zr>Z23LlS<{QFoHvLk_KzxWt`cT?xF zlbM~}vvYp$`^WoxrZhxodY=2a@9VnmyCQv&n+xyXT6N&Z1hI1`@fQR^EGA;2 z9w2nsio!o4>YK#E`E7#O8x?P1^G86G_h>DA{LvwSsu`;YS|b@bLN# zk3F39$m1IxTfgCnCvXZvcRcF$bt4giI39iH{835Abzg034e?qOrTemvi@tszQHfvO z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ni16RSg!&;J(^q&eyU literal 0 HcmV?d00001 diff --git a/src/Image.cc b/src/Image.cc index 00d39bb..6938884 100644 --- a/src/Image.cc +++ b/src/Image.cc @@ -692,12 +692,20 @@ Image::decodeJPEGIntoSurface(jpeg_decompress_struct *info) { jpeg_read_scanlines(info, &src, 1); uint32_t *row = (uint32_t *)(data + stride * y); for (int x = 0; x < width; ++x) { - int bx = 3 * x; - uint32_t *pixel = row + x; - *pixel = 255 << 24 - | src[bx + 0] << 16 - | src[bx + 1] << 8 - | src[bx + 2]; + if (info->jpeg_color_space == 1) { + uint32_t *pixel = row + x; + *pixel = 255 << 24 + | src[x] << 16 + | src[x] << 8 + | src[x]; + } else { + int bx = 3 * x; + uint32_t *pixel = row + x; + *pixel = 255 << 24 + | src[bx + 0] << 16 + | src[bx + 1] << 8 + | src[bx + 2]; + } } }