• Advertisement
Sign in to follow this  

Surface From is green!

This topic is 4474 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 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
Advertisement
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
Sign in to follow this  

  • Advertisement