Browse Source

TGAImporter: adopted to Magnum changes, allow direct file opening.

pull/34/head
Vladimír Vondruš 14 years ago
parent
commit
53170e0437
  1. 7
      src/Plugins/TGAImporter/TGAImporter.cpp
  2. 4
      src/Plugins/TGAImporter/TGAImporter.h

7
src/Plugins/TGAImporter/TGAImporter.cpp

@ -28,6 +28,13 @@ namespace Magnum { namespace Plugins { namespace TGAImporter {
static_assert(sizeof(TGAImporter::Header) == 18, "TGAImporter: header size is not 18 bytes");
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) {
if(_image) close();
if(!in.good()) return false;

4
src/Plugins/TGAImporter/TGAImporter.h

@ -28,10 +28,12 @@ namespace Magnum { namespace Plugins { namespace TGAImporter {
class TGAImporter: public AbstractImporter {
public:
TGAImporter(Corrade::PluginManager::AbstractPluginManager* manager = 0, const std::string& plugin = ""): AbstractImporter(manager, plugin) {}
inline virtual ~TGAImporter() { close(); }
inline int features() const { return OpenFile|OpenStream; }
bool open(std::istream& in);
bool open(const std::string& filename);
void close();
inline size_t image2DCount() const { return _image ? 1 : 0; }

Loading…
Cancel
Save