98{
99
100 QImage blurredImage = image.copy();
102
103
104 int x, y;
105 QRgb *origRgb, *blurredRgb, *edgeRgb;
106 uchar *origScanline;
107 uchar *blurredScanline;
108 uchar *edgesScanline = NULL;
109
110 for(y=0; y<image.height(); y++)
111 {
112 origScanline = image.scanLine(y);
113 blurredScanline = blurredImage.scanLine(y);
115 {
116 int edgeY = ((
edgeImage->height()-1) * (y+offset.y())) / (fullImageRes.height()-1);
117 edgesScanline =
edgeImage->scanLine(edgeY);
118 }
119
120 for(x=0; x<image.width(); x++)
121 {
122
123 origRgb = ((QRgb*)origScanline+x);
124 double r1 = ((double)qRed(*origRgb) )/255.0;
125 double g1 = ((double)qGreen(*origRgb) )/255.0;
126 double b1 = ((double)qBlue(*origRgb) )/255.0;
127
128 blurredRgb = ((QRgb*)blurredScanline+x);
129 double r2 = ((double)qRed(*blurredRgb) )/255.0;
130 double g2 = ((double)qGreen(*blurredRgb) )/255.0;
131 double b2 = ((double)qBlue(*blurredRgb) )/255.0;
132
133
134 float alpha;
136 alpha = 1.0f;
137 else
138 {
139 int edgeX = ((
edgeImage->width()-1) * (x+offset.x())) / (fullImageRes.width()-1);
140 edgeRgb = ((QRgb*)edgesScanline+edgeX);
141
142 alpha = ((float) qRed( *edgeRgb )) / 255.0f;
143
144
145 if(!blurEdges)
146 alpha = 1.0f - alpha;
147 }
148
149
150 double h1,s1,v1;
152
153 double h2,s2,v2;
155
156
157 v1 = (alpha *
MIN(
MAX(2*v1 - v2, 0), 1.0 )) + (1-alpha)*v1;
158
159
161 int rp = (int)
MIN(
MAX((r1*255), 0), 255 );
162 int gp = (int)
MIN(
MAX((g1*255), 0), 255 );
163 int bp = (int)
MIN(
MAX((
b1*255), 0), 255 );
164
165
166 *origRgb = qRgb(rp,gp,bp);
167 }
168 }
169
170}
void blurImage(QImage &image, float sigma)