| View previous topic :: View next topic |
| Author |
Message |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Fri Sep 21, 2007 7:08 pm Post subject: c++ Monochrome HBITMAP is not what i want |
|
|
monochrome is 2 colors, black and white
i want 24 bit color, not 1 bit
i can't get it to work though
Run the program and see the hdc is monochrome
The first BitBlt stores the hBitmap
The second paints the hBitmap onto the hdc
can anyone help?
_________________
Last edited by HomerSexual on Fri Sep 21, 2007 7:38 pm; edited 1 time in total |
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Fri Sep 21, 2007 7:20 pm Post subject: |
|
|
| you didn't post any source code, how are we supposed to know what you did wrong?
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri Sep 21, 2007 7:21 pm Post subject: |
|
|
true...post source =P
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Fri Sep 21, 2007 7:38 pm Post subject: |
|
|
oh yea i forgot, sorry long day
updating now
_________________
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri Sep 21, 2007 8:21 pm Post subject: |
|
|
T.T can't you just post the source instaed of attaching it...
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
HomerSexual Grandmaster Cheater Supreme
Reputation: 5
Joined: 03 Feb 2007 Posts: 1657
|
Posted: Sat Sep 22, 2007 5:31 am Post subject: |
|
|
no because its long
its win32 gui...
its like 300+ lines
not some vb shit
_________________
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sat Sep 22, 2007 7:02 am Post subject: |
|
|
Set your window as the canvas and create the bitmap on it.
A quick rundown:
| Code: |
BITMAPINFO canvas;
canvas.bmiHeader.biSize = sizeof(canvas.bmiHeader);
canvas.bmiHeader.biWidth = SIZE_OF_WINDOW-X;
canvas.bmiHeader.biHeight = -(signed int(SIZE_OF_WINDOW-Y));
canvas.bmiHeader.biPlanes = 1;
canvas.bmiHeader.biBitCount = 32;
|
Then create the DC and set it to your window:
| Code: |
HDC canvashDC;
HBITMAP canvasBmp;
unsigned char* lpCanvasBuffer;
canvasDC = CreateCompatibleDC( GetWindowDC(YourWindowHandle) );
canvasBmp = CreateDIBSection( canvasDC, &canvas, DIB_RGB_COLORS, (LPVOID*)&lpCanvasBuffer, 0, 0 );
|
Your bitmap is setup in pixels on the lpCanvasBuffer then. Pixels are setup like this:
* color[0] Blue
* color[1] Green
* color[2] Red
* color[3] Alpha
To clear the canvas buffer:
| Code: | | memset( (void*)lpCanvasBuffer, 0, WindowSizeX*WindowSizeY*4 ); |
To update the canvas:
| Code: |
PAINTSTRUCT ps;
HDC hDCDisplay = BeginPaint(YourWindowhWnd, &ps);
BitBlt(hDCDisplay, 0, 0, WindowSizeX, WindowSizeY, canvashDC, 0, 0, SRCCOPY);
EndPaint(YourWindowHwnd, &ps);
|
Then plotting pixels:
| Code: |
void PutPixel( unsigned int x, unsigned int y, unsigned char r, unsigned char g, unsigned char b )
{
unsigned int iOffset = 0;
if( x >= 0 && x < WindowSizeX && y >= 0 && y < WindowSizeY )
{
iOffset = ( (y * WindowSizeX) + x );
lpCanvasBuffer[(iOffset * 4) ] = b;
lpCanvasBuffer[(iOffset * 4)+1] = g;
lpCanvasBuffer[(iOffset * 4)+2] = r;
}
}
|
Hope that helps.
|
|
| Back to top |
|
 |
Robotex Master Cheater
Reputation: 0
Joined: 05 Sep 2006 Posts: 378 Location: The pizza country!
|
Posted: Sat Sep 22, 2007 7:13 am Post subject: |
|
|
1) you should increase COLOR_WINDOW with +1
2) try GetDesktopWindow() instead of GetDC(0)
3) use while(GetMessage(&Msg, NULL, 0, 0) > 0) because if an error happens, it will still loop
_________________
ASM/C++ Coder
Project Speranza lead developer |
|
| Back to top |
|
 |
|