Handmade Hero»Forums»Code
Pumpkin Sauce
10 posts
Resource compiler and 32bit bmps?
This is more of a general question and not really related to handmade hero but I hope it's ok I'm asking it here.

So I'm making a little practice game and I want my bmps to have an alpha channel. So far so good. I'm using VS2013 Resource system so I can embed the images into the exe, so I just have to share that.

However VS2013 doesn't seem to like 32bit bmps and the winapi LoadImage function fails.(while the same code worked fine with 24bit bmps files). When adding the bmp VisualStudio complains it's an unsupported bmp file or something.


Any ideas on how to approach this? Should I just give up and share the exe along with the spritesheet file?

Thanks.
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
Resource compiler and 32bit bmps?
Although it's not necessarily a good idea because some anti-virus software is stupid (OK, most anti-virus software is stupid), you can actually just put all your data into the EXE yourself if you want to. Since Windows doesn't care what's at the end of the EXE, you can just append all your resources to the end of the EXE and then write a header at the end that says where everything is. This would be a much better approach than trying to use the resource system because the resource system is a piece of crap.

- Casey
Pumpkin Sauce
10 posts
Resource compiler and 32bit bmps?
cmuratori
This would be a much better approach than trying to use the resource system because the resource system is a piece of crap.


Oh I've come to know that from the very first moment i used it, but my previous little game didn't require transparency so.


Thanks for the idea! But if random anti-viruses will get to complain maybe I should think of a different approach. Maybe making a little separate program that reads the bmp and makes a header file with an array containing the image pixels or something. Hm.
Timothy McCarthy
52 posts
Resource compiler and 32bit bmps?
I would look into adding the image as a custom resource. You then would use the LoadResource function to extract it.

I'm _very_ surprised/disappointed that MS isn't supporting 32bit bitmaps at this point.

- tim
Pumpkin Sauce
10 posts
Resource compiler and 32bit bmps?
Edited by Pumpkin Sauce on
@RomulusTFM It's kinda funny because when I did that I typed Bitmap when they asked me the type and it opened up an empty bitmap - its property window on the right had options for 4bit all the way to 32bits. But If I click 32bits nothing happens, I can only click 24 or less. Ah, microsoft.
Timothy McCarthy
52 posts
Resource compiler and 32bit bmps?
Ah, I assumed you already had the 32bit image.
You would load that image into the resource as a custom resource (not a bitmap) But it sound like you want to create a bitmap.

Let's reset.

I assume you want to use an existing 32bit image and then play with the alpha bits.

I don't think MS is supporting creating a 32 bit image in either DevStudio or in MS paint. so you would need something else to create the image, either a third party or your own code.

If you just want to take any image then play with the alpha bits you woudl convert an existing bitmap to a DIB and then play with it.

I haven't done this in a while so I have to see if I can dredge up an example. Have to step away for a bit but I will try to come up with asome sample code.

- tim
Pumpkin Sauce
10 posts
Resource compiler and 32bit bmps?
Edited by Pumpkin Sauce on
Sorry I wasn't clear. I DO have a 32bit image, made in gimp. But when I clicked add resource and then custom it asked me the type and i said bitmap.

I'll look up the LoadResource function (since I can just make the resource file by hand anyway) but I think I'll go to a route without the rc in the end.

Thanks!
Timothy McCarthy
52 posts
Resource compiler and 32bit bmps?
When you add the resource you don't specify a bitmap. You specify a custom resource. In my 32 bit version there is a "Custom" button. This will ask you to give the resource a name and then put you into the binary editor. you can type in a few numbers to have something to save. when you save it will create a file with the name you specified and and extension "bin". The resoruce file should now have the names resource in it as well
1
IDR_FELONIOUS2          FELONIOUS               "feloniou.bin"


Now copy you bitmap file to feloniou.bin" and compile. The file will be a custom resource that you can load using the IDR value via LoadResource.

- tim