Pen RGB values

This forum is for general developer support questions.

Pen RGB values

Postby mritter0 » Sun Jul 02, 2017 10:20 pm

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
mritter0
 
Posts: 184
Joined: Mon Aug 25, 2014 10:41 pm
Location: Bettendorf, IA, USA

Re: Pen RGB values

Postby broadblues » Sun Jul 02, 2017 11:49 pm

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
broadblues
AmigaOS Core Developer
AmigaOS Core Developer
 
Posts: 478
Joined: Sat Jun 18, 2011 3:40 am
Location: Portsmouth, UK

Re: Pen RGB values

Postby mritter0 » Mon Jul 03, 2017 2:17 am

Got it. Thanks.
Workbench Explorer - A better way to browse drawers
User avatar
mritter0
 
Posts: 184
Joined: Mon Aug 25, 2014 10:41 pm
Location: Bettendorf, IA, USA


Return to General Developer Support

Who is online

Users browsing this forum: No registered users and 2 guests