xref: /reactos/base/applications/mspaint/dib.h (revision 7f26a396)
1 /*
2  * PROJECT:    PAINT for ReactOS
3  * LICENSE:    LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
4  * PURPOSE:    Some DIB related functions
5  * COPYRIGHT:  Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
6  */
7 
8 #pragma once
9 
10 BOOL IsBitmapBlackAndWhite(HBITMAP hbm);
11 HBITMAP CreateDIBWithProperties(int width, int height);
12 HBITMAP CreateMonoBitmap(int width, int height, BOOL bWhite);
13 HBITMAP CreateColorDIB(int width, int height, COLORREF rgb);
14 HBITMAP CachedBufferDIB(HBITMAP hbm, int minimalWidth, int minimalHeight);
15 HBITMAP ConvertToBlackAndWhite(HBITMAP hbm);
16 
17 HBITMAP CopyMonoImage(HBITMAP hbm, INT cx = 0, INT cy = 0);
18 
19 static inline HBITMAP CopyDIBImage(HBITMAP hbm, INT cx = 0, INT cy = 0)
20 {
21     return (HBITMAP)CopyImage(hbm, IMAGE_BITMAP, cx, cy, LR_COPYRETURNORG | LR_CREATEDIBSECTION);
22 }
23 
24 int GetDIBWidth(HBITMAP hbm);
25 int GetDIBHeight(HBITMAP hbm);
26 
27 BOOL SaveDIBToFile(HBITMAP hBitmap, LPCWSTR FileName, BOOL fIsMainFile, REFGUID guidFileType = GUID_NULL);
28 
29 HBITMAP DoLoadImageFile(HWND hwnd, LPCWSTR name, BOOL fIsMainFile);
30 
31 void SetFileInfo(LPCWSTR name, LPWIN32_FIND_DATAW pFound, BOOL isAFile);
32 
33 HBITMAP InitializeImage(LPCWSTR name, LPWIN32_FIND_DATAW pFound, BOOL isFile);
34 HBITMAP SetBitmapAndInfo(HBITMAP hBitmap, LPCWSTR name, LPWIN32_FIND_DATAW pFound, BOOL isFile);
35 
36 HBITMAP Rotate90DegreeBlt(HDC hDC1, INT cx, INT cy, BOOL bRight, BOOL bMono);
37 
38 HBITMAP SkewDIB(HDC hDC1, HBITMAP hbm, INT nDegree, BOOL bVertical, BOOL bMono = FALSE);
39 
40 float PpcmFromDpi(float dpi);
41 
42 #define ROUND(x) (INT)((x) + 0.5)
43 
44 HGLOBAL BitmapToClipboardDIB(HBITMAP hBitmap);
45 HBITMAP BitmapFromClipboardDIB(HGLOBAL hGlobal);
46 HBITMAP BitmapFromHEMF(HENHMETAFILE hEMF);
47 HBITMAP getSubImage(HBITMAP hbmWhole, const RECT& rcPartial);
48 void putSubImage(HBITMAP hbmWhole, const RECT& rcPartial, HBITMAP hbmPart);
49