Back to index

scribus-ng  1.3.4.dfsg+svn20071115
scimgdataloader_qt.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #include <qfile.h>
00008 #include <qfileinfo.h>
00009 #include "scimgdataloader_qt.h"
00010 
00011 ScImgDataLoader_QT::ScImgDataLoader_QT(void) : ScImgDataLoader()
00012 {
00013        initSupportedFormatList();
00014 }
00015 
00016 void ScImgDataLoader_QT::initSupportedFormatList(void)
00017 {
00018        m_supportedFormats.clear();
00019        QStringList fmtList = QImage::inputFormatList();
00020        for (uint i = 0; i < fmtList.count(); i++)
00021               m_supportedFormats.append( fmtList[i].lower() );
00022 }
00023 
00024 void ScImgDataLoader_QT::loadEmbeddedProfile(const QString& fn)
00025 {
00026        m_embeddedProfile.resize(0);
00027        m_profileComponents = 0;
00028 }
00029 
00030 bool ScImgDataLoader_QT::loadPicture(const QString& fn, int /*res*/, bool /*thumbnail*/)
00031 {
00032        if (!QFile::exists(fn))
00033               return false;
00034        initialize();
00035        if (m_image.load(fn))
00036        {
00037               m_imageInfoRecord.type = 6;
00038               m_imageInfoRecord.exifDataValid = false;
00039               float xres = m_image.dotsPerMeterX() * 0.0254;
00040               float yres = m_image.dotsPerMeterY() * 0.0254;
00041               int resInf = m_imageInfoRecord.lowResType;
00042               m_image = m_image.convertDepth(32);
00043               m_image.setAlphaBuffer(true);
00044               m_image.setDotsPerMeterX (QMAX(2834, (int) (xres / 0.0254)));
00045               m_image.setDotsPerMeterY (QMAX(2834, (int) (yres / 0.0254)));
00046               m_imageInfoRecord.colorspace = 0;
00047               m_imageInfoRecord.xres = QMAX(72, qRound(xres));
00048               m_imageInfoRecord.yres = QMAX(72, qRound(yres));
00049               m_imageInfoRecord.lowResType = resInf;
00050               m_imageInfoRecord.BBoxX = 0;
00051               m_imageInfoRecord.BBoxH = m_image.height();
00052               return true;
00053        }
00054        return true;
00055 }
00056 
00057 void ScImgDataLoader_QT::preloadAlphaChannel(const QString& fn, int res)
00058 {
00059        initialize();
00060        QFileInfo fi = QFileInfo(fn);
00061        if (!fi.exists())
00062               return;
00063        QString ext = fi.extension(false).lower();
00064        if ((ext == "jpg") || (ext == "jpeg"))
00065               return;
00066        if (m_image.load(fn))
00067        {
00068               m_image = m_image.convertDepth(32);
00069               if (m_image.hasAlphaBuffer())
00070                      m_image.setAlphaBuffer(true);
00071        }
00072 }