1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
void MainWindow::MakeImage()
{
QTime myTimer;
myTimer.start();
#pragma omp parallel
{
for(unsigned y=0; y<ImageHeight; ++y)
{
double c_im = MaxIm - y*Im_factor;
for(unsigned x=0; x<ImageWidth; ++x)
{
double c_re = MinRe + x*Re_factor;
double Z_re = c_re, Z_im = c_im;
unsigned NumIter=MaxIterations;
bool isInside = true;
for(unsigned n=0; n<MaxIterations; ++n)
{
double Z_re2 = Z_re*Z_re, Z_im2 = Z_im*Z_im;
if(Z_re2 + Z_im2 > 4)
{
isInside = false;
NumIter = n;
break;
}
Z_im = 2*Z_re*Z_im + c_im;
Z_re = Z_re2 - Z_im2 + c_re;
}
/*if(isInside)
result->setPixel(x,y,qRgb(200,0,0));
else
{
result->setPixel(x,y,qRgb(NumIter%256,0,255 * (NumIter < MaxIterations)));
}*/
if(isInside)
result->setPixel(x,y,qRgb(0, 0, 0)); // black
else
{
double z = sqrt(x * x + y * y);
int brightness = 256. * log2(1.75 + NumIter - log2(log2(z))) / log2(double(MaxIterations));
result->setPixel(x,y,qRgb(brightness, brightness, 255));
}
//END
}
}
}
qDebug() << "Rendering took " << myTimer.elapsed() << "ms";
}
| |