Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Hello ... I am trying to read an image from a buffer (an RGBA blob) using MagickReadImageBlob(). The program is running but doing something weird - It is actually getting a weirdly downsampled version of the image - It divides the image to 4 quadrants, and puts a downsampled version of the image in the upper two quadrants and leaves the lower two completely blank.
I filled the buffer (an unsigned char* ) by sequentially filling it up in the R-G-B-A for each pixel. The image is read row-by-row. Does the function require the blob to in a format different from this?
Hi Magick, thanks for the reply - but it didn't work out yet ... I've used MagickSetSize(wand, width, height), MagickSetFormat(wand, "rgba") along with MagickSetImageDepth(wand, .
Anything else I'm missing??
You'll need to post a minimum set of code we can download, compile, and run to reproduce the problem. Our standard mantra is if we can reproduce a problem, we can fix it.
Sorry for being obscure here, but I am not able to find a minimal way to put up the code, as the code is spread across different functions and packages I'm working on.
Anyways, I see what is happening wrong with it : Magick, u got it rite when u said it has to do with the Pixel Depth. I traced the program with GDB and I found that the MagickReadImageBlob is reading 16-bit pixels, effectively leaving half-the image (as my buffer is made of 8-bit pixels), leading to the weird effect described in the original post.
I found a solution, though I don't really like it much: I reinstalled IM with the build parameter MAGICKCORE_QUANTUM_DEPTH set to 8. That set things right, though the program would be heavily dependent on the installation of IM.
Additionally, I find that the function MagickSetImageDepth() is not really doing anything, as 5-6 lines into its execution, I see that it finds the parameter wand->images to be NULL and exits the function going into a block of exception-related code.
So, basically it comes down to this: Is there any way that we can change the parameter MAGICKCORE_QUANTUM_DEPTH through MagickWand?
(because this is what MagickReadImageBlob uses as bits per pixel to read images from buffers.).
Alternately, one can just create a copy of the buffer in the pattern the ReadImageBlob function expects it to be, and solve the problem. (This Takes up a lot of memory though and wouldn't sit pretty with low-end devices..)