2 Copyright (C) 2001-2006, William Joseph.
5 This file is part of GtkRadiant.
7 GtkRadiant is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 GtkRadiant is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GtkRadiant; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #if !defined(INCLUDED_IMAGELIB_H)
23 #define INCLUDED_IMAGELIB_H
27 #include "idatastream.h"
32 unsigned char red, green, blue, alpha;
35 class RGBAImage : public Image
37 RGBAImage(const RGBAImage& other);
38 RGBAImage& operator=(const RGBAImage& other);
41 unsigned int width, height;
43 RGBAImage(unsigned int _width, unsigned int _height)
44 : pixels(new RGBAPixel[_width * _height]), width(_width), height(_height)
56 byte* getRGBAPixels() const
58 return reinterpret_cast<byte*>(pixels);
60 unsigned int getWidth() const
64 unsigned int getHeight() const
70 class RGBAImageFlags : public RGBAImage
76 RGBAImageFlags(unsigned short _width, unsigned short _height, int surfaceFlags, int contentFlags, int value) :
77 RGBAImage(_width, _height), m_surfaceFlags(surfaceFlags), m_contentFlags(contentFlags), m_value(value)
81 int getSurfaceFlags() const
83 return m_surfaceFlags;
85 int getContentFlags() const
87 return m_contentFlags;
96 inline InputStream::byte_type* ArchiveFile_loadBuffer(ArchiveFile& file, std::size_t& length)
98 InputStream::byte_type* buffer = (InputStream::byte_type*)malloc(file.size() + 1);
99 length = file.getInputStream().read(buffer, file.size());
100 buffer[file.size()] = 0;
104 inline void ArchiveFile_freeBuffer(InputStream::byte_type* buffer)
109 class ScopedArchiveBuffer
113 InputStream::byte_type* buffer;
115 ScopedArchiveBuffer(ArchiveFile& file)
117 buffer = ArchiveFile_loadBuffer(file, length);
119 ~ScopedArchiveBuffer()
121 ArchiveFile_freeBuffer(buffer);
125 class PointerInputStream : public InputStream
129 PointerInputStream(const byte* pointer)
133 std::size_t read(byte* buffer, std::size_t length)
135 const byte* end = m_read + length;
138 *buffer++ = *m_read++;
142 void seek(std::size_t offset)