ReactOS  0.4.14-dev-831-gef8c9239
dib.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

HBITMAP CreateDIBWithProperties (int width, int height)
 
int GetDIBWidth (HBITMAP hbm)
 
int GetDIBHeight (HBITMAP hbm)
 
void SaveDIBToFile (HBITMAP hBitmap, LPTSTR FileName, HDC hDC, LPSYSTEMTIME time, int *size, int hRes, int vRes)
 
void LoadDIBFromFile (HBITMAP *hBitmap, LPCTSTR name, LPSYSTEMTIME time, int *size, int *hRes, int *vRes)
 
void ShowFileLoadError (LPCTSTR name)
 

Function Documentation

◆ CreateDIBWithProperties()

HBITMAP CreateDIBWithProperties ( int  width,
int  height 
)

Definition at line 16 of file dib.cpp.

17 {
18  BITMAPINFO bmi;
19  ZeroMemory(&bmi, sizeof(BITMAPINFO));
20  bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
21  bmi.bmiHeader.biWidth = width;
23  bmi.bmiHeader.biPlanes = 1;
24  bmi.bmiHeader.biBitCount = 24;
26  return CreateDIBSection(NULL, &bmi, DIB_RGB_COLORS, NULL, NULL, 0);
27 }
GLint GLint GLsizei width
Definition: gl.h:1546
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1475
struct tagBITMAPINFOHEADER BITMAPINFOHEADER
#define ZeroMemory
Definition: winbase.h:1642
DWORD biCompression
Definition: amvideo.idl:35
smooth NULL
Definition: ftsmooth.c:416
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
HBITMAP WINAPI CreateDIBSection(HDC hDC, CONST BITMAPINFO *BitmapInfo, UINT Usage, VOID **Bits, HANDLE hSection, DWORD dwOffset)
Definition: bitmap.c:197
#define DIB_RGB_COLORS
Definition: wingdi.h:366
#define BI_RGB
Definition: precomp.h:41

Referenced by SelectionModel::CalculateBoundingBoxAndContents(), SelectionModel::CalculateContents(), ImageModel::Crop(), ImageModel::ImageModel(), and SelectionModel::ScaleContentsToFit().

◆ GetDIBHeight()

int GetDIBHeight ( HBITMAP  hbm)

Definition at line 38 of file dib.cpp.

39 {
40  BITMAP bm;
41  GetObject(hBitmap, sizeof(BITMAP), &bm);
42  return bm.bmHeight;
43 }
#define GetObject
Definition: wingdi.h:4467
Definition: bl.h:1331
static HBITMAP hBitmap
Definition: timezone.c:35

Referenced by SelectionModel::DrawSelectionStretched(), ImageModel::GetHeight(), SelectionModel::InsertFromHBITMAP(), CMainWindow::InsertSelectionFromHBITMAP(), and SelectionModel::ScaleContentsToFit().

◆ GetDIBWidth()

int GetDIBWidth ( HBITMAP  hbm)

Definition at line 30 of file dib.cpp.

31 {
32  BITMAP bm;
33  GetObject(hBitmap, sizeof(BITMAP), &bm);
34  return bm.bmWidth;
35 }
#define GetObject
Definition: wingdi.h:4467
Definition: bl.h:1331
static HBITMAP hBitmap
Definition: timezone.c:35

Referenced by SelectionModel::DrawSelectionStretched(), ImageModel::GetWidth(), SelectionModel::InsertFromHBITMAP(), CMainWindow::InsertSelectionFromHBITMAP(), and SelectionModel::ScaleContentsToFit().

◆ LoadDIBFromFile()

void LoadDIBFromFile ( HBITMAP hBitmap,
LPCTSTR  name,
LPSYSTEMTIME  time,
int size,
int hRes,
int vRes 
)

Definition at line 84 of file dib.cpp.

85 {
86  CImage img;
87  img.Load(name);
88  *hBitmap = img.Detach();
89 
90  if (!hBitmap)
91  {
93  return;
94  }
95 
96  // update time and size
97  HANDLE hFile =
100  {
102  return;
103  }
104 
105  if (time)
106  {
107  FILETIME ft;
108  GetFileTime(hFile, NULL, NULL, &ft);
110  }
111  if (size)
112  *size = GetFileSize(hFile, NULL);
113 
114  HDC hScreenDC = GetDC(NULL);
115  *hRes = (int)(GetDeviceCaps(hScreenDC, LOGPIXELSX) * 1000 / 25.4);
116  *vRes = (int)(GetDeviceCaps(hScreenDC, LOGPIXELSY) * 1000 / 25.4);
117  ReleaseDC(NULL, hScreenDC);
118 
120 }
#define LOGPIXELSX
Definition: wingdi.h:717
#define CloseHandle
Definition: compat.h:406
HDC WINAPI GetDC(_In_opt_ HWND)
static HDC
Definition: imagelist.c:92
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
__u16 time
Definition: mkdosfs.c:366
#define FILE_SHARE_READ
Definition: compat.h:125
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:434
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
GLsizeiptr size
Definition: glext.h:5919
GLint GLvoid * img
Definition: gl.h:1956
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define GENERIC_READ
Definition: compat.h:124
_In_ HANDLE hFile
Definition: mswsock.h:90
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
#define FILE_FLAG_SEQUENTIAL_SCAN
Definition: disk.h:43
void ShowFileLoadError(LPCTSTR name)
Definition: dib.cpp:74
Definition: name.c:38
#define LOGPIXELSY
Definition: wingdi.h:718
static HBITMAP hBitmap
Definition: timezone.c:35
BOOL WINAPI GetFileTime(IN HANDLE hFile, OUT LPFILETIME lpCreationTime OPTIONAL, OUT LPFILETIME lpLastAccessTime OPTIONAL, OUT LPFILETIME lpLastWriteTime OPTIONAL)
Definition: fileinfo.c:1046
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31

Referenced by _tWinMain(), CMainWindow::OnCommand(), and CMainWindow::OnDropFiles().

◆ SaveDIBToFile()

void SaveDIBToFile ( HBITMAP  hBitmap,
LPTSTR  FileName,
HDC  hDC,
LPSYSTEMTIME  time,
int size,
int  hRes,
int  vRes 
)

Definition at line 46 of file dib.cpp.

47 {
48  CImage img;
49  img.Attach(hBitmap);
50  img.Save(FileName); // TODO: error handling
51  img.Detach();
52 
53  // update time and size
54 
55  HANDLE hFile =
58  return;
59 
60  if (time)
61  {
62  FILETIME ft;
63  GetFileTime(hFile, NULL, NULL, &ft);
65  }
66  if (size)
68 
69  // TODO: update hRes and vRes
70 
72 }
#define CloseHandle
Definition: compat.h:406
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
__u16 time
Definition: mkdosfs.c:366
#define FILE_SHARE_READ
Definition: compat.h:125
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:434
BOOL WINAPI FileTimeToSystemTime(IN CONST FILETIME *lpFileTime, OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:188
GLsizeiptr size
Definition: glext.h:5919
GLint GLvoid * img
Definition: gl.h:1956
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
#define GENERIC_READ
Definition: compat.h:124
_In_ HANDLE hFile
Definition: mswsock.h:90
IN OUT PVCB OUT PDIRENT OUT PBCB IN BOOLEAN CreateFile
Definition: fatprocs.h:904
#define FILE_FLAG_SEQUENTIAL_SCAN
Definition: disk.h:43
static HBITMAP hBitmap
Definition: timezone.c:35
BOOL WINAPI GetFileTime(IN HANDLE hFile, OUT LPFILETIME lpCreationTime OPTIONAL, OUT LPFILETIME lpLastAccessTime OPTIONAL, OUT LPFILETIME lpLastWriteTime OPTIONAL)
Definition: fileinfo.c:1046

Referenced by CMainWindow::OnCommand(), and ImageModel::SaveImage().

◆ ShowFileLoadError()

void ShowFileLoadError ( LPCTSTR  name)

Definition at line 74 of file dib.cpp.

75 {
76  CString strText;
78  CString strProgramName;
79  strProgramName.LoadString(IDS_PROGRAMNAME);
80  mainWindow.MessageBox(strText, strProgramName, MB_OK | MB_ICONEXCLAMATION);
81 }
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define IDS_PROGRAMNAME
Definition: definitions.h:203
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:668
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
#define IDS_LOADERRORTEXT
Definition: definitions.h:238
#define MB_OK
Definition: winuser.h:784
Definition: name.c:38
BOOL LoadString(_In_ UINT nID)
Definition: cstringt.h:506
int MessageBox(LPCTSTR lpszText, LPCTSTR lpszCaption=NULL, UINT nType=MB_OK)
Definition: atlwin.h:934
CMainWindow mainWindow
Definition: main.cpp:62

Referenced by LoadDIBFromFile().