#ifndef __C_IMAGE_H_INCLUDED__
#define __C_IMAGE_H_INCLUDED__
#include "IImage.h"
#include "rect.h"
namespace irr
{
namespace video
{
class CImage : public IImage
{
public:
CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size,
void* data, bool ownForeignMemory=true, bool deleteMemory = true);
CImage(ECOLOR_FORMAT format, const core::dimension2d<u32>& size);
virtual ~CImage();
virtual void* lock()
{
return Data;
}
virtual void unlock() {}
virtual const core::dimension2d<u32>& getDimension() const;
virtual u32 getBitsPerPixel() const;
virtual u32 getBytesPerPixel() const;
virtual u32 getImageDataSizeInBytes() const;
virtual u32 getImageDataSizeInPixels() const;
virtual u32 getRedMask() const;
virtual u32 getGreenMask() const;
virtual u32 getBlueMask() const;
virtual u32 getAlphaMask() const;
virtual SColor getPixel(u32 x, u32 y) const;
virtual void setPixel(u32 x, u32 y, const SColor &color, bool blend = false );
virtual ECOLOR_FORMAT getColorFormat() const;
virtual u32 getPitch() const { return Pitch; }
virtual void copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT format, u32 pitch=0);
virtual void copyToScaling(IImage* target);
virtual void copyTo(IImage* target, const core::position2d<s32>& pos=core::position2d<s32>(0,0));
virtual void copyTo(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect=0);
virtual void copyToWithAlpha(IImage* target, const core::position2d<s32>& pos,
const core::rect<s32>& sourceRect, const SColor &color,
const core::rect<s32>* clipRect = 0);
virtual void copyToScalingBoxFilter(IImage* target, s32 bias = 0, bool blend = false);
virtual void fill(const SColor &color);
void drawRectangle(const core::rect<s32>& rect, const SColor &color);
void drawLine(const core::position2d<s32>& from, const core::position2d<s32>& to, const SColor &color);
private:
void initData();
inline SColor getPixelBox ( s32 x, s32 y, s32 fx, s32 fy, s32 bias ) const;
u8* Data;
core::dimension2d<u32> Size;
u32 BytesPerPixel;
u32 Pitch;
ECOLOR_FORMAT Format;
bool DeleteMemory;
};
}
}
#endif