#include "Texture.h" #include "Image.h" using namespace Framework; // Contents of the Texture class // Constructor Texture::Texture(TextureDirection dir) : ReferenceCounter(), direction(dir) { bild = 0; lastGr = Point(0, 0); id = -1; changed = 0; } // Destructor Texture::~Texture() { if (bild) bild->release(); } // Sets a pointer to the image that contains the texture // b: The pointer to the image void Texture::setImageZ(Image* b) { if (bild != b) changed = 1; if (bild) bild->release(); bild = b; } // Sets the image that contains the texture by copying it // b: The image to be copied void Texture::setImage(Image* b) { if (!b) return; if (bild != b) changed = 1; if (!bild || bild->getWidth() != b->getWidth() || bild->getHeight() != b->getHeight()) { if (!bild) bild = new Image(); bild->newImage(b->getWidth(), b->getHeight(), 0); } bild->drawImage(0, 0, bild->getWidth(), bild->getHeight(), *b); b->release(); } // Returns a pointer to the image Image* Texture::getImage() const { return bild ? dynamic_cast(bild->getThis()) : 0; } // Returns a pointer to the image without increased reference counter Image* Texture::zImage() const { return bild; } // Returns the id of the texture if it was registered in a TextureList. // (see Framework::zTextureRegister()) int Texture::getId() const { return id; } TextureDirection Framework::Texture::getDirection() const { return direction; }