Ooops
January 26, 2021, 06:26:43 AM

Author Topic: [bb] Real RGB by BlitzSupport [ 1+ years ago ]  (Read 443 times)

Offline BlitzBot

  • Jr. Member
  • **
  • Posts: 1
[bb] Real RGB by BlitzSupport [ 1+ years ago ]
« on: June 29, 2017, 12:28:38 AM »
Title : Real RGB
Author : BlitzSupport
Posted : 1+ years ago

Description : GetColor sometimes returns unexpected values. This isn't a Blitz bug; it's the result of your graphics card translating the colours you've asked for into something it can display (so if you think you're plotting in 255, 255, 255, GetColor might return 248, 248, 248 or similar).

This function will tell you the actual values your graphics card is using for any given RGB colour.
 


Code :
Code: BlitzBasic
  1.  
  2. Type RGB
  3.         Field r
  4.         Field g
  5.         Field b
  6. End Type
  7.  
  8. Function GetRealRGB.RGB (r, g, b)
  9.  
  10. ; Being nice and drawing on my own pixel :)
  11.  
  12.         tempbuffer = GraphicsBuffer ()
  13.         temp = CreateImage (1, 1)
  14.         SetBuffer ImageBuffer (temp)
  15.         real.RGB = New RGB
  16.         Color r, g, b: Plot 0, 0: GetColor 0, 0
  17.         real
  18.  = ColorRed ()
  19.         realg = ColorGreen ()
  20.         real = ColorBlue ()
  21.         SetBuffer tempbuffer
  22.         FreeImage temp
  23.         Return real
  24.  
  25. End Function
  26.  
  27. ; Use it like this: supply the RGB values you *think* you're using,
  28. ; and it returns the *actual* RGB values your gfx card is using...
  29.  
  30.  real.RGB = GetRealRGB (255, 255, 255)
  31.  
  32.  Print real
  33.  
  34.  Print realg
  35.  Print real
  36.  


Comments : none...

 

SimplePortal 2.3.6 © 2008-2014, SimplePortal