mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-03 09:23:37 +00:00
SWORD25: Remove redundant colorspace defines and code.
svn-id: r53312
This commit is contained in:
parent
99e8337e63
commit
dcf70dc6a6
@ -91,32 +91,6 @@ public:
|
||||
enum COLOR_FORMATS {
|
||||
/// Undefined/unknown colour format
|
||||
CF_UNKNOWN = 0,
|
||||
/// 16-bit colour format (R5G5B5)
|
||||
CF_RGB15,
|
||||
/// 16-bit colour format (R5G6R5)
|
||||
CF_RGB16,
|
||||
/**
|
||||
* Special alpha colour format of the engine, which supports very quick display using MMX instructions.
|
||||
* The pixels are 16-bits wide and have the same format as #CF_RGB15. In addition, each pixel has an 8-bit
|
||||
* alpha value.
|
||||
* It summarises groupings of pixels pixels and four alpha values in a 12-byte data block.
|
||||
* The data is stored in the following order:
|
||||
* Alpha0 Alpha1 Alpha2 Alpha3 Pixel0 Pixel1 Pixel2 Pixel3
|
||||
* If the number of pixels in a line is not divisible by 4, then unused pixels and alpha values can have
|
||||
* arbitrary values.
|
||||
*/
|
||||
CF_RGB15_INTERLEAVED,
|
||||
/**
|
||||
* Special alpha colour format of the engine, which supports very quick display using MMX instructions.
|
||||
* The pixels are 16-bits wide and have the same format as #CF_RGB16. In addition, each pixel has an 8-bit
|
||||
* alpha value.
|
||||
* It summarises groupings of pixels pixels and four alpha values in a 12-byte data block.
|
||||
* The data is stored in the following order:
|
||||
* Alpha0 Alpha1 Alpha2 Alpha3 Pixel0 Pixel1 Pixel2 Pixel3
|
||||
* If the number of pixels in a line is not divisible by 4, then unused pixels and alpha values can have
|
||||
* arbitrary values.
|
||||
*/
|
||||
CF_RGB16_INTERLEAVED,
|
||||
/**
|
||||
* 24-bit colour format (R8G8B8)
|
||||
*/
|
||||
@ -314,14 +288,6 @@ public:
|
||||
*/
|
||||
static int GetPixelSize(GraphicEngine::COLOR_FORMATS ColorFormat) {
|
||||
switch (ColorFormat) {
|
||||
case GraphicEngine::CF_RGB16:
|
||||
case GraphicEngine::CF_RGB15:
|
||||
return 2;
|
||||
|
||||
case GraphicEngine::CF_RGB16_INTERLEAVED:
|
||||
case GraphicEngine::CF_RGB15_INTERLEAVED:
|
||||
return 3;
|
||||
|
||||
case GraphicEngine::CF_ARGB32:
|
||||
return 4;
|
||||
default:
|
||||
@ -338,16 +304,7 @@ public:
|
||||
*/
|
||||
static int CalcPitch(GraphicEngine::COLOR_FORMATS ColorFormat, int Width) {
|
||||
switch (ColorFormat) {
|
||||
case GraphicEngine::CF_RGB16:
|
||||
case GraphicEngine::CF_RGB15:
|
||||
return Width * 2;
|
||||
|
||||
case GraphicEngine::CF_RGB16_INTERLEAVED:
|
||||
case GraphicEngine::CF_RGB15_INTERLEAVED:
|
||||
return (Width + 3) / 4 * 12;
|
||||
|
||||
case GraphicEngine::CF_ARGB32:
|
||||
case GraphicEngine::CF_ABGR32:
|
||||
return Width * 4;
|
||||
|
||||
default:
|
||||
|
@ -60,12 +60,7 @@ namespace Sword25 {
|
||||
- Die Klasse muss eine statische Methode haben, die eine Instanz von ihr erzeugt und einen Pointer darauf zurückgibt.
|
||||
- Diese Methode muss in der Liste in der Datei imageloader_ids.h eingetragen werden.
|
||||
- Die Klasse muss JEDES Eingabebild seines Bildformates in die folgenden Farbformate konvertieren können:
|
||||
- BS_GraphicEngine::CF_RGB16
|
||||
- BS_GraphicEngine::CF_RGB15
|
||||
- BS_GraphicEngine::CF_RGB16_INTERLEAVED
|
||||
- BS_GraphicEngine::CF_RGB15_INTERLEAVED
|
||||
- BS_GraphicEngine::CF_ARGB32
|
||||
- BS_GraphicEngine::CF_BGRA32
|
||||
- Zum Konvertieren der Bilddaten können die Hilfsmethoden dieser Klasse benutzt werden, die ARGB Bilddaten in alle benötigten
|
||||
Farbformate konvertieren.
|
||||
*/
|
||||
@ -86,10 +81,6 @@ public:
|
||||
@param FileSize die Größe der Bilddaten in Byte.
|
||||
@param ColorFormat gibt das gewünschte Farbformat an, in das die Bilddaten konvertiert werden sollen.<br>
|
||||
Folgende Farbformate werden unterstützt:
|
||||
- BS_GraphicEngine::CF_RGB16
|
||||
- BS_GraphicEngine::CF_RGB15
|
||||
- BS_GraphicEngine::CF_RGB16_INTERLEAVED
|
||||
- BS_GraphicEngine::CF_RGB15_INTERLEAVED
|
||||
- BS_GraphicEngine::CF_ARGB32
|
||||
@param pUncompressedData nach erfolgreichen Laden zeigt dieser Pointer auf die enpackten und konvertierten Bilddaten.
|
||||
@param Width gibt nach erfolgreichen Laden die Breite des geladenen Bildes an.
|
||||
@ -156,10 +147,6 @@ protected:
|
||||
@param FileSize die Größe der Bilddaten in Byte.
|
||||
@param ColorFormat gibt das gewünschte Farbformat an, in das die Bilddaten konvertiert werden sollen.<br>
|
||||
Folgende Farbformate werden unterstützt:
|
||||
- BS_GraphicEngine::CF_RGB16
|
||||
- BS_GraphicEngine::CF_RGB15
|
||||
- BS_GraphicEngine::CF_RGB16_INTERLEAVED
|
||||
- BS_GraphicEngine::CF_RGB15_INTERLEAVED
|
||||
- BS_GraphicEngine::CF_ARGB32
|
||||
@param pUncompressedData nach erfolgreichen Laden zeigt dieser Pointer auf die enpackten und konvertierten Bilddaten.
|
||||
@param Width gibt nach erfolgreichen Laden die Breite des geladenen Bildes an.
|
||||
@ -193,144 +180,6 @@ protected:
|
||||
|
||||
//@}
|
||||
|
||||
//@{
|
||||
/** @name Konvertierungsmethoden */
|
||||
|
||||
/**
|
||||
@brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_RGB16 Farbformat.
|
||||
@param pSrcData ein Pointer auf die Quelldaten.
|
||||
@param pDestData ein Pointer auf den Zielpuffern.
|
||||
@param Width die Anzahl der Pixel in der Bildzeile.
|
||||
@remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß ist.<br>
|
||||
Es sind mindestens Width * 2 Byte notwendig.
|
||||
*/
|
||||
static void RowARGB32ToRGB16(byte *pSrcData, byte *pDestData, uint Width) {
|
||||
for (uint i = 0; i < Width; i++) {
|
||||
((uint16_t *)pDestData)[i] = ((pSrcData[2] >> 3) << 11) | ((pSrcData[1] >> 2) << 5) | (pSrcData[0] >> 3);
|
||||
pSrcData += 4;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_RGB15 Farbformat.
|
||||
@param pSrcData ein Pointer auf die Quelldaten.
|
||||
@param pDestData ein Pointer auf den Zielpuffern.
|
||||
@param Width die Anzahl der Pixel in der Bildzeile.
|
||||
@remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß ist.<br>
|
||||
Es sind mindestens Width * 2 Byte notwendig.
|
||||
*/
|
||||
static void RowARGB32ToRGB15(byte *pSrcData, byte *pDestData, uint Width) {
|
||||
for (uint i = 0; i < Width; i++) {
|
||||
((uint16_t *)pDestData)[i] = ((pSrcData[2] >> 3) << 10) | ((pSrcData[1] >> 3) << 5) | (pSrcData[0] >> 3);
|
||||
pSrcData += 4;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_RGB16_INTERLEAVED Farbformat.
|
||||
@param pSrcData ein Pointer auf die Quelldaten.
|
||||
@param pDestData ein Pointer auf den Zielpuffern.
|
||||
@param Width die Anzahl der Pixel in der Bildzeile.
|
||||
@remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß sein muss.<br>
|
||||
Es sind mindestens ((Width + 3) / 4) * 12 Byte notwendig.
|
||||
*/
|
||||
static void RowARGB32ToRGB16_INTERLEAVED(byte *pSrcData, byte *pDestData, uint Width) {
|
||||
// Die Pixelblöcke erstellen, dabei werden immer jeweils 4 Pixel zu einem Block zusammengefasst
|
||||
uint BlockFillCount = 0;
|
||||
uint AlphaBlock = 0;
|
||||
for (uint i = 0; i < Width; i++) {
|
||||
// Alphawert in den Alphablock schreiben
|
||||
AlphaBlock = (AlphaBlock >> 8) | (pSrcData[BlockFillCount * 4 + 3] << 24);
|
||||
|
||||
// Füllstand der Pixelblockes aktualisieren
|
||||
BlockFillCount++;
|
||||
|
||||
// Sobald 4 Alphawerte gesammelt wurden, oder die Zeile zu Ende ist wird der Pixelblock in den Zielpuffer geschrieben
|
||||
if (BlockFillCount == 4 || i == (Width - 1)) {
|
||||
// Falls der AlphaBlock nicht ganz gefüllt ist muss geshiftet werden um sicherzustellen, dass die Alphawerte
|
||||
// "left aligned" sind.
|
||||
AlphaBlock >>= (4 - BlockFillCount) * 8;
|
||||
|
||||
// Alphablock schreiben
|
||||
*((uint *)pDestData) = AlphaBlock;
|
||||
pDestData += 4;
|
||||
|
||||
// Pixel konvertieren und schreiben
|
||||
RowARGB32ToRGB16(pSrcData, pDestData, BlockFillCount);
|
||||
|
||||
// Pointer auf den nächsten Platz im Zielpuffer setzen
|
||||
pDestData += 8;
|
||||
|
||||
// Pointer auf die nächsten 4 Pixel im Quellpuffer setzen
|
||||
pSrcData += 16;
|
||||
|
||||
// Neuen Pixelblock beginnen
|
||||
BlockFillCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_RGB15_INTERLEAVED Farbformat.
|
||||
@param pSrcData ein Pointer auf die Quelldaten.
|
||||
@param pDestData ein Pointer auf den Zielpuffern.
|
||||
@param Width die Anzahl der Pixel in der Bildzeile.
|
||||
@remark Es gilt zu beachten, dass der Zielpuffer ausreichend groß ist.<br>
|
||||
Es sind mindestens (Width / 4 + Width % 4) * 3 Byte notwendig.
|
||||
*/
|
||||
static void RowARGB32ToRGB15_INTERLEAVED(byte *pSrcData, byte *pDestData, uint Width) {
|
||||
// Die Pixelblöcke erstellen, dabei werden immer jeweils 4 Pixel zu einem Block zusammengefasst
|
||||
uint BlockFillCount = 0;
|
||||
uint AlphaBlock = 0;
|
||||
for (uint i = 0; i < Width; i++) {
|
||||
// Alphawert in den Alphablock schreiben
|
||||
AlphaBlock = (AlphaBlock >> 8) | (pSrcData[BlockFillCount * 4 + 3] << 24);
|
||||
|
||||
// Füllstand der Pixelblockes aktualisieren
|
||||
BlockFillCount++;
|
||||
|
||||
// Sobald 4 Alphawerte gesammelt wurden, oder die Zeile zu Ende ist wird der Pixelblock in den Zielpuffer geschrieben
|
||||
if (BlockFillCount == 4 || i == (Width - 1)) {
|
||||
// Falls der AlphaBlock nicht ganz gefüllt ist muss geshiftet werden um sicherzustellen, dass die Alphawerte
|
||||
// "left aligned" sind.
|
||||
AlphaBlock >>= (4 - BlockFillCount) * 8;
|
||||
|
||||
// Alphablock schreiben
|
||||
*((uint *)pDestData) = AlphaBlock;
|
||||
pDestData += 4;
|
||||
|
||||
// Pixel konvertieren und schreiben
|
||||
RowARGB32ToRGB15(pSrcData, pDestData, BlockFillCount);
|
||||
|
||||
// Pointer auf den nächsten Platz im Zielpuffer setzen
|
||||
pDestData += 8;
|
||||
|
||||
// Pointer auf die nächsten 4 Pixel im Quellpuffer setzen
|
||||
pSrcData += 16;
|
||||
|
||||
// Neuen Pixelblock beginnen
|
||||
BlockFillCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@brief Konvertiert eine Bildzeile mit ARGB Pixeldaten in das BS_GraphicEngine::CF_BGRA32 Farbformat.
|
||||
@param pSrcData ein Pointer auf die Quelldaten.
|
||||
@param pDestData ein Pointer auf den Zielpuffern.
|
||||
@param Width die Anzahl der Pixel in der Bildzeile.
|
||||
*/
|
||||
static void RowARGB32ToABGR32(byte *pSrcData, byte *pDestData, uint Width) {
|
||||
for (uint i = 0; i < Width; ++i) {
|
||||
*pDestData++ = pSrcData[2];
|
||||
*pDestData++ = pSrcData[1];
|
||||
*pDestData++ = pSrcData[0];
|
||||
*pDestData++ = pSrcData[3];
|
||||
|
||||
pSrcData += 4;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
|
@ -75,12 +75,7 @@ bool PNGLoader::DoDecodeImage(const byte *FileDataPtr, uint FileSize, GraphicEn
|
||||
int i;
|
||||
|
||||
// Zielfarbformat überprüfen
|
||||
if (ColorFormat != GraphicEngine::CF_RGB16 &&
|
||||
ColorFormat != GraphicEngine::CF_RGB15 &&
|
||||
ColorFormat != GraphicEngine::CF_RGB16_INTERLEAVED &&
|
||||
ColorFormat != GraphicEngine::CF_RGB15_INTERLEAVED &&
|
||||
ColorFormat != GraphicEngine::CF_ARGB32 &&
|
||||
ColorFormat != GraphicEngine::CF_ABGR32) {
|
||||
if (ColorFormat != GraphicEngine::CF_ARGB32) {
|
||||
BS_LOG_ERRORLN("Illegal or unsupported color format.");
|
||||
return false;
|
||||
}
|
||||
@ -157,31 +152,9 @@ bool PNGLoader::DoDecodeImage(const byte *FileDataPtr, uint FileSize, GraphicEn
|
||||
|
||||
// Zeile konvertieren
|
||||
switch (ColorFormat) {
|
||||
case GraphicEngine::CF_RGB16:
|
||||
RowARGB32ToRGB16((byte *)RawDataBuffer, (byte *)&UncompressedDataPtr[i * Pitch], Width);
|
||||
break;
|
||||
|
||||
case GraphicEngine::CF_RGB15:
|
||||
RowARGB32ToRGB15((byte *)RawDataBuffer, (byte *)&UncompressedDataPtr[i * Pitch], Width);
|
||||
break;
|
||||
|
||||
case GraphicEngine::CF_RGB16_INTERLEAVED:
|
||||
RowARGB32ToRGB16_INTERLEAVED((byte *)RawDataBuffer, (byte *)&UncompressedDataPtr[i * Pitch], Width);
|
||||
break;
|
||||
|
||||
case GraphicEngine::CF_RGB15_INTERLEAVED:
|
||||
RowARGB32ToRGB15_INTERLEAVED((byte *)RawDataBuffer,
|
||||
(byte *)&UncompressedDataPtr[i * Pitch], Width);
|
||||
break;
|
||||
|
||||
case GraphicEngine::CF_ARGB32:
|
||||
memcpy(&UncompressedDataPtr[i * Pitch], RawDataBuffer, Pitch);
|
||||
break;
|
||||
|
||||
case GraphicEngine::CF_ABGR32:
|
||||
RowARGB32ToABGR32((byte *)RawDataBuffer, (byte *)&UncompressedDataPtr[i * Pitch], Width);
|
||||
break;
|
||||
|
||||
default:
|
||||
assert(0);
|
||||
}
|
||||
@ -209,30 +182,6 @@ bool PNGLoader::DoDecodeImage(const byte *FileDataPtr, uint FileSize, GraphicEn
|
||||
|
||||
// Bilddaten zeilenweise in das gewünschte Ausgabeformat konvertieren
|
||||
switch (ColorFormat) {
|
||||
case GraphicEngine::CF_RGB16:
|
||||
for (i = 0; i < Height; i++)
|
||||
RowARGB32ToRGB16((byte *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
|
||||
(byte *)&UncompressedDataPtr[i * Pitch], Width);
|
||||
break;
|
||||
|
||||
case GraphicEngine::CF_RGB15:
|
||||
for (i = 0; i < Height; i++)
|
||||
RowARGB32ToRGB15((byte *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
|
||||
(byte *)&UncompressedDataPtr[i * Pitch], Width);
|
||||
break;
|
||||
|
||||
case GraphicEngine::CF_RGB16_INTERLEAVED:
|
||||
for (i = 0; i < Height; i++)
|
||||
RowARGB32ToRGB16_INTERLEAVED((byte *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
|
||||
(byte *)&UncompressedDataPtr[i * Pitch], Width);
|
||||
break;
|
||||
|
||||
case GraphicEngine::CF_RGB15_INTERLEAVED:
|
||||
for (i = 0; i < Height; i++)
|
||||
RowARGB32ToRGB15_INTERLEAVED((byte *)(&RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)]),
|
||||
(byte *)&UncompressedDataPtr[i * Pitch], Width);
|
||||
break;
|
||||
|
||||
case GraphicEngine::CF_ARGB32:
|
||||
for (i = 0; i < Height; i++)
|
||||
memcpy(&UncompressedDataPtr[i * Pitch], &RawDataBuffer[i * png_get_rowbytes(png_ptr, info_ptr)], Pitch);
|
||||
|
@ -77,7 +77,7 @@ SWImage::SWImage(const Common::String &filename, bool &result) :
|
||||
|
||||
// Das Bild dekomprimieren
|
||||
byte *pUncompressedData;
|
||||
if (!ImageLoader::LoadImage(pFileData, fileSize, GraphicEngine::CF_ABGR32, pUncompressedData, _width, _height, pitch)) {
|
||||
if (!ImageLoader::LoadImage(pFileData, fileSize, GraphicEngine::CF_ARGB32, pUncompressedData, _width, _height, pitch)) {
|
||||
BS_LOG_ERRORLN("Could not decode image.");
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user