mirror of
https://github.com/creyD/intelliphoto.git
synced 2026-04-14 20:30:32 +02:00
start of history
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#include <QSize>
|
||||
#include <QPainter>
|
||||
|
||||
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){
|
||||
if(fastRendererOn) {
|
||||
imageData = imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
@@ -15,6 +15,7 @@ IntelliImage::IntelliImage(int width, int height, bool fastRendererOn)
|
||||
|
||||
}
|
||||
|
||||
|
||||
IntelliImage::~IntelliImage(){
|
||||
|
||||
}
|
||||
@@ -158,3 +159,15 @@ void IntelliImage::updateRendererSetting(bool fastRendererOn){
|
||||
this->imageData = imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
}
|
||||
|
||||
int IntelliImage::getWidth() const{
|
||||
return imageData.width();
|
||||
}
|
||||
|
||||
int IntelliImage::getHeight() const{
|
||||
return imageData.height();
|
||||
}
|
||||
|
||||
bool IntelliImage::isFastRendering() const{
|
||||
return this->fastRenderering;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,14 @@ class UnitTest;
|
||||
|
||||
class IntelliTool;
|
||||
|
||||
/*!
|
||||
* \brief The Types, which an Image can be.
|
||||
*/
|
||||
enum class ImageType {
|
||||
RASTERIMAGE,
|
||||
SHAPEDIMAGE
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief An abstract class which manages the basic IntelliImage operations.
|
||||
*/
|
||||
@@ -24,13 +32,6 @@ friend UnitTest;
|
||||
friend IntelliTool;
|
||||
public:
|
||||
|
||||
/*!
|
||||
* \brief The Types, which an Image can be.
|
||||
*/
|
||||
enum class ImageType {
|
||||
RASTERIMAGE,
|
||||
SHAPEDIMAGE
|
||||
};
|
||||
|
||||
protected:
|
||||
void resizeImage(QImage*image, const QSize &newSize);
|
||||
@@ -59,6 +60,7 @@ public:
|
||||
*/
|
||||
IntelliImage(int width, int height, bool fastRendererOn);
|
||||
|
||||
|
||||
/*!
|
||||
* \brief An Abstract Destructor.
|
||||
*/
|
||||
@@ -170,6 +172,12 @@ virtual QImage getImageData();
|
||||
*/
|
||||
virtual void setImageData(const QImage& newData);
|
||||
|
||||
virtual int getWidth() const;
|
||||
|
||||
virtual int getHeight() const;
|
||||
|
||||
virtual bool isFastRendering() const;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -5,18 +5,28 @@
|
||||
|
||||
IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererOn)
|
||||
: IntelliImage(width, height, fastRendererOn){
|
||||
TypeOfImage = IntelliImage::ImageType::RASTERIMAGE;
|
||||
TypeOfImage = ImageType::RASTERIMAGE;
|
||||
this->fastRenderering = fastRendererOn;
|
||||
}
|
||||
|
||||
/*
|
||||
IntelliRasterImage::IntelliRasterImage(const IntelliRasterImage& image)
|
||||
: IntelliImage(image.getWidth(), image.getHeight(), image.isFastRendering()){
|
||||
this->TypeOfImage = ImageType::RASTERIMAGE;
|
||||
IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), this->fastRenderering);
|
||||
raster->imageData.copy(0,0,image.getWidth(),image.getWidth());
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
IntelliRasterImage::~IntelliRasterImage(){
|
||||
|
||||
}
|
||||
|
||||
IntelliImage* IntelliRasterImage::getDeepCopy(){
|
||||
IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), false);
|
||||
IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), this->fastRenderering);
|
||||
raster->imageData.fill(Qt::transparent);
|
||||
raster->TypeOfImage = IntelliImage::ImageType::RASTERIMAGE;
|
||||
raster->TypeOfImage = ImageType::RASTERIMAGE;
|
||||
return raster;
|
||||
}
|
||||
|
||||
|
||||
61
src/Image/IntelliRasterImage.cpp.autosave
Normal file
61
src/Image/IntelliRasterImage.cpp.autosave
Normal file
@@ -0,0 +1,61 @@
|
||||
#include "Image/IntelliRasterImage.h"
|
||||
#include <QPainter>
|
||||
#include <QRect>
|
||||
#include <QDebug>
|
||||
|
||||
IntelliRasterImage::IntelliRasterImage(int width, int height, bool fastRendererOn)
|
||||
: IntelliImage(width, height, fastRendererOn){
|
||||
TypeOfImage = ImageType::RASTERIMAGE;
|
||||
this->fastRenderering = fastRendererOn;
|
||||
}
|
||||
|
||||
|
||||
IntelliRasterImage::Copy(const IntelliRasterImage& image)
|
||||
: IntelliImage(image.getWidth(), image.getHeight(), image.isFastRendering()){
|
||||
this->TypeOfImage = ImageType::RASTERIMAGE;
|
||||
IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), this->fastRenderering);
|
||||
raster->imageData.copy(0,0,image.getWidth(),image.getWidth());
|
||||
}
|
||||
|
||||
|
||||
|
||||
IntelliRasterImage::~IntelliRasterImage(){
|
||||
|
||||
}
|
||||
|
||||
IntelliImage* IntelliRasterImage::getDeepCopy(){
|
||||
IntelliRasterImage* raster = new IntelliRasterImage(imageData.width(), imageData.height(), this->fastRenderering);
|
||||
raster->imageData.fill(Qt::transparent);
|
||||
raster->TypeOfImage = ImageType::RASTERIMAGE;
|
||||
return raster;
|
||||
}
|
||||
|
||||
void IntelliRasterImage::calculateVisiblity(){
|
||||
// not used in raster image
|
||||
}
|
||||
|
||||
QImage IntelliRasterImage::getDisplayable(int alpha){
|
||||
return getDisplayable(imageData.size(), alpha);
|
||||
}
|
||||
|
||||
QImage IntelliRasterImage::getDisplayable(const QSize& displaySize, int alpha){
|
||||
QImage copy = imageData;
|
||||
if(fastRenderering) {
|
||||
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);
|
||||
clr.setAlpha(std::min(alpha, clr.alpha()));
|
||||
copy.setPixelColor(x,y, clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderering) {
|
||||
copy = copy.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
return copy.scaled(displaySize,Qt::IgnoreAspectRatio);
|
||||
}
|
||||
|
||||
void IntelliRasterImage::setPolygon(const std::vector<QPoint>& polygonData){
|
||||
return;
|
||||
}
|
||||
@@ -26,6 +26,8 @@ public:
|
||||
*/
|
||||
IntelliRasterImage(int width, int height, bool fastRendererOn);
|
||||
|
||||
//IntelliRasterImage(const IntelliRasterImage& image);
|
||||
|
||||
/*!
|
||||
* \brief An Destructor.
|
||||
*/
|
||||
|
||||
@@ -6,10 +6,19 @@
|
||||
|
||||
IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererOn)
|
||||
: IntelliRasterImage(width, height, fastRendererOn){
|
||||
TypeOfImage = IntelliImage::ImageType::SHAPEDIMAGE;
|
||||
TypeOfImage = ImageType::SHAPEDIMAGE;
|
||||
this->fastRenderering = fastRendererOn;
|
||||
}
|
||||
|
||||
/*
|
||||
IntelliShapedImage::IntelliShapedImage(const IntelliShapedImage& image)
|
||||
: IntelliRasterImage(image.getWidth(), image.getHeight(), image.isFastRendering()){
|
||||
this->TypeOfImage = ImageType::SHAPEDIMAGE;
|
||||
IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), this->fastRenderering);
|
||||
shaped->imageData.copy(0,0,image.getWidth(),image.getWidth());
|
||||
}
|
||||
*/
|
||||
|
||||
IntelliShapedImage::~IntelliShapedImage(){
|
||||
|
||||
}
|
||||
@@ -19,10 +28,10 @@ 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(), this->fastRenderering);
|
||||
shaped->setPolygon(this->polygonData);
|
||||
shaped->imageData.fill(Qt::transparent);
|
||||
shaped->TypeOfImage = IntelliImage::ImageType::SHAPEDIMAGE;
|
||||
shaped->TypeOfImage = ImageType::SHAPEDIMAGE;
|
||||
return shaped;
|
||||
}
|
||||
|
||||
|
||||
120
src/Image/IntelliShapedImage.cpp.autosave
Normal file
120
src/Image/IntelliShapedImage.cpp.autosave
Normal file
@@ -0,0 +1,120 @@
|
||||
#include "Image/IntelliShapedImage.h"
|
||||
#include "IntelliHelper/IntelliTriangulation.h"
|
||||
#include <QPainter>
|
||||
#include <QRect>
|
||||
#include <QDebug>
|
||||
|
||||
IntelliShapedImage::IntelliShapedImage(int width, int height, bool fastRendererOn)
|
||||
: IntelliRasterImage(width, height, fastRendererOn){
|
||||
TypeOfImage = ImageType::SHAPEDIMAGE;
|
||||
this->fastRenderering = fastRendererOn;
|
||||
}
|
||||
|
||||
IntelliShapedImage::Copy(const IntelliShapedImage& image)
|
||||
: IntelliRasterImage(image.getWidth(), image.getHeight(), image.isFastRendering()){
|
||||
this->TypeOfImage = ImageType::SHAPEDIMAGE;
|
||||
IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), this->fastRenderering);
|
||||
shaped->imageData.copy(0,0,image.getWidth(),image.getWidth());
|
||||
}
|
||||
|
||||
IntelliShapedImage::~IntelliShapedImage(){
|
||||
|
||||
}
|
||||
|
||||
QImage IntelliShapedImage::getDisplayable(int alpha){
|
||||
return getDisplayable(imageData.size(),alpha);
|
||||
}
|
||||
|
||||
IntelliImage* IntelliShapedImage::getDeepCopy(){
|
||||
IntelliShapedImage* shaped = new IntelliShapedImage(imageData.width(), imageData.height(), this->fastRenderering);
|
||||
shaped->setPolygon(this->polygonData);
|
||||
shaped->imageData.fill(Qt::transparent);
|
||||
shaped->TypeOfImage = ImageType::SHAPEDIMAGE;
|
||||
return shaped;
|
||||
}
|
||||
|
||||
void IntelliShapedImage::calculateVisiblity(){
|
||||
if(polygonData.size()<2) {
|
||||
return;
|
||||
}
|
||||
if(fastRenderering) {
|
||||
this->imageData = imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
|
||||
if(polygonData.size()<=2) {
|
||||
QColor clr;
|
||||
for(int y = 0; y<imageData.height(); y++) {
|
||||
for(int x = 0; x<imageData.width(); x++) {
|
||||
clr = imageData.pixel(x,y);
|
||||
clr.setAlpha(255);
|
||||
imageData.setPixelColor(x,y,clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderering) {
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
return;
|
||||
}
|
||||
QColor clr;
|
||||
for(int y = 0; y<imageData.height(); y++) {
|
||||
for(int x = 0; x<imageData.width(); x++) {
|
||||
QPoint ptr(x,y);
|
||||
clr = imageData.pixelColor(x,y);
|
||||
bool isInPolygon = IntelliTriangulation::isInPolygon(triangles, ptr);
|
||||
if(isInPolygon) {
|
||||
clr.setAlpha(std::min(255, clr.alpha()));
|
||||
}else{
|
||||
clr.setAlpha(0);
|
||||
}
|
||||
imageData.setPixelColor(x,y,clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderering) {
|
||||
this->imageData = this->imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
}
|
||||
|
||||
QImage IntelliShapedImage::getDisplayable(const QSize& displaySize, int alpha){
|
||||
QImage copy = imageData;
|
||||
if(fastRenderering) {
|
||||
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);
|
||||
clr.setAlpha(std::min(alpha,clr.alpha()));
|
||||
copy.setPixelColor(x,y, clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderering) {
|
||||
copy = copy.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
return copy.scaled(displaySize,Qt::IgnoreAspectRatio);
|
||||
}
|
||||
|
||||
void IntelliShapedImage::setPolygon(const std::vector<QPoint>& polygonData){
|
||||
if(polygonData.size()<3) {
|
||||
this->polygonData.clear();
|
||||
}else{
|
||||
this->polygonData.clear();
|
||||
for(auto element:polygonData) {
|
||||
this->polygonData.push_back(QPoint(element.x(), element.y()));
|
||||
}
|
||||
triangles = IntelliTriangulation::calculateTriangles(polygonData);
|
||||
if(fastRenderering) {
|
||||
imageData = imageData.convertToFormat(QImage::Format_ARGB32);
|
||||
}
|
||||
for(int y = 0; y<imageData.height(); y++) {
|
||||
for(int x = 0; x<imageData.width(); x++) {
|
||||
QColor clr = imageData.pixelColor(x,y);
|
||||
clr.setAlpha(255);
|
||||
imageData.setPixelColor(x,y,clr);
|
||||
}
|
||||
}
|
||||
if(fastRenderering) {
|
||||
imageData = imageData.convertToFormat(QImage::Format_Indexed8);
|
||||
}
|
||||
}
|
||||
calculateVisiblity();
|
||||
return;
|
||||
}
|
||||
@@ -38,6 +38,7 @@ public:
|
||||
*/
|
||||
IntelliShapedImage(int width, int height, bool fastRendererOn);
|
||||
|
||||
//IntelliShapedImage(const IntelliShapedImage& image);
|
||||
/*!
|
||||
* \brief An Destructor.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user