![]() ![]() ![]() So, red prevails between 6 and 2, green between 2 and 4 and blue between 4 and 6. So, essentially at points 1, 3 and 5 you have the primary colours red, green and blue, that correspond to hue values of 0°, 120° and 240° and at the points 2, 4 and 6 you have the secondary colours yellow, cyan and magenta that correspond to hue values of 60°, 180° and 300°. Take a look at these images:įigure 1 represents a slice of the "cylindrical" HSV colour space which is schematically represented by figure 2. I will give you a brief explication of how this works. I suggest to open up the colour picker and start moving the sliders and look at how the number vary: this can help a lot to understand the correspondences between the two systems. The problem is that, due to the fact that RGB is a "cubic" colour space while HSV is a "cylindrical" one, there is no straightforward conversion matrix between these systems (like there is, for example, from RGB to NTSC YIQ), so you'll find a lot of if statements and some calculation that, at first, can be quite obscure. There are some interesting points in the program, which I would like to remark here.įirst of all, the HSV/RGB conversion routines : While RGB to HSV is quite easy to understand, HSV to RGB can be quite tricky. It's really simple so I won't comment it here, just remember to link with the CPicker.lib file and put the DLL in your exe folder (or in a system folder, but I don't recommend it!). The sample application (CPickerTest) shows you how to use the control. SetRGB calls the UpdateHSV method of CurrCol, and SetHSV calls UpdateRGB so, when you update RGB, HSV will automatically be updated and vice versa.įinally GetCurrentColour and GetOldColour are used to retrieve the currently selected colour and the previously selected one. Other useful functions are SetRGB, SetHSV, and SetAlpha, that are used to set the components of the current color. The alpha slider and value are displayed but disabled and set to 100%, colours are opaque. The alpha slider and value are displayed and can be modified, colours can be transparent. The alpha slider and value are not displayed. There are three possible values for this parameter, defined in CPicker.h: CP_NO_ALPHA To create the dialog you should call CreateColourPicker: this function expects one parameter, to know if it should display the full dialog with the alpha slider or not. Note that calling the constructor just initializes the colours, it does not create the colour picker. You can also use the second constructor to initialize h, s and v, by passing false as IsRGB. ![]() We have two constructors: both need a handle to the parent window of the dialog and the second also initializes r, g, b and a. Void SetHSV(unsigned short h, unsigned short s, unsigned short v) Void SetRGB(unsigned short r, unsigned short g, unsigned short b) Void CreatecolourPicker( short AlphaUsage) CColourPicker(HWND hParentWindow, unsigned short r, ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |