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/icon_util.h" | 5 #include "ui/gfx/icon_util.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/files/important_file_writer.h" | 10 #include "base/files/important_file_writer.h" |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 ICONINFO ii = {0}; | 362 ICONINFO ii = {0}; |
363 ii.fIcon = FALSE; | 363 ii.fIcon = FALSE; |
364 ii.xHotspot = hotspot.x(); | 364 ii.xHotspot = hotspot.x(); |
365 ii.yHotspot = hotspot.y(); | 365 ii.yHotspot = hotspot.y(); |
366 ii.hbmMask = mask.get(); | 366 ii.hbmMask = mask.get(); |
367 ii.hbmColor = bitmap_handle.get(); | 367 ii.hbmColor = bitmap_handle.get(); |
368 | 368 |
369 return base::win::ScopedHICON(CreateIconIndirect(&ii)); | 369 return base::win::ScopedHICON(CreateIconIndirect(&ii)); |
370 } | 370 } |
371 | 371 |
| 372 gfx::Point IconUtil::GetHotSpotFromHICON(HICON icon) { |
| 373 ScopedICONINFO icon_info; |
| 374 gfx::Point hotspot; |
| 375 if (::GetIconInfo(icon, &icon_info)) |
| 376 hotspot = gfx::Point(icon_info.xHotspot, icon_info.yHotspot); |
| 377 |
| 378 return hotspot; |
| 379 } |
372 SkBitmap IconUtil::CreateSkBitmapFromHICONHelper(HICON icon, | 380 SkBitmap IconUtil::CreateSkBitmapFromHICONHelper(HICON icon, |
373 const gfx::Size& s) { | 381 const gfx::Size& s) { |
374 DCHECK(icon); | 382 DCHECK(icon); |
375 DCHECK(!s.IsEmpty()); | 383 DCHECK(!s.IsEmpty()); |
376 | 384 |
377 // Allocating memory for the SkBitmap object. We are going to create an ARGB | 385 // Allocating memory for the SkBitmap object. We are going to create an ARGB |
378 // bitmap so we should set the configuration appropriately. | 386 // bitmap so we should set the configuration appropriately. |
379 SkBitmap bitmap; | 387 SkBitmap bitmap; |
380 bitmap.allocN32Pixels(s.width(), s.height()); | 388 bitmap.allocN32Pixels(s.width(), s.height()); |
381 bitmap.eraseARGB(0, 0, 0, 0); | 389 bitmap.eraseARGB(0, 0, 0, 0); |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 // Once we compute the size for a singe AND mask scan line, we multiply that | 702 // Once we compute the size for a singe AND mask scan line, we multiply that |
695 // number by the image height in order to get the total number of bytes for | 703 // number by the image height in order to get the total number of bytes for |
696 // the AND mask. Thus, for a 15X15 image, we need 15 * 4 which is 60 bytes | 704 // the AND mask. Thus, for a 15X15 image, we need 15 * 4 which is 60 bytes |
697 // for the monochrome bitmap representing the AND mask. | 705 // for the monochrome bitmap representing the AND mask. |
698 size_t and_line_length = (bitmap.width() + 7) >> 3; | 706 size_t and_line_length = (bitmap.width() + 7) >> 3; |
699 and_line_length = (and_line_length + 3) & ~3; | 707 and_line_length = (and_line_length + 3) & ~3; |
700 size_t and_mask_size = and_line_length * bitmap.height(); | 708 size_t and_mask_size = and_line_length * bitmap.height(); |
701 size_t masks_size = *xor_mask_size + and_mask_size; | 709 size_t masks_size = *xor_mask_size + and_mask_size; |
702 *bytes_in_resource = masks_size + sizeof(BITMAPINFOHEADER); | 710 *bytes_in_resource = masks_size + sizeof(BITMAPINFOHEADER); |
703 } | 711 } |
OLD | NEW |