Get RGB value for a named PEN

3 posts / 0 new
Last post
dbstastny
dbstastny's picture
Offline
Last seen: 1 month 3 weeks ago
Joined: 2017-02-04 00:01
Get RGB value for a named PEN

How would one go about converting a named PEN such as BACKGROUNDPEN to an RGB value?

Regards
Doug

broadblues
broadblues's picture
Offline
Last seen: 3 days 22 hours ago
Joined: 2012-05-02 21:48
Re: Get RGB value for a named PEN

Something like this compile with: gcc -o ram:getrgb ram:getrgb.c -lauto

  1. #include <proto/intuition.h>
  2. #include <proto/graphics.h>
  3. #include <proto/dos.h>
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7. struct Screen *scr = IIntuition->LockPubScreen(NULL);
  8. if(scr)
  9. {
  10. struct DrawInfo *dri = IIntuition->GetScreenDrawInfo(scr);
  11. if(dri)
  12. {
  13. uint32 rgb[3];
  14.  
  15. IGraphics->GetRGB32(scr->ViewPort.ColorMap,
  16. dri->dri_Pens[BACKGROUNDPEN],1,rgb);
  17. IDOS->Printf("R %ld G %ld B %ld\n",((rgb[0] & 0xFF000000)>> 24),
  18. ((rgb[1] & 0xFF000000)>> 24),
  19. ((rgb[2] & 0xFF000000)>> 24));
  20.  
  21. IIntuition->FreeScreenDrawInfo(scr,dri);
  22. }
  23. IIntuition->UnlockPubScreen(NULL,scr);
  24. }
  25. }

Please read up on the various functions and structures in the autodocs as there are various range limitations on number of pens etc, that I haven't checked for in this quick example.

dbstastny
dbstastny's picture
Offline
Last seen: 1 month 3 weeks ago
Joined: 2017-02-04 00:01
Re: Get RGB value for a named PEN

Thanks that points me in the right direction. Much appreciated.

DStastny
Log in or register to post comments