系统架构设计师辅导:处理图像

时间:2023-01-11 04:44:58 系统架构师 我要投稿
  • 相关推荐

系统架构设计师辅导:处理图像

  如果您的应用程序显示大量图像文件(例如,.jpg 和 .gif 文件),则您可以通过以位图格式预先呈现图像来显著改善显示性能。要使用该技术,请首先从文件中加载图像,然后使用 PARGB 格式将其呈现为位图。下面的代码示例从磁盘中加载文件,然后使用该类将图像呈现为预乘的、Alpha 混合 RGB 格式。例如:

系统架构设计师辅导:处理图像

  [C#]

  if ( image != null && image is Bitmap )

  {

  Bitmap bm = (Bitmap)image;

  Bitmap newImage = new Bitmap( bm.Width, bm.Height,

  System.Drawing.Imaging.PixelFormat.Format32bppPArgb );

  using ( Graphics g = Graphics.FromImage( newImage ) )

  {

  g.DrawImage( bm, new Rectangle( 0,0, bm.Width, bm.Height ) );

  }

  image = newImage;

  }

  [Visual Basic .NET]

  If Not(image Is Nothing) AndAlso (TypeOf image Is Bitmap) Then

  Dim bm As Bitmap = CType(image, Bitmap)

  Dim newImage As New Bitmap(bm.Width, bm.Height, _

  System.Drawing.Imaging.PixelFormat.Format32bppPArgb)

  Using g As Graphics = Graphics.FromImage(newImage)

  g.DrawImage(bm, New Rectangle(0, 0, bm.Width, bm.Height))

  End Using

  image = newImage

  End If

【系统架构设计师辅导:处理图像】相关文章:

系统架构设计师要素06-03

系统架构设计师考试说明05-15

系统架构设计师考试之路06-03

系统架构设计师:优化显示速度06-03

系统架构设计师:考虑用户的观点06-03

系统架构设计师考试报考条件05-17

优秀系统架构设计师需要具备的条件05-20

系统架构设计师:性能调整和诊断06-03

智慧健康系统架构05-15