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