Windows/MFC

[GDI+] HueSaturationLightnessParams Structure

aucd29 2013. 10. 2. 18:16
The HueSaturationLightnessParams structure contains members that specify hue, saturation and lightness adjustments to a bitmap.

You can adjust the hue, saturation, and lightness of a bitmap by following these steps.

Create and initialize a HueSaturationLightnessParams structure.
Pass the address of the HueSaturationLightnessParams structure to the SetParameters method of a HueSaturationLightness object.
Pass the address of the HueSaturationLightness object to the Graphics::DrawImage method or to the Bitmap::ApplyEffect method.

Syntax

typedef struct {
    INT hueLevel;
    INT saturationLevel;
    INT lightnessLevel;
} HueSaturationLightnessParams;
Members

hueLevel
Integer in the range -180 through 180 that specifies the change in hue. A value of 0 specifies no change. Positive values specify counterclockwise rotation on the color wheel. Negative values specify clockwise rotation on the color wheel.
saturationLevel
Integer in the range -100 through 100 that specifies the change in saturation. A value of 0 specifies no change. Positive values specify increased saturation and negative values specify decreased saturation.
lightnessLevel
Integer in the range -100 through 100 that specifies the change in lightness. A value of 0 specifies no change. Positive values specify increased lightness and negative values specify decreased lightness.

[code]
VOID Example_HSLSetParameters(HDC hdc)
{
Graphics graphics(hdc);
Image myImage(L"Photograph.jpg");

REAL srcWidth = (REAL)myImage.GetWidth();
REAL srcHeight = (REAL)myImage.GetHeight();
RectF srcRect(0.0f, 0.0f, srcWidth, srcHeight);
Matrix myMatrix(1.0f, 0.0f, 0.0f, 1.0f, 450.0f, 20.0f);

HueSaturationLightnessParams myHSLParams;

myHSLParams.hueLevel = 0;
myHSLParams.lightnessLevel = 0;
myHSLParams.saturationLevel = 50;

HueSaturationLightness myHSL;
myHSL.SetParameters(&myHSLParams);

// Draw the image with no change.
graphics.DrawImage(&myImage, 20.0, 20.0, srcWidth, srcHeight);

// Draw the image with increased saturation.
graphics.DrawImage(&myImage, &srcRect, &myMatrix, &myHSL, NULL, UnitPixel);
}
[/code]