mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-13 20:00:32 +02:00
Merge branch 'Helper_Variablen' into 'dev-stupidrenderer'
# Conflicts: # src/Image/IntelliImage.h # src/IntelliPhoto.pro # src/Layer/PaintingArea.h
This commit is contained in:
@@ -2,16 +2,9 @@
|
||||
#include <QSize>
|
||||
#include <QPainter>
|
||||
|
||||
IntelliImage::IntelliImage(int width, int height, bool fastRendererOn)
|
||||
: imageData(QSize(width, height), fastRendererOn ? QImage::Format_Indexed8 : QImage::Format_ARGB32){
|
||||
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;
|
||||
IntelliImage::IntelliImage(int weight, int height)
|
||||
: imageData(QSize(weight, height), QImage::Format_ARGB32){
|
||||
imageData.fill(QColor(255,255,255,255));
|
||||
|
||||
}
|
||||
|
||||
@@ -30,7 +23,7 @@ bool IntelliImage::loadImage(const QString &filePath){
|
||||
// scaled Image to size of Layer
|
||||
loadedImage = loadedImage.scaled(imageData.size(),Qt::IgnoreAspectRatio);
|
||||
|
||||
imageData = loadedImage.convertToFormat(fastRenderer ? QImage::Format_Indexed8 : QImage::Format_ARGB32);
|
||||
imageData = loadedImage.convertToFormat(QImage::Format_ARGB32);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -40,23 +33,17 @@ void IntelliImage::resizeImage(QImage*image, const QSize &newSize){
|
||||
return;
|
||||
|
||||
// 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));
|
||||
|
||||
// Draw the image
|
||||
QPainter painter(&newImage);
|
||||
painter.drawImage(QPoint(0, 0), *image);
|
||||
*image = newImage;
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
}
|
||||
|
||||
void IntelliImage::drawPixel(const QPoint &p1, const QColor& color){
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
// Used to draw on the widget
|
||||
// Used to draw on the widget
|
||||
QPainter painter(&imageData);
|
||||
|
||||
// Set the current settings for the pen
|
||||
@@ -64,32 +51,20 @@ void IntelliImage::drawPixel(const QPoint &p1, const QColor& color){
|
||||
|
||||
// Draw a line from the last registered point to the current
|
||||
painter.drawPoint(p1);
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
}
|
||||
|
||||
void IntelliImage::drawPoint(const QPoint &p1, const QColor& color, const int& penWidth){
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
// Used to draw on the widget
|
||||
// Used to draw on the widget
|
||||
QPainter painter(&imageData);
|
||||
|
||||
// Set the current settings for the pen
|
||||
painter.setPen(QPen(color, penWidth, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
// Draw a line from the last registered point to the current
|
||||
painter.drawPoint(p1);
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
}
|
||||
|
||||
void IntelliImage::drawLine(const QPoint &p1, const QPoint& p2, const QColor& color, const int& penWidth){
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
// Used to draw on the widget
|
||||
// Used to draw on the widget
|
||||
QPainter painter(&imageData);
|
||||
|
||||
// Set the current settings for the pen
|
||||
@@ -97,30 +72,12 @@ void IntelliImage::drawLine(const QPoint &p1, const QPoint& p2, const QColor& co
|
||||
|
||||
// Draw a line from the last registered point to the current
|
||||
painter.drawLine(p1, p2);
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
}
|
||||
|
||||
void IntelliImage::drawPlain(const QColor& color){
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
imageData.fill(color);
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
imageData.fill(color);
|
||||
}
|
||||
|
||||
QColor IntelliImage::getPixelColor(QPoint& point){
|
||||
if(fastRenderer){
|
||||
QImage copy = this->imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
return copy.pixelColor(point);
|
||||
}
|
||||
return imageData.pixelColor(point);
|
||||
}
|
||||
|
||||
void IntelliImage::updateRendererSetting(bool fastRendererOn){
|
||||
this->fastRenderer = fastRendererOn;
|
||||
this->imageData = this->imageData.convertToFormat(fastRenderer ? QImage::Format_Indexed8 : QImage::Format_ARGB32);
|
||||
return imageData.pixelColor(point);
|
||||
}
|
||||
|
||||
@@ -40,20 +40,13 @@ QImage imageData;
|
||||
* \brief The Type, an Image is.
|
||||
*/
|
||||
ImageType TypeOfImage;
|
||||
|
||||
/*!
|
||||
* \brief fastRenderer is the flag that represents the usage of 8bit pictures.
|
||||
*/
|
||||
bool fastRenderer;
|
||||
|
||||
public:
|
||||
/*!
|
||||
* \brief The Construcor of the IntelliImage. Given the Image dimensions.
|
||||
* \param width - The width of the Image.
|
||||
* \param height - The height of the Image.
|
||||
* \param fastRendererOn - Represents the flag for 8bit picture handelling.
|
||||
*/
|
||||
IntelliImage(int width, int height, bool fastRendererOn);
|
||||
IntelliImage(int width, int height);
|
||||
|
||||
/*!
|
||||
* \brief An Abstract Destructor.
|
||||
@@ -148,13 +141,6 @@ virtual bool loadImage(const QString &filePath);
|
||||
* \return The color of the Pixel as QColor.
|
||||
*/
|
||||
virtual QColor getPixelColor(QPoint& point);
|
||||
|
||||
/*!
|
||||
* \brief updateRendererSetting updates the existing image format to the new format.
|
||||
* \param fastRendererOn flag for the 8bit image handeling.
|
||||
*/
|
||||
virtual void updateRendererSetting(bool fastRendererOn);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,10 +3,9 @@
|
||||
#include <QRect>
|
||||
#include <QDebug>
|
||||
|
||||
IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererOn)
|
||||
: IntelliImage(width, height, fastRendererOn){
|
||||
IntelliRasterImage::IntelliRasterImage(int weight, int height)
|
||||
: IntelliImage(weight, height){
|
||||
TypeOfImage = IntelliImage::ImageType::Raster_Image;
|
||||
this->fastRenderer = fastRendererOn;
|
||||
}
|
||||
|
||||
IntelliRasterImage::~IntelliRasterImage(){
|
||||
@@ -14,7 +13,7 @@ IntelliRasterImage::~IntelliRasterImage(){
|
||||
}
|
||||
|
||||
IntelliImage* IntelliRasterImage::getDeepCopy(){
|
||||
IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), false);
|
||||
IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height());
|
||||
raster->imageData.fill(Qt::transparent);
|
||||
raster->TypeOfImage = IntelliImage::ImageType::Raster_Image;
|
||||
return raster;
|
||||
@@ -30,9 +29,6 @@ QImage IntelliRasterImage::getDisplayable(int alpha){
|
||||
|
||||
QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){
|
||||
QImage copy = imageData;
|
||||
if(fastRenderer){
|
||||
copy = copy.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
for(int y = 0; y<copy.height(); y++) {
|
||||
for(int x = 0; x<copy.width(); x++) {
|
||||
QColor clr = copy.pixelColor(x,y);
|
||||
@@ -40,9 +36,6 @@ QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){
|
||||
copy.setPixelColor(x,y, clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderer){
|
||||
copy = copy.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
return copy.scaled(displaySize,Qt::IgnoreAspectRatio);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,9 +18,8 @@ public:
|
||||
* \brief The Construcor of the IntelliRasterImage. Given the Image dimensions.
|
||||
* \param width - The width of the Image.
|
||||
* \param height - The height of the Image.
|
||||
* \param fastRendererOn - Represents the flag for 8bit picture handelling.
|
||||
*/
|
||||
IntelliRasterImage(int width, int height, bool fastRendererOn);
|
||||
IntelliRasterImage(int width, int height);
|
||||
|
||||
/*!
|
||||
* \brief An Destructor.
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
#include <QRect>
|
||||
#include <QDebug>
|
||||
|
||||
IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererOn)
|
||||
: IntelliRasterImage(width, height, fastRendererOn){
|
||||
IntelliShapedImage::IntelliShapedImage(int weight, int height)
|
||||
: IntelliRasterImage(weight, height){
|
||||
TypeOfImage = IntelliImage::ImageType::Shaped_Image;
|
||||
this->fastRenderer = fastRendererOn;
|
||||
}
|
||||
|
||||
IntelliShapedImage::~IntelliShapedImage(){
|
||||
@@ -19,7 +18,7 @@ QImage IntelliShapedImage::getDisplayable(int alpha){
|
||||
}
|
||||
|
||||
IntelliImage* IntelliShapedImage::getDeepCopy(){
|
||||
IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), false);
|
||||
IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height());
|
||||
shaped->setPolygon(this->polygonData);
|
||||
shaped->imageData.fill(Qt::transparent);
|
||||
shaped->TypeOfImage = IntelliImage::ImageType::Shaped_Image;
|
||||
@@ -27,11 +26,7 @@ IntelliImage* IntelliShapedImage::getDeepCopy(){
|
||||
}
|
||||
|
||||
void IntelliShapedImage::calculateVisiblity(){
|
||||
if(fastRenderer){
|
||||
this->imageData = imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
|
||||
if(polygonData.size()<=2) {
|
||||
if(polygonData.size()<=2) {
|
||||
QColor clr;
|
||||
for(int y=0; y<imageData.height(); y++) {
|
||||
for(int x=0; x<imageData.width(); x++) {
|
||||
@@ -40,9 +35,6 @@ void IntelliShapedImage::calculateVisiblity(){
|
||||
imageData.setPixelColor(x,y,clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderer){
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
return;
|
||||
}
|
||||
QColor clr;
|
||||
@@ -59,16 +51,10 @@ void IntelliShapedImage::calculateVisiblity(){
|
||||
imageData.setPixelColor(x,y,clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderer){
|
||||
this->imageData = 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<copy.height(); y++) {
|
||||
for(int x = 0; x<copy.width(); x++) {
|
||||
QColor clr = copy.pixelColor(x,y);
|
||||
@@ -76,9 +62,6 @@ QImage IntelliShapedImage::getDisplayable(const QSize& displaySize, int alpha){
|
||||
copy.setPixelColor(x,y, clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderer){
|
||||
copy = copy.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
return copy.scaled(displaySize,Qt::IgnoreAspectRatio);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,9 +30,8 @@ public:
|
||||
* \brief The Construcor of the IntelliShapedImage. Given the Image dimensions.
|
||||
* \param width - The width of the Image.
|
||||
* \param height - The height of the Image.
|
||||
* \param fastRendererOn - Represents the flag for 8bit picture handelling.
|
||||
*/
|
||||
IntelliShapedImage(int width, int height, bool fastRendererOn);
|
||||
IntelliShapedImage(int width, int height);
|
||||
|
||||
/*!
|
||||
* \brief An Destructor.
|
||||
|
||||
Reference in New Issue
Block a user