Back to index

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

#include <scimgdataloader_jpeg.h>

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

List of all members.

Public Member Functions

 ScImgDataLoader_JPEG (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 ()
bool marker_is_icc (jpeg_saved_marker_ptr marker)
bool marker_is_photoshop (jpeg_saved_marker_ptr marker)
bool read_jpeg_marker (UINT8 requestmarker, j_decompress_ptr cinfo, JOCTET **icc_data_ptr, unsigned int *icc_data_len)
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 26 of file scimgdataloader_jpeg.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 37 of file scimgdataloader_jpeg.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_JPEG::initSupportedFormatList ( void  ) [protected]

Definition at line 42 of file scimgdataloader_jpeg.cpp.

{
       m_supportedFormats.clear();
       m_supportedFormats.append( "jpg" );
       m_supportedFormats.append( "jpeg" );
}

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_JPEG::loadEmbeddedProfile ( const QString &  fn) [virtual]

Implements ScImgDataLoader.

Definition at line 49 of file scimgdataloader_jpeg.cpp.

{
       m_embeddedProfile.resize(0);
       m_profileComponents = 0;
       if (!QFile::exists(fn))
              return;
       struct jpeg_decompress_struct cinfo;
       struct my_error_mgr         jerr;
       FILE     *infile;
       cinfo.err = jpeg_std_error (&jerr.pub);
       jerr.pub.error_exit = my_error_exit;
       infile = NULL;
       if (setjmp (jerr.setjmp_buffer))
       {
              jpeg_destroy_decompress (&cinfo);
              if (infile)
                     fclose (infile);
              return;
       }
       jpeg_create_decompress (&cinfo);
       if ((infile = fopen (fn.local8Bit(), "rb")) == NULL)
              return;
       jpeg_stdio_src(&cinfo, infile);
       jpeg_save_markers(&cinfo, ICC_MARKER, 0xFFFF);
       jpeg_read_header(&cinfo, true);
       //jpeg_start_decompress(&cinfo);
       unsigned int EmbedLen = 0;
       unsigned char* EmbedBuffer;
       if (read_jpeg_marker(ICC_MARKER,&cinfo, &EmbedBuffer, &EmbedLen))
       {
              cmsHPROFILE prof = cmsOpenProfileFromMem(EmbedBuffer, EmbedLen);
              if (prof)
              {
                     if (static_cast<int>(cmsGetColorSpace(prof)) == icSigRgbData)
                            m_profileComponents = 3;
                     if (static_cast<int>(cmsGetColorSpace(prof)) == icSigCmykData)
                            m_profileComponents = 4;
                     m_embeddedProfile.duplicate((const char*) EmbedBuffer, EmbedLen);
              }
              cmsCloseProfile(prof);
              free(EmbedBuffer);
       }
       //(void) jpeg_finish_decompress(&cinfo);
       fclose (infile);
       jpeg_destroy_decompress (&cinfo);
}

Here is the call graph for this function:

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

Implements ScImgDataLoader.

Definition at line 102 of file scimgdataloader_jpeg.cpp.

{
       bool isCMYK = false;
       bool fromPS = false;
       float xres = 72.0, yres = 72.0;
       if (!QFile::exists(fn))
              return false;
       ExifData ExifInf;
       struct jpeg_decompress_struct cinfo;
       struct my_error_mgr         jerr;
       FILE     *infile;
       cinfo.err = jpeg_std_error (&jerr.pub);
       jerr.pub.error_exit = my_error_exit;
       infile = NULL;

       initialize();
       m_imageInfoRecord.type = 0;
       m_imageInfoRecord.exifInfo.thumbnail = QImage();
       if (setjmp (jerr.setjmp_buffer))
       {
              jpeg_destroy_decompress (&cinfo);
              if (infile)
                     fclose (infile);
              return false;
       }
       jpeg_create_decompress (&cinfo);
       if ((infile = fopen (fn.local8Bit(), "rb")) == NULL)
              return false;
       jpeg_stdio_src(&cinfo, infile);
       jpeg_save_markers(&cinfo, ICC_MARKER, 0xFFFF);
       jpeg_save_markers(&cinfo, PHOTOSHOP_MARKER, 0xFFFF);
       jpeg_read_header(&cinfo, true);
       jpeg_start_decompress(&cinfo);
       bool exi = ExifInf.scan(fn);
       if ((exi) && (ExifInf.exifDataValid))
       {
              if (cinfo.output_components == 4)
                     m_imageInfoRecord.colorspace = 1;
              else if (cinfo.output_components == 3)
                     m_imageInfoRecord.colorspace = 0;
              else if (cinfo.output_components == 1)
                     m_imageInfoRecord.colorspace = 2;
              if ((!ExifInf.isNullThumbnail()) && thumbnail)
              {
                     m_image = ExifInf.getThumbnail();
                     m_imageInfoRecord.exifInfo.thumbnail = ExifInf.getThumbnail();
                     if (cinfo.output_components == 4)
                     {
                            QRgb *s;
                            unsigned char cc, cm, cy, ck;
                            for( int yit=0; yit < m_image.height(); ++yit )
                            {
                                   s = (QRgb*)(m_image.scanLine( yit ));
                                   for(int xit=0; xit < m_image.width(); ++xit )
                                   {
                                          cc = 255 - qRed(*s);
                                          cm = 255 - qGreen(*s);
                                          cy = 255 - qBlue(*s);
                                          ck = QMIN(QMIN(cc, cm), cy);
                                          *s = qRgba(cc-ck,cm-ck,cy-ck,ck);
                                          s++;
                                   }
                            }
                     }
              }
              else
                     m_imageInfoRecord.exifInfo.thumbnail = QImage();
              m_imageInfoRecord.exifInfo.cameraName = ExifInf.getCameraModel();
              m_imageInfoRecord.exifInfo.cameraVendor = ExifInf.getCameraMake();
              m_imageInfoRecord.exifInfo.comment = ExifInf.getComment();
              m_imageInfoRecord.exifInfo.width = ExifInf.getWidth();
              m_imageInfoRecord.exifInfo.height = ExifInf.getHeight();
              m_imageInfoRecord.exifInfo.userComment = ExifInf.getUserComment();
              m_imageInfoRecord.exifInfo.dateTime = ExifInf.getDateTime();
              m_imageInfoRecord.exifInfo.ApertureFNumber = ExifInf.getApertureFNumber();
              m_imageInfoRecord.exifInfo.ExposureTime = ExifInf.getExposureTime();
              m_imageInfoRecord.exifInfo.ISOequivalent = ExifInf.getISOequivalent();
              m_imageInfoRecord.exifDataValid = true;
              if (cinfo.density_unit == 0)
              {
                     xres = 72;
                     yres = 72;
              }
              else if ( cinfo.density_unit == 1 )
              {
                     xres = cinfo.X_density;
                     yres = cinfo.Y_density;
              }
              else if ( cinfo.density_unit == 2 )
              {
                     xres = cinfo.X_density * 2.54;
                     yres = cinfo.Y_density * 2.54;
              }
              if( xres <= 1.0 || yres <= 1.0 || xres > 3000.0 || yres > 3000.0 )
              {
                     xres = yres = 72.0;
                     QFileInfo qfi(fn);
                     m_message = QObject::tr("%1 may be corrupted : missing or wrong resolution tags").arg(qfi.fileName());
                     m_msgType = warningMsg;
              }
              m_imageInfoRecord.xres = qRound(xres);
              m_imageInfoRecord.yres = qRound(yres);
              m_imageInfoRecord.progressive = jpeg_has_multiple_scans(&cinfo);
              if ((!ExifInf.isNullThumbnail()) && thumbnail)
              {
                     jpeg_destroy_decompress(&cinfo);
                     fclose(infile);
                     return true;
              }
       }
       else
              m_imageInfoRecord.exifDataValid = false;
       m_imageInfoRecord.exifInfo.thumbnail = QImage();
       unsigned int EmbedLen = 0;
       unsigned char* EmbedBuffer;
       if (read_jpeg_marker(ICC_MARKER,&cinfo, &EmbedBuffer, &EmbedLen))
       {
              const char *Descriptor;
              cmsHPROFILE prof = cmsOpenProfileFromMem(EmbedBuffer, EmbedLen);
              Descriptor = cmsTakeProductDesc(prof);
              m_embeddedProfile.duplicate((const char*) EmbedBuffer, EmbedLen);
              m_imageInfoRecord.profileName = QString(Descriptor);
              m_imageInfoRecord.isEmbedded = true;
              free(EmbedBuffer);
       }
       else
       {
              m_imageInfoRecord.isEmbedded = false;
              m_imageInfoRecord.profileName = "";
       }
       unsigned int PhotoshopLen = 0;
       unsigned char * PhotoshopBuffer;
       if (cinfo.density_unit == 0)
       {
              xres = 72;
              yres = 72;
              m_image.setDotsPerMeterX(2834);
              m_image.setDotsPerMeterY(2834);
       }
       else if ( cinfo.density_unit == 1 )
       {
              xres = cinfo.X_density;
              yres = cinfo.Y_density;
              m_image.setDotsPerMeterX( int(100. * cinfo.X_density / 2.54) );
              m_image.setDotsPerMeterY( int(100. * cinfo.Y_density / 2.54) );
       }
       else if ( cinfo.density_unit == 2 )
       {
              xres = cinfo.X_density * 2.54;
              yres = cinfo.Y_density * 2.54;
              m_image.setDotsPerMeterX( int(100. * cinfo.X_density) );
              m_image.setDotsPerMeterY( int(100. * cinfo.Y_density) );
       }
       if( xres <= 1.0 || yres <= 1.0 || xres > 3000.0 || yres > 3000.0 )
       {
              xres = yres = 72.0;
              m_image.setDotsPerMeterX(2834);
              m_image.setDotsPerMeterY(2834);
              QFileInfo qfi(fn);
              m_message = QObject::tr("%1 may be corrupted : missing or wrong resolution tags").arg(qfi.fileName());
              m_msgType = warningMsg;
       }
       m_imageInfoRecord.xres = qRound(xres);
       m_imageInfoRecord.yres = qRound(yres);
       if (cinfo.output_components == 4)
       {
              isCMYK = true;
              m_imageInfoRecord.colorspace = 1;
       }
       else if (cinfo.output_components == 3)
              m_imageInfoRecord.colorspace = 0;
       else if (cinfo.output_components == 1)
              m_imageInfoRecord.colorspace = 2;
       m_imageInfoRecord.progressive = jpeg_has_multiple_scans(&cinfo);

       if (read_jpeg_marker(PHOTOSHOP_MARKER,&cinfo, &PhotoshopBuffer, &PhotoshopLen) )
       {
              if (PhotoshopLen != 0)
              {
                     bool savEx = m_imageInfoRecord.exifDataValid;
                     QByteArray arrayPhot(PhotoshopLen);
                     arrayPhot.setRawData((const char*)PhotoshopBuffer,PhotoshopLen);
                     QDataStream strPhot(arrayPhot,IO_ReadOnly);
                     strPhot.setByteOrder( QDataStream::BigEndian );
                     PSDHeader fakeHeader;
                     fakeHeader.width = cinfo.output_width;
                     fakeHeader.height = cinfo.output_height;
                     if (cinfo.output_components == 4)
                            m_imageInfoRecord.colorspace = 1;
                     else if (cinfo.output_components == 3)
                            m_imageInfoRecord.colorspace = 0;
                     else if (cinfo.output_components == 1)
                            m_imageInfoRecord.colorspace = 2;
                     m_imageInfoRecord.progressive = jpeg_has_multiple_scans(&cinfo);
                     parseRessourceData(strPhot, fakeHeader, PhotoshopLen);
                     // Photoshop resolution is more accurate than jpeg header resolution
                     xres = m_imageInfoRecord.xres;
                     yres = m_imageInfoRecord.yres;
                     m_image.setDotsPerMeterX( int(100. * m_imageInfoRecord.xres / 2.54) );
                     m_image.setDotsPerMeterY( int(100. * m_imageInfoRecord.yres / 2.54) );
                     if( xres <= 1.0 || yres <= 1.0 || xres > 3000.0 || yres > 3000.0 )
                     {
                            xres = yres = 72.0;
                            m_imageInfoRecord.xres = qRound(xres);
                            m_imageInfoRecord.yres = qRound(yres);
                            m_image.setDotsPerMeterX(2834);
                            m_image.setDotsPerMeterY(2834);
                            QFileInfo qfi(fn);
                            m_message = QObject::tr("%1 may be corrupted : missing or wrong resolution tags").arg(qfi.fileName());
                            m_msgType = warningMsg;
                     }
                     if (m_imageInfoRecord.exifDataValid && thumbnail)
                     {
                            m_image.create(m_imageInfoRecord.exifInfo.width, m_imageInfoRecord.exifInfo.height, 32 );
                            m_imageInfoRecord.exifInfo.width = cinfo.output_width;
                            m_imageInfoRecord.exifInfo.height = cinfo.output_height;
                            if (cinfo.output_components == 4)
                            {
                                   m_image.setAlphaBuffer(false);
                                   QRgb *d;
                                   QRgb *s;
                                   unsigned char cc, cm, cy, ck;
                                   for( int yit=0; yit < m_image.height(); ++yit )
                                   {
                                          d = (QRgb*)(m_image.scanLine( yit ));
                                          s = (QRgb*)(m_imageInfoRecord.exifInfo.thumbnail.scanLine( yit ));
                                          for(int xit=0; xit < m_image.width(); ++xit )
                                          {
                                                 cc = 255 - qRed(*s);
                                                 cm = 255 - qGreen(*s);
                                                 cy = 255 - qBlue(*s);
                                                 ck = QMIN(QMIN(cc, cm), cy);
                                                 *d = qRgba(cc-ck,cm-ck,cy-ck,ck);
                                                 s++;
                                                 d++;
                                          }
                                   }
                            }
                            else
                                   m_image = m_imageInfoRecord.exifInfo.thumbnail.copy();
                     }
                     m_imageInfoRecord.valid = (m_imageInfoRecord.PDSpathData.size())>0?true:false; // The only interest is vectormask
                     arrayPhot.resetRawData((const char*)PhotoshopBuffer,PhotoshopLen);
                     free( PhotoshopBuffer );
                     if (m_imageInfoRecord.exifDataValid && thumbnail)
                     {
                            jpeg_destroy_decompress(&cinfo);
                            fclose(infile);
                            return true;
                     }
                     m_imageInfoRecord.exifInfo.thumbnail = QImage();
                     m_imageInfoRecord.exifDataValid = savEx;
                     fromPS = true;
              }
       }
       if ( cinfo.output_components == 3 || cinfo.output_components == 4)
              m_image.create( cinfo.output_width, cinfo.output_height, 32 );
       else if ( cinfo.output_components == 1 )
       {
              m_image.create( cinfo.output_width, cinfo.output_height, 8, 256 );
              for (int i=0; i<256; i++)
                     m_image.setColor(i, qRgb(i,i,i));
       }
       if (!m_image.isNull())
       {
              uchar** lines = m_image.jumpTable();
              while (cinfo.output_scanline < cinfo.output_height)
                     (void) jpeg_read_scanlines(&cinfo, lines + cinfo.output_scanline, cinfo.output_height);
              if ( cinfo.output_components == 3 )
              {
                     uchar *in;
                     QRgb *out;
                     for (uint j=0; j<cinfo.output_height; j++)
                     {
                            in = m_image.scanLine(j) + cinfo.output_width * 3;
                            out = (QRgb*) m_image.scanLine(j);
                            for (uint i=cinfo.output_width; i--; )
                            {
                                   in -= 3;
                                   out[i] = qRgb(in[0], in[1], in[2]);
                            }
                     }
              }
              if ( cinfo.output_components == 4 )
              {
                     int method = 0;
                     if (cinfo.jpeg_color_space == JCS_YCCK)
                            method = 1;
                     else if (fromPS)
                     {
                            if ((cinfo.jpeg_color_space == JCS_CMYK) && (cinfo.saw_Adobe_marker) && (cinfo.Adobe_transform == 0))
                                   method = 2;
                     }
                     else if ((cinfo.jpeg_color_space == JCS_CMYK) && (cinfo.saw_Adobe_marker))
                            method = 1;
                     QRgb *ptr;
                     unsigned char c, m, y ,k;
                     unsigned char *p;
                     for (int i = 0; i < m_image.height(); i++)
                     {
                            ptr = (QRgb*)  m_image.scanLine(i);
                            if (method == 1)
                            {
                                   for (int j = 0; j <  m_image.width(); j++)
                                   {
                                          p = (unsigned char *) ptr;
                                          c = p[0];
                                          m = p[1];
                                          y =  p[2];
                                          k =  p[3];
                                          *ptr = qRgba(255 - c, 255 - m, 255 - y, 255 - k);
                                          ptr++;
                                   }
                            }
                            else if (method == 2)
                            {
                                   for (int j = 0; j <  m_image.width(); j++)
                                   {
                                          p = (unsigned char *) ptr;
                                          c = p[0];
                                          m = p[1];
                                          y =  p[2];
                                          k =  p[3];
                                          *ptr = qRgba(255 - c, 255 - m, 255 - y, k);
                                          ptr++;
                                   }
                            }
                            else
                            {
                                   for (int j = 0; j <  m_image.width(); j++)
                                   {
                                          p = (unsigned char *) ptr;
                                          c = p[0];
                                          m = p[1];
                                          y =  p[2];
                                          k =  p[3];
                                          *ptr = qRgba(y, m, c, k);
                                          ptr++;
                                   }
                            }
                     }
                     isCMYK = true;
              }
              else
                     isCMYK = false;
              if ( cinfo.output_components == 1 )
              {
                     QImage tmpImg = m_image.convertDepth(32);
                     m_image.create( cinfo.output_width, cinfo.output_height, 32 );
                     QRgb *s;
                     QRgb *d;
                     for( int yi=0; yi < tmpImg.height(); ++yi )
                     {
                            s = (QRgb*)(tmpImg.scanLine( yi ));
                            d = (QRgb*)(m_image.scanLine( yi ));
                            for(int xi=0; xi < tmpImg.width(); ++xi )
                            {
                                   (*d) = (*s);
                                   s++;
                                   d++;
                            }
                     }
              }
              m_image.setAlphaBuffer(true);
       }
       (void) jpeg_finish_decompress(&cinfo);
       fclose (infile);
       jpeg_destroy_decompress (&cinfo);
       m_imageInfoRecord.layerInfo.clear();
       m_imageInfoRecord.BBoxX = 0;
       m_imageInfoRecord.BBoxH = m_image.height();
       return (!m_image.isNull());
}

Here is the call graph for this function:

bool ScImgDataLoader_JPEG::marker_is_icc ( jpeg_saved_marker_ptr  marker) [protected]

Definition at line 476 of file scimgdataloader_jpeg.cpp.

{
       return
           marker->marker == ICC_MARKER &&
           marker->data_length >= ICC_OVERHEAD_LEN &&
           /* verify the identifying string */
           GETJOCTET(marker->data[0]) == 0x49 &&
           GETJOCTET(marker->data[1]) == 0x43 &&
           GETJOCTET(marker->data[2]) == 0x43 &&
           GETJOCTET(marker->data[3]) == 0x5F &&
           GETJOCTET(marker->data[4]) == 0x50 &&
           GETJOCTET(marker->data[5]) == 0x52 &&
           GETJOCTET(marker->data[6]) == 0x4F &&
           GETJOCTET(marker->data[7]) == 0x46 &&
           GETJOCTET(marker->data[8]) == 0x49 &&
           GETJOCTET(marker->data[9]) == 0x4C &&
           GETJOCTET(marker->data[10]) == 0x45 &&
           GETJOCTET(marker->data[11]) == 0x0;
}

Here is the caller graph for this function:

bool ScImgDataLoader_JPEG::marker_is_photoshop ( jpeg_saved_marker_ptr  marker) [protected]

Definition at line 496 of file scimgdataloader_jpeg.cpp.

{
       return
           marker->marker == PHOTOSHOP_MARKER &&
           marker->data_length >= ICC_OVERHEAD_LEN &&
           /* verify the identifying string */
           GETJOCTET(marker->data[0]) == 0x50 &&
           GETJOCTET(marker->data[1]) == 0x68 &&
           GETJOCTET(marker->data[2]) == 0x6F &&
           GETJOCTET(marker->data[3]) == 0x74 &&
           GETJOCTET(marker->data[4]) == 0x6F &&
           GETJOCTET(marker->data[5]) == 0x73 &&
           GETJOCTET(marker->data[6]) == 0x68 &&
           GETJOCTET(marker->data[7]) == 0x6F &&
           GETJOCTET(marker->data[8]) == 0x70 &&
           GETJOCTET(marker->data[9]) == 0x20 &&
           GETJOCTET(marker->data[10]) == 0x33 &&
           GETJOCTET(marker->data[11]) == 0x2E &&
           GETJOCTET(marker->data[12]) == 0x30 &&
           GETJOCTET(marker->data[13]) == 0x0;
}

Here is the caller 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_JPEG::preloadAlphaChannel ( const QString &  fn,
int  res 
) [virtual]

Implements ScImgDataLoader.

Definition at line 96 of file scimgdataloader_jpeg.cpp.

{
       // No support for aplha in jpeg pictures
       initialize();
}

Here is the call graph for this function:

bool ScImgDataLoader_JPEG::read_jpeg_marker ( UINT8  requestmarker,
j_decompress_ptr  cinfo,
JOCTET **  icc_data_ptr,
unsigned int icc_data_len 
) [protected]

Definition at line 521 of file scimgdataloader_jpeg.cpp.

{
       jpeg_saved_marker_ptr marker;
       int num_markers = 0;
       int seq_no;
       JOCTET *icc_data;
       unsigned int total_length;
#define MAX_SEQ_NO  255            /* sufficient since marker numbers are bytes */
       char marker_present[MAX_SEQ_NO+1];   /* 1 if marker found */
       unsigned int data_length[MAX_SEQ_NO+1]; /* size of profile data in marker */
       unsigned int data_offset[MAX_SEQ_NO+1]; /* offset for data in marker */

       *icc_data_ptr = NULL;              /* avoid confusion if false return */
       *icc_data_len = 0;

       /* This first pass over the saved markers discovers whether there are
        * any ICC markers and verifies the consistency of the marker numbering.
        */

       for (seq_no = 1; seq_no <= MAX_SEQ_NO; seq_no++)
              marker_present[seq_no] = 0;
       seq_no = 0;
       for (marker = cinfo->marker_list; marker != NULL; marker = marker->next)
       {
              if (requestmarker == ICC_MARKER && marker_is_icc(marker))
              {
                     if (num_markers == 0)
                            num_markers = GETJOCTET(marker->data[13]);
                     else if (num_markers != GETJOCTET(marker->data[13]))
                            return false;        /* inconsistent num_markers fields */
                     seq_no = GETJOCTET(marker->data[12]);
                     if (seq_no <= 0 || seq_no > num_markers)
                            return false;        /* bogus sequence number */
                     if (marker_present[seq_no])
                            return false;        /* duplicate sequence numbers */
                     marker_present[seq_no] = 1;
                     data_length[seq_no] = marker->data_length - ICC_OVERHEAD_LEN;
              }
              else if(requestmarker == PHOTOSHOP_MARKER && marker_is_photoshop(marker))
              {
                     num_markers = ++seq_no;
                     marker_present[seq_no] = 1;
                     data_length[seq_no] = marker->data_length - ICC_OVERHEAD_LEN;
              }
       }

       if (num_markers == 0)
              return false;

       /* Check for missing markers, count total space needed,
        * compute offset of each marker's part of the data.
        */

       total_length = 0;
       for (seq_no = 1; seq_no <= num_markers; seq_no++)
       {
              if (marker_present[seq_no] == 0)
                     return false;        /* missing sequence number */
              data_offset[seq_no] = total_length;
              total_length += data_length[seq_no];
       }

       if (total_length <= 0)
              return false;        /* found only empty markers? */

       /* Allocate space for assembled data */
       icc_data = (JOCTET *) malloc(total_length * sizeof(JOCTET));
       if (icc_data == NULL)
              return false;        /* oops, out of memory */
       seq_no=0;
       /* and fill it in */
       for (marker = cinfo->marker_list; marker != NULL; marker = marker->next)
       {
              if ( (requestmarker == ICC_MARKER && marker_is_icc(marker)) ||
                      (requestmarker == PHOTOSHOP_MARKER && marker_is_photoshop(marker)) || (requestmarker == 0xE1))
              {
                     JOCTET FAR *src_ptr;
                     JOCTET *dst_ptr;
                     unsigned int length;
                     if(requestmarker == ICC_MARKER)
                            seq_no = GETJOCTET(marker->data[12]);
                     else if(requestmarker == PHOTOSHOP_MARKER)
                            seq_no++;
                     dst_ptr = icc_data + data_offset[seq_no];
                     src_ptr = marker->data + ICC_OVERHEAD_LEN;
                     length = data_length[seq_no];
                     while (length--)
                     {
                            *dst_ptr++ = *src_ptr++;
                     }
              }
       }

       *icc_data_ptr = icc_data;
       *icc_data_len = total_length;

       return true;
}

Here is the call graph for this function:

Here is the caller 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: