Create surface from monochrome bitmap

Is possible to create surface from monochrome pixels? I got blank
image with this command :
SDL_CreateRGBSurfaceFrom(adata,image.size.cx,image.size.cy,8,4,0,0,0,0);

thanks

Hi,
pitch shouldn’t be 4 but should be the same as the width of your image,
since you have 1 byte per pixel.

But then you come to another problem. 1-Byte surfaces will have a
palette. So you have to change palatte index 0 and 1 to different colors
to actually see something.

Cheers, Tobias.Am 20.09.2012 12:31, schrieb wahono sri:

Is possible to create surface from monochrome pixels? I got blank
image with this command :
SDL_CreateRGBSurfaceFrom(adata,image.size.cx,image.size.cy,8,4,0,0,0,0);

thanks


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Thanks Tobias for your answer, I try it before but could not result
right image, than I change it. :slight_smile:
How about SDL_ConvertPixels? What is pixel format for monochrome
bitmap, is it SDL_PIXELFORMAT_INDEX8?

ThanksOn 20 September 2012 17:37, Tobias Leich wrote:

Hi,
pitch shouldn’t be 4 but should be the same as the width of your image,
since you have 1 byte per pixel.

But then you come to another problem. 1-Byte surfaces will have a
palette. So you have to change palatte index 0 and 1 to different colors
to actually see something.

Cheers, Tobias.