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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 79 |
80 // The delta filter is PNG_FILTER_SUB instead of PNG_ALL_FILTERS, to reduce | 80 // The delta filter is PNG_FILTER_SUB instead of PNG_ALL_FILTERS, to reduce |
81 // the filter computations. | 81 // the filter computations. |
82 png_set_filter(png, PNG_FILTER_TYPE_BASE, PNG_FILTER_SUB); | 82 png_set_filter(png, PNG_FILTER_TYPE_BASE, PNG_FILTER_SUB); |
83 | 83 |
84 png_set_write_fn(png, output, writeOutput, 0); | 84 png_set_write_fn(png, output, writeOutput, 0); |
85 png_set_IHDR(png, info, imageSize.width(), imageSize.height(), 8, | 85 png_set_IHDR(png, info, imageSize.width(), imageSize.height(), 8, |
86 PNG_COLOR_TYPE_RGB_ALPHA, 0, 0, 0); | 86 PNG_COLOR_TYPE_RGB_ALPHA, 0, 0, 0); |
87 png_write_info(png, info); | 87 png_write_info(png, info); |
88 | 88 |
89 return wrapUnique(new PNGImageEncoderState(png, info)); | 89 return WTF::wrapUnique(new PNGImageEncoderState(png, info)); |
90 } | 90 } |
91 | 91 |
92 void PNGImageEncoder::writeOneRowToPng(unsigned char* pixels, | 92 void PNGImageEncoder::writeOneRowToPng(unsigned char* pixels, |
93 PNGImageEncoderState* encoderState) { | 93 PNGImageEncoderState* encoderState) { |
94 png_write_row(encoderState->png(), pixels); | 94 png_write_row(encoderState->png(), pixels); |
95 } | 95 } |
96 | 96 |
97 void PNGImageEncoder::finalizePng(PNGImageEncoderState* encoderState) { | 97 void PNGImageEncoder::finalizePng(PNGImageEncoderState* encoderState) { |
98 png_write_end(encoderState->png(), encoderState->info()); | 98 png_write_end(encoderState->png(), encoderState->info()); |
99 } | 99 } |
(...skipping 19 matching lines...) Expand all Loading... |
119 | 119 |
120 bool PNGImageEncoder::encode(const ImageDataBuffer& imageData, | 120 bool PNGImageEncoder::encode(const ImageDataBuffer& imageData, |
121 Vector<unsigned char>* output) { | 121 Vector<unsigned char>* output) { |
122 if (!imageData.pixels()) | 122 if (!imageData.pixels()) |
123 return false; | 123 return false; |
124 | 124 |
125 return encodePixels(imageData.size(), imageData.pixels(), output); | 125 return encodePixels(imageData.size(), imageData.pixels(), output); |
126 } | 126 } |
127 | 127 |
128 } // namespace blink | 128 } // namespace blink |
OLD | NEW |