Browse Source

Another fix to issue #520

pull/703/head
Canming Huang 4 years ago
parent
commit
147c2c2459
  1. 12
      Emgu.CV.Platform/Emgu.CV.Bitmap/BitmapExtension.cs

12
Emgu.CV.Platform/Emgu.CV.Bitmap/BitmapExtension.cs

@ -443,7 +443,8 @@ namespace Emgu.CV
}
return imageFrom1bppIndexed;
default:
#region Handle other image type
#region Handle other image type
Mat imageDefault = new Mat();
Byte[,,] data = new byte[size.Height, size.Width, 4];
for (int i = 0; i < size.Width; i++)
for (int j = 0; j < size.Height; j++)
@ -457,13 +458,18 @@ namespace Emgu.CV
GCHandle dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);
try
{
return new Mat(new int[] { size.Height, size.Width, 4 }, DepthType.Cv8U, dataHandle.AddrOfPinnedObject());
using (Mat mat = new Mat(new int[] {size.Height, size.Width, 4}, DepthType.Cv8U,
dataHandle.AddrOfPinnedObject()))
{
mat.CopyTo(imageDefault);
}
}
finally
{
dataHandle.Free();
}
#endregion
return imageDefault;
#endregion
}
}

Loading…
Cancel
Save