title: Pixel manipulation using sdl
body: <p>I am trying to manipulate pixel using sdl and manage to read them up now. Below is my sample code. When I print I this <code>printf("\npixelvalue is  is : %d",MyPixel);</code> I get values like this </p>
  
  <pre><code>11275780
  11275776 
  etc 
  </code></pre>
  
  <p>I know these are not in hex form but how to manipulate say I want to filter just the blue colors out? Secondly after manipulation how to generate the new image?</p>
  
  <pre><code>#include "SDL.h"
  
  int main( int argc, char* argv[] )
  {
    SDL_Surface *screen, *image;
    SDL_Event event;
    Uint8 *keys;
    int done = 0;
  
    if (SDL_Init(SDL_INIT_VIDEO) == -1)
    {
      printf("Can't init SDL: %s\n", SDL_GetError());
      exit(1);
    }
    atexit(SDL_Quit);
    SDL_WM_SetCaption("sample1", "app.ico");
  
    /* obtain the SDL surfance of the video card */
    screen = SDL_SetVideoMode(640, 480, 24, SDL_HWSURFACE);
    if (screen == NULL)
    {
      printf("Can't set video mode: %s\n", SDL_GetError());
      exit(1);
    }
    printf("Loading here");
  
    /* load BMP file */
    image = SDL_LoadBMP("testa.bmp");
    Uint32* pixels = (Uint32*)image-&gt;pixels;
    int width = image-&gt;w;
    int height = image-&gt;h;
    printf("Widts is : %d",image-&gt;w);
  
    for(int iH = 1; iH&lt;=height; iH++)
      for(int iW = 1; iW&lt;=width; iW++)
      {
        printf("\nIh is : %d",iH);
        printf("\nIw is : %d",iW);
        Uint32* MyPixel = pixels + ( (iH-1) + image-&gt;w ) + iW;
        printf("\npixelvalue is  is : %d",MyPixel);
      }
  
    if (image == NULL) {
      printf("Can't load image of tux: %s\n", SDL_GetError());
      exit(1);
    }
  
    /* Blit image to the video surface */
    SDL_BlitSurface(image, NULL, screen, NULL);   
    SDL_UpdateRect(screen, 0, 0, screen-&gt;w, screen-&gt;h);
  
    /* free the image if it is no longer needed */
    SDL_FreeSurface(image);
  
    /* process the keyboard event */
    while (!done)
    {
      // Poll input queue, run keyboard loop
      while ( SDL_PollEvent(&amp;event) )
      {
        if ( event.type == SDL_QUIT ) 
        {
          done = 1;
          break;
        }
      }
      keys = SDL_GetKeyState(NULL);
      if (keys[SDLK_q])
      {
        done = 1;
      }
      // Release CPU for others
      SDL_Delay(100);
    }
    // Release memeory and Quit SDL
    SDL_FreeSurface(screen);
    SDL_Quit();
    return 0;    
  }
  </code></pre>