#include "Image/IntelliShapedImage.h" #include "IntelliHelper/IntelliTriangulation.h" #include #include #include IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererOn) : IntelliRasterImage(width, height, fastRendererOn){ TypeOfImage = IntelliImage::ImageType::Shaped_Image; this->fastRenderer = fastRendererOn; } IntelliShapedImage::~IntelliShapedImage(){ } QImage IntelliShapedImage::getDisplayable(int alpha){ return getDisplayable(imageData.size(),alpha); } IntelliImage* IntelliShapedImage::getDeepCopy(){ IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), false); shaped->setPolygon(this->polygonData); shaped->imageData.fill(Qt::transparent); shaped->TypeOfImage = IntelliImage::ImageType::SHAPEDIMAGE; return shaped; } void IntelliShapedImage::calculateVisiblity(){ if(fastRenderer){ this->imageData = imageData.convertToFormat(QImage::Format_ARGB32); } if(polygonData.size()<=2) { QColor clr; for(int y=0; yimageData = this->imageData.convertToFormat(QImage::Format_Indexed8); } return; } QColor clr; for(int y=0; yimageData = 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); } for(int y = 0; y& polygonData){ if(polygonData.size()<3) { this->polygonData.clear(); }else{ this->polygonData.clear(); for(auto element:polygonData) { this->polygonData.push_back(QPoint(element.x(), element.y())); } triangles = IntelliTriangulation::calculateTriangles(polygonData); } calculateVisiblity(); return; }