Advertisement
Guest User

Untitled

a guest
Apr 20th, 2017
70
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void unsharpMask(SDL_Surface* inputSurface,SDL_Surface* outputSurface)
  2. {
  3.   Uint32* pixels = (Uint32*)inputSurface->pixels;
  4.   Uint32* outputPixels=(Uint32*)outputSurface->pixels;
  5.   Uint32* blurredPixels=(Uint32*)blurredSurface->pixels;
  6.   meanBlur(infoSurface,blurredSurface);
  7.   for (int i=0;i<inputSurface->h;i++)
  8.     {
  9.       for(int j=0;j<inputSurface->w;j++)
  10.         {
  11.             Uint8 rOriginal,gOriginal,bOriginal;
  12.             Uint8 rBlurred,gBlurred,bBlurred;
  13.             Uint32 rMask,gMask,bMask;
  14.             Uint32 rFinal,gFinal,bFinal;
  15.             SDL_GetRGB(blurredPixels[i*blurredSurface->w+j],blurredSurface->format,&rBlurred,&gBlurred,&bBlurred);
  16.             SDL_GetRGB(pixels[i*inputSurface->w+j],inputSurface->format,&rOriginal,&gOriginal,&bOriginal);
  17.  
  18.             rMask=rOriginal - rBlurred;
  19.             rFinal=rOriginal + rMask;
  20.             if(rFinal>255) rFinal=255;
  21.             if(rFinal<=0) rFinal=0;
  22.  
  23.             gMask=gOriginal - gBlurred;
  24.             gFinal=gOriginal + gMask;
  25.             if(gFinal>255) gFinal=255;
  26.             if(gFinal<0) gFinal=0;
  27.  
  28.             bMask=bOriginal - bBlurred;
  29.             bFinal=bOriginal + bMask;
  30.             if(bFinal>255) bFinal=255;
  31.             if(bFinal<0) bFinal=0;
  32.  
  33.  
  34.             Uint32 pixel =SDL_MapRGB(outputSurface->format,rFinal,gFinal,bFinal);
  35.             outputPixels[i *outputSurface->w+j]=pixel;
  36.         }
  37.     }
  38. }
Advertisement
RAW Paste Data Copied
Advertisement