本文整理汇总了C++中ImageAttributes::SetGamma方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageAttributes::SetGamma方法的具体用法?C++ ImageAttributes::SetGamma怎么用?C++ ImageAttributes::SetGamma使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageAttributes
的用法示例。
在下文中一共展示了ImageAttributes::SetGamma方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rc
/*
gamma 参数的典型值在 1.0 到 2.2 之间;但在某些情况下,0.1 到 5.0 范围内的值也很有用。
imageAttr.SetGamma 参数值越大,图像越暗,反之则越亮
*/
Bitmap * HighlightBitmap(Bitmap * pSrc, float fGamma, BOOL bCreate )
{
if (pSrc == NULL) return NULL;
if (fGamma <= 0.0f) return NULL;
RectF rc(0.0f, 0.0f, (float)pSrc->GetWidth(), (float)pSrc->GetHeight());
if ( rc.IsEmptyArea()) return NULL;
Bitmap * pResult = !bCreate ? pSrc : new Bitmap( (int)rc.Width, (int)rc.Height, pSrc->GetPixelFormat() );
if( pResult == NULL ) return NULL;
Graphics * g = Graphics::FromImage(pResult);
if ( g == NULL)
{
if (bCreate) { delete pResult; pResult = NULL; }
return NULL;
}
ImageAttributes imageAttr;
//////////////////////////////////////////////////////////////////////////
#if TRUE
imageAttr.SetGamma( 1/fGamma );
#else
Gdiplus:: ColorMatrix HotMat =
{1.05f, 0.00f, 0.00f, 0.00f,0.00f,
0.00f, 1.05f, 0.00f, 0.00f, 0.00f,
0.00f, 0.00f, 1.05f, 0.00f, 0.00f,
0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
0.05f, 0.05f, 0.05f, 0.00f, 1.00f};
imageAttr.SetColorMatrix(&HotMat);
#endif
//////////////////////////////////////////////////////////////////////////
Status status = g->DrawImage(pSrc, rc, 0, 0, (float)pSrc->GetWidth(), (float)pSrc->GetHeight()
,Gdiplus:: UnitPixel, &imageAttr);
delete g; g = NULL;
if ( Ok != status )
{
if (bCreate) { delete pResult; pResult = NULL; }
return NULL;
}
return pResult;
}
示例2: GDIPlus_AlphaBlend
BOOL GDIPlus_AlphaBlend(HDC hdcDest, int nXOriginDest, int nYOriginDest, int nWidthDest, int nHeightDest, HDC hdcSrc, int nXOriginSrc, int nYOriginSrc, int nWidthSrc, int nHeightSrc, BLENDFUNCTION * bf)
{
Graphics g(hdcDest);
BITMAP bmp;
HBITMAP hbmp = (HBITMAP)GetCurrentObject(hdcSrc, OBJ_BITMAP);
GetObject(hbmp, sizeof(BITMAP), &bmp);
Bitmap *bm;
if (bmp.bmBitsPixel == 32 && bf->AlphaFormat) {
bm = new Bitmap(bmp.bmWidth, bmp.bmHeight, bmp.bmWidthBytes, PixelFormat32bppPARGB, (BYTE*)bmp.bmBits);
bm->RotateFlip(RotateNoneFlipY);
}
else bm = new Bitmap(hbmp, nullptr);
ImageAttributes attr;
ColorMatrix Matrix =
{
1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, ((float)bf->SourceConstantAlpha) / 255, 0.0f,
0.0f, 0.0f, 0.0f, 0.0f, 1.0f
};
attr.SetColorMatrix(&Matrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);
if (bf->BlendFlags & 128 && nWidthDest < nWidthSrc && nHeightDest < nHeightSrc) {
g.SetInterpolationMode(InterpolationModeHighQualityBicubic);
g.SetPixelOffsetMode(PixelOffsetModeHalf);
attr.SetGamma((REAL)0.8, ColorAdjustTypeBitmap);
}
else g.SetInterpolationMode(InterpolationModeLowQuality);
RectF rect((float)nXOriginDest, (float)nYOriginDest, (float)nWidthDest, (float)nHeightDest);
g.DrawImage(bm, rect, (float)nXOriginSrc, (float)nYOriginSrc, (float)nWidthSrc, (float)nHeightSrc, UnitPixel, &attr, nullptr, nullptr);
delete bm;
return TRUE;
}
示例3: DrawHighlight
void DrawHighlight( Image * pImage, Graphics * pGraphics, RectF rcDraw, float fGamma /*= 2.2f */ )
{
if (pGraphics == NULL) return;
if (pImage == NULL) return;
ImageAttributes imageAttr;
//////////////////////////////////////////////////////////////////////////
#if FALSE
imageAttr.SetGamma( 1/fGamma );
#else
Gdiplus:: ColorMatrix HotMat =
{1.05f, 0.00f, 0.00f, 0.00f,0.00f,
0.00f, 1.05f, 0.00f, 0.00f, 0.00f,
0.00f, 0.00f, 1.05f, 0.00f, 0.00f,
0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
0.05f, 0.05f, 0.05f, 0.00f, 1.00f};
imageAttr.SetColorMatrix(&HotMat);
#endif
//////////////////////////////////////////////////////////////////////////
RectF rc (0.0f, 0.0f, (float)pImage->GetWidth(), (float)pImage->GetHeight());
pGraphics->DrawImage( pImage, rcDraw, rc.GetLeft(), rc.GetTop(), rc.Width, rc.Height
, Gdiplus:: UnitPixel, &imageAttr );
}