[SDL] SDL_CreateRGBSurfaceFrom

David martin vilanew at gmail.com
Wed Mar 14 08:54:58 PDT 2012


Great that did the trick. I have modified the pitch to w*3 so that the 
surface looks like that now:
  SDL_Surface *image = SDL_CreateRGBSurfaceFrom(
  picture.data[0],
  w,
  h,
  24,
  w*3,
  0, 0, 0, 0);

Got correct image !!!
thanks


On 03/14/2012 05:31 PM, Bl0ckeduser wrote:
> David martin wrote:
>> SDL_Surface *image = SDL_CreateRGBSurfaceFrom(
>> picture.data[0],
>> w,
>> h,
>> 24,
>> w,
>> 0, 0, 0, 0);
>
> I believe your pitch (fifth argument) should be w * 3, not w, as in
> 24-bit RGB there are 3 bytes for each pixel.
>
>  From the SDL documentation:
>
> "Pitch is the size of the scanline of the surface, in bytes, i.e.
> widthInPixels*bytesPerPixel."





More information about the SDL mailing list