Dear all,

I'm writing a software that creates blocks using vil. However, I can´t get tha last block. For example in a 1024 x 768 image, using block size 204x173, I´ll have 6 blocks in
horizontal line (five with lenght 204 and one with lenght 4). How do I get this last block?

my code:

BlockedImage LoadBlockedImage::getBlock(int positionInColumn, int positionRow) {
   
    BlockedImage imageReturned;

    vil_image_view<vil_rgb<vxl_byte> > img = this->imageBlocked->get_block( positionInColumn,positionRow);
   
    imageReturned.width = img.ni();
    imageReturned.height = img.nj();
    imageReturned.r = new Byte[imageReturned.width * imageReturned.height];
    imageReturned.g = new Byte[imageReturned.width * imageReturned.height];
    imageReturned.b = new Byte[imageReturned.width * imageReturned.height ];
        
    for ( unsigned int j = 0, k = 0; j < img.nj(); ++j) {
        for ( unsigned int i = 0; i < img.ni(); ++i, k++){            
            imageReturned.r[k] = img(i,j).r;
            imageReturned.g [k] = img(i,j).g;
            imageReturned.b[k] = img(i,j).b;            
        }
    }
   
    return imageReturned;
}

BlockedImage is a simple struct.

Thanks in advance
Best Regards

--
Arthur Gonçalves