mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-16 05:10:32 +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)
|
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){
|
||||||
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;
|
this->fastRenderer = fastRendererOn;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,8 @@ void PaintingArea::setLayerDimensions(int maxWidth, int maxHeight){
|
|||||||
//set standart parameter
|
//set standart parameter
|
||||||
this->maxWidth = maxWidth;
|
this->maxWidth = maxWidth;
|
||||||
this->maxHeight = maxHeight;
|
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
|
// Roots the widget to the top left even if resized
|
||||||
setAttribute(Qt::WA_StaticContents);
|
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) {
|
}else if(type==IntelliImage::ImageType::Shaped_Image) {
|
||||||
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);
|
||||||
return static_cast<int>(layerBundle.size())-1;
|
return static_cast<int>(layerBundle.size())-1;
|
||||||
}
|
}
|
||||||
@@ -120,7 +124,7 @@ bool PaintingArea::save(const QString &filePath, const char*fileFormat){
|
|||||||
this->drawLayers(true);
|
this->drawLayers(true);
|
||||||
|
|
||||||
if(!strcmp(fileFormat,"PNG")) {
|
if(!strcmp(fileFormat,"PNG")) {
|
||||||
QImage visibleImage = Canvas->convertToFormat(QImage::Format_Indexed8);
|
QImage visibleImage = Canvas->convertToFormat(QImage::Format_Indexed8);
|
||||||
fileFormat = "png";
|
fileFormat = "png";
|
||||||
if (visibleImage.save(filePath, fileFormat)) {
|
if (visibleImage.save(filePath, fileFormat)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -310,7 +314,7 @@ void PaintingArea::paintEvent(QPaintEvent*event){
|
|||||||
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
QRect dirtyRec = event->rect();
|
QRect dirtyRec = event->rect();
|
||||||
painter.drawImage(dirtyRec, *Canvas, dirtyRec);
|
painter.drawImage(dirtyRec, *Canvas, dirtyRec);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,15 +345,16 @@ void PaintingArea::selectLayerDown(){
|
|||||||
|
|
||||||
void PaintingArea::drawLayers(bool forSaving){
|
void PaintingArea::drawLayers(bool forSaving){
|
||||||
if(forSaving) {
|
if(forSaving) {
|
||||||
Canvas->fill(Qt::GlobalColor::transparent);
|
Canvas->fill(Qt::GlobalColor::transparent);
|
||||||
}else{
|
}else{
|
||||||
Canvas->fill(Qt::GlobalColor::black);
|
Canvas->fill(Qt::GlobalColor::black);
|
||||||
}
|
}
|
||||||
for(size_t i=0; i<layerBundle.size(); i++) {
|
for(size_t i=0; i<layerBundle.size(); i++) {
|
||||||
LayerObject layer = layerBundle[i];
|
LayerObject layer = layerBundle[i];
|
||||||
QImage cpy = layer.image->getDisplayable(layer.alpha);
|
QImage cpy = layer.image->getDisplayable(layer.alpha);
|
||||||
if(renderSettings.getFastRenderer()){
|
if(renderSettings.getFastRenderer()){
|
||||||
cpy = cpy.convertToFormat(QImage::Format_ARGB32);
|
cpy = cpy.convertToFormat(QImage::Format_ARGB32);
|
||||||
|
*Canvas = Canvas->convertToFormat(QImage::Format_ARGB32);
|
||||||
}
|
}
|
||||||
QColor clr_0;
|
QColor clr_0;
|
||||||
QColor clr_1;
|
QColor clr_1;
|
||||||
@@ -359,7 +364,7 @@ void PaintingArea::drawLayers(bool forSaving){
|
|||||||
for(int x=0; x<layer.width; x++) {
|
for(int x=0; x<layer.width; x++) {
|
||||||
if(layer.widthOffset+x<0) continue;
|
if(layer.widthOffset+x<0) continue;
|
||||||
if(layer.widthOffset+x>=maxWidth) break;
|
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);
|
clr_1=cpy.pixelColor(x,y);
|
||||||
float t = static_cast<float>(clr_1.alpha())/255.f;
|
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);
|
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){
|
void PaintingArea::createTempTopLayer(int idx){
|
||||||
|
|||||||
Reference in New Issue
Block a user