OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/jpeg_codec.h" | 5 #include "ui/gfx/codec/jpeg_codec.h" |
6 | 6 |
7 #include <setjmp.h> | 7 #include <setjmp.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 SkBitmap* JPEGCodec::Decode(const unsigned char* input, size_t input_size) { | 615 SkBitmap* JPEGCodec::Decode(const unsigned char* input, size_t input_size) { |
616 int w, h; | 616 int w, h; |
617 std::vector<unsigned char> data_vector; | 617 std::vector<unsigned char> data_vector; |
618 if (!Decode(input, input_size, FORMAT_SkBitmap, &data_vector, &w, &h)) | 618 if (!Decode(input, input_size, FORMAT_SkBitmap, &data_vector, &w, &h)) |
619 return NULL; | 619 return NULL; |
620 | 620 |
621 // Skia only handles 32 bit images. | 621 // Skia only handles 32 bit images. |
622 int data_length = w * h * 4; | 622 int data_length = w * h * 4; |
623 | 623 |
624 SkBitmap* bitmap = new SkBitmap(); | 624 SkBitmap* bitmap = new SkBitmap(); |
625 bitmap->setConfig(SkBitmap::kARGB_8888_Config, w, h); | 625 bitmap->allocN32Pixels(w, h); |
626 bitmap->allocPixels(); | |
627 memcpy(bitmap->getAddr32(0, 0), &data_vector[0], data_length); | 626 memcpy(bitmap->getAddr32(0, 0), &data_vector[0], data_length); |
628 | 627 |
629 return bitmap; | 628 return bitmap; |
630 } | 629 } |
631 | 630 |
632 } // namespace gfx | 631 } // namespace gfx |
OLD | NEW |