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++] how to load png in dialog

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Tue Apr 29, 2008 12:49 pm    Post subject: [c++] how to load png in dialog Reply with quote

i have sucessfully loaded a bmp in my c++ dialog. but the problem is that its background is white in contrast to my pure black dialog background. i was wondering if there is anyway to make the bmp background to transparent.

or if its possible to load a png instead ( which contains transparent background)

here is what i did to load the bmp, anyone know how i can do the same to png for transparent effect?

Code:

HBITMAP Pic = NULL;
Pic = LoadBitmap(GetModuleHandle("pcomdebug"),MAKEINTRESOURCE(IDB_BALL)); 
// load the pic from the resource bmp in IDB_BALL


Code:


   case WM_PAINT:
      {
         BITMAP bm;
         PAINTSTRUCT ps;
         HDC hdc = BeginPaint(hWnd, &ps);
         HDC hdcMem = CreateCompatibleDC(hdc);
         HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, Pic);
         GetObject(Pic, sizeof(bm), &bm);
         BitBlt(hdc, 5, 40, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
// draw the bmp with specific size and coordinates

         SelectObject(hdcMem, hbmOld);
         DeleteDC(hdcMem);
         EndPaint(hWnd, &ps);
      }
      break;


tx for any help

_________________

w8 baby.com Banner contest, Come join NOW!!
Check us out for Prize deatils


Last edited by Bizarro on Tue Apr 29, 2008 2:37 pm; edited 1 time in total
Back to top
View user's profile Send private message
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Tue Apr 29, 2008 1:53 pm    Post subject: Reply with quote

I don't know exactly but I think you have to create a mask image or something, and then change the following line:
BitBlt(hdc, 5, 40, bm.bmWidth, bm.bmHeight, hdcMem, 0, 0, SRCCOPY);
SRCCOPY should be something like SRCAND.
That's all I know
Back to top
View user's profile Send private message
Bizarro
I post too much
Reputation: 0

Joined: 01 May 2007
Posts: 2648

PostPosted: Tue Apr 29, 2008 2:03 pm    Post subject: Reply with quote

its alright, my friend just helped me made a bmp with black background.
it fits perfectly Very Happy

but if anyone can show me a way to load png, it would be great
________
Machine


Last edited by Bizarro on Tue Feb 01, 2011 11:59 am; edited 1 time in total
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Tue Apr 29, 2008 2:47 pm    Post subject: Reply with quote

Why are you doing all that extra work on WM_PAINT over and over?

Load / create it once then just blit it form the offscreen buffer.
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: Wed Apr 30, 2008 10:26 am    Post subject: Reply with quote

You can use external libraries such as pngLib (yes, not libpng), which you can get from:

http://www.madwizard.org/programming/projects/pnglib

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
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