Page 1 of 1

PixelGetBlueQuantum doesn't work in HDRI

Posted: 2014-06-19T14:49:37-07:00
by Danack
The ImageMagick wand functions for getting colors as quantum values seem to not work. Code below gives the output:
Color pink Blue value is 0.796078, quantum adab
Color purple Blue value is 0.501961, quantum adab
Color red Blue value is 0.000000, quantum adab
Color blue Blue value is 1.000000, quantum adab
Coincidentally, 'adab' appears to be part of the MagickSignature:

"#define MagickSignature 0xabacadabUL"



Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <wand/MagickWand.h>

int main(int argc,char **argv) {
    int i;
    double blueValue;
    Quantum blueQuantum;
    
    MagickWandGenesis();
    char * color;
    
    PixelWand *pixel_wand = NULL;
    
    char *colors[] = {"pink", "purple", "red", "blue", "rgb(13, 13, 13)"};
    
    for (i=0; i<4 ; i++) {
    
        color = colors[i];
        
        pixel_wand = NewPixelWand();    
        PixelSetColor(pixel_wand, color);
    
        blueValue = PixelGetBlue(pixel_wand);
        blueQuantum = PixelGetBlueQuantum(pixel_wand);

        printf("Color %s \t Blue value is %f, quantum %x\n", color, blueValue, blueQuantum);

    }
    
    MagickWandTerminus();
    
    return(0);
}

Re: PixelGetBlueQuantum doesn't work

Posted: 2014-06-20T03:22:16-07:00
by magick
We changed %x to %d in your print statement and it returns expected results:
  • Color pink Blue value is 0.796078, quantum 52171
    Color purple Blue value is 0.501961, quantum 32896
    Color red Blue value is 0.000000, quantum 0
    Color blue Blue value is 1.000000, quantum 65535

Re: PixelGetBlueQuantum doesn't work

Posted: 2014-06-20T15:44:45-07:00
by Danack
Hi,

It looks like the issue only occurs when ImageMagick is compiled with --enable-hdri for both Q16 and Q32.

Is calling PixelGetBlueQuantum a valid thing to do when ImageMagick has been compiled as the HDRI version?

cheers
Dan

Re: PixelGetBlueQuantum doesn't work in HDRI

Posted: 2014-06-21T05:25:11-07:00
by magick
For HDRI, you need %g as the Quantum format specifier. We get:
  • -> ./wand
    Color pink Blue value is 0.796078, quantum 52171.000000
    Color purple Blue value is 0.501961, quantum 32896.000000
    Color red Blue value is 0.000000, quantum 0.000000
    Color blue Blue value is 1.000000, quantum 65535.000000