Results 1 to 3 of 3

Thread: pixel level modifications on an SDL_Surface

  1. #1
    Join Date
    Oct 2009
    Beans
    1

    pixel level modifications on an SDL_Surface

    hi guys,

    i'm a newbie using sdl in C++. I did my codes to try to get rgb color components from an 8-bit grayscale image using what was taught here : <html>http://sdl.beuc.net/sdl.wiki/SDL_PixelFormat</html>

    However, I keep getting this error: incompatible types in assignment at this line:
    color = fmt->palette->colors[index];

    My partial code as shown below:

    void colorInterpolation(SDL_Surface *s)
    {
    SDL_PixelFormat *fmt;
    Uint32 temp, pixel;
    Uint8 red, green, blue, alpha, index;
    SDL_Color *color;

    fmt=s->format;

    /* Check the bitdepth of the surface */
    if(fmt->BitsPerPixel!=8){
    fprintf(stderr, "Not an 8-bit surface.\n");
    return;
    }

    SDL_LockSurface(s);
    ..............
    ............
    /* Get the topleft pixel */
    index = *(Uint8 *)s->pixels;
    color = fmt->palette->colors[index]; //ERROR : incompatible types in assignment WHY??????
    .............
    ...........
    .......

    Your advice is highly appreciated!!! thanks!

  2. #2
    Join Date
    Jan 2009
    Location
    Arizona, US
    Beans
    113
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: pixel level modifications on an SDL_Surface

    Did you check the return types of what you're trying to assign?

  3. #3
    Join Date
    Nov 2005
    Location
    Almeria, Spain
    Beans
    276
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: pixel level modifications on an SDL_Surface

    You're getting an SDL_Color type, not a pointer to it (SDL_Color *).

    Try redefining your var declaration to "SDL_Color color" or this:

    Code:
    color = &(fmt->palette->colors[index]);
    Should be it, but can't check it right now.
    Francisco Camenforte Torres
    http://fmct.blogspot.com

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •