my last posting was 2013, where I successfully integrated ImageMagick for reading and writing 16-bit gray image files in my C++ software. Now I am working on a completely new version from scratch on. For some reason, I fail doing even the simplest things with ImageMagick and I don't know what happens. Any help would be much appreciated. Currently I am working with ImageMagick 7.0.7-0 Q16 x86_64 on a Mac.
Please have a look on this code (stripped down without error detection and other things, hopefully I introduced no issues doing this):
Code: Select all
Magick::Image img;
img.read("Mars_gray.tif");
Magick::Pixels view(img);
const uint16_t* pixels = view.getConst(0,0,img.columns(), img.rows());
for (int i=0; i<20; ++i)
{
std::cout << i << ": " << (int)pixels[i] << " " << (int)pixels[i]/256 << std::endl;
}
Code: Select all
0: 50432 197
1: 18245 71
2: 50432 197
3: 18245 71
4: 50176 196
5: 18244 71
6: 50432 197
7: 18245 71
8: 50688 198
9: 18246 71
10: 50944 199
11: 18247 71
12: 51200 200
13: 18248 71
14: 51200 200
15: 18248 71
16: 50944 199
17: 18247 71
18: 50432 197
19: 18245 71
197, 197, 196, 197, 198, 199, 200, 200, 199, 197
Each of them is represented by a 2-byte-value, as expected. What the hell are the other two bytes (18245) following each pixel value?
You can download this image here: Mars_gray.tif. I created it for testing purposes and it is a special case, since I identify says
Code: Select all
Depth: 16/8-bit
Channel depth:
Gray: 8-bit
Code: Select all
Depth: 16-bit
Channel depth:
Gray: 16-bit
Best regards,
Stefan