C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 18th, 2002, 03:14 PM
KilerCris KilerCris is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Bensalem PA
Posts: 58 KilerCris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
Send a message via ICQ to KilerCris Send a message via AIM to KilerCris Send a message via Yahoo to KilerCris
GDI Question

I've been looking around on MSDN and the internet and can't find how to draw bitmaps with GDI(not plus). All I want to know is the syntax for drawing a bitmap(from a resource or external file) to a device context at a given coordinate. Thanks for any help.

Reply With Quote
  #2  
Old October 18th, 2002, 10:33 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,406 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 10 h 18 m 59 sec
Reputation Power: 4080
You're looking for the BitBlt() function.
http://msdn.microsoft.com/library/d...itmaps_0fzo.asp
Hope this helps!

Reply With Quote
  #3  
Old October 19th, 2002, 12:07 PM
KilerCris KilerCris is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Bensalem PA
Posts: 58 KilerCris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
Send a message via ICQ to KilerCris Send a message via AIM to KilerCris Send a message via Yahoo to KilerCris
Yeah I found that much but how do I load and get a device context to a bitmap file or resource?

Reply With Quote
  #4  
Old October 19th, 2002, 01:17 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 9th Plane (9000 - 9499 posts)
 
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
Posts: 9,406 Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 46th Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Months 10 h 18 m 59 sec
Reputation Power: 4080
You can load the image with LoadImage(), if loading from file, or LoadBitmap(), if loading from resource. Next, you need to get the device context for your current window, which you can obtain with GetDC(). After that, you have to create a compatible device context with GetCompatibleDC() and use BitBlt() to draw to it. The code would go something like this:
Code:
HDC hDC, hDCBmp;
HBITMAP hBitmap;
BITMAP bmp; 

hBitmap = LoadBitmap(...) or (HBITMAP)LoadImage(...);
hDC = GetDC(hWnd);
hDCBmp = CreateCompatibleDC(hDC);

GetObject(hBitmap, sizeof(BITMAP), &bmp);
SelectObject(hDCBmp, hBitmap);
BitBlt(hDC,100,100, bmp.bmWidth,bmp.bmHeight, hDCBmp, 0,0, SRCCOPY);

DeleteObject(hBitmap);
DeleteDC(hDCBmp);
ReleaseDC(hDC);

Please note that this code is off the top of my head and I did not test it. However, it ought to be pretty close to what you need. Don't forget to check MSDN for more information on the functions. Hope this helps!

Reply With Quote
  #5  
Old October 19th, 2002, 03:47 PM
KilerCris KilerCris is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Bensalem PA
Posts: 58 KilerCris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
Send a message via ICQ to KilerCris Send a message via AIM to KilerCris Send a message via Yahoo to KilerCris
Thank you, i'll try it later.

Reply With Quote
  #6  
Old October 23rd, 2002, 12:56 AM
TechNoFear TechNoFear is offline
Offensive Member
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2002
Location: in the perfect world
Posts: 618 TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 13 h 50 m
Reputation Power: 26
This code snippet is a memory leak. The hBitmap will never be released as it is still selected into the HDC.

You can not delete a GDI object while it is selected into a HDC.

You must catch the returns of SelectObject() .
Before the function exits you must restore the HDC to its original resources and delete the created ones.

Reply With Quote
  #7  
Old October 23rd, 2002, 05:42 AM
KilerCris KilerCris is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2001
Location: Bensalem PA
Posts: 58 KilerCris User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
Send a message via ICQ to KilerCris Send a message via AIM to KilerCris Send a message via Yahoo to KilerCris
yeah thanks I noticed that too. I had found the LoadBitmap function in MSDN before but it said that it was depricated and I was wondering what is supposed to replace it?

Reply With Quote
  #8  
Old October 23rd, 2002, 10:16 PM
TechNoFear TechNoFear is offline
Offensive Member
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2002
Location: in the perfect world
Posts: 618 TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 13 h 50 m
Reputation Power: 26
LoadImage()
__________________
The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.

Frank Zappa

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > GDI Question

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap