269 {
270 ARGBPixel newPixel;
271
272 byte v = (byte) (pixel.V * 255 / 100);
273 if (pixel.S == 0)
274 {
275 newPixel = new ARGBPixel(255, v, v, v);
276 }
277 else
278 {
279 int h = pixel.H / 60 % 6;
280 float f = pixel.H / 60.0f - pixel.H / 60;
281
282 byte p = (byte) (pixel.V * (100 - pixel.S) * 255 / 10000);
283 byte q = (byte) (pixel.V * (100 - (int) (f * pixel.S)) * 255 / 10000);
284 byte t = (byte) (pixel.V * (100 - (int) ((1.0f - f) * pixel.S)) * 255 / 10000);
285
286 switch (h)
287 {
288 case 0:
289 newPixel = new ARGBPixel(255, v, t, p);
290 break;
291 case 1:
292 newPixel = new ARGBPixel(255, q, v, p);
293 break;
294 case 2:
295 newPixel = new ARGBPixel(255, p, v, t);
296 break;
297 case 3:
298 newPixel = new ARGBPixel(255, p, q, v);
299 break;
300 case 4:
301 newPixel = new ARGBPixel(255, t, p, v);
302 break;
303 default:
304 newPixel = new ARGBPixel(255, v, p, q);
305 break;
306 }
307 }
308
309 return newPixel;
310 }