Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


c++ Monochrome HBITMAP is not what i want

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Fri Sep 21, 2007 7:08 pm    Post subject: c++ Monochrome HBITMAP is not what i want Reply with quote

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?



The Extension 'rar' was deactivated by an board admin, therefore this Attachment is not displayed.


_________________


Last edited by HomerSexual on Fri Sep 21, 2007 7:38 pm; edited 1 time in total
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Fri Sep 21, 2007 7:20 pm    Post subject: Reply with quote

you didn't post any source code, how are we supposed to know what you did wrong?
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Sep 21, 2007 7:21 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Fri Sep 21, 2007 7:38 pm    Post subject: Reply with quote

oh yea i forgot, sorry long day

updating now

_________________
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Fri Sep 21, 2007 8:21 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
HomerSexual
Grandmaster Cheater Supreme
Reputation: 5

Joined: 03 Feb 2007
Posts: 1657

PostPosted: Sat Sep 22, 2007 5:31 am    Post subject: Reply with quote

no because its long

its win32 gui...

its like 300+ lines

not some vb shit

_________________
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Sep 22, 2007 7:02 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Robotex
Master Cheater
Reputation: 0

Joined: 05 Sep 2006
Posts: 378
Location: The pizza country!

PostPosted: Sat Sep 22, 2007 7:13 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites