#include <qimage.h>
#include <qstring.h>
#include <cstdlib>
#include <time.h>
#include "pointillism.h"
#include "blackWhite.h"
#include "manipulationOptions.h"
Go to the source code of this file.
|
| void | pickRandomPixelWithinBlock (int width, int height, int blockX, int blockY, int BLOCK_SIZE, int &x, int &y) |
| |
| 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 *) |
| |
◆ computeLocalGrayVal()
| double computeLocalGrayVal |
( |
QImage * |
image, |
|
|
int |
x, |
|
|
int |
y |
|
) |
| |
Definition at line 67 of file pointillism.cpp.
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;
Referenced by pointillismEffect().
◆ drawDotAt()
| void drawDotAt |
( |
QImage * |
image, |
|
|
int |
x, |
|
|
int |
y, |
|
|
int |
|
|
) |
| |
Definition at line 98 of file pointillism.cpp.
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);
Referenced by pointillismEffect().
◆ pickRandomPixelWithinBlock()
| void pickRandomPixelWithinBlock |
( |
int |
width, |
|
|
int |
height, |
|
|
int |
blockX, |
|
|
int |
blockY, |
|
|
int |
BLOCK_SIZE, |
|
|
int & |
x, |
|
|
int & |
y |
|
) |
| |
Definition at line 42 of file pointillism.cpp.
47 int dx = rand() % BLOCK_SIZE;
48 int dy = rand() % BLOCK_SIZE;
49 x = blockX*BLOCK_SIZE + dx;
50 y = blockY*BLOCK_SIZE + dy;
References height, and width.
Referenced by pointillismEffect().
◆ pixelValid()
| bool pixelValid |
( |
QImage * |
image, |
|
|
int |
x, |
|
|
int |
y |
|
) |
| |
◆ pointillismEffect()
Definition at line 109 of file pointillism.cpp.
112 srand(
unsigned(time(NULL)) );
118 QImage*
editedImage =
new QImage( originalImage->width(),
119 originalImage->height(),
120 originalImage->depth() );
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++)
161 if( curGrayVal > goalGrayVal )
168 delete originalImage;
169 originalImage = NULL;
QImage * blackWhiteEffect(QString filename, ManipulationOptions *options)
double computeLocalGrayVal(QImage *image, int x, int y)
void pickRandomPixelWithinBlock(int width, int height, int blockX, int blockY, int BLOCK_SIZE, int &x, int &y)
void drawDotAt(QImage *image, int x, int y, int)
References blackWhiteEffect(), computeLocalGrayVal(), drawDotAt(), editedImage, height, pickRandomPixelWithinBlock(), and width.
Referenced by EditingInterface::applyEffect().