void Image3unorm8::copyArray(const Color1* src, int w, int h) { resize(w, h); int N = w * h; Color3unorm8* dst = getCArray(); for (int i = 0; i < N; ++i) { dst[i].r = dst[i].g = dst[i].b = Color1unorm8(src[i]).value; } }
void Image1unorm8::copyArray(const Color4* src, int w, int h) { resize(w, h); int N = w * h; Color1unorm8* dst = getCArray(); for (int i = 0; i < N; ++i) { dst[i] = Color1unorm8(Color1(src[i].rgb().average())); } }
void Image1unorm8::copyArray(const Color1* src, int w, int h) { resize(w, h); int N = w * h; Color1unorm8* dst = getCArray(); for (int i = 0; i < N; ++i) { dst[i] = Color1unorm8(src[i]); } }
shared_ptr<class Image1unorm8> Image3unorm8::getChannel(int c) const { debugAssert(c >= 0 && c <= 2); shared_ptr<Image1unorm8> dst = Image1unorm8::createEmpty(width(), height(), wrapMode()); const Color3unorm8* srcArray = getCArray(); Color1unorm8* dstArray = dst->getCArray(); const int N = width() * height(); for (int i = 0; i < N; ++i) { dstArray[i] = Color1unorm8(srcArray[i][c]); } return dst; }
Image1unorm8::Image1unorm8(int w, int h, WrapMode wrap) : Map2D<Color1unorm8, Color1>(w, h, wrap) { setAll(Color1unorm8(unorm8::zero())); }