Page 1 of 1

GD bit depth

PostPosted: May 14, 2003 @ 9:52am
by gersen
I'm writing a game for ppc, for now I'm using my own graph lib that was a derived version of my own lib for series60 (nokia 7650, 3650 etc). However I want to use GD for ppc mainly for his high ppc compatibility and probably better performance (with 2.01 release that support multiple pixel write :wink:). I use my own image loader and I make some conversion on the loading process. How can I get the bit depth currently used by GD? On my lib I convert on my loader the depth image (always 16 bit) on 16 (no conversion), 15 or 12 bit to support current depth screen.

Thanks.

PostPosted: May 14, 2003 @ 10:21am
by Johan
Hi Thomas,

The easiest way is to:

(1) Load the header of your image go get the width and height
(2) Create a new CGapiSurface of that width and height
(3) Lock the surface to get exclusive access (CGapiSurface::GetBuffer)
(3) CGapiSurface::GetBuffer returns a STRUCT with surface information. Check the pixel format as buffer.dwPixelFormat:
case GDPIXELFORMAT_555: Surface is 15-bit x555
case GDPIXELFORMAT_565: Surface is 16-bit 565
(4) Copy your image to the surface
(5) Release the buffer with CGapiSurface::ReleaseBuffer

PostPosted: May 14, 2003 @ 10:35am
by gersen
Thanks for your quick answer Johan! :)