void imageblur(SDL_Surface *screen, float nopa = 0.5){ // Fast blur by T.M. - www.HC-Codes.net int lev = screen->w; int kor = screen->h; Uint8 *mpos = (Uint8 *)(screen->pixels); Uint8 *p; float r, g, b; float opa = 1-nopa; int x, y; int lev4 = lev*4; int leve = lev-1; int kore = kor-1; // Ei turhaan yritetä blurrata jos tulos ei eroa alkuperäisestä: if(nopa > 0){ p = mpos; for(y = 0; y < kor; y++){ // Vasemmalta oikealle: r = p[0]; g = p[1]; b = p[2]; for(x = 0; x < lev; x++){ p[0] = (int)((r = p[0]*opa+r*nopa)+0.5); p[1] = (int)((g = p[1]*opa+g*nopa)+0.5); p[2] = (int)((b = p[2]*opa+b*nopa)+0.5); p+=4; } // Oikealta vasemmalle: p-=4; r = p[0]; g = p[1]; b = p[2]; for(x = leve; x >= 0; x--){ p[0] = (int)((r = p[0]*opa+r*nopa)+0.5); p[1] = (int)((g = p[1]*opa+g*nopa)+0.5); p[2] = (int)((b = p[2]*opa+b*nopa)+0.5); p-=4; } p+=lev4+4; } for(x = 0; x < lev; x++){ // Ylhäältä alas: p = mpos+(x<<2); r = p[0]; g = p[1]; b = p[2]; for(y = 0; y < kor; y++){ p[0] = (int)((r = p[0]*opa+r*nopa)+0.5); p[1] = (int)((g = p[1]*opa+g*nopa)+0.5); p[2] = (int)((b = p[2]*opa+b*nopa)+0.5); p+=lev4; } // Alhaalta ylös: p-=lev4; r = p[0]; g = p[1]; b = p[2]; for(y = kore; y >= 0; y--){ p[0] = (int)((r = p[0]*opa+r*nopa)+0.5); p[1] = (int)((g = p[1]*opa+g*nopa)+0.5); p[2] = (int)((b = p[2]*opa+b*nopa)+0.5); p-=lev4; } } } }
Aihe on jo aika vanha, joten et voi enää vastata siihen.