Page 1 of 1

ColorRGB values

Posted: 2013-05-21T13:15:39-07:00
by smajler
Hi can anybody explain me why this code:

Code: Select all

Magick::ColorRGB color( 255 , 128 , 64 );
	  
	  cout<<color.red()<<" ";
	  cout<<color.redQuantum()<<endl;

	  cout<<color.green()<<" ";
	  cout<<color.greenQuantum()<<endl;

	  cout<<color.blue()<<" ";
	  cout<<color.blueQuantum()<<endl;
outputs values:
0.996124 65281
0.998062 65408
0.999039 65472

There is no value like 255, 128, 64.

Re: ColorRGB values

Posted: 2013-05-21T13:23:04-07:00
by magick
Looks like you're using the 16-bit release of ImageMagick. You can either divide the 16-bits value by 257 to scale it to [0..255] or multiply the normalized value by 255.

Re: ColorRGB values

Posted: 2013-05-21T13:49:44-07:00
by smajler
Where can i find sources to compile 8 bit version?

Re: ColorRGB values

Posted: 2013-05-21T16:06:40-07:00
by fmw42
http://www.imagemagick.org/script/insta ... e.php#unix

just add --with-quantum-depth=8 to your ./configure command

Re: ColorRGB values

Posted: 2013-05-21T21:21:04-07:00
by smajler
i'm using windows with visual2010. Anyway don't you see that red green blue values are very close to each other and dividing by 256 returns ~255 is it correct? I think they should be different.

EDIT:
Found in VisualMagick\ configure.exe button to edit "magick-baseconfig.h" and there is a define :

Code: Select all

#define MAGICKCORE_QUANTUM_DEPTH 16
If i change it to 8 IM will be compiled with 8 bit quantum depth or is it something else ?

Re: ColorRGB values

Posted: 2013-05-23T00:52:13-07:00
by smajler
SOLVED.

I have compiled IM do 8 bit with

Code: Select all

#define MAGICKCORE_QUANTUM_DEPTH 8
Now code:

Code: Select all

Magick::ColorRGB color( 255 , 128 , 64 );
	  
	  cout<<256-color.red()*255<<" ";
	  cout<<256-color.green()*255<<" ";
	  cout<<256-color.blue()*255<<" ";
Does exacly what i wanted, output is 255, 128, 64. Anyway when i try to

Code: Select all

cout<<color.redQuantum
console prints trashes (@%!$!@ etc :D)
Also when i want color from pixelPacket i need to get it by ColorRGB:

Code: Select all

Magick::PixelPacket *pixels = newImage.getPixels(0, 0, w, h);
Magick::ColorRGB  getColor=pixels[0];
Becouse

Code: Select all

pixels[0].red
also returns trashes (@%!$!@ etc :D) I don't know why it works like that but i've got what i wanted :)

Thanks for help:)