21 Magick Image select_block Magick Image src TBlock tag 22 Magick Ima

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
21 Magick::Image *select_block(Magick::Image &src, TBlock &tag) {
22 Magick::Image *res = new Magick::Image(Magick::Geometry(tag.size.x,tag.size.y) ,Magick::Color("black"));
23 res->modifyImage();
24 res->type(Magick::TrueColorType);
25 Magick::Pixels resPx(*res), srcPx(src);
26 Magick::PixelPacket *resPxP = resPx.get(0,0,tag.size.x,tag.size.y);
27 Magick::PixelPacket *srcPxP = srcPx.get(tag.margin.x-1,tag.margin.y-1,tag.size .x,tag.size.y);
28 for (int i=0; i < tag.size.x*tag.size.y; i++)
29 *(resPxP++) = *(srcPxP++);
30 resPx.sync();
31 #ifdef _DEBUG
32 std::cerr << "I [select_block]: selected rows " << res->rows()
33 << " cols " << res->columns() << std::endl;
34 #endif
35 return res;
36 }