系统架构设计师辅导:处理图像
- 系统架构师
- 关注:2.6W次
如果您的'应用程序显示大量图像文件(例如,.jpg 和 .gif 文件),则您可以通过以位图格式预先呈现图像来显著改善显示性能。要使用该技术,请首先从文件中加载图像,然后使用 PARGB 格式将其呈现为位图。下面的代码示例从磁盘中加载文件,然后使用该类将图像呈现为预乘的、Alpha 混合 RGB 格式。例如:
[C#]
if ( image != null && image is Bitmap )
{
Bitmap bm = (Bitmap)image;
Bitmap newImage = new Bitmap( h, bm.Height,
System.Drawing.Imaging.PixelFormat.Format32bppPArgb );
using ( Graphics g = Image( newImage ) )
{
Image( bm, new Rectangle( 0,0, h, ht ) );
}
image = newImage;
}
[Visual Basic ]
If Not(image Is Nothing) AndAlso (TypeOf image Is Bitmap) Then
Dim bm As Bitmap = CType(image, Bitmap)
Dim newImage As New Bitmap(h, ht, _
System.Drawing.Imaging.PixelFormat.Format32bppPArgb)
Using g As Graphics = Image(newImage)
Image(bm, New Rectangle(0, 0, h, ht))
End Using
image = newImage
End If
- 文章版权属于文章作者所有,转载请注明 https://xuezhezhai.com/zys/xitrzong/vk02e2.html