mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-13 11:50:31 +02:00
Updated it works kinda
TOdo: fix BUGS
This commit is contained in:
@@ -27,14 +27,17 @@ IntelliImage* IntelliShapedImage::getDeepCopy(){
|
||||
}
|
||||
|
||||
void IntelliShapedImage::calculateVisiblity(){
|
||||
if(fastRenderering) {
|
||||
if(polygonData.size()<2){
|
||||
return;
|
||||
}
|
||||
if(fastRenderering) {
|
||||
this->imageData = imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
|
||||
if(polygonData.size()<=2) {
|
||||
QColor clr;
|
||||
for(int y=0; y<imageData.height(); y++) {
|
||||
for(int x=0; x<imageData.width(); x++) {
|
||||
for(int x=0; x<imageData.width(); x++) {
|
||||
clr = imageData.pixel(x,y);
|
||||
clr.setAlpha(255);
|
||||
imageData.setPixelColor(x,y,clr);
|
||||
@@ -52,7 +55,7 @@ void IntelliShapedImage::calculateVisiblity(){
|
||||
clr = imageData.pixelColor(x,y);
|
||||
bool isInPolygon = IntelliTriangulation::isInPolygon(triangles, ptr);
|
||||
if(isInPolygon) {
|
||||
clr.setAlpha(std::min(255, clr.alpha()));
|
||||
clr.setAlpha(std::min(255, clr.alpha()));
|
||||
}else{
|
||||
clr.setAlpha(0);
|
||||
}
|
||||
@@ -91,6 +94,19 @@ void IntelliShapedImage::setPolygon(const std::vector<QPoint>& polygonData){
|
||||
this->polygonData.push_back(QPoint(element.x(), element.y()));
|
||||
}
|
||||
triangles = IntelliTriangulation::calculateTriangles(polygonData);
|
||||
if(fastRenderering){
|
||||
imageData = imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
for(int y = 0; y<imageData.height(); y++) {
|
||||
for(int x = 0; x<imageData.width(); x++) {
|
||||
QColor clr = imageData.pixelColor(x,y);
|
||||
clr.setAlpha(255);
|
||||
imageData.setPixelColor(x,y,clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderering){
|
||||
imageData = imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
}
|
||||
calculateVisiblity();
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user