![]() ![]() Note that the dialog box in Figure 1 doesn't provide any way to select an alpha component other than 255, allowing only fully opaque colors. The RGB color system combines three color coordinates, along with a value that indicates the transparency of the color that's often referred to as the "alpha" component of the color, and creates a 32-bit unsigned integer value that represents the color. The HSL values range from 0 to 240.įigure 1** Standard Color Selection in Windows ** In this dialog box, the individual RGB values contain 8-bit values and range from 0 all the way up to 255. Disregarding the left-hand side of the dialog box, which simply allows you to select from a palette of preselected colors, the right-hand pane allows you to drag the color selector with your mouse, or enter colors using two different color spaces, Red/Green/Blue (RGB) or Hue/Saturation/Luminosity (HSL). Figure 1 shows the standard Windows dialog box with the Define Custom Colors button selected, so the right-hand pane appears, allowing you to define your own colors. This representation of color choices is often called a "color space" because color representations normally allow you to refer to colors by a set of coordinates in three-dimensional space. The standard Windows color-selection dialog box represents colors in just two of the many ways you might represent colors in code. This article focuses on two specific areas: investigating different color-selection techniques and explaining the members of the System.Drawing namespace that make the sample application work. You can lay out the indicators just about any way you like, and the sample application includes two different layouts for the dialog box. The sample's layout and appearance are easy to modify. That is not true, however, and in this article I'll provide a simple-to-use replacement for the standard color-selection dialog box. Along the way, you'll get tips to help you use GDI+ in your own apps.īecause Windows® provides a standard common dialog box for selecting colors (see Figure 1) it's easy to assume that this is the only method for selecting colors. In this article, the author describes several color selection schemes, and uses GDI+ (via the System.Drawing namespace) to create a component that makes it possible for your own applications to provide a simpler, friendlier color chooser. For instance, the standard Windows color-selection dialog box allows you to work with the HSL color scheme in an indirect way. NETĪlthough most developers and APIs use the RGB scheme when working with colors, it's not the only available way to represent or select colors. This article assumes you're familiar with C# and Visual Basic. NET or C#Ĭode download available at: GDIColorPicker.exe(395 KB) ![]() A Primer on Building a Color Picker User Control with GDI+ in Visual Basic. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |