45 width(mipMap.width), height(mipMap.height), size(mipMap.size), image(i) {
61 data.swap(right.
data);
65 getPixel(y * width + x, r, g, b, a);
69 assert(n < (
int)size);
73 r = data[n * 3 + 0] / 255.0f;
74 g = data[n * 3 + 1] / 255.0f;
75 b = data[n * 3 + 2] / 255.0f;
78 r = data[n * 3 + 2] / 255.0f;
79 g = data[n * 3 + 1] / 255.0f;
80 b = data[n * 3 + 0] / 255.0f;
83 r = data[n * 4 + 0] / 255.0f;
84 g = data[n * 4 + 1] / 255.0f;
85 b = data[n * 4 + 2] / 255.0f;
86 a = data[n * 4 + 3] / 255.0f;
88 r = data[n * 4 + 2] / 255.0f;
89 g = data[n * 4 + 1] / 255.0f;
90 b = data[n * 4 + 0] / 255.0f;
91 a = data[n * 4 + 3] / 255.0f;
93 throw Common::Exception(
"ImageDecoder::MipMap::getPixel(): Unsupported pixel format %d",
98 getPixel(y * width + x, r, g, b, a);
102 assert(n < (
int)size);
106 data[n * 3 + 0] =
CLIP(r, 0.0f, 1.0f) * 255.0f;
107 data[n * 3 + 1] =
CLIP(g, 0.0f, 1.0f) * 255.0f;
108 data[n * 3 + 2] =
CLIP(b, 0.0f, 1.0f) * 255.0f;
110 data[n * 3 + 2] =
CLIP(r, 0.0f, 1.0f) * 255.0f;
111 data[n * 3 + 1] =
CLIP(g, 0.0f, 1.0f) * 255.0f;
112 data[n * 3 + 0] =
CLIP(b, 0.0f, 1.0f) * 255.0f;
114 data[n * 4 + 0] =
CLIP(r, 0.0f, 1.0f) * 255.0f;
115 data[n * 4 + 1] =
CLIP(g, 0.0f, 1.0f) * 255.0f;
116 data[n * 4 + 2] =
CLIP(b, 0.0f, 1.0f) * 255.0f;
117 data[n * 4 + 3] =
CLIP(a, 0.0f, 1.0f) * 255.0f;
119 data[n * 4 + 2] =
CLIP(r, 0.0f, 1.0f) * 255.0f;
120 data[n * 4 + 1] =
CLIP(g, 0.0f, 1.0f) * 255.0f;
121 data[n * 4 + 0] =
CLIP(b, 0.0f, 1.0f) * 255.0f;
122 data[n * 4 + 3] =
CLIP(a, 0.0f, 1.0f) * 255.0f;
124 throw Common::Exception(
"ImageDecoder::MipMap::setPixel(): Unsupported pixel format %d",
158 for (MipMaps::const_iterator m = image.
_mipMaps.begin(); m != image.
_mipMaps.end(); ++m)
247 MipMap decompressed(
this);
251 decompressed.
swap(**m);
PixelFormat getFormat() const
Return the image data's general format.
Generic image decoder interface.
The global graphics manager.
void getPixel(int x, int y, float &r, float &g, float &b, float &a) const
Get the color values of the pixel at this position.
A class holding an UTF-8 string.
void reset(PointerType o=0)
Resets the pointer with the new value.
A simple TGA image dumper.
static bool hasValidDimensions(PixelFormatRaw format, int32 width, int32 height)
Are these image dimensions valid for this format?
MipMap(const ImageDecoder *i=0)
Common::ScopedArray< byte > data
The mip map's data.
bool _isCubeMap
Is this image a cube map? A cube map always needs to have 6 layers!
Implementing the reading stream interfaces for plain memory blocks.
const TXI & getTXI() const
Return the texture information TXI, which may be embedded in the image.
bool isCubeMap() const
Is this image a cube map?
size_t getLayerCount() const
Return the number of layers contained in the image.
int height
The mip map's height.
A simple scoped smart pointer template.
void decompress()
Manually decompress the texture image data.
bool dumpTGA(const Common::UString &fileName) const
Dump the image into a TGA.
void dumpTGA(const Common::UString &fileName, const ImageDecoder *image)
Dump image into a TGA file.
Basic exceptions to throw.
void decompressDXT3(byte *dest, Common::SeekableReadStream &src, uint32 width, uint32 height, uint32 pitch)
Utility templates and functions.
void setPixel(int x, int y, float r, float g, float b, float a)
Set the color values of the pixel at this position.
void decompressDXT1(byte *dest, Common::SeekableReadStream &src, uint32 width, uint32 height, uint32 pitch)
size_t _layerCount
Number of layers in this image.
PixelFormatRaw getFormatRaw() const
Return the image data's raw format.
PixelFormatRaw _formatRaw
void decompressDXT5(byte *dest, Common::SeekableReadStream &src, uint32 width, uint32 height, uint32 pitch)
const MipMap & getMipMap(size_t mipMap, size_t layer=0) const
Return a mip map.
Simple memory based 'stream', which implements the ReadStream interface for a plain memory block...
Image related utility functions.
A scoped plain pointer, allowing pointer-y access and normal deletion.
const ImageDecoder * image
The image the mip map belongs to.
PixelDataType getDataType() const
Return the image data pixel's type.
PointerType get() const
Returns the plain pointer value.
int width
The mip map's width.
ImageDecoder & operator=(const ImageDecoder &image)
Manual S3TC DXTn decompression methods.
A generic interface for image decoders.
size_t getMipMapCount() const
Return the number of mip maps contained in the image.
T CLIP(T v, T amin, T amax)
uint32 size
The mip map's size in bytes.
bool hasAlpha() const
Does the image data have alpha? .
bool isCompressed() const
Is the image data compressed?
void SWAP(T &a, T &b)
Template method which swaps the values of its two parameters.