Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef __SP_VIDEO_IMAGEBUFFER_H__
00009 #define __SP_VIDEO_IMAGEBUFFER_H__
00010
00011
00012 #include "Base/spStandard.hpp"
00013 #include "Base/spDimension.hpp"
00014 #include "Base/spImageManagement.hpp"
00015 #include "Base/spMath.hpp"
00016 #include "Base/spMaterialColor.hpp"
00017 #include "RenderSystem/spTextureFlags.hpp"
00018 #include "FileFormats/Image/spImageFormatInterfaces.hpp"
00019
00020
00021 namespace sp
00022 {
00023 namespace video
00024 {
00025
00026
00036 class SP_EXPORT ImageBuffer
00037 {
00038
00039 public:
00040
00041 virtual ~ImageBuffer();
00042
00043
00044
00046 dim::point2di getPixelCoord(const dim::point2df &Pos) const;
00047
00049 void setPixelColor(const s32 Pos, const color &Color);
00050 void setPixelColor(const dim::point2di &Pos, const color &Color);
00051 void setPixelColor(const dim::vector3di &Pos, const color &Color);
00052
00054 void setPixelVector(const s32 Pos, const dim::vector4df &Color);
00055 void setPixelVector(const dim::point2di &Pos, const dim::vector4df &Color);
00056 void setPixelVector(const dim::vector3di &Pos, const dim::vector4df &Color);
00057
00059 color getPixelColor(const s32 Pos) const;
00060 color getPixelColor(const dim::point2di &Pos) const;
00061 color getPixelColor(const dim::vector3di &Pos) const;
00062
00064 dim::vector4df getPixelVector(const s32 Pos) const;
00065 dim::vector4df getPixelVector(const dim::point2di &Pos) const;
00066 dim::vector4df getPixelVector(const dim::vector3di &Pos) const;
00067
00072 dim::vector4df getInterpolatedPixel(const dim::point2df &Pos) const;
00073
00075 void setBuffer(const void* ImageBuffer);
00076
00078 virtual bool isSizePOT() const;
00079
00081 virtual dim::size2di getSizePOT() const;
00082
00084 virtual void setSizePOT();
00085
00087 virtual void adjustFormatD3D();
00088
00089
00090
00095 virtual ImageBuffer* copy() const = 0;
00097 virtual void copy(const ImageBuffer* Other) = 0;
00098
00100 virtual bool setFormat(const EPixelFormats Format) = 0;
00102 virtual void setSize(const dim::size2di &Size) = 0;
00104 virtual bool setDepth(u32 Depth) = 0;
00105
00107 virtual void invertColors() = 0;
00109 virtual void flipColors() = 0;
00111 virtual void flipImageHorizontal() = 0;
00113 virtual void flipImageVertical() = 0;
00115 virtual void turnImage(const EImageTurnDegrees Degree) = 0;
00116
00118 virtual u32 getDataTypeSize() const = 0;
00119
00121 virtual void* getBuffer() = 0;
00122 virtual const void* getBuffer() const = 0;
00123
00125 virtual void setBuffer(const void* ImageBuffer, const dim::point2di &Pos, const dim::size2di &Size) = 0;
00126
00128 virtual void getBuffer(void* ImageBuffer, const dim::point2di &Pos, const dim::size2di &Size) const = 0;
00129
00138 virtual bool appendImageBuffer(const ImageBuffer* AdditionalBuffer, bool isAppendBottom = true) = 0;
00139
00147 virtual void setColorKey(const color &Color, u8 Tolerance = 0);
00149 virtual void setColorKey(const dim::point2di &Pos, u8 Alpha = 0, u8 Tolerance = 0);
00150 virtual void setColorKeyAlpha(const EAlphaBlendingTypes Mode = BLENDING_BRIGHT);
00151 virtual void setColorKeyMask(ImageBuffer* MaskImage, const EAlphaBlendingTypes Mode = BLENDING_BRIGHT);
00152
00154 virtual void grayToAlpha() = 0;
00155
00162 virtual void createBuffer(const void* InitBuffer = 0) = 0;
00164 virtual void deleteBuffer() = 0;
00165
00166
00167
00169 static u32 getFormatSize(const EPixelFormats Format);
00171 static bool hasAlphaChannel(const EPixelFormats Format);
00172
00173
00174
00175 inline EImageBufferTypes getType() const
00176 {
00177 return Type_;
00178 }
00179
00181 inline dim::size2di getSize() const
00182 {
00183 return Size_;
00184 }
00186 inline dim::vector3di getSizeVector() const
00187 {
00188 return dim::vector3di(Size_.Width, Size_.Height, Depth_);
00189 }
00191 inline u32 getPixelCount() const
00192 {
00193 return getSize().getArea() * Depth_;
00194 }
00196 inline u32 getPixelSize() const
00197 {
00198 return getFormatSize() * getDataTypeSize();
00199 }
00201 inline u32 getBufferSize() const
00202 {
00203 return getPixelCount() * getPixelSize();
00204 }
00209 inline u32 getDepth() const
00210 {
00211 return Depth_;
00212 }
00213
00215 inline EPixelFormats getFormat() const
00216 {
00217 return Format_;
00218 }
00220 inline u32 getFormatSize() const
00221 {
00222 return FormatSize_;
00223 }
00225 inline bool hasAlphaChannel() const
00226 {
00227 return ImageBuffer::hasAlphaChannel(Format_);
00228 }
00229
00231 inline color getColorKey() const
00232 {
00233 return ColorKey_;
00234 }
00235
00236 protected:
00237
00238 ImageBuffer(const EImageBufferTypes Type);
00239 ImageBuffer(const EImageBufferTypes Type, const EPixelFormats Format, const dim::size2di &Size, u32 Depth = 1);
00240
00241
00242
00244 bool copyBase(const ImageBuffer &Other);
00245
00246
00247
00248 EImageBufferTypes Type_;
00249
00250 EPixelFormats Format_;
00251 u32 FormatSize_;
00252
00253 dim::size2di Size_;
00254 u32 Depth_;
00255
00256 color ColorKey_;
00257
00258 };
00259
00260
00261 }
00262
00263 }
00264
00265
00266 #endif
00267
00268
00269
00270