43 int blockX,
int blockY,
47 int dx = rand() % BLOCK_SIZE;
48 int dy = rand() % BLOCK_SIZE;
49 x = blockX*BLOCK_SIZE + dx;
50 y = blockY*BLOCK_SIZE + dy;
54 if(x >= width ) x = width-1;
55 if(y >= height) y = height-1;
69 int weights[3][3] = { {1,2,1}, {2,4,2}, {1,2,1} };
74 for(yp = QMAX( y-1, 0); yp < QMIN( image->height()-1, y+1 ); yp++)
76 uchar* scanLine = image->scanLine(yp);
78 for(xp = QMAX( x-1, 0); xp< QMIN( image->width()-1, x+1 ); xp++)
89 sum+= (weights[weightX][weightY] * qGray( *((QRgb*)scanLine+xp) ) );
90 divisorSum+= weights[weightX][weightY];
95 return sum/divisorSum;
102 uchar* scanLine = image->scanLine(y);
103 QRgb* rgb = ((QRgb*)scanLine+x);
104 int red = qRed(*rgb);
105 red = (int) (0.6*red);
106 *rgb = qRgb( red, red, red);
112 srand(
unsigned(time(NULL)) );
118 QImage*
editedImage =
new QImage( originalImage->width(),
119 originalImage->height(),
120 originalImage->depth() );
123 editedImage->fill( qRgb(255,255,255) );
130 const int BLOCK_SIZE = 8;
133 int blocksWide = editedImage->width() / BLOCK_SIZE;
134 if(blocksWide*BLOCK_SIZE < editedImage->
width())
137 int blocksTall = editedImage->height() / BLOCK_SIZE;
138 if(blocksTall*BLOCK_SIZE < editedImage->
height())
143 for(
int i=0; i<10; i++)
146 for(bx=0; bx<blocksWide; bx++)
148 for(by=0; by<blocksTall; by++)
152 editedImage->height(),
161 if( curGrayVal > goalGrayVal )
168 delete originalImage;
169 originalImage = NULL;
bool pixelValid(QImage *image, int x, int y)
double computeLocalGrayVal(QImage *image, int x, int y)
void drawDotAt(QImage *image, int x, int y, int)
QImage * pointillismEffect(QString filename, ManipulationOptions *)
QImage * blackWhiteEffect(QString filename, ManipulationOptions *options)
void pickRandomPixelWithinBlock(int width, int height, int blockX, int blockY, int BLOCK_SIZE, int &x, int &y)