Commit 8664e608 cuiya

add openimage

1 个父辈 0afd9157
...@@ -26,12 +26,31 @@ namespace Acc.Img ...@@ -26,12 +26,31 @@ namespace Acc.Img
{ {
if (imagePath.ToLower().EndsWith(".raw")) if (imagePath.ToLower().EndsWith(".raw"))
{ {
pngB = false; pngB = false;
Bitmap[] images = ReadRaw(imagePath); byte[] src = System.IO.File.ReadAllBytes(imagePath);
if (images != null) int width = 3072;
int height = 3072;
int n = 0;
byte[] buff = new byte[src.Length * 3];
for (int i = 0; i < src.Length; i += 2)
{ {
image = images[1]; short ss = BitConverter.ToInt16(src, i);
ss *= 10;
byte[] bb = BitConverter.GetBytes(ss);
buff[n++] = bb[0];
buff[n++] = bb[1];
buff[n++] = bb[0];
buff[n++] = bb[1];
buff[n++] = bb[0];
buff[n++] = bb[1];
} }
Bitmap bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format48bppRgb);
System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, width, height), System.Drawing.Imaging.ImageLockMode.ReadWrite, bmp.PixelFormat);
System.Runtime.InteropServices.Marshal.Copy(buff, 0, bmpData.Scan0, bmpData.Stride * height);
bmp.UnlockBits(bmpData);
//bmp.Save(@"C:\Users\ASA\Desktop\222.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
image= bmp;
} }
else else
{ {
...@@ -227,8 +246,8 @@ namespace Acc.Img ...@@ -227,8 +246,8 @@ namespace Acc.Img
{ {
itemArea = 3; itemArea = 3;
} }
int totalCount = CountBlobs(blobList, itemArea, ref grayMat); int totalCount = CountBlobs(blobList, itemArea, ref imageMat);
image = BitmapConverter.ToBitmap(grayMat); image = BitmapConverter.ToBitmap(imageMat);
return totalCount; return totalCount;
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!