#ifndef HGL_2D_BITMAP_INCLUDE #define HGL_2D_BITMAP_INCLUDE #include #include namespace hgl { /** * 简单的2D象素处理 */ template class Bitmap { uint width,height; T *data; public: Bitmap() { data=nullptr; width=height=0; } ~Bitmap() { delete[] data; } bool Create(uint w,uint h) { if(!w||!h)return(false); if(data) { if(width==w&&height==h)return(true); } width=w; height=h; delete[] data; data=new T[width*height*CHANNELS]; return(true); } void Clear() { if(data) { delete[] data; data=nullptr; } width=height=0; } void ClearColor(T *color) { if(!data||!color)return; uint total=width*height; T *p=data; for(size_t i=0; i *outputs) { if(!data||!outputs) return(false); T *sp=data; AutoDeleteArray op=new T *[CHANNELS]; for(uint i=0;i *inputs) { if(!data||!inputs) return(false); T *dp=data; AutoDeleteArray ip=new T *[CHANNELS]; for(uint i=0;i=width||y>=height)return; T *p=data+(y*width+x)*CHANNELS; for(uint i=0;i=width||y>=height)return(false); T *p=data+(y*width+x)*CHANNELS; for(uint i=0;i class Bitmap using BitmapR8 =Bitmap; using BitmapR16 =Bitmap; using BitmapR32U =Bitmap; using BitmapR32F =Bitmap; using BitmapRG8 =Bitmap; using BitmapRG16 =Bitmap; using BitmapRG32U =Bitmap; using BitmapRG32F =Bitmap; using BitmapRGBA8 =Bitmap; using BitmapRGBA16 =Bitmap; using BitmapRGBA32U =Bitmap; using BitmapRGBA32F =Bitmap; }//namespace hgl #endif//HGL_2D_BITMAP_INCLUDE