Commit 8664e608 cuiya

add openimage

1 个父辈 0afd9157
......@@ -27,11 +27,30 @@ namespace Acc.Img
if (imagePath.ToLower().EndsWith(".raw"))
{
pngB = false;
Bitmap[] images = ReadRaw(imagePath);
if (images != null)
{
image = images[1];
}
byte[] src = System.IO.File.ReadAllBytes(imagePath);
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)
{
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
{
......@@ -227,8 +246,8 @@ namespace Acc.Img
{
itemArea = 3;
}
int totalCount = CountBlobs(blobList, itemArea, ref grayMat);
image = BitmapConverter.ToBitmap(grayMat);
int totalCount = CountBlobs(blobList, itemArea, ref imageMat);
image = BitmapConverter.ToBitmap(imageMat);
return totalCount;
}
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!