| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Apple Computer, Inc. | 2 * Copyright (C) 2006 Apple Computer, Inc. |
| 3 * | 3 * |
| 4 * Portions are Copyright (C) 2001-6 mozilla.org | 4 * Portions are Copyright (C) 2001-6 mozilla.org |
| 5 * | 5 * |
| 6 * Other contributors: | 6 * Other contributors: |
| 7 * Stuart Parmenter <stuart@mozilla.com> | 7 * Stuart Parmenter <stuart@mozilla.com> |
| 8 * | 8 * |
| 9 * Copyright (C) 2007-2009 Torch Mobile, Inc. | 9 * Copyright (C) 2007-2009 Torch Mobile, Inc. |
| 10 * | 10 * |
| (...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 | 639 |
| 640 template <J_COLOR_SPACE colorSpace> void setPixel(ImageFrame& buffer, ImageFrame
::PixelData* pixel, JSAMPARRAY samples, int column) | 640 template <J_COLOR_SPACE colorSpace> void setPixel(ImageFrame& buffer, ImageFrame
::PixelData* pixel, JSAMPARRAY samples, int column) |
| 641 { | 641 { |
| 642 JSAMPLE* jsample = *samples + column * (colorSpace == JCS_RGB ? 3 : 4); | 642 JSAMPLE* jsample = *samples + column * (colorSpace == JCS_RGB ? 3 : 4); |
| 643 | 643 |
| 644 switch (colorSpace) { | 644 switch (colorSpace) { |
| 645 case JCS_RGB: | 645 case JCS_RGB: |
| 646 buffer.setRGBA(pixel, jsample[0], jsample[1], jsample[2], 0xFF); | 646 buffer.setRGBA(pixel, jsample[0], jsample[1], jsample[2], 0xFF); |
| 647 break; | 647 break; |
| 648 case JCS_CMYK: | 648 case JCS_CMYK: |
| 649 // Source is 'Inverted CMYK', output is RGB. | 649 buffer.setInvertedCMYK(pixel, jsample[0], jsample[1], jsample[2], jsampl
e[3]); |
| 650 // See: http://www.easyrgb.com/math.php?MATH=M12#text12 | |
| 651 // Or: http://www.ilkeratalay.com/colorspacesfaq.php#rgb | |
| 652 // From CMYK to CMY: | |
| 653 // X = X * (1 - K ) + K [for X = C, M, or Y] | |
| 654 // Thus, from Inverted CMYK to CMY is: | |
| 655 // X = (1-iX) * (1 - (1-iK)) + (1-iK) => 1 - iX*iK | |
| 656 // From CMY (0..1) to RGB (0..1): | |
| 657 // R = 1 - C => 1 - (1 - iC*iK) => iC*iK [G and B similar] | |
| 658 unsigned k = jsample[3]; | |
| 659 buffer.setRGBA(pixel, jsample[0] * k / 255, jsample[1] * k / 255, jsampl
e[2] * k / 255, 0xFF); | |
| 660 break; | 650 break; |
| 661 } | 651 } |
| 662 } | 652 } |
| 663 | 653 |
| 664 template <J_COLOR_SPACE colorSpace> bool outputRows(JPEGImageReader* reader, Ima
geFrame& buffer) | 654 template <J_COLOR_SPACE colorSpace> bool outputRows(JPEGImageReader* reader, Ima
geFrame& buffer) |
| 665 { | 655 { |
| 666 JSAMPARRAY samples = reader->samples(); | 656 JSAMPARRAY samples = reader->samples(); |
| 667 jpeg_decompress_struct* info = reader->info(); | 657 jpeg_decompress_struct* info = reader->info(); |
| 668 int width = info->output_width; | 658 int width = info->output_width; |
| 669 | 659 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 // has failed. | 748 // has failed. |
| 759 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) | 749 if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived()) |
| 760 setFailed(); | 750 setFailed(); |
| 761 // If we're done decoding the image, we don't need the JPEGImageReader | 751 // If we're done decoding the image, we don't need the JPEGImageReader |
| 762 // anymore. (If we failed, |m_reader| has already been cleared.) | 752 // anymore. (If we failed, |m_reader| has already been cleared.) |
| 763 else if (!m_frameBufferCache.isEmpty() && (m_frameBufferCache[0].status() ==
ImageFrame::FrameComplete)) | 753 else if (!m_frameBufferCache.isEmpty() && (m_frameBufferCache[0].status() ==
ImageFrame::FrameComplete)) |
| 764 m_reader.clear(); | 754 m_reader.clear(); |
| 765 } | 755 } |
| 766 | 756 |
| 767 } | 757 } |
| OLD | NEW |