[email protected] | 1a30dd3 | 2012-01-28 00:56:43 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 267c03d | 2011-02-02 23:03:07 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef UI_GFX_GDI_UTIL_H_ |
| 6 | #define UI_GFX_GDI_UTIL_H_ |
[email protected] | 267c03d | 2011-02-02 23:03:07 | [diff] [blame] | 7 | |
[email protected] | 267c03d | 2011-02-02 23:03:07 | [diff] [blame] | 8 | #include <windows.h> |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 9 | #include <vector> |
[email protected] | 267c03d | 2011-02-02 23:03:07 | [diff] [blame] | 10 | |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 11 | #include "ui/gfx/geometry/rect.h" |
[email protected] | d34e407 | 2013-09-05 20:28:30 | [diff] [blame] | 12 | #include "ui/gfx/gfx_export.h" |
[email protected] | 82d74e9 | 2012-07-18 17:11:55 | [diff] [blame] | 13 | #include "ui/gfx/path.h" |
[email protected] | 267c03d | 2011-02-02 23:03:07 | [diff] [blame] | 14 | |
| 15 | namespace gfx { |
| 16 | |
| 17 | // Creates a BITMAPINFOHEADER structure given the bitmap's size. |
[email protected] | 4ffa789 | 2013-09-27 16:56:06 | [diff] [blame] | 18 | GFX_EXPORT void CreateBitmapHeader(int width, int height, |
| 19 | BITMAPINFOHEADER* hdr); |
[email protected] | 267c03d | 2011-02-02 23:03:07 | [diff] [blame] | 20 | |
[email protected] | 267c03d | 2011-02-02 23:03:07 | [diff] [blame] | 21 | // Creates a BITMAPV4HEADER structure given the bitmap's size. You probably |
| 22 | // only need to use BMP V4 if you need transparency (alpha channel). This |
| 23 | // function sets the AlphaMask to 0xff000000. |
[email protected] | 4ffa789 | 2013-09-27 16:56:06 | [diff] [blame] | 24 | GFX_EXPORT void CreateBitmapV4Header(int width, int height, |
| 25 | BITMAPV4HEADER* hdr); |
[email protected] | 267c03d | 2011-02-02 23:03:07 | [diff] [blame] | 26 | |
| 27 | // Creates a monochrome bitmap header. |
| 28 | void CreateMonochromeBitmapHeader(int width, int height, BITMAPINFOHEADER* hdr); |
| 29 | |
| 30 | // Modify the given hrgn by subtracting the given rectangles. |
[email protected] | 4ffa789 | 2013-09-27 16:56:06 | [diff] [blame] | 31 | GFX_EXPORT void SubtractRectanglesFromRegion( |
[email protected] | 507bad5 | 2011-08-06 04:51:07 | [diff] [blame] | 32 | HRGN hrgn, |
| 33 | const std::vector<gfx::Rect>& cutouts); |
[email protected] | 267c03d | 2011-02-02 23:03:07 | [diff] [blame] | 34 | |
[email protected] | 4ffa789 | 2013-09-27 16:56:06 | [diff] [blame] | 35 | GFX_EXPORT HRGN ConvertPathToHRGN(const gfx::Path& path); |
[email protected] | 82d74e9 | 2012-07-18 17:11:55 | [diff] [blame] | 36 | |
[email protected] | 1a30dd3 | 2012-01-28 00:56:43 | [diff] [blame] | 37 | // Calculate scale to fit an entire page on DC. |
pkasting | 46a6291 | 2014-10-09 21:30:00 | [diff] [blame] | 38 | GFX_EXPORT float CalculatePageScale(HDC dc, int page_width, int page_height); |
[email protected] | 1a30dd3 | 2012-01-28 00:56:43 | [diff] [blame] | 39 | |
| 40 | // Apply scaling to the DC. |
pkasting | 46a6291 | 2014-10-09 21:30:00 | [diff] [blame] | 41 | GFX_EXPORT bool ScaleDC(HDC dc, float scale_factor); |
[email protected] | 1a30dd3 | 2012-01-28 00:56:43 | [diff] [blame] | 42 | |
[email protected] | 4ffa789 | 2013-09-27 16:56:06 | [diff] [blame] | 43 | GFX_EXPORT void StretchDIBits(HDC hdc, |
| 44 | int dest_x, int dest_y, int dest_w, int dest_h, |
| 45 | int src_x, int src_y, int src_w, int src_h, |
| 46 | void* pixels, const BITMAPINFO* bitmap_info); |
[email protected] | b4f0016 | 2013-03-09 02:51:14 | [diff] [blame] | 47 | |
[email protected] | 267c03d | 2011-02-02 23:03:07 | [diff] [blame] | 48 | } // namespace gfx |
| 49 | |
| 50 | #endif // UI_GFX_GDI_UTIL_H_ |