1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
| void CBitmap::SplitRGB2CMY (CBitmap &bmpCyan, CBitmap &bmpMagenta,
CBitmap &bmpYellow) const
{
int iWidth, iHeight;
iWidth = this->GetWidth();
iHeight = this->GetHeight();
HDC hdcWnd = GetDC (this->hwnd);
HBITMAP hbmpCyan = CreateCompatibleBitmap (hdcWnd, iWidth, iHeight);
if (hbmpCyan == NULL)
throw CException (ERROR_NOCREATECOMPATIBLEBITMAP,
"CBitmap::SplitCMY", "CBitmap", "hbmpCyan");
HBITMAP hbmpMagenta = CreateCompatibleBitmap (hdcWnd, iWidth, iHeight);
if (hbmpMagenta == NULL)
{
DeleteObject (hbmpCyan);
throw CException (ERROR_NOCREATECOMPATIBLEBITMAP,
"CBitmap::SplitCMY", "CBitmap", "hbmpMagenta");
}
HBITMAP hbmpYellow = CreateCompatibleBitmap (hdcWnd, iWidth, iHeight);
if (hbmpYellow == NULL)
{
DeleteObject (hbmpMagenta);
DeleteObject (hbmpCyan);
throw CException (ERROR_NOCREATECOMPATIBLEBITMAP,
"CBitmap::SplitCMY", "CBitmap", "hbmpYellow");
}
HDC hdcMemThis = CreateCompatibleDC (hdcWnd); //Creer compatible DC in mem
SelectObject(hdcMemThis, this->hbmpImage); //Image aan Memory DC toekennen
HDC hdcMemCyan = CreateCompatibleDC (hdcWnd); //Creer compatible DC in mem
SelectObject(hdcMemCyan, hbmpCyan); //Image aan Memory DC toekennen
HDC hdcMemMagenta = CreateCompatibleDC (hdcWnd); //Creer compatible DC in mem
SelectObject(hdcMemMagenta, hbmpMagenta); //Image aan Memory DC toekennen
HDC hdcMemYellow = CreateCompatibleDC (hdcWnd); //Creer compatible DC in mem
SelectObject(hdcMemYellow, hbmpYellow); //Image aan Memory DC toekennen
BYTE byCyan, byMagenta, byYellow;
COLORREF col;
for (int iY=0; iY<iHeight; iY++)
{
for (int iX=0; iX<iWidth; iX++)
{
col = ::GetPixel (hdcMemThis, iX, iY);
byCyan = 255 - GetRValue (col);
byMagenta = 255 - GetGValue (col);
byYellow = 255 - GetBValue (col);
col = RGB(0, byCyan, byCyan);
::SetPixel (hdcMemCyan, iX, iY, col);
col = RGB(byMagenta, 0, byMagenta);
::SetPixel (hdcMemMagenta, iX, iY, col);
col = RGB(byYellow, byYellow, 0);
::SetPixel (hdcMemYellow, iX, iY, col);
}
}
if (bmpCyan.hbmpImage != NULL)
DeleteObject (bmpCyan.hbmpImage);
bmpCyan.hbmpImage = hbmpCyan;
if (bmpMagenta.hbmpImage != NULL)
DeleteObject (bmpMagenta.hbmpImage);
bmpMagenta.hbmpImage = hbmpMagenta;
if (bmpYellow.hbmpImage != NULL)
DeleteObject (bmpYellow.hbmpImage);
bmpYellow.hbmpImage = hbmpYellow;
DeleteDC (hdcMemYellow);
DeleteDC (hdcMemMagenta);
DeleteDC (hdcMemCyan);
DeleteDC (hdcMemThis);
ReleaseDC (hwnd, hdcWnd);
} |