bool Texture::reload() { if (_name.empty()) return false; ::Aurora::FileType type = ::Aurora::kFileTypeNone; ImageDecoder *image = 0; TXI *txi = 0; try { txi = loadTXI (_name); image = loadImage(_name, type, txi); } catch (Common::Exception &e) { delete txi; e.add("Failed to reload texture \"%s\" (%d)", _name.c_str(), type); throw; } removeFromQueues(); set(_name, image, type, txi); addToQueues(); return true; }
void PLTFile::load(Common::SeekableReadStream &plt) { // --- PLT header --- AuroraBase::readHeader(plt); if (_id != kPLTID) throw Common::Exception("Not a PLT file (%s)", Common::debugTag(_id).c_str()); if (_version != kVersion1) throw Common::Exception("Unsupported PLT file version %s", Common::debugTag(_version).c_str()); const uint32 layers = plt.readUint32LE(); if (layers > kLayerMAX) throw Common::Exception("Too many layers (%d)", layers); plt.skip(4); // Unknown const uint32 width = plt.readUint32LE(); const uint32 height = plt.readUint32LE(); if ((plt.size() - plt.pos()) < (int32) (2 * width * height)) throw Common::Exception("Not enough data"); // --- PLT layer data --- uint32 size = width * height; _dataImage = new uint8[size]; _dataLayers = new uint8[size]; uint8 *image = _dataImage; uint8 *layer = _dataLayers; while (size-- > 0) { *image++ = plt.readByte(); *layer++ = MIN<uint8>(plt.readByte(), kLayerMAX - 1); } // --- Create the actual texture surface --- // Initialize it to pink, for high debug visibility _surface = new Surface(width, height); _surface->fill(0xFF, 0x00, 0xFF, 0xFF); set(_name, _surface, ::Aurora::kFileTypePLT, 0); addToQueues(); }
Texture::Texture(const Common::UString &name, ImageDecoder *image, ::Aurora::FileType type, TXI *txi) : _name(name), _type(type), _image(0), _txi(0), _width(0), _height(0) { set(name, image, type, txi); addToQueues(); }
void Texture::refresh() { removeFromQueues(); addToQueues(); }