#include"Image2D.h" struct HalfImage { virtual void Process(void *,void *,const uint,const uint,const uint)=0; }; template struct HalfImageImple:public HalfImage { void Process(void *target,void *source,const uint width,const uint height,const uint channels) override { const uint line_length=width*channels; T *tp=(T *)target; T *sp0=(T *)source; T *sp1=sp0+channels; T *sp2=sp0+line_length; T *sp3=sp1+line_length; for(uint row=0;row;else if(type==PixelDataType::U16)hi=new HalfImageImple;else if(type==PixelDataType::U32)hi=new HalfImageImple;else if(type==PixelDataType::F32)hi=new HalfImageImple;else if(type==PixelDataType::F64)hi=new HalfImageImple;else return(nullptr); uint hw=width>>1; uint hh=height>>1; void *new_data=new uint8[hw*hh*channels]; hi->Process(new_data,data,width,height,channels); delete hi; return(new Image2D(hw,hh,channels,type,new_data)); }