Q&A - Question

Convert .Net System.Color to TGIS_Color (and vice versa)

Question
AdaC asked on June 26, 2018, keyword: Developer Kernel
Hi, 

Is there some sample code somewhere on how to convert between a .net System.Drawing.Color and a TGIS_Color?

Thanks,

Hamish
Answers
Tomasz Kosinski (TatukGIS) replied March 20, 2018

Something like

Color WindormsColor( TGIS_Color _color )
{
  Return ( Color.FromArgb( _color.A, _color.R, _color.G, _color.B ) ) ;
}

TGIS_Color GISColor( Color _color )
{
  Return ( TGIS_Color.FromARGB( _color.A, _color.R, _color.G, _color.B ) ) ; 
}
Edielson Silverio da Silva replied June 26, 2018
private Color to_native_color(TGIS_Color _cl) {
        
// Return Color.FromArgb(CType(_cl.ToARGB, Integer))
        
return Color.FromArgb(BitConverter.ToInt32(BitConverter.GetBytes(_cl.ToARGB), 0));
    
}
    
    
private TGIS_Color to_gis_color(Color _cl) {
        
return TGIS_Color.FromARGB(BitConverter.ToUInt32(BitConverter.GetBytes(_cl.ToArgb), 0));
    
}
If you would like to answer the question please Sign In.
*
*
Please review our recent Privacy Policy.
If you have any questions or requests, please contact us.
Rules
The Questions and Answers (Q & A) is intended to provide a means of communication between TatukGIS customers.
 
  1. Licensed users (with active maintenance play) of TatukGIS products may contribute to the Q & A content. Read-only access is available to anyone.
  2. Keep the content positive and professional.
  3. Be courteous to others by posting information when a question or issue asked on the Q & A is answered or resolved by other means (such as with help from TatukGIS technical support). Offer others at least a hint how the posted question was answered or the issue was resolved.
  4. The Q & A is not a replacement for TatukGIS technical support. TatukGIS team may or may not regularly follow or contribute content.