Simplify and speed up the hsl and hsv slider creation code in the color picker dialog

Originally committed to SVN as r5766.
This commit is contained in:
Thomas Goyne 2011-10-24 20:17:30 +00:00
parent c1de03210d
commit 374a43cd8b
1 changed files with 8 additions and 12 deletions

View File

@ -662,26 +662,22 @@ DialogColorPicker::DialogColorPicker(wxWindow *parent, wxColour initial_color, C
rgb_slider[2] = make_rgb_image(slider_width, 2); rgb_slider[2] = make_rgb_image(slider_width, 2);
// luminance // luminance
unsigned char *oslid = (unsigned char *)malloc(slider_width*256*3); unsigned char *slid = (unsigned char *)malloc(slider_width*256*3);
unsigned char *slid = oslid;
for (int y = 0; y < 256; y++) { for (int y = 0; y < 256; y++) {
for (int x = 0; x < slider_width; x++) { memset(slid + y * slider_width * 3, y, slider_width * 3);
*slid++ = clip_colorval(y);
*slid++ = clip_colorval(y);
*slid++ = clip_colorval(y);
}
} }
wxImage sliderimg(slider_width, 256, oslid); wxImage sliderimg(slider_width, 256, slid);
hsl_slider = new wxBitmap(sliderimg); hsl_slider = new wxBitmap(sliderimg);
oslid = slid = (unsigned char *)malloc(slider_width*256*3); slid = (unsigned char *)malloc(slider_width*256*3);
for (int y = 0; y < 256; y++) { for (int y = 0; y < 256; y++) {
unsigned char rgb[3];
hsv_to_rgb(y, 255, 255, rgb, rgb + 1, rgb + 2);
for (int x = 0; x < slider_width; x++) { for (int x = 0; x < slider_width; x++) {
hsv_to_rgb(y, 255, 255, slid, slid+1, slid+2); memcpy(slid + y * slider_width * 3 + x * 3, rgb, 3);
slid += 3;
} }
} }
sliderimg.SetData(oslid); sliderimg.SetData(slid);
hsv_slider = new wxBitmap(sliderimg); hsv_slider = new wxBitmap(sliderimg);
// Create the controls for the dialog // Create the controls for the dialog