OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/gfx/codec/png_codec.h" | 5 #include "ui/gfx/codec/png_codec.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "third_party/libpng/png.h" | 9 #include "third_party/libpng/png.h" |
10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 png_set_user_transform_info(png_ptr, state, 0, 0); | 269 png_set_user_transform_info(png_ptr, state, 0, 0); |
270 } | 270 } |
271 | 271 |
272 // Tell libpng to send us rows for interlaced pngs. | 272 // Tell libpng to send us rows for interlaced pngs. |
273 if (interlace_type == PNG_INTERLACE_ADAM7) | 273 if (interlace_type == PNG_INTERLACE_ADAM7) |
274 png_set_interlace_handling(png_ptr); | 274 png_set_interlace_handling(png_ptr); |
275 | 275 |
276 png_read_update_info(png_ptr, info_ptr); | 276 png_read_update_info(png_ptr, info_ptr); |
277 | 277 |
278 if (state->bitmap) { | 278 if (state->bitmap) { |
279 state->bitmap->setConfig(SkBitmap::kARGB_8888_Config, | 279 state->bitmap->allocN32Pixels(state->width, state->height); |
280 state->width, state->height); | |
281 state->bitmap->allocPixels(); | |
282 } else if (state->output) { | 280 } else if (state->output) { |
283 state->output->resize( | 281 state->output->resize( |
284 state->width * state->output_channels * state->height); | 282 state->width * state->output_channels * state->height); |
285 } | 283 } |
286 } | 284 } |
287 | 285 |
288 void DecodeRowCallback(png_struct* png_ptr, png_byte* new_row, | 286 void DecodeRowCallback(png_struct* png_ptr, png_byte* new_row, |
289 png_uint_32 row_num, int pass) { | 287 png_uint_32 row_num, int pass) { |
290 if (!new_row) | 288 if (!new_row) |
291 return; // Interlaced image; row didn't change this pass. | 289 return; // Interlaced image; row didn't change this pass. |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 } | 806 } |
809 | 807 |
810 PNGCodec::Comment::Comment(const std::string& k, const std::string& t) | 808 PNGCodec::Comment::Comment(const std::string& k, const std::string& t) |
811 : key(k), text(t) { | 809 : key(k), text(t) { |
812 } | 810 } |
813 | 811 |
814 PNGCodec::Comment::~Comment() { | 812 PNGCodec::Comment::~Comment() { |
815 } | 813 } |
816 | 814 |
817 } // namespace gfx | 815 } // namespace gfx |
OLD | NEW |