aboutsummaryrefslogtreecommitdiff
path: root/engines/sword25
diff options
context:
space:
mode:
authorMax Horn2010-10-24 01:32:52 +0000
committerMax Horn2010-10-24 01:32:52 +0000
commit4d6fb4e76819f7e5621685a32f4ff075e7b5674c (patch)
treef82389b36af75bd02a6cee4bac0981d0e0c308af /engines/sword25
parent7cc8811a5c9b63703c2131841745cd5b7e5f009a (diff)
downloadscummvm-rg350-4d6fb4e76819f7e5621685a32f4ff075e7b5674c.tar.gz
scummvm-rg350-4d6fb4e76819f7e5621685a32f4ff075e7b5674c.tar.bz2
scummvm-rg350-4d6fb4e76819f7e5621685a32f4ff075e7b5674c.zip
SWORD25: Get rid of colorFormat parameter in PNGLoader API
Only CF_ARGB32 was supported anyway. svn-id: r53756
Diffstat (limited to 'engines/sword25')
-rw-r--r--engines/sword25/gfx/image/pngloader.cpp62
-rw-r--r--engines/sword25/gfx/image/pngloader.h19
-rw-r--r--engines/sword25/gfx/image/renderedimage.cpp5
-rw-r--r--engines/sword25/gfx/image/swimage.cpp5
4 files changed, 27 insertions, 64 deletions
diff --git a/engines/sword25/gfx/image/pngloader.cpp b/engines/sword25/gfx/image/pngloader.cpp
index 53ed44f7bf..5c2be4c168 100644
--- a/engines/sword25/gfx/image/pngloader.cpp
+++ b/engines/sword25/gfx/image/pngloader.cpp
@@ -92,7 +92,12 @@ static void png_user_read_data(png_structp png_ptr, png_bytep data, png_size_t l
*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 @@ bool PNGLoader::doDecodeImage(const byte *fileDataPtr, uint fileSize, GraphicEn
int interlaceType;
int i;
- // Zielfarbformat überprüfen
- if (colorFormat != GraphicEngine::CF_ARGB32) {
- BS_LOG_ERRORLN("Illegal or unsupported color format.");
- return false;
- }
-
- // PNG Signatur überprüfen
+ // Check for valid PNG signature
if (!doIsCorrectImageFormat(fileDataPtr, fileSize)) {
error("png_check_sig failed");
}
@@ -136,7 +135,7 @@ bool PNGLoader::doDecodeImage(const byte *fileDataPtr, uint fileSize, GraphicEn
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ür die endgültigen Bilddaten reservieren
// Dieses geschieht vor dem reservieren von Speicher für temporäre Bilddaten um die Fragmentierung des Speichers gering zu halten
@@ -181,13 +180,7 @@ bool PNGLoader::doDecodeImage(const byte *fileDataPtr, uint fileSize, GraphicEn
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ück eingelesen
@@ -211,15 +204,8 @@ bool PNGLoader::doDecodeImage(const byte *fileDataPtr, uint fileSize, GraphicEn
png_read_image(png_ptr, pRowPtr);
// Bilddaten zeilenweise in das gewünschte 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ätzlichen Daten am Ende des Bildes lesen
@@ -236,13 +222,13 @@ bool PNGLoader::doDecodeImage(const byte *fileDataPtr, uint fileSize, GraphicEn
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 überprüfen
+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 @@ bool PNGLoader::doImageProperties(const byte *fileDataPtr, uint fileSize, Graphi
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::doImageProperties(const byte *fileDataPtr, uint fileSize, Graphi
}
-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);
-}
-
-bool PNGLoader::doIsCorrectImageFormat(const byte *fileDataPtr, uint fileSize) {
- return (fileSize > 8) && png_check_sig(const_cast<byte *>(fileDataPtr), 8);
+ return doImageProperties(fileDataPtr + pngOffset, fileSize - pngOffset, width, height);
}
-bool PNGLoader::isCorrectImageFormat(const byte *fileDataPtr, uint fileSize) {
- uint pngOffset = findEmbeddedPNG(fileDataPtr, fileSize);
- return doIsCorrectImageFormat(fileDataPtr + pngOffset, fileSize - pngOffset);
-}
} // End of namespace Sword25
diff --git a/engines/sword25/gfx/image/pngloader.h b/engines/sword25/gfx/image/pngloader.h
index e4b9f66f58..e0d68ff8b9 100644
--- a/engines/sword25/gfx/image/pngloader.h
+++ b/engines/sword25/gfx/image/pngloader.h
@@ -49,18 +49,15 @@ class PNGLoader {
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 @@ public:
* 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 @@ public:
* @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);
};
diff --git a/engines/sword25/gfx/image/renderedimage.cpp b/engines/sword25/gfx/image/renderedimage.cpp
index a989b2be60..9392eca044 100644
--- a/engines/sword25/gfx/image/renderedimage.cpp
+++ b/engines/sword25/gfx/image/renderedimage.cpp
@@ -70,16 +70,15 @@ RenderedImage::RenderedImage(const Common::String &filename, bool &result) :
}
// 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;
diff --git a/engines/sword25/gfx/image/swimage.cpp b/engines/sword25/gfx/image/swimage.cpp
index 2ea077f93e..f0a8899bb6 100644
--- a/engines/sword25/gfx/image/swimage.cpp
+++ b/engines/sword25/gfx/image/swimage.cpp
@@ -59,16 +59,15 @@ SWImage::SWImage(const Common::String &filename, bool &result) :
}
// 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;
}