Sign in to follow this  
tjrr3d

Surface From is green!

Recommended Posts

tjrr3d    122
I have an image in memory - originally stored as char* - so i captured it with the code: camTexture = SDL_CreateRGBSurfaceFrom( (void*)frame640x480->imageData, frame640x480->width, frame640x480->height, 24, 960, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff); But the image has a green tint! the original image is captured as a 320x280 image with 24 byte pixel depth. And the display surface is created with a 800x600 resolution with the same pixel format. I tried changing the mask stuff. But still green or with some settings yellow. Anyone know why?

Share this post


Link to post
Share on other sites
Rob Loach    1504
A couple of notes:
  • frame640x480 - Although it really doesn't matter that much, but that is a bad naming convention [wink]. What if you want to change the frame to 800x600? Would "frame" be more appropriate?
  • If you take a look at SDL_CreateRGBSurfaceFrom, you'll notice that the last four parameters are the masks. In SDL_Surface, you'll see SDL_PixelFormat *format. SDL_PixelFormat contains the masks for the surface. So your final function would be something like:
    camTexture = SDL_CreateRGBSurfaceFrom( (void*)frame640x480->imageData, frame640x480->width, frame640x480->height, 24, 960, frame640x480->format->Rmask, frame640x480->format->Gmask, frame640x480->format->Bmask, frame640x480->format->Amask);</t>

This is only if frame is a surface itself and, as you said, it worked with 0 [smile].

Share this post


Link to post
Share on other sites

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