void CPixmap::addEffect(const PictureEffect & effect) { switch (effect.effect) { case PictureEffect::ClearEffects: clearEffects(); break; case PictureEffect::FlipH: toHFlip(); break; case PictureEffect::FlipV: toVFlip(); break; case PictureEffect::InvertColors: toInvertedColors(); break; case PictureEffect::NVG: toNVG(); break; case PictureEffect::BlackAndWhite: toBlackAndWhite(); break; case PictureEffect::Glow: toGlow((int)effect.param); break; case PictureEffect::Sepia: toSepia(); break; case PictureEffect::Opacity: m_effects.push_back(PictureEffect(PictureEffect::Opacity, (qreal)effect.param)); break; case PictureEffect::Crop: crop(effect.cropingRect); break; } }
/* void CPixmap::toLuminosity(int value) { m_effects.push_back(...); QImage img = this->toImage(); QImage dest(img.size(), img.format()); QColor pixel; for(int x=0; x<img.width();x++) { for (int y=0; y<img.height(); y++) { pixel = img.pixel(x, y); int green = pixel.green() + value; int red = pixel.red() + value; int blue = pixel.blue() + value; if(green > 255) green = 255; else if(green < 0) green = 0; if(red > 255) red = 255; else if(red < 0) red = 0; if(blue > 255) blue = 255; else if(blue <0) blue = 0; pixel.setGreen(green); pixel.setBlue(blue); pixel.setRed(red); dest.setPixel(x,y,pixel.rgb()); } } updateImage(dest); } */ void CPixmap::crop(const QRect &cropingRect) { if(cropingRect.isNull()) return; m_effects.push_back(PictureEffect(PictureEffect::Crop, PictureEffect::Crop, cropingRect)); QImage img = this->toImage().copy(cropingRect); updateImage(img); }
void PictureContent::crop() { if (!m_photo) return; CroppingDialog dial(m_photo); #if defined(MOBILE_UI) dial.showMaximized(); #endif if (dial.exec() != QDialog::Accepted) return; QRect cropRect = dial.getCroppingRect(); if (!cropRect.isNull()) addEffect(PictureEffect(PictureEffect::Crop, 0, cropRect)); }
void CPixmap::toGlow(int radius) { m_effects.push_back(PictureEffect(PictureEffect::Glow, (qreal)radius)); GlowEffectWidget effect; QImage dest = effect.glow(this->toImage(), radius); updateImage(dest); }