小编Yur*_*ury的帖子

使用LockBits时的AccessViolation

我想使用LockBits方法更快地比较相似图像,如下所示

using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;

public class CompareImages {

 public static void Main ( String[] args ) {

 Bitmap bm1 = new Bitmap ( "PB270029.JPG" );  
 Console.WriteLine ( bm1.PixelFormat.ToString() );

 int width = bm1.Width;
 int height = bm1.Height;
 Console.WriteLine ( "width = " + width + "  height = " + height );

 Rectangle rect1 = new Rectangle ( 0, 0, width, height );
 BitmapData bm1Data = bm1.LockBits ( rect1, ImageLockMode.ReadOnly, bm1.PixelFormat );

 Console.WriteLine ( "stride …
Run Code Online (Sandbox Code Playgroud)

c#

3
推荐指数
1
解决办法
3680
查看次数

标签 统计

c# ×1