From 53170e04377d46fc255b162f1cf1a537e7f8ef26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 25 Jan 2012 20:53:04 +0100 Subject: [PATCH] TGAImporter: adopted to Magnum changes, allow direct file opening. --- src/Plugins/TGAImporter/TGAImporter.cpp | 7 +++++++ src/Plugins/TGAImporter/TGAImporter.h | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Plugins/TGAImporter/TGAImporter.cpp b/src/Plugins/TGAImporter/TGAImporter.cpp index 7d1574f72..f38c5162f 100644 --- a/src/Plugins/TGAImporter/TGAImporter.cpp +++ b/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; diff --git a/src/Plugins/TGAImporter/TGAImporter.h b/src/Plugins/TGAImporter/TGAImporter.h index 40933ff48..80db81947 100644 --- a/src/Plugins/TGAImporter/TGAImporter.h +++ b/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; }