mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-12 19:40:28 +02:00
Uncrustify all .cpp files
This commit is contained in:
@@ -3,15 +3,15 @@
|
||||
#include <QPainter>
|
||||
|
||||
IntelliImage::IntelliImage(int width, int height, bool fastRendererOn)
|
||||
: imageData(QSize(width, height), fastRendererOn ? QImage::Format_Indexed8 : QImage::Format_ARGB32){
|
||||
if(fastRendererOn){
|
||||
imageData = imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
imageData.fill(QColor(255,255,255,255));
|
||||
if(fastRendererOn){
|
||||
imageData = imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
this->fastRenderer = fastRendererOn;
|
||||
: imageData(QSize(width, height), fastRendererOn ? QImage::Format_Indexed8 : QImage::Format_ARGB32){
|
||||
if(fastRendererOn) {
|
||||
imageData = imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
imageData.fill(QColor(255,255,255,255));
|
||||
if(fastRendererOn) {
|
||||
imageData = imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
this->fastRenderer = fastRendererOn;
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ bool IntelliImage::loadImage(const QString &filePath){
|
||||
// scaled Image to size of Layer
|
||||
loadedImage = loadedImage.scaled(imageData.size(),Qt::IgnoreAspectRatio);
|
||||
|
||||
imageData = loadedImage.convertToFormat(fastRenderer ? QImage::Format_Indexed8 : QImage::Format_ARGB32);
|
||||
imageData = loadedImage.convertToFormat(fastRenderer ? QImage::Format_Indexed8 : QImage::Format_ARGB32);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -40,23 +40,23 @@ void IntelliImage::resizeImage(QImage*image, const QSize &newSize){
|
||||
return;
|
||||
|
||||
// Create a new image to display and fill it with white
|
||||
QImage newImage(newSize, QImage::Format_ARGB32);
|
||||
QImage newImage(newSize, QImage::Format_ARGB32);
|
||||
newImage.fill(qRgb(255, 255, 255));
|
||||
|
||||
// Draw the image
|
||||
QPainter painter(&newImage);
|
||||
painter.drawImage(QPoint(0, 0), *image);
|
||||
*image = newImage;
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
if(fastRenderer) {
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
}
|
||||
|
||||
void IntelliImage::drawPixel(const QPoint &p1, const QColor& color){
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
// Used to draw on the widget
|
||||
if(fastRenderer) {
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
// Used to draw on the widget
|
||||
QPainter painter(&imageData);
|
||||
|
||||
// Set the current settings for the pen
|
||||
@@ -64,32 +64,32 @@ void IntelliImage::drawPixel(const QPoint &p1, const QColor& color){
|
||||
|
||||
// Draw a line from the last registered point to the current
|
||||
painter.drawPoint(p1);
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
if(fastRenderer) {
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
}
|
||||
|
||||
void IntelliImage::drawPoint(const QPoint &p1, const QColor& color, const int& penWidth){
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
// Used to draw on the widget
|
||||
if(fastRenderer) {
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
// Used to draw on the widget
|
||||
QPainter painter(&imageData);
|
||||
|
||||
// Set the current settings for the pen
|
||||
painter.setPen(QPen(color, penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
// Draw a line from the last registered point to the current
|
||||
painter.drawPoint(p1);
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
if(fastRenderer) {
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
}
|
||||
|
||||
void IntelliImage::drawLine(const QPoint &p1, const QPoint& p2, const QColor& color, const int& penWidth){
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
// Used to draw on the widget
|
||||
if(fastRenderer) {
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
// Used to draw on the widget
|
||||
QPainter painter(&imageData);
|
||||
|
||||
// Set the current settings for the pen
|
||||
@@ -97,34 +97,34 @@ void IntelliImage::drawLine(const QPoint &p1, const QPoint& p2, const QColor& co
|
||||
|
||||
// Draw a line from the last registered point to the current
|
||||
painter.drawLine(p1, p2);
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
if(fastRenderer) {
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
}
|
||||
|
||||
void IntelliImage::drawPlain(const QColor& color){
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
imageData.fill(color);
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
if(fastRenderer) {
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
imageData.fill(color);
|
||||
if(fastRenderer) {
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
}
|
||||
|
||||
QColor IntelliImage::getPixelColor(QPoint& point){
|
||||
if(fastRenderer){
|
||||
QImage copy = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
return copy.pixelColor(point);
|
||||
}
|
||||
return imageData.pixelColor(point);
|
||||
if(fastRenderer) {
|
||||
QImage copy = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
return copy.pixelColor(point);
|
||||
}
|
||||
return imageData.pixelColor(point);
|
||||
}
|
||||
|
||||
QImage IntelliImage::getImageData(){
|
||||
return this->imageData;
|
||||
return this->imageData;
|
||||
}
|
||||
|
||||
void IntelliImage::updateRendererSetting(bool fastRendererOn){
|
||||
this->fastRenderer = fastRendererOn;
|
||||
this->imageData = this->imageData.convertToFormat(fastRenderer ? QImage::Format_Indexed8 : QImage::Format_ARGB32);
|
||||
this->fastRenderer = fastRendererOn;
|
||||
this->imageData = this->imageData.convertToFormat(fastRenderer ? QImage::Format_Indexed8 : QImage::Format_ARGB32);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
#include <QDebug>
|
||||
|
||||
IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererOn)
|
||||
: IntelliImage(width, height, fastRendererOn){
|
||||
TypeOfImage = IntelliImage::ImageType::RASTERIMAGE;
|
||||
this->fastRenderer = fastRendererOn;
|
||||
: IntelliImage(width, height, fastRendererOn){
|
||||
TypeOfImage = IntelliImage::ImageType::RASTERIMAGE;
|
||||
this->fastRenderer = fastRendererOn;
|
||||
}
|
||||
|
||||
IntelliRasterImage::~IntelliRasterImage(){
|
||||
@@ -14,7 +14,7 @@ IntelliRasterImage::~IntelliRasterImage(){
|
||||
}
|
||||
|
||||
IntelliImage* IntelliRasterImage::getDeepCopy(){
|
||||
IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), false);
|
||||
IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), false);
|
||||
raster->imageData.fill(Qt::transparent);
|
||||
raster->TypeOfImage = IntelliImage::ImageType::RASTERIMAGE;
|
||||
return raster;
|
||||
@@ -30,9 +30,9 @@ QImage IntelliRasterImage::getDisplayable(int alpha){
|
||||
|
||||
QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){
|
||||
QImage copy = imageData;
|
||||
if(fastRenderer){
|
||||
copy = copy.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
if(fastRenderer) {
|
||||
copy = copy.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
for(int y = 0; y<copy.height(); y++) {
|
||||
for(int x = 0; x<copy.width(); x++) {
|
||||
QColor clr = copy.pixelColor(x,y);
|
||||
@@ -40,9 +40,9 @@ QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){
|
||||
copy.setPixelColor(x,y, clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderer){
|
||||
copy = copy.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
if(fastRenderer) {
|
||||
copy = copy.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
return copy.scaled(displaySize,Qt::IgnoreAspectRatio);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
#include <QDebug>
|
||||
|
||||
IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererOn)
|
||||
: IntelliRasterImage(width, height, fastRendererOn){
|
||||
TypeOfImage = IntelliImage::ImageType::SHAPEDIMAGE;
|
||||
this->fastRenderer = fastRendererOn;
|
||||
: IntelliRasterImage(width, height, fastRendererOn){
|
||||
TypeOfImage = IntelliImage::ImageType::SHAPEDIMAGE;
|
||||
this->fastRenderer = fastRendererOn;
|
||||
}
|
||||
|
||||
IntelliShapedImage::~IntelliShapedImage(){
|
||||
@@ -19,7 +19,7 @@ QImage IntelliShapedImage::getDisplayable(int alpha){
|
||||
}
|
||||
|
||||
IntelliImage* IntelliShapedImage::getDeepCopy(){
|
||||
IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), false);
|
||||
IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), false);
|
||||
shaped->setPolygon(this->polygonData);
|
||||
shaped->imageData.fill(Qt::transparent);
|
||||
shaped->TypeOfImage = IntelliImage::ImageType::SHAPEDIMAGE;
|
||||
@@ -27,11 +27,11 @@ IntelliImage* IntelliShapedImage::getDeepCopy(){
|
||||
}
|
||||
|
||||
void IntelliShapedImage::calculateVisiblity(){
|
||||
if(fastRenderer){
|
||||
this->imageData = imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
if(fastRenderer) {
|
||||
this->imageData = imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
|
||||
if(polygonData.size()<=2) {
|
||||
if(polygonData.size()<=2) {
|
||||
QColor clr;
|
||||
for(int y=0; y<imageData.height(); y++) {
|
||||
for(int x=0; x<imageData.width(); x++) {
|
||||
@@ -40,9 +40,9 @@ void IntelliShapedImage::calculateVisiblity(){
|
||||
imageData.setPixelColor(x,y,clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
if(fastRenderer) {
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
return;
|
||||
}
|
||||
QColor clr;
|
||||
@@ -50,7 +50,7 @@ void IntelliShapedImage::calculateVisiblity(){
|
||||
for(int x=0; x<imageData.width(); x++) {
|
||||
QPoint ptr(x,y);
|
||||
clr = imageData.pixelColor(x,y);
|
||||
bool isInPolygon = IntelliTriangulation::isInPolygon(triangles, ptr);
|
||||
bool isInPolygon = IntelliTriangulation::isInPolygon(triangles, ptr);
|
||||
if(isInPolygon) {
|
||||
clr.setAlpha(std::min(255, clr.alpha()));
|
||||
}else{
|
||||
@@ -59,16 +59,16 @@ void IntelliShapedImage::calculateVisiblity(){
|
||||
imageData.setPixelColor(x,y,clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
if(fastRenderer) {
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
}
|
||||
|
||||
QImage IntelliShapedImage::getDisplayable(const QSize& displaySize, int alpha){
|
||||
QImage copy = imageData;
|
||||
if(fastRenderer){
|
||||
copy = copy.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
if(fastRenderer) {
|
||||
copy = copy.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
for(int y = 0; y<copy.height(); y++) {
|
||||
for(int x = 0; x<copy.width(); x++) {
|
||||
QColor clr = copy.pixelColor(x,y);
|
||||
@@ -76,9 +76,9 @@ QImage IntelliShapedImage::getDisplayable(const QSize& displaySize, int alpha){
|
||||
copy.setPixelColor(x,y, clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderer){
|
||||
copy = copy.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
if(fastRenderer) {
|
||||
copy = copy.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
return copy.scaled(displaySize,Qt::IgnoreAspectRatio);
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ void IntelliShapedImage::setPolygon(const std::vector<QPoint>& polygonData){
|
||||
for(auto element:polygonData) {
|
||||
this->polygonData.push_back(QPoint(element.x(), element.y()));
|
||||
}
|
||||
triangles = IntelliTriangulation::calculateTriangles(polygonData);
|
||||
triangles = IntelliTriangulation::calculateTriangles(polygonData);
|
||||
}
|
||||
calculateVisiblity();
|
||||
return;
|
||||
|
||||
@@ -31,7 +31,7 @@ PaintingArea::PaintingArea(int maxWidth, int maxHeight, QWidget*parent)
|
||||
polygon.push_back(QPoint(000,100));
|
||||
layerBundle[0].image->setPolygon(polygon);
|
||||
|
||||
this->addLayer(200,200,150,150,IntelliImage::ImageType::RASTERIMAGE);
|
||||
this->addLayer(200,200,150,150,IntelliImage::ImageType::RASTERIMAGE);
|
||||
layerBundle[1].image->drawPlain(QColor(0,255,0,255));
|
||||
layerBundle[1].alpha=200;
|
||||
|
||||
@@ -59,10 +59,10 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff
|
||||
newLayer.height = height;
|
||||
newLayer.widthOffset = widthOffset;
|
||||
newLayer.heightOffset = heightOffset;
|
||||
if(type==IntelliImage::ImageType::RASTERIMAGE) {
|
||||
newLayer.image = new IntelliRasterImage(width,height,renderSettings.getFastRenderer());
|
||||
}else if(type==IntelliImage::ImageType::SHAPEDIMAGE) {
|
||||
newLayer.image = new IntelliShapedImage(width, height, renderSettings.getFastRenderer());
|
||||
if(type==IntelliImage::ImageType::RASTERIMAGE) {
|
||||
newLayer.image = new IntelliRasterImage(width,height,renderSettings.getFastRenderer());
|
||||
}else if(type==IntelliImage::ImageType::SHAPEDIMAGE) {
|
||||
newLayer.image = new IntelliShapedImage(width, height, renderSettings.getFastRenderer());
|
||||
}
|
||||
newLayer.alpha = 255;
|
||||
this->layerBundle.push_back(newLayer);
|
||||
@@ -158,13 +158,13 @@ void PaintingArea::movePositionActive(int x, int y){
|
||||
}
|
||||
|
||||
void PaintingArea::moveActiveLayer(int idx){
|
||||
if(Tool != nullptr){
|
||||
if(Tool->getIsDrawing()){
|
||||
IntelliTool* temp = copyActiveTool();
|
||||
delete this->Tool;
|
||||
this->Tool = temp;
|
||||
}
|
||||
}
|
||||
if(Tool != nullptr) {
|
||||
if(Tool->getIsDrawing()) {
|
||||
IntelliTool* temp = copyActiveTool();
|
||||
delete this->Tool;
|
||||
this->Tool = temp;
|
||||
}
|
||||
}
|
||||
if(idx==1) {
|
||||
this->selectLayerUp();
|
||||
}else if(idx==-1) {
|
||||
|
||||
Reference in New Issue
Block a user