Browse Source

Renamed TGAImporter -> TgaImporter.

pull/34/head
Vladimír Vondruš 14 years ago
parent
commit
f17de6a63d
  1. 13
      src/Plugins/TGAImporter/CMakeLists.txt
  2. 2
      src/Plugins/TGAImporter/Test/CMakeLists.txt
  3. 13
      src/Plugins/TgaImporter/CMakeLists.txt
  4. 2
      src/Plugins/TgaImporter/Test/CMakeLists.txt
  5. 34
      src/Plugins/TgaImporter/Test/TgaImporterTest.cpp
  6. 8
      src/Plugins/TgaImporter/Test/TgaImporterTest.h
  7. 0
      src/Plugins/TgaImporter/TgaImporter.conf
  8. 22
      src/Plugins/TgaImporter/TgaImporter.cpp
  9. 14
      src/Plugins/TgaImporter/TgaImporter.h

13
src/Plugins/TGAImporter/CMakeLists.txt

@ -1,13 +0,0 @@
corrade_add_plugin(TGAImporter ${MAGNUM_PLUGINS_IMPORTER_INSTALL_DIR} TGAImporter.conf TGAImporter.cpp)
target_link_libraries(TGAImporter ${MAGNUM_LIBRARY})
if(BUILD_TESTS)
add_library(TGAImporterTestLib TGAImporter.cpp)
target_link_libraries(TGAImporterTestLib ${MAGNUM_LIBRARY} ${CORRADE_UTILITY_LIBRARY} ${CORRADE_PLUGINMANAGER_LIBRARY})
enable_testing()
add_subdirectory(Test)
endif()
if(WIN32)
target_link_libraries(TGAImporter ${CORRADE_UTILITY_LIBRARY} ${CORRADE_PLUGINMANAGER_LIBRARY})
endif()

2
src/Plugins/TGAImporter/Test/CMakeLists.txt

@ -1,2 +0,0 @@
corrade_add_test(TGAImporterTest TGAImporterTest.h TGAImporterTest.cpp)
target_link_libraries(TGAImporterTest TGAImporterTestLib)

13
src/Plugins/TgaImporter/CMakeLists.txt

@ -0,0 +1,13 @@
corrade_add_plugin(TgaImporter ${MAGNUM_PLUGINS_IMPORTER_INSTALL_DIR} TgaImporter.conf TgaImporter.cpp)
target_link_libraries(TgaImporter ${MAGNUM_LIBRARY})
if(BUILD_TESTS)
add_library(TgaImporterTestLib TgaImporter.cpp)
target_link_libraries(TgaImporterTestLib ${MAGNUM_LIBRARY} ${CORRADE_UTILITY_LIBRARY} ${CORRADE_PLUGINMANAGER_LIBRARY})
enable_testing()
add_subdirectory(Test)
endif()
if(WIN32)
target_link_libraries(TgaImporter ${CORRADE_UTILITY_LIBRARY} ${CORRADE_PLUGINMANAGER_LIBRARY})
endif()

2
src/Plugins/TgaImporter/Test/CMakeLists.txt

@ -0,0 +1,2 @@
corrade_add_test(TgaImporterTest TgaImporterTest.h TgaImporterTest.cpp)
target_link_libraries(TgaImporterTest TgaImporterTestLib)

34
src/Plugins/TGAImporter/Test/TGAImporterTest.cpp → src/Plugins/TgaImporter/Test/TgaImporterTest.cpp

@ -13,64 +13,64 @@
GNU Lesser General Public License version 3 for more details.
*/
#include "TGAImporterTest.h"
#include "TgaImporterTest.h"
#include <QtTest/QTest>
#include "Utility/Debug.h"
#include "../TGAImporter.h"
#include "../TgaImporter.h"
using namespace std;
using namespace Corrade::Utility;
QTEST_APPLESS_MAIN(Magnum::Trade::TGAImporter::Test::TGAImporterTest)
QTEST_APPLESS_MAIN(Magnum::Trade::TgaImporter::Test::TgaImporterTest)
namespace Magnum { namespace Trade { namespace TGAImporter { namespace Test {
namespace Magnum { namespace Trade { namespace TgaImporter { namespace Test {
void TGAImporterTest::paletted() {
void TgaImporterTest::paletted() {
const char data[] = { 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
istringstream in(string(data, sizeof(data)));
ostringstream debug;
Error::setOutput(&debug);
TGAImporter importer;
TgaImporter importer;
QVERIFY(!importer.open(in));
QCOMPARE(debug.str().c_str(), "TGAImporter: paletted files are not supported\n");
QCOMPARE(debug.str().c_str(), "TgaImporter: paletted files are not supported\n");
}
void TGAImporterTest::nonRgb() {
void TgaImporterTest::nonRgb() {
const char data[] = { 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
istringstream in(string(data, sizeof(data)));
ostringstream debug;
Error::setOutput(&debug);
TGAImporter importer;
TgaImporter importer;
QVERIFY(!importer.open(in));
QCOMPARE(debug.str().c_str(), "TGAImporter: non-RGB files are not supported\n");
QCOMPARE(debug.str().c_str(), "TgaImporter: non-RGB files are not supported\n");
}
void TGAImporterTest::bits16() {
void TgaImporterTest::bits16() {
const char data[] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16, 0 };
istringstream in(string(data, sizeof(data)));
ostringstream debug;
Error::setOutput(&debug);
TGAImporter importer;
TgaImporter importer;
QVERIFY(!importer.open(in));
QCOMPARE(debug.str().c_str(), "TGAImporter: unsupported bits-per-pixel: 16\n");
QCOMPARE(debug.str().c_str(), "TgaImporter: unsupported bits-per-pixel: 16\n");
}
void TGAImporterTest::bits24() {
void TgaImporterTest::bits24() {
const char data[] = {
0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 24, 0,
1, 2, 3, 2, 3, 4, 3, 4, 5, 4, 5, 6, 5, 6, 7, 6, 7, 8
};
std::istringstream in(string(data, sizeof(data)));
TGAImporter importer;
TgaImporter importer;
QVERIFY(importer.open(in));
auto image = importer.image2D(0);
QVERIFY(image->colorFormat() == AbstractTexture::ColorFormat::BGR);
@ -79,14 +79,14 @@ void TGAImporterTest::bits24() {
QVERIFY(string(static_cast<const char*>(image->data())) == string(data + 18, 2*3*3));
}
void TGAImporterTest::bits32() {
void TgaImporterTest::bits32() {
const char data[] = {
0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 3, 0, 32, 0,
1, 2, 3, 1, 2, 3, 4, 1, 3, 4, 5, 1, 4, 5, 6, 1, 5, 6, 7, 1, 6, 7, 8, 1
};
std::istringstream in(string(data, sizeof(data)));
TGAImporter importer;
TgaImporter importer;
QVERIFY(importer.open(in));
auto image = importer.image2D(0);
QVERIFY(image->colorFormat() == AbstractTexture::ColorFormat::BGRA);

8
src/Plugins/TGAImporter/Test/TGAImporterTest.h → src/Plugins/TgaImporter/Test/TgaImporterTest.h

@ -1,5 +1,5 @@
#ifndef Magnum_Trade_TGAImporter_Test_TGAImporterTest_h
#define Magnum_Trade_TGAImporter_Test_TGAImporterTest_h
#ifndef Magnum_Trade_TgaImporter_Test_TgaImporterTest_h
#define Magnum_Trade_TgaImporter_Test_TgaImporterTest_h
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
@ -17,9 +17,9 @@
#include <QtCore/QObject>
namespace Magnum { namespace Trade { namespace TGAImporter { namespace Test {
namespace Magnum { namespace Trade { namespace TgaImporter { namespace Test {
class TGAImporterTest: public QObject {
class TgaImporterTest: public QObject {
Q_OBJECT
private slots:

0
src/Plugins/TGAImporter/TGAImporter.conf → src/Plugins/TgaImporter/TgaImporter.conf

22
src/Plugins/TGAImporter/TGAImporter.cpp → src/Plugins/TgaImporter/TgaImporter.cpp

@ -13,7 +13,7 @@
GNU Lesser General Public License version 3 for more details.
*/
#include "TGAImporter.h"
#include "TgaImporter.h"
#include "Utility/Endianness.h"
#include "Math/Vector2.h"
@ -22,20 +22,20 @@
using namespace std;
using namespace Corrade::Utility;
PLUGIN_REGISTER(Magnum::Trade::TGAImporter::TGAImporter, "cz.mosra.magnum.Trade.AbstractImporter/0.1")
PLUGIN_REGISTER(Magnum::Trade::TgaImporter::TgaImporter, "cz.mosra.magnum.Trade.AbstractImporter/0.1")
namespace Magnum { namespace Trade { namespace TGAImporter {
namespace Magnum { namespace Trade { namespace TgaImporter {
static_assert(sizeof(TGAImporter::Header) == 18, "TGAImporter: header size is not 18 bytes");
static_assert(sizeof(TgaImporter::Header) == 18, "TgaImporter: header size is not 18 bytes");
bool TGAImporter::TGAImporter::open(const string& filename) {
bool TgaImporter::TgaImporter::open(const string& filename) {
ifstream in(filename.c_str());
bool status = open(in);
in.close();
return status;
}
bool TGAImporter::open(std::istream& in) {
bool TgaImporter::open(std::istream& in) {
if(_image) close();
if(!in.good()) return false;
@ -47,12 +47,12 @@ bool TGAImporter::open(std::istream& in) {
header.height = Endianness::littleEndian<unsigned short>(header.height);
if(header.colorMapType != 0) {
Error() << "TGAImporter: paletted files are not supported";
Error() << "TgaImporter: paletted files are not supported";
return false;
}
if(header.imageType != 2) {
Error() << "TGAImporter: non-RGB files are not supported";
Error() << "TgaImporter: non-RGB files are not supported";
return false;
}
@ -65,7 +65,7 @@ bool TGAImporter::open(std::istream& in) {
colorFormat = AbstractTexture::ColorFormat::BGRA;
break;
default:
Error() << "TGAImporter: unsupported bits-per-pixel:" << (int) header.bpp;
Error() << "TgaImporter: unsupported bits-per-pixel:" << (int) header.bpp;
return false;
}
@ -79,12 +79,12 @@ bool TGAImporter::open(std::istream& in) {
return true;
}
void TGAImporter::close() {
void TgaImporter::close() {
delete _image;
_image = nullptr;
}
ImageData2D* TGAImporter::image2D(size_t id) {
ImageData2D* TgaImporter::image2D(size_t id) {
return _image;
}

14
src/Plugins/TGAImporter/TGAImporter.h → src/Plugins/TgaImporter/TgaImporter.h

@ -1,5 +1,5 @@
#ifndef Magnum_Trade_TGAImporter_TGAImporter_h
#define Magnum_Trade_TGAImporter_TGAImporter_h
#ifndef Magnum_Trade_TgaImporter_TgaImporter_h
#define Magnum_Trade_TgaImporter_TgaImporter_h
/*
Copyright © 2010, 2011, 2012 Vladimír Vondruš <mosra@centrum.cz>
@ -16,17 +16,17 @@
*/
/** @file
* @brief Class Magnum::Trade::TGAImporter::TGAImporter
* @brief Class Magnum::Trade::TgaImporter::TgaImporter
*/
#include "Trade/AbstractImporter.h"
namespace Magnum { namespace Trade { namespace TGAImporter {
namespace Magnum { namespace Trade { namespace TgaImporter {
class TGAImporter: public AbstractImporter {
class TgaImporter: public AbstractImporter {
public:
TGAImporter(Corrade::PluginManager::AbstractPluginManager* manager = 0, const std::string& plugin = ""): AbstractImporter(manager, plugin), _image(nullptr) {}
inline virtual ~TGAImporter() { close(); }
TgaImporter(Corrade::PluginManager::AbstractPluginManager* manager = 0, const std::string& plugin = ""): AbstractImporter(manager, plugin), _image(nullptr) {}
inline virtual ~TgaImporter() { close(); }
inline int features() const { return OpenFile|OpenStream; }
Loading…
Cancel
Save