當前位置: 首頁>>代碼示例>>C#>>正文


C# SolidBrush.SafeDispose方法代碼示例

本文整理匯總了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);
      }
    }
開發者ID:edalex86,項目名稱:MediaPortal-1,代碼行數:70,代碼來源:VisualizationWindow.cs


注:本文中的System.Drawing.SolidBrush.SafeDispose方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。