r18164 by fschmid - Adapt last changes of the .pict file importer to the scimageloader for .pict files.

scribus-commit scribus-commit at lists.scribus.net
Tue Feb 26 20:24:01 UTC 2013


Author: fschmid
Date: Tue Feb 26 20:24:00 2013
New Revision: 18164

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18164
Log:
Adapt last changes of the .pict file importer to the scimageloader for .pict files.

Modified:
    trunk/Scribus/scribus/scimgdataloader_pict.cpp
    trunk/Scribus/scribus/scimgdataloader_pict.h
    trunk/Scribus/scribus/util_formats.h

Modified: trunk/Scribus/scribus/scimgdataloader_pict.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18164&path=/trunk/Scribus/scribus/scimgdataloader_pict.cpp
==============================================================================
--- trunk/Scribus/scribus/scimgdataloader_pict.cpp (original)
+++ trunk/Scribus/scribus/scimgdataloader_pict.cpp Tue Feb 26 20:24:00 2013
@@ -69,22 +69,89 @@
 	m_profileComponents = 0;
 }
 
+void ScImgDataLoader_PICT::parseHeader(QString fName, double &x, double &y, double &b, double &h)
+{
+	QFile f(fName);
+	if (f.open(QIODevice::ReadOnly))
+	{
+		QDataStream ts(&f);
+		ts.setByteOrder(QDataStream::BigEndian);
+		ts.device()->seek(512);
+		qint16 pgX, pgY, pgW, pgH, dummy;
+		ts >> dummy >> pgX >> pgY >> pgW >> pgH;
+		quint16 vers, vers2, vers3;
+		ts >> vers;
+		if (vers == 0x1101)
+		{
+			pctVersion = 1;
+			h = pgW - pgX;
+			b = pgH - pgY;
+			x = pgY;
+			y = pgX;
+			resX = 72.0;
+			resY = 72.0;
+		}
+		else if (vers == 0x0011)
+		{
+			ts >> vers2 >> vers3;
+			if ((vers2 == 0x02FF) && (vers3 == 0x0C00))
+			{
+				pctVersion = 2;
+				qint16 vExt;
+				ts >> vExt;
+				if (vExt == -1)
+				{
+					ts >> dummy;
+					quint32 xres, yres;
+					xres = 72;
+					yres = 72;
+					qint32 pgX2, pgY2, pgW2, pgH2;
+					ts >> pgX2 >> pgY2 >> pgW2 >> pgH2;
+					ts >> dummy;
+					ts >> dummy;
+					resX = 72.0;
+					resY = 72.0;
+					h = pgW - pgX;
+					b = pgH - pgY;
+					x = pgY;
+					y = pgX;
+				}
+				else if (vExt == -2)
+				{
+					ts >> dummy;
+					quint16 xres, yres;
+					ts >> xres >> dummy >> yres >> dummy;
+					ts >> pgX >> pgY >> pgW >> pgH;
+					ts >> dummy;
+					h = pgW - pgX;
+					b = pgH - pgY;
+					x = pgY;
+					y = pgX;
+					resX = xres;
+					resY = yres;
+				}
+			}
+		}
+		f.close();
+	}
+}
+
 bool ScImgDataLoader_PICT::loadPicture(const QString& fn, int /*page*/, int /*res*/, bool /*thumbnail*/)
 {
 	if (!QFile::exists(fn))
 		return false;
 	initialize();
+	double x, y, w, h;
+	parseHeader(fn, x, y, w, h);
+	docWidth = w;
+	docHeight = h;
+	baseX = -x;
+	baseY = -y;
 	QFile f(fn);
 	if (f.open(QIODevice::ReadOnly))
 	{
 		QDataStream ts(&f);
-		ts.device()->seek(512);
-		qint16 pgX, pgY, pgW, pgH, dummy;
-		ts >> dummy >> pgX >> pgY >> pgW >> pgH;
-		docWidth = pgH - pgY;
-		docHeight = pgW - pgX;
-		baseX = -pgY;
-		baseY = -pgX;
+		ts.device()->seek(522);
 		m_image = QImage(docWidth, docHeight, QImage::Format_ARGB32);
 		if (m_image.isNull())
 			return false;
@@ -136,8 +203,8 @@
 		imagePainter.end();
 		m_imageInfoRecord.type = ImageTypeOther;
 		m_imageInfoRecord.exifDataValid = false;
-		m_imageInfoRecord.xres = 72;
-		m_imageInfoRecord.yres = 72;
+		m_imageInfoRecord.xres = resX;
+		m_imageInfoRecord.yres = resY;
 		m_imageInfoRecord.BBoxX = 0;
 		m_imageInfoRecord.colorspace = ColorSpaceRGB;
 		m_imageInfoRecord.BBoxH = m_image.height();
@@ -1339,7 +1406,7 @@
 						*q++ = qRgba(r, g, b, 255);
 					}
 				}
-				else if (component_size == 8)
+				else if ((component_size == 8) || (component_size == 24))
 				{
 					QRgb *q = (QRgb*)(image.scanLine(rr));
 					for (uint xx = 0; xx < (uint) pixCols; xx++)
@@ -1377,7 +1444,7 @@
 		isPixmap = true;
 		imageData.resize(0);
 	}
-	if ((component_size == 8) || (component_size == 1) || (component_size == 5) || (component_size == 4) || (!isPixmap) || (skipOpcode))
+	if ((component_size == 24) || (component_size == 8) || (component_size == 1) || (component_size == 5) || (component_size == 4) || (!isPixmap) || (skipOpcode))
 	{
 		image = image.convertToFormat(QImage::Format_ARGB32);
 		if (!isPixmap)

Modified: trunk/Scribus/scribus/scimgdataloader_pict.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18164&path=/trunk/Scribus/scribus/scimgdataloader_pict.h
==============================================================================
--- trunk/Scribus/scribus/scimgdataloader_pict.h (original)
+++ trunk/Scribus/scribus/scimgdataloader_pict.h Tue Feb 26 20:24:00 2013
@@ -32,6 +32,7 @@
 	virtual bool loadPicture(const QString& fn, int page, int res, bool thumbnail);
 
 private:
+	void parseHeader(QString fName, double &x, double &y, double &b, double &h);
 	void parsePict(QDataStream &ts);
 	void alignStreamToWord(QDataStream &ts, uint len);
 	void handleColor(QDataStream &ts, bool back);
@@ -67,6 +68,7 @@
 	int baseX, baseY;
 	int docWidth;
 	int docHeight;
+	double resX, resY;
 
 	double LineW;
 	QColor backColor;

Modified: trunk/Scribus/scribus/util_formats.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18164&path=/trunk/Scribus/scribus/util_formats.h
==============================================================================
--- trunk/Scribus/scribus/util_formats.h (original)
+++ trunk/Scribus/scribus/util_formats.h Tue Feb 26 20:24:00 2013
@@ -41,7 +41,7 @@
 #ifdef GMAGICK_FOUND
 			IMAGESIMGFRAME	= 1|2|4|16|32|64|128|256|512|65536|1048576,  // all Types suitable for Image Frames
 #else
-			IMAGESIMGFRAME	= 1|2|4|16|32|64|128|256|512|524288|1048576,  // all Types suitable for Image Frames
+			IMAGESIMGFRAME	= 1|2|4|16|32|64|128|256|512|262144|524288|1048576,  // all Types suitable for Image Frames
 #endif
 			VECTORIMAGES	= 1|64|1024|2048|16384|32768|131072|262144,  // All pure vector image types
 			RASTORIMAGES	= 2|4|8|32|128|256|512|65536|524288|1048576,  // All pure rastor image types
@@ -67,7 +67,7 @@
 			UNICONV			= 131072, // UniConvertor
 			PCT				= 262144,  // Mac Pict
 			BMP				= 524288,  // BMP
-			PGF				= 1048576,  // PGF
+			PGF				= 1048576  // PGF
 		};
 	
 /*




More information about the scribus-commit mailing list