| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/gfx/png_encoder.h" | 6 #include "base/gfx/png_encoder.h" |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "third_party/skia/include/core/SkBitmap.h" | 9 #include "third_party/skia/include/core/SkBitmap.h" |
| 10 #include "third_party/skia/include/core/SkUnPreMultiply.h" | 10 #include "third_party/skia/include/core/SkUnPreMultiply.h" |
| 11 | 11 |
| 12 extern "C" { | 12 extern "C" { |
| 13 #if defined(USE_SYSTEM_LIBPNG) |
| 14 #include <png.h> |
| 15 #else |
| 13 #include "third_party/libpng/png.h" | 16 #include "third_party/libpng/png.h" |
| 17 #endif |
| 14 } | 18 } |
| 15 | 19 |
| 16 namespace { | 20 namespace { |
| 17 | 21 |
| 18 // Converts BGRA->RGBA and RGBA->BGRA. | 22 // Converts BGRA->RGBA and RGBA->BGRA. |
| 19 void ConvertBetweenBGRAandRGBA(const unsigned char* input, int pixel_width, | 23 void ConvertBetweenBGRAandRGBA(const unsigned char* input, int pixel_width, |
| 20 unsigned char* output) { | 24 unsigned char* output) { |
| 21 for (int x = 0; x < pixel_width; x++) { | 25 for (int x = 0; x < pixel_width; x++) { |
| 22 const unsigned char* pixel_in = &input[x * 4]; | 26 const unsigned char* pixel_in = &input[x * 4]; |
| 23 unsigned char* pixel_out = &output[x * 4]; | 27 unsigned char* pixel_out = &output[x * 4]; |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 divided[i + 3] = alpha; | 231 divided[i + 3] = alpha; |
| 228 } | 232 } |
| 229 i += bbp; | 233 i += bbp; |
| 230 } | 234 } |
| 231 } | 235 } |
| 232 | 236 |
| 233 return Encode(divided.get(), | 237 return Encode(divided.get(), |
| 234 PNGEncoder::FORMAT_RGBA, input.width(), input.height(), | 238 PNGEncoder::FORMAT_RGBA, input.width(), input.height(), |
| 235 input.width() * bbp, discard_transparency, output); | 239 input.width() * bbp, discard_transparency, output); |
| 236 } | 240 } |
| OLD | NEW |