Surface From is green!

Started by
1 comment, last by Rob Loach 18 years, 5 months ago
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?
Advertisement
Nevermind just changed all the masks to 0x00000000
-Sweet!
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].
Rob Loach [Website] [Projects] [Contact]

This topic is closed to new replies.

Advertisement