blob: 03ae91b3d0b79434f61131b53f3f601df9851abb [file] [log] [blame]
[email protected]1a30dd32012-01-28 00:56:431// Copyright (c) 2012 The Chromium Authors. All rights reserved.
[email protected]267c03d2011-02-02 23:03:072// 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]267c03d2011-02-02 23:03:077
8#include <vector>
9#include <windows.h>
10
[email protected]d34e4072013-09-05 20:28:3011#include "ui/gfx/gfx_export.h"
[email protected]08397d52011-02-05 01:53:3812#include "ui/gfx/rect.h"
[email protected]82d74e92012-07-18 17:11:5513#include "ui/gfx/path.h"
[email protected]267c03d2011-02-02 23:03:0714
15namespace gfx {
16
17// Creates a BITMAPINFOHEADER structure given the bitmap's size.
[email protected]4ffa7892013-09-27 16:56:0618GFX_EXPORT void CreateBitmapHeader(int width, int height,
19 BITMAPINFOHEADER* hdr);
[email protected]267c03d2011-02-02 23:03:0720
21// Creates a BITMAPINFOHEADER structure given the bitmap's size and
22// color depth in bits per pixel.
23void CreateBitmapHeaderWithColorDepth(int width, int height, int color_depth,
24 BITMAPINFOHEADER* hdr);
25
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.
[email protected]4ffa7892013-09-27 16:56:0629GFX_EXPORT void CreateBitmapV4Header(int width, int height,
30 BITMAPV4HEADER* hdr);
[email protected]267c03d2011-02-02 23:03:0731
32// Creates a monochrome bitmap header.
33void CreateMonochromeBitmapHeader(int width, int height, BITMAPINFOHEADER* hdr);
34
35// Modify the given hrgn by subtracting the given rectangles.
[email protected]4ffa7892013-09-27 16:56:0636GFX_EXPORT void SubtractRectanglesFromRegion(
[email protected]507bad52011-08-06 04:51:0737 HRGN hrgn,
38 const std::vector<gfx::Rect>& cutouts);
[email protected]267c03d2011-02-02 23:03:0739
[email protected]4ffa7892013-09-27 16:56:0640GFX_EXPORT HRGN ConvertPathToHRGN(const gfx::Path& path);
[email protected]82d74e92012-07-18 17:11:5541
[email protected]1a30dd32012-01-28 00:56:4342// Calculate scale to fit an entire page on DC.
pkasting46a62912014-10-09 21:30:0043GFX_EXPORT float CalculatePageScale(HDC dc, int page_width, int page_height);
[email protected]1a30dd32012-01-28 00:56:4344
45// Apply scaling to the DC.
pkasting46a62912014-10-09 21:30:0046GFX_EXPORT bool ScaleDC(HDC dc, float scale_factor);
[email protected]1a30dd32012-01-28 00:56:4347
[email protected]4ffa7892013-09-27 16:56:0648GFX_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);
[email protected]b4f00162013-03-09 02:51:1452
[email protected]267c03d2011-02-02 23:03:0753} // namespace gfx
54
55#endif // UI_GFX_GDI_UTIL_H_