HSL to RGB conversion slightly different in 6.4.6
Posted: 2008-11-23T09:29:20-07:00
I'm not asserting this is a bug, just that the result is different. This may also indicate that I don't understand how to properly use MagickCore to convert HSL to RGB. The test program converts "hsla(0,48,39,0)" to a MagickPixelPacket, then back to HSL with ConvertRGBToHSL.
In 6.4.5-8, the program prints
In 6.4.6-0, it prints
In 6.4.5-8, the program prints
Code: Select all
ImageMagick 6.4.5 2008-11-18 Q16 http://www.imagemagick.org
R=37827.000000 G=13290.000000 B=13290.000000
H=0.000000 S=0.480016 L=0.389998
Code: Select all
ImageMagick 6.4.6 2008-11-22 Q16 http://www.imagemagick.org
R=37827.000000 G=13290.000000 B=13291.000000
H=0.999993 S=0.480016 L=0.389998
Code: Select all
/*
gcc `Magick-config --cflags --cppflags` to_hsla.c `Magick-config --ldflags --libs` -o to_hsla
*/
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include "magick/MagickCore.h"
int main(int argc,char **argv)
{
const char *version;
MagickPixelPacket pp;
double hue, sat, lum;
ExceptionInfo exception;
MagickCoreGenesis(argv[0], MagickFalse);
version = GetMagickVersion(NULL);
fputs(version, stderr); fputc('\n', stderr);
GetExceptionInfo(&exception);
GetMagickPixelPacket(NULL, &pp);
(void) QueryMagickColor("hsla(0,48,39,0)", &pp, &exception);
printf("R=%f G=%f B=%f\n", pp.red, pp.green, pp.blue);
ConvertRGBToHSL(pp.red, pp.green, pp.blue, &hue, &sat, &lum);
printf("H=%f S=%f L=%f\n", hue, sat, lum);
DestroyExceptionInfo(&exception);
MagickCoreTerminus();
exit(0);
}