本文整理汇总了C#中System.Drawing.SolidBrush.SafeDispose方法的典型用法代码示例。如果您正苦于以下问题:C# SolidBrush.SafeDispose方法的具体用法?C# SolidBrush.SafeDispose怎么用?C# SolidBrush.SafeDispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.SolidBrush
的用法示例。
在下文中一共展示了SolidBrush.SafeDispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawThumbnailOverlay
private void DrawThumbnailOverlay(Graphics g, float opacity)
{
try
{
if (UpdatingCoverArtImage || UpdatingCoverArtImageList)
{
return;
}
if (GUIWindowManager.IsRouted)
{
this.Hide();
return;
}
else
{
this.Show();
}
if (CurrentThumbImage == null && _CoverArtImages.Count == 0)
{
return;
}
Image img = GetNextImage();
if (img == null)
{
return;
}
Rectangle rect = new Rectangle(0, 0, Width, Height);
SolidBrush fillBrush = new SolidBrush(Color.FromArgb((int)(255f * opacity), Color.Black));
g.FillRectangle(fillBrush, rect);
fillBrush.SafeDispose();
int imgHeight = Height;
int imgWidth = imgHeight;
if (!_KeepCoverArtAspectRatio)
{
imgWidth = Width;
}
int left = (Width - imgHeight) / 2;
float[][] matrixItems = {
new float[] {1, 0, 0, 0, 0},
new float[] {0, 1, 0, 0, 0},
new float[] {0, 0, 1, 0, 0},
new float[] {0, 0, 0, opacity, 0},
new float[] {0, 0, 0, 0, 1}
};
ColorMatrix colorMatrix = new ColorMatrix(matrixItems);
ImageAttributes imgAttrib = new ImageAttributes();
imgAttrib.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
//g.DrawImage(CurrentThumbImage, new Rectangle(left, 0, imgWidth, imgHeight), 0, 0,
// CurrentThumbImage.Width, CurrentThumbImage.Height, GraphicsUnit.Pixel, imgAttrib);
g.DrawImage(img, new Rectangle(left, 0, imgWidth, imgHeight), 0, 0,
img.Width, img.Height, GraphicsUnit.Pixel, imgAttrib);
}
catch (Exception ex)
{
Console.WriteLine("DrawThumbnailOverlay caused an exception:{0}", ex);
}
}