Originally Posted by
paulogrady
Is it necessary for me to go to this lengths
It's necessary at some point because that's just how the API works, however you don't have to chuck your existing code and drop to native Gdi+. As the Argb value returned from ToArgb() is essentially just a backwards COLORREF, some bit twiddling is all that's required to be able to use the functions taking one.
Code:
// inside the for loops
Color c1 = Bmp1->GetPixel(i, j);
DWORD colorAsArgb = c1.ToArgb();
// colorAsArgb stored as 0xAARRGGBB
// instead of 0x00BBGGRR as a normal COLORREF
// so we shift and mask the appropriate bits to convert
COLORREF colorAsColorRef = RGB(LOBYTE(HIWORD(colorAsArgb)), HIBYTE(LOWORD(colorAsArgb)), LOBYTE(LOWORD(colorAsArgb)));
WORD hue, luminence, saturation;
ColorRGBToHLS(colorAsColorRef, &hue, &luminence, &saturation);
// manipulate the hls values
// however you want to
colorAsColorRef = ColorHLSToRGB(hue, luminence, saturation);
c1 = c1.FromArgb(GetRValue(colorAsColorRef), GetGValue(colorAsColorRef), GetBValue(colorAsColorRef));
Bmp1->SetPixel(i, j, c1);