| 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 <setjmp.h> | 5 #include <setjmp.h> |
| 6 | 6 |
| 7 #include "chrome/common/jpeg_codec.h" | 7 #include "chrome/common/jpeg_codec.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 507 // Use FORMAT_BGRA as that maps to Skia's 32 bit (kARGB_8888_Config) format. | 507 // Use FORMAT_BGRA as that maps to Skia's 32 bit (kARGB_8888_Config) format. |
| 508 if (!Decode(input, input_size, FORMAT_BGRA, &data_vector, &w, &h)) | 508 if (!Decode(input, input_size, FORMAT_BGRA, &data_vector, &w, &h)) |
| 509 return NULL; | 509 return NULL; |
| 510 | 510 |
| 511 // Skia only handles 32 bit images. | 511 // Skia only handles 32 bit images. |
| 512 int data_length = w * h * 4; | 512 int data_length = w * h * 4; |
| 513 | 513 |
| 514 SkBitmap* bitmap = new SkBitmap(); | 514 SkBitmap* bitmap = new SkBitmap(); |
| 515 bitmap->setConfig(SkBitmap::kARGB_8888_Config, w, h); | 515 bitmap->setConfig(SkBitmap::kARGB_8888_Config, w, h); |
| 516 bitmap->allocPixels(); | 516 bitmap->allocPixels(); |
| 517 memcpy(bitmap->getAddr32(0, 0), &data_vector[0], w * h * 4); | 517 memcpy(bitmap->getAddr32(0, 0), &data_vector[0], data_length); |
| 518 | 518 |
| 519 return bitmap; | 519 return bitmap; |
| 520 } | 520 } |
| 521 | 521 |
| OLD | NEW |