Browse Source

Ability to explicitly specify name for image from TgaImporter.

pull/34/head
Vladimír Vondruš 14 years ago
parent
commit
dc0895142a
  1. 8
      src/Plugins/TgaImporter/TgaImporter.cpp
  2. 18
      src/Plugins/TgaImporter/TgaImporter.h

8
src/Plugins/TgaImporter/TgaImporter.cpp

@ -28,18 +28,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 string& filename) {
bool TgaImporter::TgaImporter::open(const string& filename, const string& name) {
ifstream in(filename.c_str());
if(!in.good()) {
Error() << "TgaImporter: cannot open file" << filename;
return false;
}
bool status = open(in);
bool status = open(in, name);
in.close();
return status;
}
bool TgaImporter::open(istream& in) {
bool TgaImporter::open(istream& in, const string& name) {
if(_image) close();
if(!in.good()) {
Error() << "TgaImporter: cannot read input stream";
@ -91,7 +91,7 @@ bool TgaImporter::open(istream& in) {
Math::Vector2<GLsizei> dimensions(header.width, header.height);
_image = new ImageData2D(dimensions, components, buffer);
_image = new ImageData2D(name, dimensions, components, buffer);
return true;
}

18
src/Plugins/TgaImporter/TgaImporter.h

@ -46,8 +46,22 @@ class TGAIMPORTER_EXPORT TgaImporter: public AbstractImporter {
inline Features features() const { return Feature::OpenFile|Feature::OpenStream; }
bool open(std::istream& in);
bool open(const std::string& filename);
/**
* @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, ""); }
/**
* @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 unsigned int image2DCount() const { return _image ? 1 : 0; }

Loading…
Cancel
Save