Subversion Repositories Scribus

Rev

Rev 11331 | Rev 11611 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5977 jghali 1
/*
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.
6
*/
10223 cbradney 7
#include <QFile>
8
#include <QFileInfo>
8569 jghali 9
#include <QByteArray>
10
#include <QImageReader>
11
#include <QList>
5937 jghali 12
#include "scimgdataloader_qt.h"
13
 
14
ScImgDataLoader_QT::ScImgDataLoader_QT(void) : ScImgDataLoader()
15
{
16
        initSupportedFormatList();
17
}
18
 
19
void ScImgDataLoader_QT::initSupportedFormatList(void)
20
{
21
        m_supportedFormats.clear();
8569 jghali 22
        QList<QByteArray> fmtList = QImageReader::supportedImageFormats();
23
        for (int i = 0; i < fmtList.count(); i++)
10398 cbradney 24
                m_supportedFormats.append( fmtList[i].toLower() );
5937 jghali 25
}
26
 
27
void ScImgDataLoader_QT::loadEmbeddedProfile(const QString& fn)
28
{
29
        m_embeddedProfile.resize(0);
30
        m_profileComponents = 0;
31
}
32
 
33
bool ScImgDataLoader_QT::loadPicture(const QString& fn, int /*res*/, bool /*thumbnail*/)
34
{
35
        if (!QFile::exists(fn))
36
                return false;
37
        initialize();
38
        if (m_image.load(fn))
39
        {
11331 jghali 40
                m_imageInfoRecord.type = ImageTypeOther;
5937 jghali 41
                m_imageInfoRecord.exifDataValid = false;
42
                float xres = m_image.dotsPerMeterX() * 0.0254;
43
                float yres = m_image.dotsPerMeterY() * 0.0254;
44
                int resInf = m_imageInfoRecord.lowResType;
10561 fschmid 45
                m_image = m_image.convertToFormat(QImage::Format_ARGB32);
8562 jghali 46
                m_image.setDotsPerMeterX (qMax(2834, (int) (xres / 0.0254)));
47
                m_image.setDotsPerMeterY (qMax(2834, (int) (yres / 0.0254)));
11331 jghali 48
                m_imageInfoRecord.colorspace = ColorSpaceRGB;
8562 jghali 49
                m_imageInfoRecord.xres = qMax(72, qRound(xres));
50
                m_imageInfoRecord.yres = qMax(72, qRound(yres));
5937 jghali 51
                m_imageInfoRecord.lowResType = resInf;
52
                m_imageInfoRecord.BBoxX = 0;
53
                m_imageInfoRecord.BBoxH = m_image.height();
54
                return true;
55
        }
11468 fschmid 56
        return false; //TODO: I think this should be false!
5937 jghali 57
}
58
 
11468 fschmid 59
bool ScImgDataLoader_QT::preloadAlphaChannel(const QString& fn, int res, bool& hasAlpha)
5937 jghali 60
{
61
        initialize();
11468 fschmid 62
        hasAlpha = false;
5937 jghali 63
        QFileInfo fi = QFileInfo(fn);
64
        if (!fi.exists())
11468 fschmid 65
                return false;
10561 fschmid 66
        QString ext = fi.suffix().toLower();
5937 jghali 67
        if ((ext == "jpg") || (ext == "jpeg"))
11468 fschmid 68
        {
69
                hasAlpha = false;
70
                return true;
71
        }
5937 jghali 72
        if (m_image.load(fn))
11468 fschmid 73
        {
10561 fschmid 74
                m_image = m_image.convertToFormat(QImage::Format_ARGB32);
11468 fschmid 75
                hasAlpha = true;
76
                return true;
77
        }
78
        return false;
5937 jghali 79
}