-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathjpegimage.cpp
More file actions
51 lines (42 loc) · 1.33 KB
/
jpegimage.cpp
File metadata and controls
51 lines (42 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "jpegimage.h"
#include <QDebug>
JPEGImage::JPEGImage(): imageFilter("JPEG File (*.jpg)") {
extensionList.push_back( "*.jpeg" );
extensionList.push_back("*.jpg");
}
JPEGImage::~JPEGImage() {
//delete jpeg
}
void JPEGImage::init(QWidget*) {
}
void JPEGImage::deinit() {
}
QString JPEGImage::filter() const {
return imageFilter;
}
bool JPEGImage::exportImage(const ImageStatePtr imageState, const QString& filename) {
if(imageState->format()!=QImage::Format_RGB888){
cout<<"Invalid picture format. Picture format must be RGB 888";
return false;
}
LayerPtr currentLayer=imageState->activeLayer();
QImage currentPicture(currentLayer->getData(),imageState->width(),imageState->height(),QImage::Format_RGB888);
JpegEncode j(currentPicture,filename);
j.savePicture();
return true;
}
QStringList JPEGImage::extensions() const {
return extensionList;
}
ImageStatePtr JPEGImage::importImage(const QString& filename) {
try {
QFile inputFile(filename);
JpegDecode picture(inputFile);
//return ImageStatePtr(new ImageState(filename, QImage(picture.getImage())));
return picture.imagePtr;
} catch(const char err[]) {
qDebug()<<"JPEG error: "<<err;
return ImageStatePtr(0);
}
}
Q_EXPORT_PLUGIN2(plugin_JPEGImage, JPEGImage)