RGB24toRGB16
16BitRgbColour = RGB24toRGB16(Rgb)
 
Parameters:

    Rgb = The 24 Bit RGB colour you want to convert
Returns:

    16BitRgbColour = The 16 bit RGB colour in 565 format
 

      The RGB24toRGB16 function will covert a 24bit RGB colour value to a 16bit RGB colour value.



FACTS:


      * The input colour must be in 24 or 32bit the form. $--RRGGBB

      * The function will convert the colour to a 16bit (rrrrrggggggbbbbb 565) format.

      * Converting between 24bit and 16Bit means some colour information is lost such as the lower bits of R,G,B and all of the alpha channel information.




Mini Tutorial:


      Show some examples

  
  
; convert some colours to 16bit (565) pixel format and back again
  Show_Converted_16bit_Colour(RGB(255,255,255))
  Show_Converted_16bit_Colour(RGB(255,0,0))
  Show_Converted_16bit_Colour(RGB(0,255,0))
  Show_Converted_16bit_Colour(RGB(0,0,255))
  
  
  Sync
  WaitKey
  
  
  
Function Show_Converted_16bit_Colour(ThisRGB)
  
; Print the Colour Value in Hex$
  Print Hex$(ThisRgb)
  
; Convert the 24bit colour to a 16bit equivalent
; Note: some of the lower bits of the colour will
; be lose during the conversion !!
  NewCol_16Bit = RGB24ToRGB16(ThisRgb)
  
; Print the Colour Value in Hex$
  Print Hex$(NewCol_16Bit)
  
; Now Convert the 16 bit colour back to 24 bit
  
  NewCol_24Bit = RGB16ToRGB24( NewCol_16Bit)
  Print Hex$(NewCol_24Bit)
  Print ""
EndFunction
  
  


This example would output.

  
  $00FFFFFF
  $0000FFFF
  $00F8FCF8
  
  $00FF0000
  $0000F800
  $00F80000
  
  $0000FF00
  $000007E0
  $0000FC00
  
  $000000FF
  $0000001F
  $000000F8
  
  

 
Related Info: ARGB | RGB | Rgb15toRgb24 | Rgb16toRgb24 | Rgb24toRgb15 | RGBA | RGBB | RGBG | RGBR :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com