ReactOS  0.4.14-dev-50-g13bb5e2
adjust.c File Reference
#include <precomp.h>
Include dependency graph for adjust.c:

Go to the source code of this file.

Functions

BOOL DisplayBlackAndWhite (HWND hwnd, HDC hdcMem, HBITMAP hBitmap)
 
BOOL DisplayInvertedColors (HWND hwnd, HDC hdcMem, HBITMAP hBitmap)
 
BOOL DisplayBlur (HWND hwnd, HDC hdcMem, HBITMAP hBitmap)
 
BOOL DisplaySharpness (HWND hwnd, HDC hdcMem, HBITMAP hBitmap)
 

Function Documentation

◆ DisplayBlackAndWhite()

BOOL DisplayBlackAndWhite ( HWND  hwnd,
HDC  hdcMem,
HBITMAP  hBitmap 
)

Definition at line 5 of file adjust.c.

8 {
9  BITMAPINFO bi;
10  BITMAP bitmap;
11  BOOL bRes;
12  DWORD Count = 0;
13  INT i, j;
14  PBYTE pBits;
15  RECT rc;
16 
18  sizeof(BITMAP),
19  &bitmap);
20 
21  /* Bitmap header */
22  bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
23  bi.bmiHeader.biWidth = bitmap.bmWidth;
24  bi.bmiHeader.biHeight = bitmap.bmHeight;
25  bi.bmiHeader.biPlanes = 1;
26  bi.bmiHeader.biBitCount = 32;
28  bi.bmiHeader.biSizeImage = bitmap.bmWidth * bitmap.bmHeight * 4;
29  bi.bmiHeader.biClrUsed = 0;
31 
32  /* Buffer */
33  pBits = (PBYTE)HeapAlloc(ProcessHeap,
34  0,
35  bitmap.bmWidth * bitmap.bmHeight * 4);
36  if (!pBits)
37  return FALSE;
38 
39  /* get the bits from the original bitmap */
40  bRes = GetDIBits(hdcMem,
41  hBitmap,
42  0,
43  bitmap.bmHeight,
44  pBits,
45  &bi,
47 
48  for (i = 0; i < bitmap.bmHeight; i++)
49  {
50  for (j = 0; j < bitmap.bmWidth; j++)
51  {
52  DWORD Val = 0;
53  INT b, g, r;
54 
55  CopyMemory(&Val,
56  &pBits[Count],
57  4);
58 
59  /* Get pixels in reverse order */
60  b = GetRValue(Val);
61  g = GetGValue(Val);
62  r = GetBValue(Val);
63 
64  /* get the average color value */
65  Val = (r + g + b) / 3;
66 
67  /* assign to RGB color */
68  Val = RGB(Val, Val, Val);
69  CopyMemory(&pBits[Count],
70  &Val,
71  4);
72 
73  Count+=4;
74  }
75  }
76 
77  /* Set the new pixel bits */
79  hBitmap,
80  0,
81  bRes,
82  pBits,
83  &bi,
85 
87  0,
88  pBits);
89 
91  &rc);
92 
94  &rc,
95  FALSE);
96 
97  return TRUE;
98 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1471
DWORD biClrImportant
Definition: amvideo.idl:40
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define GetRValue(rgb)
Definition: wingdi.h:2930
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
int32_t INT
Definition: typedefs.h:56
#define GetGValue(rgb)
Definition: wingdi.h:2931
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD biCompression
Definition: amvideo.idl:35
#define b
Definition: ke_i.h:79
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
Definition: uimain.c:88
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define RGB(r, g, b)
Definition: wingdi.h:2935
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define CopyMemory
Definition: winbase.h:1633
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD biSizeImage
Definition: amvideo.idl:36
#define GetObject
Definition: wingdi.h:4463
HANDLE ProcessHeap
Definition: servman.c:15
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
Definition: bl.h:1331
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)
#define GetBValue(rgb)
Definition: wingdi.h:2932
static HBITMAP bitmap
Definition: clipboard.c:1344
#define DIB_RGB_COLORS
Definition: wingdi.h:366
int WINAPI SetDIBits(_In_opt_ HDC, _In_ HBITMAP, _In_ UINT, _In_ UINT, _In_ CONST VOID *, _In_ CONST BITMAPINFO *, _In_ UINT)
BYTE * PBYTE
Definition: pedump.c:66
#define BI_RGB
Definition: precomp.h:34
static HBITMAP hBitmap
Definition: timezone.c:35
#define HeapFree(x, y, z)
Definition: compat.h:394
HDC hdcMem
Definition: welcome.c:104

Referenced by MainWndCommand().

◆ DisplayBlur()

BOOL DisplayBlur ( HWND  hwnd,
HDC  hdcMem,
HBITMAP  hBitmap 
)

Definition at line 196 of file adjust.c.

199 {
200  BITMAPINFO bi;
201  BITMAP bitmap;
202  BOOL bRes;
203  DWORD Count = 0;
204  INT i, j;
205  PBYTE pBits, pBitsTemp;
206  RECT rc;
207 
209  sizeof(BITMAP),
210  &bitmap);
211 
212  /* Bitmap header */
213  bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
214  bi.bmiHeader.biWidth = bitmap.bmWidth;
215  bi.bmiHeader.biHeight = bitmap.bmHeight;
216  bi.bmiHeader.biPlanes = 1;
217  bi.bmiHeader.biBitCount = 32;
219  bi.bmiHeader.biSizeImage = bitmap.bmWidth * bitmap.bmHeight * 4;
220  bi.bmiHeader.biClrUsed = 0;
221  bi.bmiHeader.biClrImportant = 0;
222 
223  /* Buffer */
224  pBits = (PBYTE)HeapAlloc(ProcessHeap,
225  0,
226  bitmap.bmWidth * bitmap.bmHeight * 4);
227  pBitsTemp = (PBYTE)HeapAlloc(ProcessHeap,
228  0,
229  bitmap.bmWidth * bitmap.bmHeight * 4);
230  if (!pBits || !pBitsTemp)
231  return FALSE;
232 
233  /* get the bits from the original bitmap */
234  bRes = GetDIBits(hdcMem,
235  hBitmap,
236  0,
237  bitmap.bmHeight,
238  pBits,
239  &bi,
241 
242  for (i = 0; i < bitmap.bmHeight; i++)
243  {
244  for (j = 0; j < bitmap.bmWidth; j++)
245  {
246  LONG Val = 0;
247  INT b, g, r;
248  INT c1, c2, c3, c4, c5;
249 
250  CopyMemory(&Val,
251  &pBits[Count],
252  4);
253 
254  b = GetRValue(Val);
255  g = GetGValue(Val);
256  r = GetBValue(Val);
257 
258  c1 = r;
259  /* Red */
260  if ((Count < ((bitmap.bmHeight - 1) * bitmap.bmWidth * 4lu)) &&
261  (Count > (bitmap.bmWidth * 4lu)))
262  {
263  CopyMemory(&Val, &pBits[Count - (bitmap.bmWidth * 4)], 4);
264  c2 = GetBValue(Val);
265 
266  CopyMemory(&Val, &pBits[Count + 4], 4);
267  c3 = GetBValue(Val);
268 
269  CopyMemory(&Val, &pBits[(Count + (bitmap.bmWidth * 4))], 4);
270  c4 = GetBValue(Val);
271 
272  CopyMemory(&Val, &pBits[Count - 4], 4);
273  c5 = GetBValue(Val);
274 
275  r = (c1 + c2 + c3 + c4 + c5) / 5;
276  }
277 
278  /* Green */
279  c1 = g;
280  if ((Count < ((bitmap.bmHeight - 1) * bitmap.bmWidth * 4lu)) &&
281  (Count > (bitmap.bmWidth * 4lu)))
282  {
283  CopyMemory(&Val, &pBits[(Count - (bitmap.bmWidth * 4lu))], 4);
284  c2 = GetGValue(Val);
285 
286  CopyMemory(&Val, &pBits[Count + 4], 4);
287  c3 = GetGValue(Val);
288 
289  CopyMemory(&Val, &pBits[(Count + (bitmap.bmWidth * 4lu))], 4);
290  c4 = GetGValue(Val);
291 
292  CopyMemory(&Val, &pBits[Count-4], 4);
293  c5 = GetGValue(Val);
294 
295  g = (c1 + c2 + c3 + c4 + c5) / 5;
296  }
297 
298  /* Blue */
299  c1 = b;
300  if ((Count < ((bitmap.bmHeight - 1) * bitmap.bmWidth * 4lu)) &&
301  (Count > (bitmap.bmWidth * 4lu)))
302  {
303  CopyMemory(&Val, &pBits[(Count - (bitmap.bmWidth * 4l))], 4);
304  c2 = GetRValue(Val);
305 
306  CopyMemory(&Val, &pBits[Count + 4], 4);
307  c3 = GetRValue(Val);
308 
309  CopyMemory(&Val, &pBits[(Count + (bitmap.bmWidth * 4l))], 4);
310  c4 = GetRValue(Val);
311 
312  CopyMemory(&Val, &pBits[Count-4], 4);
313  c5 = GetRValue(Val);
314 
315  b = (c1 + c2 + c3 + c4 + c5) / 5;
316  }
317 
318  Val = RGB(b, g, r);
319 
320  CopyMemory(&pBitsTemp[Count],
321  &Val,
322  4);
323 
324  Count+=4;
325  }
326  }
327 
328  /* Set the new pixel bits */
330  hBitmap,
331  0,
332  bRes,
333  pBitsTemp,
334  &bi,
336 
338  0,
339  pBits);
341  0,
342  pBitsTemp);
343 
345  &rc);
346 
348  &rc,
349  FALSE);
350 
351  return TRUE;
352 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1471
DWORD biClrImportant
Definition: amvideo.idl:40
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define GetRValue(rgb)
Definition: wingdi.h:2930
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
int32_t INT
Definition: typedefs.h:56
#define GetGValue(rgb)
Definition: wingdi.h:2931
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
DWORD biCompression
Definition: amvideo.idl:35
#define b
Definition: ke_i.h:79
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
r l[0]
Definition: byte_order.h:167
Definition: uimain.c:88
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define RGB(r, g, b)
Definition: wingdi.h:2935
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define CopyMemory
Definition: winbase.h:1633
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD biSizeImage
Definition: amvideo.idl:36
#define GetObject
Definition: wingdi.h:4463
HANDLE ProcessHeap
Definition: servman.c:15
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
Definition: bl.h:1331
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)
#define GetBValue(rgb)
Definition: wingdi.h:2932
static HBITMAP bitmap
Definition: clipboard.c:1344
#define DIB_RGB_COLORS
Definition: wingdi.h:366
int WINAPI SetDIBits(_In_opt_ HDC, _In_ HBITMAP, _In_ UINT, _In_ UINT, _In_ CONST VOID *, _In_ CONST BITMAPINFO *, _In_ UINT)
BYTE * PBYTE
Definition: pedump.c:66
#define BI_RGB
Definition: precomp.h:34
static HBITMAP hBitmap
Definition: timezone.c:35
#define HeapFree(x, y, z)
Definition: compat.h:394
HDC hdcMem
Definition: welcome.c:104

Referenced by MainWndCommand().

◆ DisplayInvertedColors()

BOOL DisplayInvertedColors ( HWND  hwnd,
HDC  hdcMem,
HBITMAP  hBitmap 
)

Definition at line 102 of file adjust.c.

105 {
106  BITMAPINFO bi;
107  BITMAP bitmap;
108  BOOL bRes;
109  DWORD Count = 0;
110  INT i, j;
111  PBYTE pBits;
112  RECT rc;
113 
115  sizeof(BITMAP),
116  &bitmap);
117 
118  /* Bitmap header */
119  bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
120  bi.bmiHeader.biWidth = bitmap.bmWidth;
121  bi.bmiHeader.biHeight = bitmap.bmHeight;
122  bi.bmiHeader.biPlanes = 1;
123  bi.bmiHeader.biBitCount = 32;
125  bi.bmiHeader.biSizeImage = bitmap.bmWidth * bitmap.bmHeight * 4;
126  bi.bmiHeader.biClrUsed = 0;
127  bi.bmiHeader.biClrImportant = 0;
128 
129  /* Buffer */
130  pBits = (PBYTE)HeapAlloc(ProcessHeap,
131  0,
132  bitmap.bmWidth * bitmap.bmHeight * 4);
133  if (!pBits)
134  return FALSE;
135 
136  /* get the bits from the original bitmap */
137  bRes = GetDIBits(hdcMem,
138  hBitmap,
139  0,
140  bitmap.bmHeight,
141  pBits,
142  &bi,
144 
145  for (i = 0; i < bitmap.bmHeight; i++)
146  {
147  for (j = 0; j < bitmap.bmWidth; j++)
148  {
149  DWORD Val = 0;
150  INT b, g, r;
151 
152  CopyMemory(&Val,
153  &pBits[Count],
154  4);
155 
156  b = 255 - GetRValue(Val);
157  g = 255 - GetGValue(Val);
158  r = 255 - GetBValue(Val);
159 
160  Val = RGB(b, g, r);
161 
162  CopyMemory(&pBits[Count],
163  &Val,
164  4);
165 
166  Count+=4;
167  }
168  }
169 
170  /* Set the new pixel bits */
172  hBitmap,
173  0,
174  bRes,
175  pBits,
176  &bi,
178 
180  0,
181  pBits);
182 
184  &rc);
185 
187  &rc,
188  FALSE);
189 
190  return TRUE;
191 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1471
DWORD biClrImportant
Definition: amvideo.idl:40
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define GetRValue(rgb)
Definition: wingdi.h:2930
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
int32_t INT
Definition: typedefs.h:56
#define GetGValue(rgb)
Definition: wingdi.h:2931
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD biCompression
Definition: amvideo.idl:35
#define b
Definition: ke_i.h:79
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
Definition: uimain.c:88
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define RGB(r, g, b)
Definition: wingdi.h:2935
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define CopyMemory
Definition: winbase.h:1633
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD biSizeImage
Definition: amvideo.idl:36
#define GetObject
Definition: wingdi.h:4463
HANDLE ProcessHeap
Definition: servman.c:15
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
Definition: bl.h:1331
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)
#define GetBValue(rgb)
Definition: wingdi.h:2932
static HBITMAP bitmap
Definition: clipboard.c:1344
#define DIB_RGB_COLORS
Definition: wingdi.h:366
int WINAPI SetDIBits(_In_opt_ HDC, _In_ HBITMAP, _In_ UINT, _In_ UINT, _In_ CONST VOID *, _In_ CONST BITMAPINFO *, _In_ UINT)
BYTE * PBYTE
Definition: pedump.c:66
#define BI_RGB
Definition: precomp.h:34
static HBITMAP hBitmap
Definition: timezone.c:35
#define HeapFree(x, y, z)
Definition: compat.h:394
HDC hdcMem
Definition: welcome.c:104

Referenced by MainWndCommand().

◆ DisplaySharpness()

BOOL DisplaySharpness ( HWND  hwnd,
HDC  hdcMem,
HBITMAP  hBitmap 
)

Definition at line 357 of file adjust.c.

360 {
361  BITMAPINFO bi;
362  BITMAP bitmap;
363  BOOL bRes;
364  DWORD Count = 0;
365  INT i, j;
366  PBYTE pBits, pBitsTemp;
367  RECT rc;
368 
370  sizeof(BITMAP),
371  &bitmap);
372 
373  /* Bitmap header */
374  bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
375  bi.bmiHeader.biWidth = bitmap.bmWidth;
376  bi.bmiHeader.biHeight = bitmap.bmHeight;
377  bi.bmiHeader.biPlanes = 1;
378  bi.bmiHeader.biBitCount = 32;
380  bi.bmiHeader.biSizeImage = bitmap.bmWidth * bitmap.bmHeight * 4;
381  bi.bmiHeader.biClrUsed = 0;
382  bi.bmiHeader.biClrImportant = 0;
383 
384  /* Buffer */
385  pBits = (PBYTE)HeapAlloc(ProcessHeap,
386  0,
387  bitmap.bmWidth * bitmap.bmHeight * 4);
388  pBitsTemp = (PBYTE)HeapAlloc(ProcessHeap,
389  0,
390  bitmap.bmWidth * bitmap.bmHeight * 4);
391  if (!pBits || !pBitsTemp)
392  return FALSE;
393 
394  /* get the bits from the original bitmap */
395  bRes = GetDIBits(hdcMem,
396  hBitmap,
397  0,
398  bitmap.bmHeight,
399  pBits,
400  &bi,
402 
403  for (i = 0; i < bitmap.bmHeight; i++)
404  {
405  for (j = 0; j < bitmap.bmWidth; j++)
406  {
407  LONG Val = 0;
408  INT b, g, r;
409  INT c1, c2, c3, c4, c5;
410 
411  CopyMemory(&Val,
412  &pBits[Count],
413  4);
414 
415  b = GetRValue(Val);
416  g = GetGValue(Val);
417  r = GetBValue(Val);
418 
419  c1 = r;
420  /* Red */
421  if ((Count < ((bitmap.bmHeight - 1) * bitmap.bmWidth * 4lu)) &&
422  (Count > (bitmap.bmWidth * 4lu)))
423  {
424  CopyMemory(&Val, &pBits[Count - (bitmap.bmWidth * 4l)], 4);
425  c2 = GetBValue(Val);
426 
427  CopyMemory(&Val, &pBits[Count + 4], 4);
428  c3 = GetBValue(Val);
429 
430  CopyMemory(&Val, &pBits[(Count + (bitmap.bmWidth * 4l))], 4);
431  c4 = GetBValue(Val);
432 
433  CopyMemory(&Val, &pBits[Count - 4], 4);
434  c5 = GetBValue(Val);
435 
436  r = (c1 * 5) - (c2 + c3 + c4 + c5);
437  }
438 
439  /* Green */
440  c1 = g;
441  if ((Count < ((bitmap.bmHeight - 1)* bitmap.bmWidth * 4lu)) &&
442  (Count > (bitmap.bmWidth * 4lu)))
443  {
444  CopyMemory(&Val, &pBits[(Count - (bitmap.bmWidth * 4l))], 4);
445  c2 = GetGValue(Val);
446 
447  CopyMemory(&Val, &pBits[Count + 4], 4);
448  c3 = GetGValue(Val);
449 
450  CopyMemory(&Val, &pBits[(Count + (bitmap.bmWidth * 4l))], 4);
451  c4 = GetGValue(Val);
452 
453  CopyMemory(&Val, &pBits[Count - 4], 4);
454  c5 = GetGValue(Val);
455 
456  g = (c1 * 5) - (c2 + c3 + c4 + c5);
457  }
458 
459  /* Blue */
460  c1 = b;
461  if ((Count < ((bitmap.bmHeight - 1) * bitmap.bmWidth * 4lu)) &&
462  (Count > (bitmap.bmWidth * 4lu)))
463  {
464  CopyMemory(&Val, &pBits[(Count - (bitmap.bmWidth * 4l))], 4);
465  c2 = GetRValue(Val);
466 
467  CopyMemory(&Val, &pBits[Count + 4], 4);
468  c3 = GetRValue(Val);
469 
470  CopyMemory(&Val, &pBits[(Count+(bitmap.bmWidth * 4l))], 4);
471  c4 = GetRValue(Val);
472 
473  CopyMemory(&Val, &pBits[Count - 4], 4);
474  c5 = GetRValue(Val);
475 
476  b = (c1 * 5) - (c2 + c3 + c4 + c5);
477  }
478 
479  /* Red */
480  if (r > 255) r = 255;
481  if (r < 0) r = 0;
482 
483  /* Green */
484  if (g > 255) g = 255;
485  if (g < 0)g = 0;
486 
487  /* Blue */
488  if (b > 255) b = 255;
489  if (b < 0) b = 0;
490 
491  Val = RGB(b, g, r);
492 
493  CopyMemory(&pBitsTemp[Count],
494  &Val,
495  4);
496 
497  Count+=4;
498  }
499  }
500 
501  /* Set the new pixel bits */
503  hBitmap,
504  0,
505  bRes,
506  pBitsTemp,
507  &bi,
509 
511  0,
512  pBits);
514  0,
515  pBitsTemp);
516 
518  &rc);
519 
521  &rc,
522  FALSE);
523 
524  return TRUE;
525 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
BITMAPINFOHEADER bmiHeader
Definition: wingdi.h:1471
DWORD biClrImportant
Definition: amvideo.idl:40
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define GetRValue(rgb)
Definition: wingdi.h:2930
_Inout_ __drv_aliasesMem PSLIST_ENTRY _Inout_ PSLIST_ENTRY _In_ ULONG Count
Definition: exfuncs.h:1015
int32_t INT
Definition: typedefs.h:56
#define GetGValue(rgb)
Definition: wingdi.h:2931
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
DWORD biCompression
Definition: amvideo.idl:35
#define b
Definition: ke_i.h:79
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
r l[0]
Definition: byte_order.h:167
Definition: uimain.c:88
GLboolean GLboolean g
Definition: glext.h:6204
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define RGB(r, g, b)
Definition: wingdi.h:2935
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define CopyMemory
Definition: winbase.h:1633
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD biSizeImage
Definition: amvideo.idl:36
#define GetObject
Definition: wingdi.h:4463
HANDLE ProcessHeap
Definition: servman.c:15
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
Definition: bl.h:1331
int WINAPI GetDIBits(_In_ HDC hdc, _In_ HBITMAP hbm, _In_ UINT start, _In_ UINT cLines, _Out_opt_ LPVOID lpvBits, _At_((LPBITMAPINFOHEADER) lpbmi, _Inout_) LPBITMAPINFO lpbmi, _In_ UINT usage)
#define GetBValue(rgb)
Definition: wingdi.h:2932
static HBITMAP bitmap
Definition: clipboard.c:1344
#define DIB_RGB_COLORS
Definition: wingdi.h:366
int WINAPI SetDIBits(_In_opt_ HDC, _In_ HBITMAP, _In_ UINT, _In_ UINT, _In_ CONST VOID *, _In_ CONST BITMAPINFO *, _In_ UINT)
BYTE * PBYTE
Definition: pedump.c:66
#define BI_RGB
Definition: precomp.h:34
static HBITMAP hBitmap
Definition: timezone.c:35
#define HeapFree(x, y, z)
Definition: compat.h:394
HDC hdcMem
Definition: welcome.c:104

Referenced by MainWndCommand().