I am using ImageMagick-7.0.2-Q8 on Windows 10 64-bit using VS2013 Pro (Version 12.0.40629.00 Update 5)
With the original code fragment I posted there is no final image as the exception was thrown and the image was not written to disk.
Here is the code that generates the barcode and writes it to disk:
Code: Select all
// Read the image (quietly ignore any warnings, but not errors.)
Magick::Image Im(Magick::Geometry(BARCODE_WIDTH, BARCODE_HEIGHT), Magick::Color("white"));
Im.colorSpace(Magick::GRAYColorspace);
Im.font("CODE3X");
Im.fontPointsize(48.0);
Im.draw(Magick::DrawableText(20, 80, "*Barcode Test*"));
Im.magick("PNG");
Im.write("barcode.png");
Here is a link to the barcode image that the previous code fragment generates:
https://www.dropbox.com/sh/sb7ma8mh5552 ... L3uDa?dl=0
Here is a link to the image.tif file used below:
https://www.dropbox.com/s/3hu28uo4hd7hy ... e.tif?dl=0
As an interesting side note, I also tried the following:
Code: Select all
Magick::InitializeMagick(GetApplicationFolder().GetBuffer(0));
try {
Magick::Image target;
target.quiet(true);
target.read("image.tif");
Magick::Geometry geom = target.geometry();
size_t nHeightPixels = geom.height();
}
catch(Magick::Exception &error_) {
printf("Barcode() failed. %s.\r\n", error_.what());
}
The Geometry object returned from target.geometry() is empty (all fields set to zero or false), which is a little odd. I would have expected IM to have filled in at least some of these fields when it read the file and, given that this appears to be how you determine the size of the image you have read in, I find it a little worrying that no else seems to be having this problem.