Pen RGB values

This forum is for general developer support questions.
Post Reply
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Pen RGB values

Post by mritter0 »

Code: Select all

	if ((di=IIntuition->GetScreenDrawInfo(Scr)))
	{
		BackgroundPen=di->dri_Pens[BACKGROUNDPEN];
		IIntuition->FreeScreenDrawInfo(Scr,di);
	}
How do I go about getting the RGB values for BackgroundPen? Or any pen. I eventually want to turn them into HTML hex code, #FF00FF.
Workbench Explorer - A better way to browse drawers
User avatar
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 600
Joined: Sat Jun 18, 2011 2:40 am
Location: Portsmouth, UK
Contact:

Re: Pen RGB values

Post by broadblues »

You need to get the Colour Map of the current ViewPort and use IGraphics->GetRGB32() to read out the entries your are interested in.

in psuedo code

Screen = LockPubScreen

ViewPort = Screen->ViewPort

ColourMap = Viewport->ColourMap

uint32 colour[3];
IGraphics->GetRGB32(cm, pen, 1, &colour)

UnlockScreen

remeber the colours are in 32bits left justified fractions, dive bu 0x10101010 to get back to 0 to 255 per channel.

See intuition/screens.h and graphicas library autodoc etc for the exact structure definition in the above pseudo code.
User avatar
mritter0
Posts: 214
Joined: Mon Aug 25, 2014 9:41 pm
Location: Bettendorf, IA, USA

Re: Pen RGB values

Post by mritter0 »

Got it. Thanks.
Workbench Explorer - A better way to browse drawers
Post Reply