Browse Source

Adapted to (old) Magnum changes.

pull/34/head
Vladimír Vondruš 14 years ago
parent
commit
f58ccfa1f7
  1. 5
      src/Plugins/TgaImporter/Test/TgaImporterTest.cpp
  2. 6
      src/Plugins/TgaImporter/TgaImporter.cpp
  3. 10
      src/Plugins/TgaImporter/TgaImporter.h

5
src/Plugins/TgaImporter/Test/TgaImporterTest.cpp

@ -15,9 +15,14 @@
#include "TgaImporterTest.h" #include "TgaImporterTest.h"
#include <Utility/Debug.h>
#include <Math/Vector2.h>
#include <Trade/ImageData.h>
#include "../TgaImporter.h" #include "../TgaImporter.h"
using namespace std; using namespace std;
using namespace Corrade::Utility;
CORRADE_TEST_MAIN(Magnum::Trade::TgaImporter::Test::TgaImporterTest) CORRADE_TEST_MAIN(Magnum::Trade::TgaImporter::Test::TgaImporterTest)

6
src/Plugins/TgaImporter/TgaImporter.cpp

@ -19,7 +19,7 @@
#include <Utility/Endianness.h> #include <Utility/Endianness.h>
#include "Math/Vector2.h" #include "Math/Vector2.h"
#include "Math/Swizzle.h" #include <Swizzle.h>
#include "Trade/ImageData.h" #include "Trade/ImageData.h"
using namespace std; using namespace std;
@ -106,11 +106,11 @@ bool TgaImporter::open(istream& in, const string& name) {
if(components == AbstractImage::Components::RGB) { if(components == AbstractImage::Components::RGB) {
Math::Vector3<GLubyte>* data = reinterpret_cast<Math::Vector3<GLubyte>*>(buffer); Math::Vector3<GLubyte>* data = reinterpret_cast<Math::Vector3<GLubyte>*>(buffer);
std::transform(data, data + dimensions.product(), data, std::transform(data, data + dimensions.product(), data,
[](Math::Vector3<GLubyte> pixel) { return Math::swizzle<'b', 'g', 'r'>(pixel); }); [](Math::Vector3<GLubyte> pixel) { return swizzle<'b', 'g', 'r'>(pixel); });
} else /* RGBA */ { } else /* RGBA */ {
Math::Vector4<GLubyte>* data = reinterpret_cast<Math::Vector4<GLubyte>*>(buffer); Math::Vector4<GLubyte>* data = reinterpret_cast<Math::Vector4<GLubyte>*>(buffer);
std::transform(data, data + dimensions.product(), data, std::transform(data, data + dimensions.product(), data,
[](Math::Vector4<GLubyte> pixel) { return Math::swizzle<'b', 'g', 'r', 'a'>(pixel); }); [](Math::Vector4<GLubyte> pixel) { return swizzle<'b', 'g', 'r', 'a'>(pixel); });
} }
#endif #endif

10
src/Plugins/TgaImporter/TgaImporter.h

@ -71,9 +71,9 @@ class TGAIMPORTER_EXPORT TgaImporter: public AbstractImporter {
/** @brief TGA file header */ /** @brief TGA file header */
/** @todoc Enable @c INLINE_SIMPLE_STRUCTS again when unclosed &lt;component&gt; in tagfile is fixed*/ /** @todoc Enable @c INLINE_SIMPLE_STRUCTS again when unclosed &lt;component&gt; in tagfile is fixed*/
struct TGAIMPORTER_LOCAL Header { struct TGAIMPORTER_LOCAL Header {
GLbyte identsize; /**< @brief Size of ID field that follows header (0) */ char identsize; /**< @brief Size of ID field that follows header (0) */
GLbyte colorMapType; /**< @brief 0 = None, 1 = paletted */ char colorMapType; /**< @brief 0 = None, 1 = paletted */
GLbyte imageType; /**< @brief 0 = none, 1 = indexed, 2 = rgb, 3 = grey, +8=rle */ char imageType; /**< @brief 0 = none, 1 = indexed, 2 = rgb, 3 = grey, +8=rle */
unsigned short colorMapStart; /**< @brief First color map entry */ unsigned short colorMapStart; /**< @brief First color map entry */
unsigned short colorMapLength; /**< @brief Number of colors */ unsigned short colorMapLength; /**< @brief Number of colors */
unsigned char colorMapBpp; /**< @brief Bits per palette entry */ unsigned char colorMapBpp; /**< @brief Bits per palette entry */
@ -81,8 +81,8 @@ class TGAIMPORTER_EXPORT TgaImporter: public AbstractImporter {
unsigned short beginY; /**< @brief %Image y origin */ unsigned short beginY; /**< @brief %Image y origin */
unsigned short width; /**< @brief %Image width */ unsigned short width; /**< @brief %Image width */
unsigned short height; /**< @brief %Image height */ unsigned short height; /**< @brief %Image height */
GLbyte bpp; /**< @brief Bits per pixel (8, 16, 24, 32) */ char bpp; /**< @brief Bits per pixel (8, 16, 24, 32) */
GLbyte descriptor; /**< @brief %Image descriptor */ char descriptor; /**< @brief %Image descriptor */
}; };
#pragma pack(8) #pragma pack(8)

Loading…
Cancel
Save