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
3 // found in the LICENSE file.
5 #ifndef UI_GFX_GDI_UTIL_H_
6 #define UI_GFX_GDI_UTIL_H_
11 #include "ui/gfx/gfx_export.h"
12 #include "ui/gfx/rect.h"
13 #include "ui/gfx/path.h"
17 // Creates a BITMAPINFOHEADER structure given the bitmap's size.
18 GFX_EXPORT
void CreateBitmapHeader(int width
, int height
,
19 BITMAPINFOHEADER
* hdr
);
21 // Creates a BITMAPINFOHEADER structure given the bitmap's size and
22 // color depth in bits per pixel.
23 void CreateBitmapHeaderWithColorDepth(int width
, int height
, int color_depth
,
24 BITMAPINFOHEADER
* hdr
);
26 // Creates a BITMAPV4HEADER structure given the bitmap's size. You probably
27 // only need to use BMP V4 if you need transparency (alpha channel). This
28 // function sets the AlphaMask to 0xff000000.
29 GFX_EXPORT
void CreateBitmapV4Header(int width
, int height
,
32 // Creates a monochrome bitmap header.
33 void CreateMonochromeBitmapHeader(int width
, int height
, BITMAPINFOHEADER
* hdr
);
35 // Modify the given hrgn by subtracting the given rectangles.
36 GFX_EXPORT
void SubtractRectanglesFromRegion(
38 const std::vector
<gfx::Rect
>& cutouts
);
40 GFX_EXPORT HRGN
ConvertPathToHRGN(const gfx::Path
& path
);
42 // Calculate scale to fit an entire page on DC.
43 GFX_EXPORT
double CalculatePageScale(HDC dc
, int page_width
, int page_height
);
45 // Apply scaling to the DC.
46 GFX_EXPORT
bool ScaleDC(HDC dc
, double scale_factor
);
48 GFX_EXPORT
void StretchDIBits(HDC hdc
,
49 int dest_x
, int dest_y
, int dest_w
, int dest_h
,
50 int src_x
, int src_y
, int src_w
, int src_h
,
51 void* pixels
, const BITMAPINFO
* bitmap_info
);
55 #endif // UI_GFX_GDI_UTIL_H_