IntelliPhoto 0.5

IntelliRasterImage.cpp
Go to the documentation of this file.
1 #include "Image/IntelliRasterImage.h"
2 #include <QPainter>
3 #include <QRect>
4 #include <QDebug>
5
6 IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererOn)
7 : IntelliImage(width, height, fastRendererOn){
8 TypeOfImage = IntelliImage::ImageType::RASTERIMAGE;
9 this->fastRenderer = fastRendererOn;
10 }
11
12 IntelliRasterImage::~IntelliRasterImage(){
13
14 }
15
16 IntelliImage* IntelliRasterImage::getDeepCopy(){
17 IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), false);
18 raster->imageData.fill(Qt::transparent);
19 raster->TypeOfImage = IntelliImage::ImageType::RASTERIMAGE;
20 return raster;
21 }
22
23 void IntelliRasterImage::calculateVisiblity(){
24 // not used in raster image
25 }
26
27 QImage IntelliRasterImage::getDisplayable(int alpha){
28 return getDisplayable(imageData.size(), alpha);
29 }
30
31 QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){
32 QImage copy = imageData;
33 if(fastRenderer) {
34 copy = copy.convertToFormat(QImage::Format_ARGB32);
35 }
36 for(int y = 0; y<copy.height(); y++) {
37 for(int x = 0; x<copy.width(); x++) {
38 QColor clr = copy.pixelColor(x,y);
39 clr.setAlpha(std::min(alpha, clr.alpha()));
40 copy.setPixelColor(x,y, clr);
41 }
42 }
43 if(fastRenderer) {
44 copy = copy.convertToFormat(QImage::Format_Indexed8);
45 }
46 return copy.scaled(displaySize,Qt::IgnoreAspectRatio);
47 }
48
49 void IntelliRasterImage::setPolygon(const std::vector<QPoint>& polygonData){
50 qDebug() << "Raster Image has no polygon data " << polygonData.size() <<"\n";
51 return;
52 }
IntelliRasterImage::~IntelliRasterImage
virtual ~IntelliRasterImage() override
An Destructor.
Definition: IntelliRasterImage.cpp:12
IntelliRasterImage::IntelliRasterImage
IntelliRasterImage(int width, int height, bool fastRendererOn)
The Construcor of the IntelliRasterImage. Given the Image dimensions.
Definition: IntelliRasterImage.cpp:6
IntelliRasterImage.h
IntelliRasterImage::getDisplayable
virtual QImage getDisplayable(const QSize &displaySize, int alpha) override
A function returning the displayable ImageData in a requested transparence and size.
Definition: IntelliRasterImage.cpp:31
IntelliImage::TypeOfImage
ImageType TypeOfImage
The Type, an Image is.
Definition: IntelliImage.h:42
IntelliImage::fastRenderer
bool fastRenderer
fastRenderer is the flag that represents the usage of 8bit pictures.
Definition: IntelliImage.h:47
IntelliImage::ImageType::RASTERIMAGE
IntelliImage::imageData
QImage imageData
The underlying image data.
Definition: IntelliImage.h:37
IntelliImage
An abstract class which manages the basic IntelliImage operations.
Definition: IntelliImage.h:19
IntelliRasterImage::getDeepCopy
virtual IntelliImage * getDeepCopy() override
A function that copys all that returns a [allocated] Image.
Definition: IntelliRasterImage.cpp:16
IntelliRasterImage::calculateVisiblity
virtual void calculateVisiblity() override
A function that calculates the visibility of the image if a polygon is given. [does nothing in RASTER...
Definition: IntelliRasterImage.cpp:23
IntelliRasterImage::setPolygon
virtual void setPolygon(const std::vector< QPoint > &polygonData) override
An abstract function that sets the data of the visible Polygon, if needed.
Definition: IntelliRasterImage.cpp:49
IntelliRasterImage
The IntelliRasterImage manages a RASTERIMAGE.
Definition: IntelliRasterImage.h:9