Skip to content

Commit

Permalink
GRAPHICS: Reintroduce dumpTGA for textures
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Jan 21, 2014
1 parent 97eeec2 commit 0330701
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/engines/aurora/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#include "../../aurora/gfffile.h"
#include "../../aurora/2dafile.h"

#include "graphics/textureman.h"

#include "sound/sound.h"

#include "video/aurora/videoplayer.h"
Expand Down Expand Up @@ -188,7 +190,7 @@ bool dumpResource(const Common::UString &name, const Common::UString &file) {
}

bool dumpTGA(const Common::UString &name) {
return false;
return TextureMan.dumpTGA(name, name + ".tga");
}

bool dump2DA(const Common::UString &name) {
Expand Down
39 changes: 33 additions & 6 deletions src/graphics/textureman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ Ogre::TexturePtr TextureManager::get(const Common::UString &name) {
return texture;
}

Ogre::TexturePtr TextureManager::create(const Common::UString &name) {
ImageDecoder *TextureManager::createImage(const Common::UString &name) {
// Get the image resource
::Aurora::FileType type;
Common::SeekableReadStream *img = ResMan.getResource(::Aurora::kResourceImage, name, &type);
Expand All @@ -201,8 +201,6 @@ Ogre::TexturePtr TextureManager::create(const Common::UString &name) {
ImageDecoder *image = 0;
WinIconImage *cursor = 0;

Ogre::TexturePtr texture((Ogre::Texture *) 0);

// Load the different image formats
try {
if (type == ::Aurora::kFileTypeTGA)
Expand Down Expand Up @@ -234,8 +232,6 @@ Ogre::TexturePtr TextureManager::create(const Common::UString &name) {
if (GfxMan.needManualDeS3TC())
image->decompress();

texture = create(name, *image);

} catch (...) {
delete img;
delete image;
Expand All @@ -245,9 +241,24 @@ Ogre::TexturePtr TextureManager::create(const Common::UString &name) {
}

delete img;
delete image;
delete cursor;

return image;
}

Ogre::TexturePtr TextureManager::create(const Common::UString &name) {
ImageDecoder *image = 0;
Ogre::TexturePtr texture((Ogre::Texture *) 0);

try {
image = createImage(name);
texture = create(name, *image);
} catch (...) {
delete image;
throw;
}

delete image;
return texture;
}

Expand Down Expand Up @@ -325,4 +336,20 @@ void TextureManager::convert(Ogre::TexturePtr &texture, const ImageDecoder &imag
}
}

bool TextureManager::dumpTGA(const Common::UString &name, const Common::UString &fileName) {
ImageDecoder *image = 0;

try {
image = createImage(name);
image->dumpTGA(fileName);
} catch (Common::Exception &e) {
delete image;
printException(e, "WARNING: ");
return false;
}

delete image;
return true;
}

} // End of namespace Graphics
5 changes: 5 additions & 0 deletions src/graphics/textureman.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ class TextureManager : public Common::Singleton<TextureManager> {
/** Get the properties of a texture. */
const TextureProperties &getProperties(const Ogre::TexturePtr &texture);

/** Dump a texture into a TGA file. */
bool dumpTGA(const Common::UString &name, const Common::UString &fileName);

private:
typedef std::map<Common::UString, TextureProperties *> Properties;

Expand All @@ -96,6 +99,8 @@ class TextureManager : public Common::Singleton<TextureManager> {
Ogre::TexturePtr create(const Common::UString &name);
Ogre::TexturePtr create(const Common::UString &name, const ImageDecoder &image);

ImageDecoder *createImage(const Common::UString &name);

void convert(Ogre::TexturePtr &texture, const ImageDecoder &image, int mipMaps);
};

Expand Down

0 comments on commit 0330701

Please sign in to comment.