Browse Source

TgaImporter: adapted to Magnum changes.

Not storing image name inside ImageData greatly simplifies the
implementation. Also using `override` keyword where possible.
pull/34/head
Vladimír Vondruš 13 years ago
parent
commit
cd00422e4f
  1. 8
      src/Plugins/TgaImporter/TgaImporter.cpp
  2. 26
      src/Plugins/TgaImporter/TgaImporter.h

8
src/Plugins/TgaImporter/TgaImporter.cpp

@ -30,18 +30,18 @@ namespace Magnum { namespace Trade { namespace TgaImporter {
static_assert(sizeof(TgaImporter::Header) == 18, "TgaImporter: header size is not 18 bytes");
#endif
bool TgaImporter::TgaImporter::open(const std::string& filename, const std::string& name) {
bool TgaImporter::TgaImporter::open(const std::string& filename) {
std::ifstream in(filename.c_str());
if(!in.good()) {
Error() << "TgaImporter: cannot open file" << filename;
return false;
}
bool status = open(in, name);
bool status = open(in);
in.close();
return status;
}
bool TgaImporter::open(std::istream& in, const std::string& name) {
bool TgaImporter::open(std::istream& in) {
if(_image) close();
if(!in.good()) {
Error() << "TgaImporter: cannot read input stream";
@ -113,7 +113,7 @@ bool TgaImporter::open(std::istream& in, const std::string& name) {
}
#endif
_image = new ImageData2D(name, dimensions, format, ImageData2D::Type::UnsignedByte, buffer);
_image = new ImageData2D(dimensions, format, ImageData2D::Type::UnsignedByte, buffer);
return true;
}

26
src/Plugins/TgaImporter/TgaImporter.h

@ -44,28 +44,14 @@ class TGAIMPORTER_EXPORT TgaImporter: public AbstractImporter {
TgaImporter(Corrade::PluginManager::AbstractPluginManager* manager = 0, const std::string& plugin = ""): AbstractImporter(manager, plugin), _image(nullptr) {}
inline virtual ~TgaImporter() { close(); }
inline Features features() const { return Feature::OpenFile|Feature::OpenStream; }
inline Features features() const override { return Feature::OpenFile|Feature::OpenStream; }
/**
* @brief Open input stream with specific image name
*
* @see open(std::istream&), ImageData2D::name()
*/
bool open(std::istream& in, const std::string& name);
inline bool open(std::istream& in) { return open(in, ""); }
bool open(std::istream& in) override;
bool open(const std::string& filename) override;
void close() override;
/**
* @brief Open file with specific image name
*
* @see open(const std::string&), ImageData2D::name()
*/
bool open(const std::string& filename, const std::string& name);
inline bool open(const std::string& filename) { return open(filename, ""); }
void close();
inline std::uint32_t image2DCount() const { return _image ? 1 : 0; }
ImageData2D* image2D(std::uint32_t id);
std::uint32_t image2DCount() const override { return _image ? 1 : 0; }
ImageData2D* image2D(std::uint32_t id) override;
#pragma pack(1)
/** @brief TGA file header */

Loading…
Cancel
Save