Tuesday, May 22, 2007

How to use Gdi+ effects like Brightness, RedEye reduction

VOID Example_DrawImageRM(HDC hdc)
{
Graphics graphics(hdc);
graphics.SetPageUnit(UnitInch);
Image myImage(L"Photo.jpg");

REAL srcWidth = (REAL)myImage.GetWidth();
REAL srcHeight = (REAL)myImage.GetHeight();
RectF srcRect(0.0f, 0.0f, 1.0f, 1.0f);
Matrix myMatrix(2.0f, 0.2f, 0.3f, 1.0f, 3.0f, 2.0f);

BrightnessContrastParams briConParams;
briConParams.brightnessLevel = 0;
briConParams.contrastLevel = 30;
BrightnessContrast briCon;
briCon.SetParameters(&briConParams);

// Draw the image with increased contrast and transformed to
// fill a parallelogram.
graphics.DrawImage(&myImage, &srcRect, &myMatrix, &briCon, NULL, UnitInch);
}

No comments: