Loading a big image

jbd <[email protected]> Fri, 24 Jul 2009 10:00:17 +0000 (UTC)
Newsgroups gmane.comp.video.graphicsmagick.apis
Message-ID <[email protected]>
Hello,

i'm wondering if there is a way to an area of a big image without loading
everything from it ? I tried the Image::read(Geometry, filename) function but i
think i misunderstood it since it loads a thumbnail of the original image =)

Do you know if this is possible ? Here is some code using the previous read
function.

Sorry if i missed something in the documentation !

jb

=========
#include <Magick++.h>
#include <iostream>

int main(int argc, char* argv[])
{
    if (argc < 2) {
        std::cout << "usage: " << argv[0] << " image\n";
        return 1;
    }

    const unsigned int tile_size = 64;

    Magick::Image img;
    img.ping(argv[1]);
    Magick::Geometry geom = img.size();

    const unsigned int w = geom.width();
    const unsigned int h = geom.height();

    if (w/2 + tile_size >= geom.width() or h/2 + tile_size >= geom.height()) {
        std::cout << "Image is to small to extract a " << tile_size << "x" <<
tile_size << " tile\n";
        return 1;
    }

    img.read(Magick::Geometry(64, 64, geom.width()/2, geom.height()), argv[1]);
    img.write("output.png");
}

=========


------------------------------------------------------------------------------