本文整理汇总了C#中System.Drawing.Imaging.ImageAttributes.ClearGamma方法的典型用法代码示例。如果您正苦于以下问题:C# ImageAttributes.ClearGamma方法的具体用法?C# ImageAttributes.ClearGamma怎么用?C# ImageAttributes.ClearGamma使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Imaging.ImageAttributes
的用法示例。
在下文中一共展示了ImageAttributes.ClearGamma方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawBitmap
// ***********************************************************************
// HELPER: DrawBitmap
// INPUT : Graphics, menu item, state of the item
// NOTES : Renders the bitmap for the current item taking into account the
// current state of the item
public virtual void DrawBitmap(Graphics g, MenuItem item, DrawItemState itemState)
{
// Grab the current state of the menu item
//bool isSelected = (itemState & DrawItemState.Selected) != 0;
bool isDisabled = (itemState & DrawItemState.Disabled) != 0;
bool isChecked = (itemState & DrawItemState.Checked) != 0;
Bitmap bmp = null;
// Determine the bitmap to use if checked, radio-checked, normal
if (isChecked == true)
{
if (item.RadioCheck)
{
bmp = (Bitmap)GetEmbeddedImage(this.RadioCheckIcon);
}
else
{
bmp = (Bitmap)GetEmbeddedImage(this.CheckIcon);
}
}
else
{
if (item.RadioCheck)
{
bmp = (Bitmap)GetEmbeddedImage(this.RadioUnCheckIcon);
}
else
{
if (menuItemIconCollection.ContainsKey(item))
{
bmp = (Bitmap)GetEmbeddedImage(menuItemIconCollection[item]);
}
}
}
// if no valid bitmap is found, exit.
if (bmp == null)
{
return;
}
// Make the bitmap transparent
bmp.MakeTransparent();
// Render the bitmap (the bitmap is grayed out if the
// item is disabled)
if (isDisabled == true)
{
ImageAttributes imageAttr = new ImageAttributes();
imageAttr.SetGamma(0.2F);
Rectangle tmpRect = new Rectangle((int)BitmapBounds.X + 2, (int)BitmapBounds.Y + 2, (int)BitmapBounds.Width - 2, (int)BitmapBounds.Right - 2);
g.DrawImage(bmp, tmpRect, 0, 0, bmp.Width, bmp.Height, GraphicsUnit.Pixel, imageAttr);
imageAttr.ClearGamma();
}
else
{
g.DrawImage(bmp, BitmapBounds.X + 2, BitmapBounds.Y + 2);
}
// Free the resource.
bmp.Dispose();
}