using System.Collections.Generic; using System.Drawing; using System.Drawing.Imaging; using AForge.Math.Geometry; namespace AForge.Imaging; public class QuadrilateralFinder { public List ProcessImage(Bitmap image) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) CheckPixelFormat(((Image)image).PixelFormat); BitmapData val = image.LockBits(new Rectangle(0, 0, ((Image)image).Width, ((Image)image).Height), (ImageLockMode)1, ((Image)image).PixelFormat); List list = null; try { return ProcessImage(new UnmanagedImage(val)); } finally { image.UnlockBits(val); } } public List ProcessImage(BitmapData imageData) { return ProcessImage(new UnmanagedImage(imageData)); } public unsafe List ProcessImage(UnmanagedImage image) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 //IL_00bc: Unknown result type (might be due to invalid IL or missing references) CheckPixelFormat(image.PixelFormat); int width = image.Width; int height = image.Height; List list = new List(); byte* ptr = (byte*)image.ImageData.ToPointer(); int stride = image.Stride; if ((int)image.PixelFormat == 198659) { for (int i = 0; i < height; i++) { bool flag = true; for (int j = 0; j < width; j++) { if (ptr[j] != 0) { list.Add(new IntPoint(j, i)); flag = false; break; } } if (!flag) { for (int num = width - 1; num >= 0; num--) { if (ptr[num] != 0) { list.Add(new IntPoint(num, i)); break; } } } ptr += stride; } } else { int num2 = Image.GetPixelFormatSize(image.PixelFormat) / 8; byte* ptr2 = null; for (int k = 0; k < height; k++) { bool flag = true; ptr2 = ptr; int num3 = 0; while (num3 < width) { if (ptr2[2] != 0 || ptr2[1] != 0 || *ptr2 != 0) { list.Add(new IntPoint(num3, k)); flag = false; break; } num3++; ptr2 += num2; } if (!flag) { ptr2 = ptr + (nint)width * (nint)num2 - num2; int num4 = width - 1; while (num4 >= 0) { if (ptr2[2] != 0 || ptr2[1] != 0 || *ptr2 != 0) { list.Add(new IntPoint(num4, k)); break; } num4--; ptr2 -= num2; } } ptr += stride; } } return PointsCloud.FindQuadrilateralCorners(list); } private void CheckPixelFormat(PixelFormat format) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 if ((int)format != 198659 && (int)format != 137224 && (int)format != 2498570 && (int)format != 925707) { throw new UnsupportedImageFormatException("Unsupported pixel format of the source image."); } } }