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 ){
53 byte* getRGBAPixels() const {
54 return reinterpret_cast<byte*>( pixels );
56 unsigned int getWidth() const {
59 unsigned int getHeight() const {
64 class RGBAImageFlags : public RGBAImage
70 RGBAImageFlags( unsigned short _width, unsigned short _height, int surfaceFlags, int contentFlags, int value ) :
71 RGBAImage( _width, _height ), m_surfaceFlags( surfaceFlags ), m_contentFlags( contentFlags ), m_value( value ){
74 int getSurfaceFlags() const {
75 return m_surfaceFlags;
77 int getContentFlags() const {
78 return m_contentFlags;
80 int getValue() const {
86 inline InputStream::byte_type* ArchiveFile_loadBuffer( ArchiveFile& file, std::size_t& length ){
87 InputStream::byte_type* buffer = (InputStream::byte_type*)malloc( file.size() + 1 );
88 length = file.getInputStream().read( buffer, file.size() );
89 buffer[file.size()] = 0;
93 inline void ArchiveFile_freeBuffer( InputStream::byte_type* buffer ){
97 class ScopedArchiveBuffer
101 InputStream::byte_type* buffer;
103 ScopedArchiveBuffer( ArchiveFile& file ){
104 buffer = ArchiveFile_loadBuffer( file, length );
106 ~ScopedArchiveBuffer(){
107 ArchiveFile_freeBuffer( buffer );
111 class PointerInputStream : public InputStream
115 PointerInputStream( const byte* pointer )
118 std::size_t read( byte* buffer, std::size_t length ){
119 const byte* end = m_read + length;
120 while ( m_read != end )
122 *buffer++ = *m_read++;
126 void seek( std::size_t offset ){