Irrlicht 3D Engine
IImage.h
Go to the documentation of this file.
00001 // Copyright (C) 2002-2012 Nikolaus Gebhardt
00002 // This file is part of the "Irrlicht Engine".
00003 // For conditions of distribution and use, see copyright notice in irrlicht.h
00004 
00005 #ifndef __I_IMAGE_H_INCLUDED__
00006 #define __I_IMAGE_H_INCLUDED__
00007 
00008 #include "IReferenceCounted.h"
00009 #include "position2d.h"
00010 #include "rect.h"
00011 #include "SColor.h"
00012 
00013 namespace irr
00014 {
00015 namespace video
00016 {
00017 
00019 
00022 class IImage : public virtual IReferenceCounted
00023 {
00024 public:
00025 
00027 
00032     virtual void* lock() = 0;
00033 
00035 
00037     virtual void unlock() = 0;
00038 
00040     virtual const core::dimension2d<u32>& getDimension() const = 0;
00041 
00043     virtual u32 getBitsPerPixel() const = 0;
00044 
00046     virtual u32 getBytesPerPixel() const = 0;
00047 
00049     virtual u32 getImageDataSizeInBytes() const = 0;
00050 
00052     virtual u32 getImageDataSizeInPixels() const = 0;
00053 
00055     virtual SColor getPixel(u32 x, u32 y) const = 0;
00056 
00058     virtual void setPixel(u32 x, u32 y, const SColor &color, bool blend = false ) = 0;
00059 
00061     virtual ECOLOR_FORMAT getColorFormat() const = 0;
00062 
00064     virtual u32 getRedMask() const = 0;
00065 
00067     virtual u32 getGreenMask() const = 0;
00068 
00070     virtual u32 getBlueMask() const = 0;
00071 
00073     virtual u32 getAlphaMask() const = 0;
00074 
00076     virtual u32 getPitch() const =0;
00077 
00079     virtual void copyToScaling(void* target, u32 width, u32 height, ECOLOR_FORMAT format=ECF_A8R8G8B8, u32 pitch=0) =0;
00080 
00082     virtual void copyToScaling(IImage* target) =0;
00083 
00085     virtual void copyTo(IImage* target, const core::position2d<s32>& pos=core::position2d<s32>(0,0)) =0;
00086 
00088     virtual void copyTo(IImage* target, const core::position2d<s32>& pos, const core::rect<s32>& sourceRect, const core::rect<s32>* clipRect=0) =0;
00089 
00091     virtual void copyToWithAlpha(IImage* target, const core::position2d<s32>& pos,
00092             const core::rect<s32>& sourceRect, const SColor &color,
00093             const core::rect<s32>* clipRect = 0) =0;
00094 
00096     virtual void copyToScalingBoxFilter(IImage* target, s32 bias = 0, bool blend = false) = 0;
00097 
00099     virtual void fill(const SColor &color) =0;
00100 
00102     static u32 getBitsPerPixelFromFormat(const ECOLOR_FORMAT format)
00103     {
00104         switch(format)
00105         {
00106         case ECF_A1R5G5B5:
00107             return 16;
00108         case ECF_R5G6B5:
00109             return 16;
00110         case ECF_R8G8B8:
00111             return 24;
00112         case ECF_A8R8G8B8:
00113             return 32;
00114         case ECF_R16F:
00115             return 16;
00116         case ECF_G16R16F:
00117             return 32;
00118         case ECF_A16B16G16R16F:
00119             return 64;
00120         case ECF_R32F:
00121             return 32;
00122         case ECF_G32R32F:
00123             return 64;
00124         case ECF_A32B32G32R32F:
00125             return 128;
00126         default:
00127             return 0;
00128         }
00129     }
00130 
00132 
00135     static bool isRenderTargetOnlyFormat(const ECOLOR_FORMAT format)
00136     {
00137         switch(format)
00138         {
00139             case ECF_A1R5G5B5:
00140             case ECF_R5G6B5:
00141             case ECF_R8G8B8:
00142             case ECF_A8R8G8B8:
00143                 return false;
00144             default:
00145                 return true;
00146         }
00147     }
00148 
00149 };
00150 
00151 } // end namespace video
00152 } // end namespace irr
00153 
00154 #endif
00155