Color Conversion between ArcGIS and. net

Source: Internet
Author: User

Color Conversion between ArcGIS and. net

/// <Summary> convert the Color Structure in. net to the icolor interface in ArcGIS Engine. // </Summary>

/// <Param name = "color"> the system. Drawing. Color Structure in. Net indicates the argb color. </param>

/// <Returns> icolor interface in ArcGIS egnine </returns>

Public static icolor convertcolortoicolor (color)

{

Icolor pcolor = new rgbcolorclass ();

Pcolor. RGB = color. B * 65536 + color. g * 256 + color. R;

Return pcolor;

}

Recommended by netizens, you can also use the built-in colortranslator method as follows:

Int I = colortranslator. Toole (colordlg. Color );

Pcolor. RGB = I;

The test is available. The principle is the same as that of the first method.

# Region converts the irgbcolor interface in ArcGIS Engine to the color structure in. net.

/// <Summary>

/// Convert the irgbcolor interface in ArcGIS Engine to the color structure in. net.

/// </Summary>

/// <Param name = "prgbcolor"> irgbcolor </param>

/// <Returns> the system. Drawing. Color Structure in. Net indicates the argb color. </returns>

Public static color convertirgbcolortocolor (irgbcolor prgbcolor)

{

Return colortranslator. fromole (prgbcolor. RGB );

}

# Endregion

// Obtain the color from the color palette

Color pdotbackcolor;

Colordialog colordialog1 = new colordialog ();

Colordialog1.allowfullopen = true;

Colordialog1.fullopen = true;

// Set the color. The "help" button exists in the dialog box. It does not exist by default.

Colordialog1.showhelp = true;

// Set the initial color of the color dialog box, so if you select "cancel" in the dialog box, the dialog box will re-color

Colordialog1.color = color. darkblue;

If (colordialog1.showdialog ()! = Dialogresult. Cancel)

{

Pdotbackcolor = colordialog1.color;

Btndotbackcolor. backcolor = pdotbackcolor;

}

// Convert the color interface to the icolor Interface

Icolor color = (icolor) ESRI. ArcGIS. ADF. converter. torgbcolor (pdotbackcolor );

Ifillsymbol pfillsymbol = new simplefillsymbolclass ();

// Assign color to pfillsymbol

Pfillsymbol. Color = color;

 

From: http://changqingnew.blog.163.com/blog/static/10752338201001010323518/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.