[Scummvm-cvs-logs] SF.net SVN: scummvm:[53756] scummvm/trunk/engines/sword25/gfx/image
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Sun Oct 24 03:32:53 CEST 2010
Revision: 53756
http://scummvm.svn.sourceforge.net/scummvm/?rev=53756&view=rev
Author: fingolfin
Date: 2010-10-24 01:32:52 +0000 (Sun, 24 Oct 2010)
Log Message:
-----------
SWORD25: Get rid of colorFormat parameter in PNGLoader API
Only CF_ARGB32 was supported anyway.
Modified Paths:
--------------
scummvm/trunk/engines/sword25/gfx/image/pngloader.cpp
scummvm/trunk/engines/sword25/gfx/image/pngloader.h
scummvm/trunk/engines/sword25/gfx/image/renderedimage.cpp
scummvm/trunk/engines/sword25/gfx/image/swimage.cpp
Modified: scummvm/trunk/engines/sword25/gfx/image/pngloader.cpp
===================================================================
--- scummvm/trunk/engines/sword25/gfx/image/pngloader.cpp 2010-10-24 01:32:15 UTC (rev 53755)
+++ scummvm/trunk/engines/sword25/gfx/image/pngloader.cpp 2010-10-24 01:32:52 UTC (rev 53756)
@@ -92,7 +92,12 @@
*ref += length;
}
-bool PNGLoader::doDecodeImage(const byte *fileDataPtr, uint fileSize, GraphicEngine::COLOR_FORMATS colorFormat, byte *&uncompressedDataPtr, int &width, int &height, int &pitch) {
+static bool doIsCorrectImageFormat(const byte *fileDataPtr, uint fileSize) {
+ return (fileSize > 8) && png_check_sig(const_cast<byte *>(fileDataPtr), 8);
+}
+
+
+bool PNGLoader::doDecodeImage(const byte *fileDataPtr, uint fileSize, byte *&uncompressedDataPtr, int &width, int &height, int &pitch) {
png_structp png_ptr = NULL;
png_infop info_ptr = NULL;
png_bytep rawDataBuffer = NULL;
@@ -103,13 +108,7 @@
int interlaceType;
int i;
- // Zielfarbformat \xFCberpr\xFCfen
- if (colorFormat != GraphicEngine::CF_ARGB32) {
- BS_LOG_ERRORLN("Illegal or unsupported color format.");
- return false;
- }
-
- // PNG Signatur \xFCberpr\xFCfen
+ // Check for valid PNG signature
if (!doIsCorrectImageFormat(fileDataPtr, fileSize)) {
error("png_check_sig failed");
}
@@ -136,7 +135,7 @@
png_get_IHDR(png_ptr, info_ptr, (png_uint_32 *)&width, (png_uint_32 *)&height, &bitDepth, &colorType, &interlaceType, NULL, NULL);
// Pitch des Ausgabebildes berechnen
- pitch = GraphicEngine::calcPitch(colorFormat, width);
+ pitch = GraphicEngine::calcPitch(GraphicEngine::CF_ARGB32, width);
// Speicher f\xFCr die endg\xFCltigen Bilddaten reservieren
// Dieses geschieht vor dem reservieren von Speicher f\xFCr tempor\xE4re Bilddaten um die Fragmentierung des Speichers gering zu halten
@@ -181,13 +180,7 @@
png_read_row(png_ptr, rawDataBuffer, NULL);
// Zeile konvertieren
- switch (colorFormat) {
- case GraphicEngine::CF_ARGB32:
- memcpy(&uncompressedDataPtr[i * pitch], rawDataBuffer, pitch);
- break;
- default:
- assert(0);
- }
+ memcpy(&uncompressedDataPtr[i * pitch], rawDataBuffer, pitch);
}
} else {
// PNGs mit Interlacing werden an einem St\xFCck eingelesen
@@ -211,15 +204,8 @@
png_read_image(png_ptr, pRowPtr);
// Bilddaten zeilenweise in das gew\xFCnschte Ausgabeformat konvertieren
- switch (colorFormat) {
- case GraphicEngine::CF_ARGB32:
- for (i = 0; i < height; i++)
- memcpy(&uncompressedDataPtr[i * pitch], &rawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)], pitch);
- break;
- default:
- error("Unhandled case in DoDecodeImage");
- break;
- }
+ for (i = 0; i < height; i++)
+ memcpy(&uncompressedDataPtr[i * pitch], &rawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)], pitch);
}
// Die zus\xE4tzlichen Daten am Ende des Bildes lesen
@@ -236,13 +222,13 @@
return true;
}
-bool PNGLoader::decodeImage(const byte *fileDataPtr, uint fileSize, GraphicEngine::COLOR_FORMATS colorFormat, byte *&uncompressedDataPtr, int &width, int &height, int &pitch) {
+bool PNGLoader::decodeImage(const byte *fileDataPtr, uint fileSize, byte *&uncompressedDataPtr, int &width, int &height, int &pitch) {
uint pngOffset = findEmbeddedPNG(fileDataPtr, fileSize);
- return doDecodeImage(fileDataPtr + pngOffset, fileSize - pngOffset, colorFormat, uncompressedDataPtr, width, height, pitch);
+ return doDecodeImage(fileDataPtr + pngOffset, fileSize - pngOffset, uncompressedDataPtr, width, height, pitch);
}
-bool PNGLoader::doImageProperties(const byte *fileDataPtr, uint fileSize, GraphicEngine::COLOR_FORMATS &colorFormat, int &width, int &height) {
- // PNG Signatur \xFCberpr\xFCfen
+bool PNGLoader::doImageProperties(const byte *fileDataPtr, uint fileSize, int &width, int &height) {
+ // Check for valid PNG signature
if (!doIsCorrectImageFormat(fileDataPtr, fileSize))
return false;
@@ -272,12 +258,6 @@
int colorType;
png_get_IHDR(png_ptr, info_ptr, (png_uint_32 *)&width, (png_uint_32 *)&height, &bitDepth, &colorType, NULL, NULL, NULL);
- // PNG-ColorType in BS ColorFormat konvertieren.
- if (colorType & PNG_COLOR_MASK_ALPHA || png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
- colorFormat = GraphicEngine::CF_ARGB32;
- else
- colorFormat = GraphicEngine::CF_RGB24;
-
// Die Strukturen freigeben
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
@@ -285,18 +265,10 @@
}
-bool PNGLoader::imageProperties(const byte *fileDataPtr, uint fileSize, GraphicEngine::COLOR_FORMATS &colorFormat, int &width, int &height) {
+bool PNGLoader::imageProperties(const byte *fileDataPtr, uint fileSize, int &width, int &height) {
uint pngOffset = findEmbeddedPNG(fileDataPtr, fileSize);
- return doImageProperties(fileDataPtr + pngOffset, fileSize - pngOffset, colorFormat, width, height);
+ return doImageProperties(fileDataPtr + pngOffset, fileSize - pngOffset, width, height);
}
-bool PNGLoader::doIsCorrectImageFormat(const byte *fileDataPtr, uint fileSize) {
- return (fileSize > 8) && png_check_sig(const_cast<byte *>(fileDataPtr), 8);
-}
-bool PNGLoader::isCorrectImageFormat(const byte *fileDataPtr, uint fileSize) {
- uint pngOffset = findEmbeddedPNG(fileDataPtr, fileSize);
- return doIsCorrectImageFormat(fileDataPtr + pngOffset, fileSize - pngOffset);
-}
-
} // End of namespace Sword25
Modified: scummvm/trunk/engines/sword25/gfx/image/pngloader.h
===================================================================
--- scummvm/trunk/engines/sword25/gfx/image/pngloader.h 2010-10-24 01:32:15 UTC (rev 53755)
+++ scummvm/trunk/engines/sword25/gfx/image/pngloader.h 2010-10-24 01:32:52 UTC (rev 53756)
@@ -49,18 +49,15 @@
protected:
PNGLoader() {} // Protected constructor to prevent instances
- static bool doIsCorrectImageFormat(const byte *fileDataPtr, uint fileSize);
- static bool doDecodeImage(const byte *fileDataPtr, uint fileSize, GraphicEngine::COLOR_FORMATS colorFormat, byte *&uncompressedDataPtr, int &width, int &height, int &pitch);
- static bool doImageProperties(const byte *fileDataPtr, uint fileSize, GraphicEngine::COLOR_FORMATS &colorFormat, int &width, int &height);
+ static bool doDecodeImage(const byte *fileDataPtr, uint fileSize, byte *&uncompressedDataPtr, int &width, int &height, int &pitch);
+ static bool doImageProperties(const byte *fileDataPtr, uint fileSize, int &width, int &height);
public:
- static bool isCorrectImageFormat(const byte *fileDataPtr, uint fileSize);
/**
* Decode an image.
* @param[in] fileDatePtr pointer to the image data
* @param[in] fileSize size of the image data in bytes
- * @param[in] colorFormat the color format to which the the data should be decoded
* @param[out] pUncompressedData if successful, this is set to a pointer containing the decoded image data
* @param[out] width if successful, this is set to the width of the image
* @param[out] height if successful, this is set to the height of the image
@@ -72,15 +69,13 @@
* it is the callers responsibility to do so.
*/
static bool decodeImage(const byte *pFileData, uint fileSize,
- GraphicEngine::COLOR_FORMATS colorFormat,
- byte *&pUncompressedData,
- int &width, int &height,
- int &pitch);
+ byte *&pUncompressedData,
+ int &width, int &height,
+ int &pitch);
/**
* Extract the properties of an image.
* @param[in] fileDatePtr pointer to the image data
* @param[in] fileSize size of the image data in bytes
- * @param[out] colorFormat if successful, this is set to the color format of the image
* @param[out] width if successful, this is set to the width of the image
* @param[out] height if successful, this is set to the height of the image
* @return returns true if extraction of the properties was successful, false in case of an error
@@ -88,9 +83,7 @@
* @remark This function does not free the image buffer passed to it,
* it is the callers responsibility to do so.
*/
- static bool imageProperties(const byte *fileDatePtr,
- uint fileSize,
- GraphicEngine::COLOR_FORMATS &colorFormat,
+ static bool imageProperties(const byte *fileDatePtr, uint fileSize,
int &width,
int &height);
};
Modified: scummvm/trunk/engines/sword25/gfx/image/renderedimage.cpp
===================================================================
--- scummvm/trunk/engines/sword25/gfx/image/renderedimage.cpp 2010-10-24 01:32:15 UTC (rev 53755)
+++ scummvm/trunk/engines/sword25/gfx/image/renderedimage.cpp 2010-10-24 01:32:52 UTC (rev 53756)
@@ -70,16 +70,15 @@
}
// Bildeigenschaften bestimmen
- GraphicEngine::COLOR_FORMATS colorFormat;
int pitch;
- if (!PNGLoader::imageProperties(pFileData, fileSize, colorFormat, _width, _height)) {
+ if (!PNGLoader::imageProperties(pFileData, fileSize, _width, _height)) {
BS_LOG_ERRORLN("Could not read image properties.");
delete[] pFileData;
return;
}
// Das Bild dekomprimieren
- if (!PNGLoader::decodeImage(pFileData, fileSize, GraphicEngine::CF_ARGB32, _data, _width, _height, pitch)) {
+ if (!PNGLoader::decodeImage(pFileData, fileSize, _data, _width, _height, pitch)) {
BS_LOG_ERRORLN("Could not decode image.");
delete[] pFileData;
return;
Modified: scummvm/trunk/engines/sword25/gfx/image/swimage.cpp
===================================================================
--- scummvm/trunk/engines/sword25/gfx/image/swimage.cpp 2010-10-24 01:32:15 UTC (rev 53755)
+++ scummvm/trunk/engines/sword25/gfx/image/swimage.cpp 2010-10-24 01:32:52 UTC (rev 53756)
@@ -59,16 +59,15 @@
}
// Bildeigenschaften bestimmen
- GraphicEngine::COLOR_FORMATS colorFormat;
int pitch;
- if (!PNGLoader::imageProperties(pFileData, fileSize, colorFormat, _width, _height)) {
+ if (!PNGLoader::imageProperties(pFileData, fileSize, _width, _height)) {
BS_LOG_ERRORLN("Could not read image properties.");
return;
}
// Das Bild dekomprimieren
byte *pUncompressedData;
- if (!PNGLoader::decodeImage(pFileData, fileSize, GraphicEngine::CF_ARGB32, pUncompressedData, _width, _height, pitch)) {
+ if (!PNGLoader::decodeImage(pFileData, fileSize, pUncompressedData, _width, _height, pitch)) {
BS_LOG_ERRORLN("Could not decode image.");
return;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list