PixelGetBlueQuantum doesn't work in HDRI

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Danack
Posts: 73
Joined: 2013-10-14T10:00:25-07:00
Authentication code: 6789

PixelGetBlueQuantum doesn't work in HDRI

Post 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);
}
Last edited by Danack on 2014-06-21T02:09:46-07:00, edited 1 time in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: PixelGetBlueQuantum doesn't work

Post 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
Danack
Posts: 73
Joined: 2013-10-14T10:00:25-07:00
Authentication code: 6789

Re: PixelGetBlueQuantum doesn't work

Post 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
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: PixelGetBlueQuantum doesn't work in HDRI

Post 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
Post Reply