2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
11
#include "scribuscore.h"
12
#include "scimgdataloader_pdf.h"
14
ScImgDataLoader_PDF::ScImgDataLoader_PDF(void) : ScImgDataLoader()
16
initSupportedFormatList();
19
void ScImgDataLoader_PDF::initSupportedFormatList(void)
21
m_supportedFormats.clear();
22
m_supportedFormats.append( "pdf" );
25
void ScImgDataLoader_PDF::loadEmbeddedProfile(const QString& fn)
27
m_embeddedProfile.resize(0);
28
m_profileComponents = 0;
31
bool ScImgDataLoader_PDF::loadPicture(const QString& fn, int gsRes, bool /*thumbnail*/)
34
if (!QFile::exists(fn))
36
QString tmpFile = QDir::convertSeparators(ScPaths::getTempFileDir() + "sc.png");
37
QString picFile = QDir::convertSeparators(fn);
42
m_imageInfoRecord.type = 4;
43
m_imageInfoRecord.exifDataValid = false;
44
args.append("-r"+QString::number(gsRes));
45
args.append("-sOutputFile="+tmpFile);
46
args.append("-dFirstPage=1");
47
args.append("-dLastPage=1");
49
int retg = callGS(args);
52
m_image.load(tmpFile);
54
m_image.setAlphaBuffer(true);
55
if (ScCore->havePNGAlpha() != 0)
57
for( int yi=0; yi < m_image.height(); ++yi )
59
QRgb *s = (QRgb*)(m_image.scanLine( yi ));
60
for(int xi=0; xi < m_image.width(); ++xi )
62
if((*s) == 0xffffffff)
68
m_imageInfoRecord.BBoxX = 0;
69
m_imageInfoRecord.BBoxH = m_image.height();
70
m_imageInfoRecord.xres = qRound(gsRes);
71
m_imageInfoRecord.yres = qRound(gsRes);
72
m_imageInfoRecord.colorspace = 0;
73
m_image.setDotsPerMeterX ((int) (xres / 0.0254));
74
m_image.setDotsPerMeterY ((int) (yres / 0.0254));
80
void ScImgDataLoader_PDF::preloadAlphaChannel(const QString& fn, int gsRes)
83
// short resolutionunit = 0;
85
QFileInfo fi = QFileInfo(fn);
89
QString ext = fi.extension(false).lower();
90
QString tmpFile = QDir::convertSeparators(ScPaths::getTempFileDir() + "sc.png");
91
QString picFile = QDir::convertSeparators(fn);
95
args.append("-r"+QString::number(gsRes));
96
// args.append("-sOutputFile=\""+tmpFile + "\"");
97
args.append("-sOutputFile="+tmpFile);
98
args.append("-dFirstPage=1");
99
args.append("-dLastPage=1");
100
// args.append("\""+picFile+"\"");
101
args.append(picFile);
102
int retg = callGS(args);
105
m_image.load(tmpFile);
107
m_image.setAlphaBuffer(true);
108
if (ScCore->havePNGAlpha() != 0)
111
for( int yi=0; yi < m_image.height(); ++yi )
113
s = (QRgb*)(m_image.scanLine( yi ));
114
for(int xi=0; xi < m_image.width(); ++xi )
116
if((*s) == 0xffffffff)