Sign in to follow this  

SDL and PhotoShop

This topic is 2647 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

I'm working with 16-bit depth in SDL to save cycles and I've got a per-pixel collision engine that reads in levels from .png files. Everything works great except when in 16-bit depth mode, SDL changes my colors, even if I save out my .png files as 16-bit.

Is there some PhotoShop setting that restricts my palette appropriately? What can I do to make sure I only paint in the colors available to SDL in 16-bit depth mode?

Pictured: Left is the PhotoShop image, the right is my game running.



Uploaded with ImageShack.us

Share this post


Link to post
Share on other sites
I am unsure if SDL does any translation on the pixels if the source and destination format are both 16 bit however I doubt you would see any performance decrease if you used 32 bit PNGs instead - especially if you ignored the alpha channel.

Share this post


Link to post
Share on other sites
Quote:
Original post by evillive2
I am unsure if SDL does any translation on the pixels if the source and destination format are both 16 bit however I doubt you would see any performance decrease if you used 32 bit PNGs instead - especially if you ignored the alpha channel.


I tested it after switching to 16-bit and my framerate almost doubled. I'm not completely sure, but I think the SDL Surface structure has formats for 16-bit and 32-bit depth and that's how it's handled. If that's the case, then it makes sense that less data is being interpreted each time the screen is flipped.

Share this post


Link to post
Share on other sites
Ok, hold on, you're confusing 2 things.

As far as games are concerned, 16-bit rendering means 16 bits per pixel. Unfortunately this is ambiguous, because there are different formats based around the different ways you can divide up 16 bits among 3 colours. The most common difference is that some modes have 6 bits for the green channel while others have 5 bits for the green channel. I don't remember exactly how it works so you'll need to look into that - perhaps SDL lets you choose a format, or perhaps it'll serve you an arbitrary one up. But you can't know what sort of palette you'd need to use until you have that information.

HOWEVER. In Photoshop what you are looking at there is not 16 bits per pixel, it's 16 bits per CHANNEL. Normally you have 8 bits per channel, which is 24 bits per pixel. When you select 16 bits per channel in Photoshop that's 48 bits per pixel! When you do this you're actually increasing the possible palette available to you by a factor of 16 million, and doubling the amount of data you'd send relative to a 24-bit pixel. Not what you intended.

I don't know how you're saving out your PNG as 16-bit, but I suspect that you're actually not. As I understand it, PNGs come in 8 bit or 24bit + alpha variety. Using Photoshop, you can actually save as a 16-bit BMP file, however. Note that it will prompt you for the exact 16-bit format that you wish to use.

Sorry I can't be more help!

Share this post


Link to post
Share on other sites
That was actually very helpful. Thank you.

Once I know the pixel formats for both SDL and .png images, I should be able to match them up to correct any color issues I might have.

Share this post


Link to post
Share on other sites

This topic is 2647 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this