Subversion Repositories Scribus

Rev

Rev 8495 | Rev 8569 | 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
*/
5937 jghali 7
#include <qfile.h>
8
#include <qfileinfo.h>
9
#include "scimgdataloader_qt.h"
10
 
11
ScImgDataLoader_QT::ScImgDataLoader_QT(void) : ScImgDataLoader()
12
{
13
        initSupportedFormatList();
14
}
15
 
16
void ScImgDataLoader_QT::initSupportedFormatList(void)
17
{
18
        m_supportedFormats.clear();
19
        QStringList fmtList = QImage::inputFormatList();
20
        for (uint i = 0; i < fmtList.count(); i++)
21
                m_supportedFormats.append( fmtList[i].lower() );
22
}
23
 
24
void ScImgDataLoader_QT::loadEmbeddedProfile(const QString& fn)
25
{
26
        m_embeddedProfile.resize(0);
27
        m_profileComponents = 0;
28
}
29
 
30
bool ScImgDataLoader_QT::loadPicture(const QString& fn, int /*res*/, bool /*thumbnail*/)
31
{
32
        if (!QFile::exists(fn))
33
                return false;
34
        initialize();
35
        if (m_image.load(fn))
36
        {
37
                m_imageInfoRecord.type = 6;
38
                m_imageInfoRecord.exifDataValid = false;
39
                float xres = m_image.dotsPerMeterX() * 0.0254;
40
                float yres = m_image.dotsPerMeterY() * 0.0254;
41
                int resInf = m_imageInfoRecord.lowResType;
42
                m_image = m_image.convertDepth(32);
43
                m_image.setAlphaBuffer(true);
8562 jghali 44
                m_image.setDotsPerMeterX (qMax(2834, (int) (xres / 0.0254)));
45
                m_image.setDotsPerMeterY (qMax(2834, (int) (yres / 0.0254)));
5937 jghali 46
                m_imageInfoRecord.colorspace = 0;
8562 jghali 47
                m_imageInfoRecord.xres = qMax(72, qRound(xres));
48
                m_imageInfoRecord.yres = qMax(72, qRound(yres));
5937 jghali 49
                m_imageInfoRecord.lowResType = resInf;
50
                m_imageInfoRecord.BBoxX = 0;
51
                m_imageInfoRecord.BBoxH = m_image.height();
52
                return true;
53
        }
54
        return true;
55
}
56
 
57
void ScImgDataLoader_QT::preloadAlphaChannel(const QString& fn, int res)
58
{
59
        initialize();
60
        QFileInfo fi = QFileInfo(fn);
61
        if (!fi.exists())
62
                return;
63
        QString ext = fi.extension(false).lower();
64
        if ((ext == "jpg") || (ext == "jpeg"))
65
                return;
66
        if (m_image.load(fn))
67
        {
68
                m_image = m_image.convertDepth(32);
69
                if (m_image.hasAlphaBuffer())
70
                        m_image.setAlphaBuffer(true);
71
        }
72
}