Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Create an image or bitmap with a different depth?

Author
Message
WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 11th Aug 2011 00:16
Is this possible? I only want to create a 4 colour bitmap so that I can overlay a map image on the screen.

Warning! May contain Nuts!
Mistrel
Retired Moderator
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 11th Aug 2011 00:58 Edited at: 11th Aug 2011 01:01
dbCreateMemblock + dbGetMemblockPtr + dbCreateMemblockFromBitmap/Image will do what you want.

By asking to create a 4 color bitmap, if you want to create an 8-bit bitmap with a custom color table of only 4 colors, see here:

http://en.wikipedia.org/wiki/BMP_file_format
http://fortunecity.com/skyscraper/windows/364/bmpffrmt.html

Even if you only want to use 4 colors, there is little reason to use an 8-bit bitmap unless you want to use the color table specifically; or for space reasons. DBP might not even support reading this type of image format if you want to convert it to a usable ID.

Alternatively, you can use Win32 to create a bitmap with GDI+, draw to it, then get a pointer to the data with GetDIBits and then use dbCreateMemblockFromImage to get an image out of it.

Or.. use GDI+ to make your bitmap and then draw it to the screen by writing to the backbuffer.

Or.. create and write to a bitmap with ImageMagick, (a good alternative to GDI+) and do the same.

WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 11th Aug 2011 03:00
GDI+ ? Something new to me.

I'm actually after just drawing a portion of the image using colour 0 as a transparency and show it as an overlay map view. Grabbing and pasting images would only slow down the program, so if I could do it directly after everything has been rendered that would be great.

Warning! May contain Nuts!
Mistrel
Retired Moderator
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 11th Aug 2011 05:33 Edited at: 11th Aug 2011 06:33
I'm still not sure what it is you're asking. Do you want chroma keying?

In DarkGDK it's: dbSetImageColorKey. In PureGDK it's: dbSetImageChromaKey.

dbLoadImage with a 'textureFlag' of 0 will support stretching, filtering, and chroma keying. A flag of 1 will support just chroma keying.

Is this what you want?

Mistrel
Retired Moderator
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 11th Aug 2011 06:14 Edited at: 11th Aug 2011 06:32
Chroma keying seems to work with ok with dbPastImage(), sprites, and 3d objects. Is this what you want?

Example with paste image:



Example with sprites:



Example with 3d:



WLGfx
17
Years of Service
User Offline
Joined: 1st Nov 2007
Location: NW United Kingdom
Posted: 11th Aug 2011 19:06
I've used the chromakeying or colorkey. It is what I'm after but what I'm going to try and do is grab a large image (forgetting memory usage for the time being) and when it comes to pasting it to the screen, I'm going to use a clipping rectangle.

I understand that png's don't actually need the setimagecolorkey or chromakey to be set before using. That all depends on whether an image of a spiders web saves smaller as a png or a jpg file.

I've always been one for optimising code for speed and with these new (well, been around for years) processors, trying to write C code for being cache friendly is difficult. So I'm always trying not to go the long way round for doing things.

Thanks Mistrel...

Warning! May contain Nuts!

Login to post a reply

Server time is: 2024-11-19 08:48:21
Your offset time is: 2024-11-19 08:48:21