IntelliPhoto 0.7

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 = ImageType::RASTERIMAGE;
9 this->fastRenderering = fastRendererOn;
10 }
11
12
13 IntelliRasterImage* IntelliRasterImage::copy(const IntelliRasterImage& image){
14 this->TypeOfImage = ImageType::RASTERIMAGE;
15 IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), this->fastRenderering);
16 raster->imageData.copy(0,0,image.getWidth(),image.getWidth());
17 return raster;
18 }
19
20
21 IntelliRasterImage::~IntelliRasterImage(){
22
23 }
24
25 IntelliImage* IntelliRasterImage::getDeepCopy(){
26 IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), false);
27 raster->imageData.fill(Qt::transparent);
28 raster->TypeOfImage = ImageType::RASTERIMAGE;
29 return raster;
30 }
31
32 void IntelliRasterImage::calculateVisiblity(){
33 // not used in raster image
34 }
35
36 QImage IntelliRasterImage::getDisplayable(int alpha){
37 return getDisplayable(imageData.size(), alpha);
38 }
39
40 QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){
41 QImage copy = imageData;
42 if(fastRenderering) {
43 copy = copy.convertToFormat(QImage::Format_ARGB32);
44 }
45 for(int y = 0; y<copy.height(); y++) {
46 for(int x = 0; x<copy.width(); x++) {
47 QColor clr = copy.pixelColor(x,y);
48 clr.setAlpha(std::min(alpha, clr.alpha()));
49 copy.setPixelColor(x,y, clr);
50 }
51 }
52 if(fastRenderering) {
53 copy = copy.convertToFormat(QImage::Format_Indexed8);
54 }
55 return copy.scaled(displaySize,Qt::IgnoreAspectRatio);
56 }
57
58 void IntelliRasterImage::setPolygon(const std::vector<QPoint>& polygonData){
59 return;
60 }
61
62 std::vector<QPoint> IntelliRasterImage::getPolygon(){
63 return std::vector<QPoint>();
64 }
ImageType::RASTERIMAGE
@ RASTERIMAGE
IntelliRasterImage::~IntelliRasterImage
virtual ~IntelliRasterImage() override
An Destructor.
Definition: IntelliRasterImage.cpp:21
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::copy
IntelliRasterImage * copy(const IntelliRasterImage &image)
Definition: IntelliRasterImage.cpp:13
IntelliImage::fastRenderering
bool fastRenderering
fastRendering is the flag that represents the usage of 8bit pictures.
Definition: IntelliImage.h:51
IntelliRasterImage::getPolygon
virtual std::vector< QPoint > getPolygon()
getPolygon
Definition: IntelliRasterImage.cpp:62
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:40
IntelliImage::TypeOfImage
ImageType TypeOfImage
The Type, an Image is.
Definition: IntelliImage.h:46
IntelliImage::imageData
QImage imageData
The underlying image data.
Definition: IntelliImage.h:41
IntelliImage
An abstract class which manages the basic IntelliImage operations.
Definition: IntelliImage.h:30
IntelliRasterImage::getDeepCopy
virtual IntelliImage * getDeepCopy() override
A function that copys all that returns a [allocated] Image.
Definition: IntelliRasterImage.cpp:25
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:32
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:58
IntelliRasterImage
The IntelliRasterImage manages a RASTERIMAGE.
Definition: IntelliRasterImage.h:12
IntelliImage::getWidth
virtual int getWidth() const
getWidth returns the width of the Image.
Definition: IntelliImage.cpp:163