ColorRGB values

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
smajler
Posts: 28
Joined: 2013-05-17T09:26:53-07:00
Authentication code: 6789

ColorRGB values

Post by smajler » 2013-05-21T13:15:39-07:00

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.

User avatar
magick
Site Admin
Posts: 11077
Joined: 2003-05-31T11:32:55-07:00

Re: ColorRGB values

Post by magick » 2013-05-21T13:23:04-07:00

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.

smajler
Posts: 28
Joined: 2013-05-17T09:26:53-07:00
Authentication code: 6789

Re: ColorRGB values

Post by smajler » 2013-05-21T13:49:44-07:00

Where can i find sources to compile 8 bit version?

User avatar
fmw42
Posts: 25664
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: ColorRGB values

Post by fmw42 » 2013-05-21T16:06:40-07:00

http://www.imagemagick.org/script/insta ... e.php#unix

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

smajler
Posts: 28
Joined: 2013-05-17T09:26:53-07:00
Authentication code: 6789

Re: ColorRGB values

Post by smajler » 2013-05-21T21:21:04-07:00

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 ?

smajler
Posts: 28
Joined: 2013-05-17T09:26:53-07:00
Authentication code: 6789

Re: ColorRGB values

Post by smajler » 2013-05-23T00:52:13-07:00

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:)

Post Reply