mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-12 19:40:28 +02:00
Now everything is Indexe 8 😲
Job done.
This commit is contained in:
@@ -4,7 +4,13 @@
|
||||
|
||||
IntelliImage::IntelliImage(int width, int height, bool fastRendererOn)
|
||||
: imageData(QSize(width, height), fastRendererOn ? QImage::Format_Indexed8 : QImage::Format_ARGB32){
|
||||
imageData.fill(QColor(255,255,255,255));
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
@@ -48,7 +48,8 @@ void PaintingArea::setLayerDimensions(int maxWidth, int maxHeight){
|
||||
//set standart parameter
|
||||
this->maxWidth = maxWidth;
|
||||
this->maxHeight = maxHeight;
|
||||
Canvas = new QImage(maxWidth,maxHeight, QImage::Format_ARGB32);
|
||||
if(renderSettings.getFastRenderer()) Canvas = new QImage(maxWidth,maxHeight, QImage::Format_Indexed8);
|
||||
else Canvas = new QImage(maxWidth,maxHeight, QImage::Format_ARGB32);
|
||||
|
||||
// Roots the widget to the top left even if resized
|
||||
setAttribute(Qt::WA_StaticContents);
|
||||
@@ -66,7 +67,10 @@ int PaintingArea::addLayer(int width, int height, int widthOffset, int heightOff
|
||||
}else if(type==IntelliImage::ImageType::Shaped_Image) {
|
||||
newLayer.image = new IntelliShapedImage(width, height, renderSettings.getFastRenderer());
|
||||
}
|
||||
newLayer.alpha = 255;
|
||||
|
||||
newLayer.alpha = 255;
|
||||
|
||||
|
||||
this->layerBundle.push_back(newLayer);
|
||||
return static_cast<int>(layerBundle.size())-1;
|
||||
}
|
||||
@@ -120,7 +124,7 @@ bool PaintingArea::save(const QString &filePath, const char*fileFormat){
|
||||
this->drawLayers(true);
|
||||
|
||||
if(!strcmp(fileFormat,"PNG")) {
|
||||
QImage visibleImage = Canvas->convertToFormat(QImage::Format_Indexed8);
|
||||
QImage visibleImage = Canvas->convertToFormat(QImage::Format_Indexed8);
|
||||
fileFormat = "png";
|
||||
if (visibleImage.save(filePath, fileFormat)) {
|
||||
return true;
|
||||
@@ -310,7 +314,7 @@ void PaintingArea::paintEvent(QPaintEvent*event){
|
||||
|
||||
QPainter painter(this);
|
||||
QRect dirtyRec = event->rect();
|
||||
painter.drawImage(dirtyRec, *Canvas, dirtyRec);
|
||||
painter.drawImage(dirtyRec, *Canvas, dirtyRec);
|
||||
update();
|
||||
}
|
||||
|
||||
@@ -341,15 +345,16 @@ void PaintingArea::selectLayerDown(){
|
||||
|
||||
void PaintingArea::drawLayers(bool forSaving){
|
||||
if(forSaving) {
|
||||
Canvas->fill(Qt::GlobalColor::transparent);
|
||||
Canvas->fill(Qt::GlobalColor::transparent);
|
||||
}else{
|
||||
Canvas->fill(Qt::GlobalColor::black);
|
||||
Canvas->fill(Qt::GlobalColor::black);
|
||||
}
|
||||
for(size_t i=0; i<layerBundle.size(); i++) {
|
||||
LayerObject layer = layerBundle[i];
|
||||
QImage cpy = layer.image->getDisplayable(layer.alpha);
|
||||
if(renderSettings.getFastRenderer()){
|
||||
cpy = cpy.convertToFormat(QImage::Format_ARGB32);
|
||||
*Canvas = Canvas->convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
QColor clr_0;
|
||||
QColor clr_1;
|
||||
@@ -359,7 +364,7 @@ void PaintingArea::drawLayers(bool forSaving){
|
||||
for(int x=0; x<layer.width; x++) {
|
||||
if(layer.widthOffset+x<0) continue;
|
||||
if(layer.widthOffset+x>=maxWidth) break;
|
||||
clr_0=Canvas->pixelColor(layer.widthOffset+x, layer.heightOffset+y);
|
||||
clr_0=Canvas->pixelColor(layer.widthOffset+x, layer.heightOffset+y);
|
||||
clr_1=cpy.pixelColor(x,y);
|
||||
float t = static_cast<float>(clr_1.alpha())/255.f;
|
||||
int r =static_cast<int>(static_cast<float>(clr_1.red())*(t)+static_cast<float>(clr_0.red())*(1.f-t)+0.5f);
|
||||
@@ -375,6 +380,9 @@ void PaintingArea::drawLayers(bool forSaving){
|
||||
}
|
||||
}
|
||||
}
|
||||
if(renderSettings.getFastRenderer()){
|
||||
*Canvas = Canvas->convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
}
|
||||
|
||||
void PaintingArea::createTempTopLayer(int idx){
|
||||
|
||||
Reference in New Issue
Block a user