Back to index

scribus-ng  1.3.4.dfsg+svn20071115
Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes
ScImgDataLoader_PDF Class Reference

#include <scimgdataloader_pdf.h>

Inheritance diagram for ScImgDataLoader_PDF:
Inheritance graph
[legend]
Collaboration diagram for ScImgDataLoader_PDF:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ScImgDataLoader_PDF (void)
virtual void preloadAlphaChannel (const QString &fn, int res)
virtual void loadEmbeddedProfile (const QString &fn)
virtual bool loadPicture (const QString &fn, int res, bool thumbnail)
const QStringList & supportedFormats (void) const
bool supportFormat (const QString &fmt)
QImage & image (void)
QByteArray & embeddedProfile (void)
ImageInfoRecordimageInfoRecord (void)
void setRequest (bool valid, QMap< int, ImageLoadRequest > req)
bool issuedErrorMsg (void) const
bool issuedWarningMsg (void) const
const QString & getMessage (void) const
virtual void initialize (void)

Public Attributes

RawImage r_image

Protected Types

enum  MsgType { noMsg = 0, warningMsg = 1, errorMsg = 2 }

Protected Member Functions

void initSupportedFormatList ()
void swapRGBA (void)
void swapRGBA (QImage *img)
QString getPascalString (QDataStream &s)
void parseRessourceData (QDataStream &s, const PSDHeader &header, uint size)

Protected Attributes

QStringList m_supportedFormats
QImage m_image
ImageInfoRecord m_imageInfoRecord
QByteArray m_embeddedProfile
int m_profileComponents
MsgType m_msgType
QString m_message

Detailed Description

Definition at line 12 of file scimgdataloader_pdf.h.


Member Enumeration Documentation

enum ScImgDataLoader::MsgType [protected, inherited]
Enumerator:
noMsg 
warningMsg 
errorMsg 

Definition at line 31 of file scimgdataloader.h.

                    {
              noMsg = 0,
              warningMsg = 1,
              errorMsg = 2
       } MsgType;

Constructor & Destructor Documentation

Definition at line 14 of file scimgdataloader_pdf.cpp.

Here is the call graph for this function:


Member Function Documentation

QByteArray& ScImgDataLoader::embeddedProfile ( void  ) [inline, inherited]

Definition at line 53 of file scimgdataloader.h.

{ return m_embeddedProfile; }
const QString& ScImgDataLoader::getMessage ( void  ) const [inline, inherited]

Definition at line 59 of file scimgdataloader.h.

{ return m_message; }
QString ScImgDataLoader::getPascalString ( QDataStream &  s) [protected, inherited]

Definition at line 36 of file scimgdataloader.cpp.

{
       uchar len, tmp;
       uint adj;
       QString ret = "";
       s >> len;
       if (len == 0)
       {
              s >> tmp;
              return ret;
       }
       for( int i = 0; i < len; i++ )
       {
              s >> tmp;
              ret += QChar(tmp);
       }
       adj = (ret.length()+1) % 2;
       s.device()->at( s.device()->at() + adj );
       return ret;
}

Here is the caller graph for this function:

QImage& ScImgDataLoader::image ( void  ) [inline, inherited]

Definition at line 51 of file scimgdataloader.h.

{ return m_image; }
ImageInfoRecord& ScImgDataLoader::imageInfoRecord ( void  ) [inline, inherited]

Definition at line 54 of file scimgdataloader.h.

{ return m_imageInfoRecord; }
void ScImgDataLoader::initialize ( void  ) [virtual, inherited]

Definition at line 14 of file scimgdataloader.cpp.

{
       m_msgType = noMsg;
       m_message.setLength(0);
       m_image = QImage();
       m_imageInfoRecord.init();
       m_embeddedProfile.resize(0);
       m_profileComponents = 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ScImgDataLoader_PDF::initSupportedFormatList ( void  ) [protected]

Definition at line 19 of file scimgdataloader_pdf.cpp.

{
       m_supportedFormats.clear();
       m_supportedFormats.append( "pdf" );
}

Here is the caller graph for this function:

bool ScImgDataLoader::issuedErrorMsg ( void  ) const [inline, inherited]

Definition at line 57 of file scimgdataloader.h.

{ return (m_msgType == errorMsg); }
bool ScImgDataLoader::issuedWarningMsg ( void  ) const [inline, inherited]

Definition at line 58 of file scimgdataloader.h.

{ return (m_msgType == warningMsg); }
void ScImgDataLoader_PDF::loadEmbeddedProfile ( const QString &  fn) [virtual]

Implements ScImgDataLoader.

Definition at line 25 of file scimgdataloader_pdf.cpp.

bool ScImgDataLoader_PDF::loadPicture ( const QString &  fn,
int  res,
bool  thumbnail 
) [virtual]

Implements ScImgDataLoader.

Definition at line 31 of file scimgdataloader_pdf.cpp.

{
       QStringList args;
       if (!QFile::exists(fn))
              return false;
       QString tmpFile = QDir::convertSeparators(ScPaths::getTempFileDir() + "sc.png");
       QString picFile = QDir::convertSeparators(fn);
       float xres = gsRes;
       float yres = gsRes;

       initialize();
       m_imageInfoRecord.type = 4;
       m_imageInfoRecord.exifDataValid = false;
       args.append("-r"+QString::number(gsRes));
       args.append("-sOutputFile="+tmpFile);
       args.append("-dFirstPage=1");
       args.append("-dLastPage=1");
       args.append(picFile);
       int retg = callGS(args);
       if (retg == 0)
       {
              m_image.load(tmpFile);
              unlink(tmpFile);
              m_image.setAlphaBuffer(true);
              if (ScCore->havePNGAlpha() != 0)
              {
                     for( int yi=0; yi < m_image.height(); ++yi )
                     {
                            QRgb *s = (QRgb*)(m_image.scanLine( yi ));
                            for(int xi=0; xi < m_image.width(); ++xi )
                            {
                                   if((*s) == 0xffffffff)
                                          (*s) &= 0x00ffffff;
                                   s++;
                            }
                     }
              }
              m_imageInfoRecord.BBoxX = 0;
              m_imageInfoRecord.BBoxH = m_image.height();
              m_imageInfoRecord.xres = qRound(gsRes);
              m_imageInfoRecord.yres = qRound(gsRes);
              m_imageInfoRecord.colorspace = 0;
              m_image.setDotsPerMeterX ((int) (xres / 0.0254));
              m_image.setDotsPerMeterY ((int) (yres / 0.0254));
              return true;
       }
       return false;
}

Here is the call graph for this function:

void ScImgDataLoader::parseRessourceData ( QDataStream &  s,
const PSDHeader header,
uint  size 
) [protected, inherited]

Definition at line 93 of file scimgdataloader.cpp.

{
       uint signature, resSize, offset, resBase, vRes, hRes, adj;
       ushort resID, hResUnit, vResUnit, dummyW;
       QString resName;
       uchar filler;
       offset = 0;
       bool first = false;
       bool pathOpen = false;
       FPoint firstPoint, firstControl;
       FPointArray clip2;
       while ((offset + 6)< size)
       {
              s >> signature;
              offset += 4;
              if(((signature >> 24)&0xff) != '8' ||
                      ((signature >> 16)&0xff) != 'B' ||
                      ((signature >> 8)&0xff) != 'I' ||
                      ((signature )&0xff) != 'M' )
                     break;
              s >> resID;
              offset += 2;
              adj = s.device()->at();
              resName = getPascalString(s);
              offset += s.device()->at() - adj;
              s >> resSize;
              if(offset + resSize > size)
                     break;
              resBase = s.device()->at();
              if ( (resID >= 0x07d0) && (resID <= 0x0bb6) )
              {
                     QString db1, db2;
                     short type;
                     uint data1, data2, data3, data4, data5, data6;
                     double frac1, frac2, frac3, frac4, frac5, frac6;
                     ushort man1, man2, man3, man4, man5, man6;
                     uint offset2;
                     offset2 = 0;
                     first = false;
                     pathOpen = false;
                     clip2.resize(0);
                     while (offset2 < resSize)
                     {
                            s >> type;
                            s >> data1;
                            frac1 = (data1 & 0x00FFFFFF) / 16777215.0;
                            man1 = (data1 & 0x0F000000) >> 24;
                            frac1 = (frac1 + man1) * header.height;
                            s >> data2;
                            frac2 = (data2 & 0x00FFFFFF) / 16777215.0;
                            man2 = (data2 & 0x0F000000) >> 24;
                            frac2 = (frac2 + man2) * header.width;
                            s >> data3;
                            frac3 = (data3 & 0x00FFFFFF) / 16777215.0;
                            man3 = (data3 & 0x0F000000) >> 24;
                            frac3 = (frac3 + man3) * header.height;
                            s >> data4;
                            frac4 = (data4 & 0x00FFFFFF) / 16777215.0;
                            man4 = (data4 & 0x0F000000) >> 24;
                            frac4 = (frac4 + man4) * header.width;
                            s >> data5;
                            frac5 = (data5 & 0x00FFFFFF) / 16777215.0;
                            man5 = (data5 & 0x0F000000) >> 24;
                            frac5 = (frac5 + man5) * header.height;
                            s >> data6;
                            frac6 = (data6 & 0x00FFFFFF) / 16777215.0;
                            man6 = (data6 & 0x0F000000) >> 24;
                            frac6 = (frac6 + man6) * header.width;
                            switch (type)
                            {
                            case 0:
                            case 3:
                                   if (pathOpen)
                                   {
                                          clip2.addPoint(firstPoint);
                                          clip2.addPoint(firstControl);
                                          clip2.setMarker();
                                   }
                                   pathOpen = false;
                                   first = true;
                                   break;
                            case 1:
                            case 2:
                            case 4:
                            case 5:
                                   if (first)
                                   {
                                          firstControl = FPoint(frac2, frac1);
                                          firstPoint = FPoint(frac4, frac3);
                                          clip2.addPoint(FPoint(frac4, frac3));
                                          clip2.addPoint(FPoint(frac6, frac5));
                                   }
                                   else
                                   {
                                          clip2.addPoint(frac4, frac3);
                                          clip2.addPoint(frac2, frac1);
                                          clip2.addPoint(frac4, frac3);
                                          clip2.addPoint(frac6, frac5);
                                   }
                                   pathOpen = true;
                                   first = false;
                                   break;
                            case 6:
                                   first = true;
                                   break;
                            default:
                                   break;
                            }
                            offset2 += 26;
                     }
                     clip2.addPoint(firstPoint);
                     clip2.addPoint(firstControl);
                     m_imageInfoRecord.PDSpathData.insert(resName, clip2.copy());
                     m_imageInfoRecord.valid = true;
              }
              else
              {
                     switch (resID)
                     {
                     case 0x0bb7:
                            adj = s.device()->at();
                            m_imageInfoRecord.clipPath = getPascalString(s);
                            offset += s.device()->at() - adj;
                            break;
                     case 0x03ed:
                            s >> hRes;
                            s >> hResUnit;
                            s >> dummyW;
                            s >> vRes;
                            s >> vResUnit;
                            s >> dummyW;
                            m_imageInfoRecord.xres = qRound(hRes / 65536.0);
                            m_imageInfoRecord.yres = qRound(vRes / 65536.0);
                            break;
                     case 0x040f:
                            m_embeddedProfile.resize(resSize);
                            s.readRawBytes(m_embeddedProfile.data(), resSize);
                            break;
                     case 0x0409:
                     case 0x040C:
                            {
                                   uint thdummy, thsize;
                                   s >> thdummy;
                                   s >> thdummy;
                                   s >> thdummy;
                                   s >> thdummy;
                                   s >> thdummy;
                                   s >> thsize;
                                   s >> thdummy;
                                   char* buffer = (char*)malloc(thsize);
                                   s.readRawBytes(buffer, thsize);
                                   QImage imth;
                                   imth.loadFromData((const uchar*)buffer, thsize, "JPEG");
                                   imth.convertDepth(32);
                                   if (resID == 0x0409)
                                          m_imageInfoRecord.exifInfo.thumbnail = imth.swapRGB();
                                   else
                                          m_imageInfoRecord.exifInfo.thumbnail = imth;
                                   m_imageInfoRecord.exifInfo.width = imth.width();
                                   m_imageInfoRecord.exifInfo.height = imth.height();
                                   m_imageInfoRecord.exifDataValid = true;
                                   free(buffer);
                            }
                     default:
                            break;
                     }
              }
              if (resBase + resSize <= size) {
                     s.device()->at( resBase + resSize );
                     offset += resSize;
              }
              if (resSize & 1)
              {
                     s >> filler;
                     offset += 1;
              }
       }
       if(offset<size)
              s.device()->at( size );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ScImgDataLoader_PDF::preloadAlphaChannel ( const QString &  fn,
int  res 
) [virtual]

Implements ScImgDataLoader.

Definition at line 80 of file scimgdataloader_pdf.cpp.

{
       float xres, yres;
//     short resolutionunit = 0;
       initialize();
       QFileInfo fi = QFileInfo(fn);
       if (!fi.exists())
              return;
       QString tmp, BBox;
       QString ext = fi.extension(false).lower();
       QString tmpFile = QDir::convertSeparators(ScPaths::getTempFileDir() + "sc.png");
       QString picFile = QDir::convertSeparators(fn);
       QStringList args;
       xres = gsRes;
       yres = gsRes;
       args.append("-r"+QString::number(gsRes));
//     args.append("-sOutputFile=\""+tmpFile + "\"");
       args.append("-sOutputFile="+tmpFile);
       args.append("-dFirstPage=1");
       args.append("-dLastPage=1");
//     args.append("\""+picFile+"\"");
       args.append(picFile);
       int retg = callGS(args);
       if (retg == 0)
       {
              m_image.load(tmpFile);
              unlink(tmpFile);
              m_image.setAlphaBuffer(true);
              if (ScCore->havePNGAlpha() != 0)
              {
                     QRgb *s;
                     for( int yi=0; yi < m_image.height(); ++yi )
                     {
                            s = (QRgb*)(m_image.scanLine( yi ));
                            for(int xi=0; xi < m_image.width(); ++xi )
                            {
                                   if((*s) == 0xffffffff)
                                          (*s) &= 0x00ffffff;
                                   s++;
                            }
                     }
              }
       }
}

Here is the call graph for this function:

void ScImgDataLoader::setRequest ( bool  valid,
QMap< int, ImageLoadRequest req 
) [inherited]

Definition at line 24 of file scimgdataloader.cpp.

const QStringList& ScImgDataLoader::supportedFormats ( void  ) const [inline, inherited]

Definition at line 48 of file scimgdataloader.h.

{ return m_supportedFormats; }
bool ScImgDataLoader::supportFormat ( const QString &  fmt) [inherited]

Definition at line 30 of file scimgdataloader.cpp.

{
       QString format = fmt.lower();
       return (m_supportedFormats.contains(format));
}
void ScImgDataLoader::swapRGBA ( void  ) [protected, inherited]

Definition at line 57 of file scimgdataloader.cpp.

{
       for (int i = 0; i < m_image.height(); ++i)
       {
              unsigned int *ptr = (unsigned int *) m_image.scanLine(i);
              unsigned char r, b;
              for (int j = 0; j < m_image.width(); ++j)
              {
                     unsigned char *p = (unsigned char *) ptr;
                     r = p[0];
                     b = p[2];
                     p[2] = r;
                     p[0] = b;
                     ptr++;
              }
       }
}
void ScImgDataLoader::swapRGBA ( QImage *  img) [protected, inherited]

Definition at line 75 of file scimgdataloader.cpp.

{
       for (int i = 0; i < img->height(); ++i)
       {
              unsigned int *ptr = (unsigned int *) img->scanLine(i);
              unsigned char r, b;
              for (int j = 0; j < img->width(); ++j)
              {
                     unsigned char *p = (unsigned char *) ptr;
                     r = p[0];
                     b = p[2];
                     p[2] = r;
                     p[0] = b;
                     ptr++;
              }
       }
}

Member Data Documentation

QByteArray ScImgDataLoader::m_embeddedProfile [protected, inherited]

Definition at line 28 of file scimgdataloader.h.

QImage ScImgDataLoader::m_image [protected, inherited]

Definition at line 26 of file scimgdataloader.h.

Definition at line 27 of file scimgdataloader.h.

QString ScImgDataLoader::m_message [protected, inherited]

Definition at line 37 of file scimgdataloader.h.

MsgType ScImgDataLoader::m_msgType [protected, inherited]

Definition at line 36 of file scimgdataloader.h.

int ScImgDataLoader::m_profileComponents [protected, inherited]

Definition at line 29 of file scimgdataloader.h.

QStringList ScImgDataLoader::m_supportedFormats [protected, inherited]

Definition at line 24 of file scimgdataloader.h.

RawImage ScImgDataLoader::r_image [inherited]

Definition at line 52 of file scimgdataloader.h.


The documentation for this class was generated from the following files: