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 "chrome/common/gfx/icon_util.h" | 5 #include "chrome/common/gfx/icon_util.h" |
| 6 |
6 #include "base/file_util.h" | 7 #include "base/file_util.h" |
7 #include "base/gfx/image_operations.h" | |
8 #include "base/gfx/size.h" | 8 #include "base/gfx/size.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "chrome/common/win_util.h" | 10 #include "chrome/common/win_util.h" |
| 11 #include "skia/ext/image_operations.h" |
11 #include "skia/include/SkBitmap.h" | 12 #include "skia/include/SkBitmap.h" |
12 | 13 |
13 // Defining the dimensions for the icon images. We store only one value because | 14 // Defining the dimensions for the icon images. We store only one value because |
14 // we always resize to a square image; that is, the value 48 means that we are | 15 // we always resize to a square image; that is, the value 48 means that we are |
15 // going to resize the given bitmap to a 48 by 48 pixels bitmap. | 16 // going to resize the given bitmap to a 48 by 48 pixels bitmap. |
16 // | 17 // |
17 // The icon images appear in the icon file in same order in which their | 18 // The icon images appear in the icon file in same order in which their |
18 // corresponding dimensions appear in the |icon_dimensions_| array, so it is | 19 // corresponding dimensions appear in the |icon_dimensions_| array, so it is |
19 // important to keep this array sorted. Also note that the maximum icon image | 20 // important to keep this array sorted. Also note that the maximum icon image |
20 // size we can handle is 255 by 255. | 21 // size we can handle is 255 by 255. |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 inserted_original_bitmap = true; | 397 inserted_original_bitmap = true; |
397 continue; | 398 continue; |
398 } | 399 } |
399 | 400 |
400 if ((bitmap_to_resize.width() < icon_dimensions_[i]) && | 401 if ((bitmap_to_resize.width() < icon_dimensions_[i]) && |
401 (bitmap_to_resize.height() < icon_dimensions_[i])) { | 402 (bitmap_to_resize.height() < icon_dimensions_[i])) { |
402 bitmaps->push_back(bitmap_to_resize); | 403 bitmaps->push_back(bitmap_to_resize); |
403 inserted_original_bitmap = true; | 404 inserted_original_bitmap = true; |
404 } | 405 } |
405 } | 406 } |
406 bitmaps->push_back(gfx::ImageOperations::Resize( | 407 bitmaps->push_back(skia::ImageOperations::Resize( |
407 bitmap_to_resize, gfx::ImageOperations::RESIZE_LANCZOS3, | 408 bitmap_to_resize, skia::ImageOperations::RESIZE_LANCZOS3, |
408 gfx::Size(icon_dimensions_[i], icon_dimensions_[i]))); | 409 gfx::Size(icon_dimensions_[i], icon_dimensions_[i]))); |
409 } | 410 } |
410 | 411 |
411 if (!inserted_original_bitmap) { | 412 if (!inserted_original_bitmap) { |
412 bitmaps->push_back(bitmap_to_resize); | 413 bitmaps->push_back(bitmap_to_resize); |
413 } | 414 } |
414 } | 415 } |
415 | 416 |
416 int IconUtil::ComputeIconFileBufferSize(const std::vector<SkBitmap>& set) { | 417 int IconUtil::ComputeIconFileBufferSize(const std::vector<SkBitmap>& set) { |
417 // We start by counting the bytes for the structures that don't depend on the | 418 // We start by counting the bytes for the structures that don't depend on the |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 // number by the image height in order to get the total number of bytes for | 469 // number by the image height in order to get the total number of bytes for |
469 // the AND mask. Thus, for a 15X15 image, we need 15 * 4 which is 60 bytes | 470 // the AND mask. Thus, for a 15X15 image, we need 15 * 4 which is 60 bytes |
470 // for the monochrome bitmap representing the AND mask. | 471 // for the monochrome bitmap representing the AND mask. |
471 int and_line_length = (bitmap.width() + 7) >> 3; | 472 int and_line_length = (bitmap.width() + 7) >> 3; |
472 and_line_length = (and_line_length + 3) & ~3; | 473 and_line_length = (and_line_length + 3) & ~3; |
473 *and_mask_size = and_line_length * bitmap.height(); | 474 *and_mask_size = and_line_length * bitmap.height(); |
474 int masks_size = *xor_mask_size + *and_mask_size; | 475 int masks_size = *xor_mask_size + *and_mask_size; |
475 *bytes_in_resource = masks_size + sizeof(BITMAPINFOHEADER); | 476 *bytes_in_resource = masks_size + sizeof(BITMAPINFOHEADER); |
476 } | 477 } |
477 | 478 |
OLD | NEW |