To load from a resource, try
HBITMAP hbitmap = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP1));
Why LoadBitmap(hInstance, "bitmap1.bmp") doesn''t work, I really can''t know. Have you tried it with full file path? You have to call GetLastError() and look up the error code in MSDN or the Error Lookup utility (ERRLOOK.EXE).
But first of all, go to MSDN (http://msdn.microsoft.com/library/default.asp) and search for LoadBitmap. Spend 5 minutes reading the article.
help in putting a bitmap
okey i got it! i mean, i know now why my line
HBITMAP hbitmap = LoadBitmap(hInstance, IDB_BITMAP1);
doesn''t work! because it''s second parameter is not fit to retrieve this kind of file then i tried using MFC''s LoadBitmap, they have the parameter which you can then use your bitmap''s ID to load your bitmap! Then there I was able to blit now my bitmap. But the problem is, i don''t want to use MFC as for now coz it''s another learning curve. So how will i use Windows GDI''s function LoadBitmap to load my bitmap? and what''s LoadImage for? Thanks!
And another thing, hope you guys are patient on my questions, does the characters/monsters/terrains say for example in Diablo 2, are first done by freehand then they port it to the computer by scanning it then they use for example Photoshop to edit and enhance their drawings and then save their work as .bmp file and then lastly in their c/c++ codes they blit these .bmp to the screen?
HBITMAP hbitmap = LoadBitmap(hInstance, IDB_BITMAP1);
doesn''t work! because it''s second parameter is not fit to retrieve this kind of file then i tried using MFC''s LoadBitmap, they have the parameter which you can then use your bitmap''s ID to load your bitmap! Then there I was able to blit now my bitmap. But the problem is, i don''t want to use MFC as for now coz it''s another learning curve. So how will i use Windows GDI''s function LoadBitmap to load my bitmap? and what''s LoadImage for? Thanks!
And another thing, hope you guys are patient on my questions, does the characters/monsters/terrains say for example in Diablo 2, are first done by freehand then they port it to the computer by scanning it then they use for example Photoshop to edit and enhance their drawings and then save their work as .bmp file and then lastly in their c/c++ codes they blit these .bmp to the screen?
Sorry wasn''t able to read first your post anyway okey i''ll try your code,
HBITMAP hbitmap = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP1));
hope this thing works, just ignore my first question thanks!
HBITMAP hbitmap = LoadBitmap(hInstance, MAKEINTRESOURCE(IDB_BITMAP1));
hope this thing works, just ignore my first question thanks!
HAHAHA it worked!!!! hahaha! Hehe
thanks! anyway, um is that function/style is still being used nowadays? or are there any other faster more efficient ways?
thanks! anyway, um is that function/style is still being used nowadays? or are there any other faster more efficient ways?
hi mickey
what I did was create an extra surface, so now I have 3 surfaces
Front-buffer, Back-buffer, tiles-buffer
then I loaded my bitmaps onto the tiles-buffer
then when I need a tile I Blit it to the back-buffer
and at the end of my game loop I Flip my back-buffer with my Frontbuffer
I think this is a good way
If any1 else knows a better way pls tell so, as I''m also a newbie and willing to learn more...
Da Cobra
what I did was create an extra surface, so now I have 3 surfaces
Front-buffer, Back-buffer, tiles-buffer
then I loaded my bitmaps onto the tiles-buffer
then when I need a tile I Blit it to the back-buffer
and at the end of my game loop I Flip my back-buffer with my Frontbuffer
I think this is a good way
If any1 else knows a better way pls tell so, as I''m also a newbie and willing to learn more...
Da Cobra
yup that''s good, anyway, i don''t get it how you load your bitmaps unto your code, is it this line where you load your bitmaps?
LoadImage(G.hinstance, File, IMAGE_BITMAP, 0, 0,
LR_CREATEDIBSECTION |LR_LOADFROMFILE)
where file is the name of your bitmap? and how come you don''t use rc files?
anyway your code is great, you have a lot of wrappers for window''s functions right?
LoadImage(G.hinstance, File, IMAGE_BITMAP, 0, 0,
LR_CREATEDIBSECTION |LR_LOADFROMFILE)
where file is the name of your bitmap? and how come you don''t use rc files?
anyway your code is great, you have a lot of wrappers for window''s functions right?
mickey: Sure it''s being used. LoadBitmap() should be fast enough in most cases, unless you want to write your own bitmap loader that''s optimized for some bit depth etc.
I hope you don''t mind a piece of general advice, but you seem to be using an awful lot of trial and error when coding. I suggest you get into the habit of reading the MSDN article before using a new function. Then maybe you won''t have to spend an entire week trying to figure out how to load a bitmap...
I hope you don''t mind a piece of general advice, but you seem to be using an awful lot of trial and error when coding. I suggest you get into the habit of reading the MSDN article before using a new function. Then maybe you won''t have to spend an entire week trying to figure out how to load a bitmap...
Hi! Do i always have to use the MAKEINTRESOURCE macro whenever i want to load my own bitmap or is there any other more efficient and faster way?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement