-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpixelPainter.cpp
142 lines (91 loc) · 2.99 KB
/
pixelPainter.cpp
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#include "pixelPainter.h"
#define PI 3.1415
using namespace std;
//I've got no idea...
//http://stackoverflow.com/questions/12378642/c-pixels-in-console-window
//HBITMAP CreateDIBSection(
// HDC hdc, // handle to DC
// CONST BITMAPINFO *pbmi, // bitmap data
// UINT iUsage, // data type indicator
// VOID **ppvBits, // bit values
// HANDLE hSection, // handle to file mapping object
// DWORD dwOffset // offset to bitmap bit values
//);
int screenSizeChange(int x, int y, int xSize, int ySize)
{
//SetWindowPos()
}
int screenDraw(unsigned char *drawing_bytes, struct xyPair window, HDC mydc)
{
//if ((!window.xSize) || (!window.ySize)) return;
if ((!window.x) || (!window.y)) return 0;
BITMAPINFO info;
info.bmiHeader.biSize = sizeof (info.bmiHeader);
info.bmiHeader.biWidth = window.x;//Size;
info.bmiHeader.biHeight = window.y;//Size;
info.bmiHeader.biPlanes = 1;
info.bmiHeader.biBitCount = 24; // 24 bits per pixel - one unsigned char for each pixel
info.bmiHeader.biCompression = BI_RGB;
info.bmiHeader.biSizeImage = 0;
info.bmiHeader.biClrUsed = 0;
info.bmiHeader.biClrImportant = 0;
HDC cDC = CreateCompatibleDC (mydc); // this is the GetDC (hwnd) where hwnd is the
// handle of the window I want to write to
HBITMAP hbmp = CreateCompatibleBitmap (cDC, window.x, window.y);
SetDIBits (cDC, hbmp, 0, window.y, drawing_bytes, &info, DIB_RGB_COLORS);
hbmp = (HBITMAP) SelectObject (cDC, hbmp);
BitBlt (cDC, 0, 0, window.x, window.y, cDC, 0, 0, SRCCOPY);
DeleteObject (SelectObject(cDC, hbmp));
DeleteDC (cDC);
}
int pixelPaint(HWND myConsole)
{
AllocConsole();
FreeConsole();
DWORD consoleThing;
HBITMAP hBitmap;
BITMAPINFO* m_Bit;
//CBitmap m_OffscreenBitmap, *m_pOldBitmap;
//FIBITMAP* m_dib;
//ATOM aso;
//Get a console handle
}
// HBITMAP CreateBitmap(
// _In_ int nWidth,
// _In_ int nHeight,
// _In_ UINT cPlanes,
// _In_ UINT cBitsPerPel,
// _In_ const VOID *lpvBits
//);
//
//
// CreateDIBSection(mydc, m_Bit, DIB_RGB_COLORS, (void**)&m_pBits, NULL, 0)
// m_OffscreenBitmap.Attach(hBitmap);
// m_pOldBitmap = m_dcOffscreen.SelectObject(&m_OffscreenBitmap);
// //hBitmap=(HBITMAP) LoadImage(NULL, _T("c:\\Temp\\Temp.bmp"), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE);
//
// int pixel =0;
//
// //Choose any color
// COLORREF COLOR = RGB(255,255,255);
//
// //Draw pixels
// for(double i = 0; i < PI * 4; i += 0.05)
// {
// SetPixel(mydc,pixel,12,COLOR);
// pixel+=1;
// }
//
// ReleaseDC(myConsole, mydc);
// cin.ignore();
// return 0;
//}
int pixelController()
{
char name[62];
int thingy = GetConsoleTitle(name, 62);
HWND myConsole;
myConsole = FindWindow(NULL, name);
//Get a handle to device context
HDC mydc = GetDC(myConsole);
}