系统架构师 百分网手机站

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

时间:2017-11-21 16:27:32 系统架构师 我要投稿

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

  如果您的'应用程序显示大量图像文件(例如,.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

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

1.系统架构设计师:优化显示速度

2.系统架构设计师要素

3.合成图像的处理方法

4.系统架构设计师的工作职责有哪些

5.系统架构设计师考试报考条件

6.系统架构设计师考试报考指南

7.系统架构设计师:性能调整和诊断

8.系统架构设计师:考虑用户的观点