Code archives/Graphics/Real RGB
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
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. | |||||
Type RGB Field r Field g Field b End Type Function GetRealRGB.RGB (r, g, b) ; Being nice and drawing on my own pixel :) tempbuffer = GraphicsBuffer () temp = CreateImage (1, 1) SetBuffer ImageBuffer (temp) real.RGB = New RGB Color r, g, b: Plot 0, 0: GetColor 0, 0 real\r = ColorRed () real\g = ColorGreen () real\b = ColorBlue () SetBuffer tempbuffer FreeImage temp Return real End Function ; Use it like this: supply the RGB values you *think* you're using, ; and it returns the *actual* RGB values your gfx card is using... real.RGB = GetRealRGB (255, 255, 255) Print real\r Print real\g Print real\b |
Comments
None.
Code Archives Forum