本文整理匯總了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);
}
}