QImage Convolution::launch ( const QImage& in_Image ) const { QRect area = getRealArea ( in_Image ); QImage imgNew(in_Image.width(), in_Image.height(), QImage::Format_RGB32); uint uiPercent, uiQuantum = in_Image.width() * in_Image.height() / 100; Kernel mKernel ( in_Image, m_width, m_height ); for (int y = 0; y < in_Image.height(); ++y){ for (int x = 0; x < in_Image.width(); ++x){ if ( area.contains(x,y) ) { mKernel.x=x; mKernel.y=y; imgNew.setPixel(x, y, calcPixel(mKernel) ); } else { imgNew.setPixel(x, y, in_Image.pixel(x,y)); } uiPercent = y * in_Image.width() + x; if (uiPercent % uiQuantum == 0) callback(uiPercent / (uiQuantum)); } } callback (100); return imgNew; }
Image * imgCopy(Image * img) { // Create a new empty image Image * copy = imgNew(img->width, img->height); // Copy the data between the images copy = memcpy(copy->data, img->data, img->width * img->height * 3 ); // return the copy return copy; }