| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2010, Google Inc. All rights reserved. | 2 * Copyright (c) 2010, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 extern "C" { | 38 extern "C" { |
| 39 #include <setjmp.h> | 39 #include <setjmp.h> |
| 40 #include <stdio.h> // jpeglib.h needs stdio.h FILE | 40 #include <stdio.h> // jpeglib.h needs stdio.h FILE |
| 41 #include "jpeglib.h" | 41 #include "jpeglib.h" |
| 42 } | 42 } |
| 43 | 43 |
| 44 namespace blink { | 44 namespace blink { |
| 45 | 45 |
| 46 struct JPEGOutputBuffer : public jpeg_destination_mgr { | 46 struct JPEGOutputBuffer : public jpeg_destination_mgr { |
| 47 DISALLOW_NEW(); |
| 47 Vector<unsigned char>* output; | 48 Vector<unsigned char>* output; |
| 48 Vector<unsigned char> buffer; | 49 Vector<unsigned char> buffer; |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 static void prepareOutput(j_compress_ptr cinfo) | 52 static void prepareOutput(j_compress_ptr cinfo) |
| 52 { | 53 { |
| 53 JPEGOutputBuffer* out = static_cast<JPEGOutputBuffer*>(cinfo->dest); | 54 JPEGOutputBuffer* out = static_cast<JPEGOutputBuffer*>(cinfo->dest); |
| 54 const size_t internalBufferSize = 8192; | 55 const size_t internalBufferSize = 8192; |
| 55 out->buffer.resize(internalBufferSize); | 56 out->buffer.resize(internalBufferSize); |
| 56 out->next_output_byte = out->buffer.data(); | 57 out->next_output_byte = out->buffer.data(); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 163 |
| 163 bool JPEGImageEncoder::encode(const ImageDataBuffer& imageData, int quality, Vec
tor<unsigned char>* output) | 164 bool JPEGImageEncoder::encode(const ImageDataBuffer& imageData, int quality, Vec
tor<unsigned char>* output) |
| 164 { | 165 { |
| 165 if (!imageData.pixels()) | 166 if (!imageData.pixels()) |
| 166 return false; | 167 return false; |
| 167 | 168 |
| 168 return encodePixels(IntSize(imageData.width(), imageData.height()), imageDat
a.pixels(), quality, output); | 169 return encodePixels(IntSize(imageData.width(), imageData.height()), imageDat
a.pixels(), quality, output); |
| 169 } | 170 } |
| 170 | 171 |
| 171 } // namespace blink | 172 } // namespace blink |
| OLD | NEW |