Esempio n. 1
0
void Image3uint8::copyArray(const Color1* src, int w, int h) {
    resize(w, h);
    int N = w * h;

    Color3uint8* dst = getCArray();
    for (int i = 0; i < N; ++i) {
        dst[i].r = dst[i].g = dst[i].b = Color1uint8(src[i]).value;
    }
}
void Image1uint8::copyArray(const Color4* src, int w, int h) {
    resize(w, h);
    int N = w * h;

    Color1uint8* dst = getCArray();
    for (int i = 0; i < N; ++i) {
        dst[i] = Color1uint8(Color1(src[i].rgb().average()));
    }
}
void Image1uint8::copyArray(const Color1* src, int w, int h) {
    resize(w, h);
    int N = w * h;

    Color1uint8* dst = getCArray();
    for (int i = 0; i < N; ++i) {
        dst[i] = Color1uint8(src[i]);
    }
}
Esempio n. 4
0
/** Saves in any of the formats supported by G3D::GImage. */
void Image1::save(const std::string& filename, GImage::Format fmt) {
    GImage im(width(), height(), 1);

    int N = im.width() * im.height();
    Color1uint8* dst = im.pixel1();
    for (int i = 0; i < N; ++i) {
        dst[i] = Color1uint8(data[i]);
    }
    
    im.save(filename, fmt);
}
ReferenceCountedPointer<class Image1uint8> Image4uint8::getChannel(int c) const {
    debugAssert(c >= 0 && c <= 3);

    Image1uint8Ref dst = Image1uint8::createEmpty(width(), height(), wrapMode());
    const Color4uint8* srcArray = getCArray();
    Color1uint8* dstArray = dst->getCArray();

    const int N = width() * height();
    for (int i = 0; i < N; ++i) {
        dstArray[i] = Color1uint8(srcArray[i][c]);
    }

    return dst;
}
Image1uint8::Image1uint8(int w, int h, WrapMode wrap) : Map2D<Color1uint8, Color1>(w, h, wrap) {
    setAll(Color1uint8(0));
}