Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Goodlife

Please help! Bitmaps!

This topic is 6936 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, I load bitmaps onto a directdraw surface via the LoadImage command, which I use to get an HBITMAP. I then bitblt this onto a surface. But... what I really want to do is keep the bitmap information in MEMORY. Ideally, I would do this: HBITMAP hbm; char *bminfo; infile=open("DABITMAP.BMP",O_BINARY/O_RDONLY); bminfo=malloc(filelength(infile)); read(infile,bminfo,filelength(infile)); close(infile); hbm=SomehowPointAtThisMemoryBitmap(bminfo); Does anyone know of a way to do this? Is a bitmap handle just a pointer, or does it contain additional information? I tried using it as ''just a pointer'' but my bitmap blitted blank. Can anyone help? I can''t just load from a resource file, because I need to let the user add bitmaps to the program-- and I want to bind all the user-created bitmaps into one big file. I definitely want to use BitBlt, because of the nice dithering it does! Thanks in advance! -- Goodlife ----------------------------- Think of your mind as a door on a house. Leave the door always closed, and it's not a house, it's a prison. Leave the door always open, and it's not a house, it's a wilderness-- all the vermin creep in.

Share this post


Link to post
Share on other sites
Advertisement
I have a set up that loads the bitmap then copies it to an offscreen surface, so I can use the blitter''s hardware acceleration. Isn''t this what everyone does?
I made my own loading functions though, I''ve never used the microsoft ones.


The_Minister

Share this post


Link to post
Share on other sites
Hey
you misunderstand the principles involved in loading bitmaps onto directx surfaces
when it is on an off screen surface it IS still in memory
then you use directx blit to blit it to the back buffer
the bitblt to put it onto the surface is just an odd way of loading the bitmap

-PoesRaven

Share this post


Link to post
Share on other sites
Okay...
Let me be clearer:
I want to use the directx bitblt commands. I use this now, to load a FILE or a RESOURCE onto a surface. Works fine, I''m happy, end of story.

However, I''m making an editor for the game. In the editor, the user can add bitmaps to the game. So, when I compile an editor file with the bitmaps in it, I need to peel them out and put them onto a surface.

I peel them out very simply:

char *newbitmap;
read(editorfile,&lengthofBMdata,4);
newbitmap=malloc(lengthofBMdata);
read(editorfile,newbitmap,lengthofBMdata);

Okay, now my bitmap is in memory. I would LOVE to bitblt this chunk of memory onto a surface. So, my question is, is HBITMAP equivalent to char*? Essentially, is HBITMAP just a pointer, or is it some sort of mad windows object?

For instance, could I do this?
HBITMAP bm;
bm=(HBITMAP)newbitmap;

The only workaround I could think of would be to dump the bitmaps to DISK, then use LoadImage to pull them in. If I did that, I''d have to turn in my programmer card and go out flipping burgers. Problem is, Windows has a way of doing things, and it''s not necessarily the simplest or most common-sense way of doing them-- in fact, whenever I''ve tried to apply common sense to the Windows APIs (directx included) I''ve gotten burned.

So, can anyone help? Is it okay to point HBITMAP at raw data, or does LoadImage do some sort of reoganization of the data? I know SOME reorganization is done, because I use LR_CREATEDIBSECTION when I LoadImage.

So c''mon programming geniuses!! How do I force the windows API to act like a normal program? How can I have a raw bitmap in memory (NOT a resource, NOT a file) and get BitBlt to use it to blt a nice dithered bitmap to a surface?

If anyone can tell me, I''ll give you a free copy of my game, if and when I by-God finish it!

Thanks in advance!!!


-- Goodlife

-----------------------------
Think of your mind as a door on a house. Leave the door always closed, and it's not a house, it's a prison. Leave the door always open, and it's not a house, it's a wilderness-- all the vermin creep in.

Share this post


Link to post
Share on other sites
Goodlife,

Sorry to not be able to offer some positive suggestions (let me think about it for a while...), but i can tell you that you definitely cannot use HBITMAP in this way.

HBITMAP is a handle and like all win32 handles it is a kernel object and can only be manipulated through win32 functions provided specifically for the purpose.

A handle is actually just a number that you use to tell the operating system which thing you want to work with. Note that the number is allocated by windows when you create the object so that later on you can say to it "Hey, i know you''ve got this thing i asked you to create earlier and you told me to use this number when i wanted to play with it, so now please go off and find where you''ve hidden it and do what i''m asking you to do with it".

Get the idea?

Share this post


Link to post
Share on other sites
Sigh... I figured that. I was hoping someone had some sort of insight like "Hey, call the windows API function LoadBitmapFromYourEditorFile(char *ptr)" and you''ll be on your way.

Sigh... sigh... sigh....

-- Goodlife

-----------------------------
Think of your mind as a door on a house. Leave the door always closed, and it's not a house, it's a prison. Leave the door always open, and it's not a house, it's a wilderness-- all the vermin creep in.

Share this post


Link to post
Share on other sites
I am not sure how helpful this post will be ..

hmm...I haven't ever used LoadImage with the LR_CREATEDIBSECTION flag, but from the documentation it appears that it returns a handle/pointer to some sort of DIB structure...somewhere in that structure should be your pointer to your bits.

And if you have the pointer to these bits, you can lock your offscreen surface and copy the bits to it.

Same holds true if you have your own bitmap reader..you can still fill the surface with data if you have a pointer to the bits.

Now, if you need to get an HBITMAP from your bits you can write your own conversion operator to return an HBITMAP as you should have all the information necessary to create one.

That way you could perform:

HBITMAP bmp = (HBITMAP)newbitmap;

and then use the resulting HBITMAP in whatever Windows functions you need.

The_Minister:

Pretty much..I load all my image data onto offscreen surfaces, then during my render I blit them to the backbuffer and flip to the primary. ...for what its worth



Edited by - mordell on 4/26/00 9:04:12 AM

Share this post


Link to post
Share on other sites
I've already answered this somewhere on gamedev.net, with code.

It is here (all one line):
http://www.gamedev.net/community/forums/Topic.asp?topic_id=10221&forum_id=12&Topic_Title=&forum_title=Graphics+Programming+and+Theory

(I don't understand why the gamedev.net topic.asp requires so much text when it takes the ID numbers anyway.)

Anyway, the post you want is near the bottom. It's by me, and has code in it.

TheTwistedOne
http://www.angrycake.com

Edited by - TheTwistedOne on 4/26/00 9:29:47 AM

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!