diff -Naurw Irrlicht/CImageLoaderRAWAlphaMap.cpp Irrlicht/CImageLoaderRAWAlphaMap.cpp --- Irrlicht/CImageLoaderRAWAlphaMap.cpp 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/CImageLoaderRAWAlphaMap.cpp 2005-11-23 15:11:12.000000000 +0100 @@ -0,0 +1,125 @@ +// Copyright (C) 2002-2005 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CImageLoaderRAWAlphaMap.h" +#include +#include "SColor.h" +#include "CColorConverter.h" +#include "CImage.h" +#include "os.h" +#include + +namespace irr +{ +namespace video +{ + //! constructor + CImageLoaderRAWAlphaMap::CImageLoaderRAWAlphaMap() : Data(0), Height(64), Width(64), BPP(8) + { +#ifdef _DEBUG + setDebugName("CImageLoaderRAWAlphaMap"); +#endif + } + + CImageLoaderRAWAlphaMap::CImageLoaderRAWAlphaMap( s32 height, s32 width, u8 bpp ) + : Data(0), Height(height), Width(width), BPP(bpp) + { +#ifdef _DEBUG + setDebugName("CImageLoaderRAWAlphaMap"); +#endif + } + + //! destructor + CImageLoaderRAWAlphaMap::~CImageLoaderRAWAlphaMap() + { + if( Data ) + delete [] Data; + } + + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".tga") + bool CImageLoaderRAWAlphaMap::isALoadableFileExtension(const c8* fileName) + { + return strstr(fileName, ".raw") != 0; + } + + + + //! returns true if the file maybe is able to be loaded by this class + bool CImageLoaderRAWAlphaMap::isALoadableFileFormat(irr::io::IReadFile* file) + { + return true; + } + + + //! creates a surface from the file + IImage* CImageLoaderRAWAlphaMap::loadImage( irr::io::IReadFile* file ) + { + file->seek(0); + Data = new c8[file->getSize()]; + file->read( Data, file->getSize() ); + + // create surface + IImage* image = 0; + + video::SColor color; + core::dimension2d size; + + switch( BPP ) + { + case 1: + //image = new CImage(ECF_A1R5G5B5, core::dimension2d(header.Width, header.Height)); + //CColorConverter::convert1BitTo16BitFlipMirror(Data, (s16*)image->lock(), header.Width, header.Height, pitch); + //image->unlock(); + break; + case 4: + //image = new CImage(ECF_A1R5G5B5, core::dimension2d(header.Width, header.Height)); + //CColorConverter::convert4BitTo16BitFlipMirror(Data, (s16*)image->lock(), header.Width, header.Height, pitch, PaletteData); + //image->unlock(); + break; + case 8: + image = new CImage( video::ECF_A8R8G8B8, core::dimension2d(512,512) ); + CColorConverter::convert8BitTo32BitFlipMirror( Data, (s32*)image->lock(), 512, 512 ); + //CColorConverter::convert8BitTo32Bit( Data, (s32*)image->lock(), 512, 512 ); + image->unlock(); + size = image->getDimension(); + for( s32 x=0; x < size.Width; ++x ) + { + for( s32 y=0; y < size.Height; ++y ) + { + color = image->getPixel( x, y ); + } + } + break; + case 16: + break; + case 24: + //image = new CImage(ECF_R8G8B8, core::dimension2d(header.Width, header.Height)); + //CColorConverter::convert24BitTo24BitFlipMirrorColorShuffle(Data, (c8*)image->lock(), header.Width, header.Height, pitch); + //image->unlock(); + break; + case 32: // thx to Reinhard Ostermeier + //image = new CImage(ECF_A8R8G8B8, core::dimension2d(header.Width, header.Height)); + //CColorConverter::convert32BitTo32BitFlipMirror((s32*)BmpData, (s32*)image->lock(), header.Width, header.Height, pitch); + //image->unlock(); + break; + }; + + // clean up + delete [] Data; + Data = 0; + + return image; + } + + + //! creates a loader which is able to load windows bitmaps + IImageLoader* createImageLoaderRAWAlphaMap( s32 height, s32 width, u8 bpp ) + { + return new CImageLoaderRAWAlphaMap( height, width, bpp ); + } + +} // end namespace video +} // end namespace irr diff -Naurw Irrlicht/CImageLoaderRAWAlphaMap.h Irrlicht/CImageLoaderRAWAlphaMap.h --- Irrlicht/CImageLoaderRAWAlphaMap.h 1970-01-01 01:00:00.000000000 +0100 +++ Irrlicht/CImageLoaderRAWAlphaMap.h 2005-11-19 12:43:28.000000000 +0100 @@ -0,0 +1,53 @@ +// Copyright (C) 2002-2005 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#ifndef __C_IMAGE_LOADER_RAW_ALPHA_MAP_H_INCLUDED__ +#define __C_IMAGE_LOADER_RAW_ALPHA_MAP_H_INCLUDED__ + +#include "IImageLoader.h" + +namespace irr +{ +namespace video +{ +/*! + Surface Loader fow RAW format Alpha Maps +*/ +class CImageLoaderRAWAlphaMap : public IImageLoader +{ +public: + + //! constructor + CImageLoaderRAWAlphaMap(); + + CImageLoaderRAWAlphaMap( s32 height, s32 width, u8 bpp ); + + //! destructor + virtual ~CImageLoaderRAWAlphaMap(); + + //! returns true if the file maybe is able to be loaded by this class + //! based on the file extension (e.g. ".tga") + virtual bool isALoadableFileExtension(const c8* fileName); + + //! returns true if the file maybe is able to be loaded by this class + virtual bool isALoadableFileFormat(irr::io::IReadFile* file); + + //! creates a surface from the file + virtual IImage* loadImage(irr::io::IReadFile* file); + +private: + s32 Height; + s32 Width; + u8 BPP; + c8* Data; + +}; + + +} // end namespace video +} // end namespace irr + + +#endif + diff -Naurw Irrlicht/CNullDriver.cpp Irrlicht/CNullDriver.cpp --- Irrlicht/CNullDriver.cpp 2005-08-29 10:18:54.000000000 +0200 +++ Irrlicht/CNullDriver.cpp 2005-11-19 12:41:54.000000000 +0100 @@ -27,13 +27,15 @@ IImageLoader* createImageLoaderPCX(); //! creates a loader which is able to load png images IImageLoader* createImageLoaderPNG(); - +//! creates a loader which is able to load RAW alpha map images +IImageLoader* createImageLoaderRAWAlphaMap( s32 RAWWidth, s32 RAWHeight, u8 RAWbpp ); //! constructor CNullDriver::CNullDriver(io::IFileSystem* io, const core::dimension2d& screenSize) : ScreenSize(screenSize), ViewPort(0,0,0,0), - FileSystem(io), PrimitivesDrawn(0), TextureCreationFlags(0) + FileSystem(io), PrimitivesDrawn(0), TextureCreationFlags(0), RAWWidth(64), RAWHeight(64), RAWbpp(8) + { #ifdef _DEBUG setDebugName("CNullDriver"); @@ -49,14 +51,14 @@ if (FileSystem) FileSystem->grab(); - // create surface loader - + // create surface loaders SurfaceLoader.push_back(video::createImageLoaderBmp()); SurfaceLoader.push_back(video::createImageLoaderJPG()); SurfaceLoader.push_back(video::createImageLoaderTGA()); SurfaceLoader.push_back(video::createImageLoaderPSD()); SurfaceLoader.push_back(video::createImageLoaderPCX()); SurfaceLoader.push_back(video::createImageLoaderPNG()); + SurfaceLoader.push_back(video::createImageLoaderRAWAlphaMap( RAWWidth, RAWHeight, RAWbpp )); // set ExposedData to 0 memset(&ExposedData, 0, sizeof(ExposedData)); @@ -1007,6 +985,14 @@ } +//! Sets the parameters for loading RAW image formats +void CNullDriver::setRAWImagerLoaderParams( s32 width, s32 height, u8 bpp ) +{ + RAWWidth = width; + RAWHeight = height; + RAWbpp = bpp; +} + //! Sets the fog mode. void CNullDriver::setFog(SColor color, bool linearFog, f32 start, f32 end, f32 density, bool pixelFog, bool rangeFog) diff -Naurw Irrlicht/CNullDriver.h Irrlicht/CNullDriver.h --- Irrlicht/CNullDriver.h 2005-08-29 10:18:10.000000000 +0200 +++ Irrlicht/CNullDriver.h 2005-11-19 12:39:48.000000000 +0100 @@ -242,6 +230,9 @@ virtual IImage* createImageFromData(ECOLOR_FORMAT format, const core::dimension2d& size, void *data, bool ownForeignMemory=true); + //! Sets the parameters for loading RAW image formats + virtual void setRAWImagerLoaderParams( s32 width, s32 height, u8 bpp ); + //! Draws a mesh buffer virtual void drawMeshBuffer(scene::IMeshBuffer* mb); @@ -417,6 +408,10 @@ SColor FogColor; SExposedVideoData ExposedData; + + s32 RAWWidth; + s32 RAWHeight; + u8 RAWbpp; }; } // end namespace video diff -Naurw Irrlicht/include/IVideoDriver.h Irrlicht/include/IVideoDriver.h --- Irrlicht/include/IVideoDriver.h 2005-08-29 10:19:52.000000000 +0200 +++ Irrlicht/include/IVideoDriver.h 2005-11-19 12:39:30.000000000 +0100 @@ -744,6 +695,14 @@ const core::dimension2d& size, void *data, bool ownForeignMemory=false) = 0; + //! Sets the parameters for loading RAW image formats + /** + \param width: width of the data + \param height: height of the data + \param bpp: Bits per pixel of the data + */ + virtual void setRAWImagerLoaderParams( s32 width, s32 height, u8 bpp ) = 0; + //! Only used by the internal engine. /** Used to notify the driver that the window was resized. Usually, there is no need to call this method. */