迈瑞BC5800出图

迈瑞BC的血球图数据采用Base64串传输。RBC和PLT仪器传输的是Base64串的比特流,把他转换成比特数组,直接当float为Y坐标画图。DIFF和Baso就是标准的图片Base64串格式(仪器设置传位图),直接还原图片,然后把图片反转颜色避免背景一片黑。

仪器绘制说明文档
仪器说明
仪器说明
直接Base64转比特当数字用
解析直方图Y坐标部分
把散点图还原之后再往内存位图画一下才能保存文件(很奇怪的现象)
还原Base64为位图

绘图类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LIS.BLL.ImageCore;
using System.Drawing;
using System.Data;
using System.IO;
using System.Drawing.Drawing2D;
namespace LIS.Mach.ImageDeal
{
    ///<summary  NoteObject="Class">
    /// [功能描述:M调用绘图测试] <para/>
    /// [创建者:zlz] <para/>
    /// [创建时间:2018年03月22日] <para/>
    ///<说明>
    ///  [说明:[功能描述:M调用绘图测试,配合M处理仪器绘图]<para/>
    ///</说明>
    ///<修改记录>
    ///    [修改时间:本次修改时间]<para/>
    ///    [修改内容:本次修改内容]<para/>
    ///</修改记录>
    ///<修改记录>
    ///    [修改时间:本次修改时间]<para/>
    ///    [修改内容:本次修改内容]<para/>
    ///    M端触发代码,其他的和监听程序一样
    ///    s retObj=##Class(wbsLisMsgAsyncHandler.LISMsg.wbsLisDrawImageAsyncHandlerSoap).%New()
    ///    s ret=retObj.DrawImage("1","绘图数据","仪器","处理M","传输次数","其他参数","LIS.Mach.ImageDeal.ImageDealTest,LIS.Mach.ImageDeal")
    ///    s ret=$$DealImage^MI.MIF000(epis,"RBC绘图数据串",mi,"和监听一样的有保存图片的M类","-1","Histogram#RBC#RBC######10#10#320#138","LIS.Mach.ImageDeal.Imagebc6800,LIS.Mach.ImageDeal")
    ///    s ret=$$DealImage^MI.MIF000(epis,"RBC带背景绘图数据串",mi,"和监听一样的有保存图片的M类","-1","Histogram#RBC#RBCH.bmp######10#10#320#138","LIS.Mach.ImageDeal.Imagebc6800,LIS.Mach.ImageDeal")
    ///    s ret=$$DealImage^MI.MIF000(epis,"PLT绘图数据串",mi,"和监听一样的有保存图片的M类","-1","Histogram#PLT#PLT######10#10#320#138","LIS.Mach.ImageDeal.Imagebc6800,LIS.Mach.ImageDeal")
    ///    s ret=$$DealImage^MI.MIF000(epis,"PLT带背景绘图数据串",mi,"和监听一样的有保存图片的M类","-1","Histogram#PLT#PLT.bmp######10#10#320#138","LIS.Mach.ImageDeal.Imagebc6800,LIS.Mach.ImageDeal")
    ///    s ret=$$DealImage^MI.MIF000(epis,"DIFF绘图数据串",mi,"和监听一样的有保存图片的M类","-1","DiffPlot#DIFF#######10#10#320#138","LIS.Mach.ImageDeal.Imagebc6800,LIS.Mach.ImageDeal")
    ///    s ret=$$DealImage^MI.MIF000(epis,"Baso绘图数据串",mi,"和监听一样的有保存图片的M类","-1","DiffPlot#Baso#######10#10#320#138","LIS.Mach.ImageDeal.Imagebc6800,LIS.Mach.ImageDeal")
    ///</修改记录>
    ///</summary>
    public class Imagebc6800 : IDrawImage
    {
        /// <summary>
        /// 绘图方法
        /// </summary>
        /// <param name="epis">流水号</param>
        /// <param name="result">结果</param>
        /// <param name="machID">仪器ID</param>
        /// <param name="dealProcess">处理M</param>
        /// <param name="index">-1认为传到最后</param>
        /// <param name="otherPara">其他参数</param>
        /// <param name="dealClass">C#处理类格式:类全名,不带后缀的动态库名</param>
        /// <returns>是否成功</returns>
        public bool DrawImage(string epis, string result, string machID, string dealProcess, string index, string otherPara, string dealClass)
        {
            //string epis = row["Epis"].ToString();
            //1.1从其他参数中获取所需要的参数
            string[] paraList = otherPara.Split('#');
            string graphType = "";
            string imgClass = "";
            string label = "";
            string title = "";
            string maxDot = "";
            string maxValue = "";
            string memo = "";
            string foreColor = "";
            string top = "";
            string left = "";
            string width = "";
            string height = "";
            if (paraList.Length > 1)
            {
                graphType = paraList[0];
                imgClass = paraList[1];
            }
            else
            {
                return true;
            }
            if (paraList.Length > 11)
            {
                title = paraList[2];
                label = paraList[3];
                maxDot = paraList[4];
                maxValue = paraList[5];
                memo = paraList[6];
                foreColor = paraList[7];
                top = paraList[8];
                left = paraList[9];
                width = paraList[10];
                height = paraList[11];

            }
            //#2.1校验必要参数是否存在
            if (String.IsNullOrEmpty(width))
            {
                width = "330";
            }
            if (String.IsNullOrEmpty(height))
            {
                height = "140";
            }
            if (String.IsNullOrEmpty(foreColor))
            {
                foreColor = "0";
            }
            //#2.2取得画图所需要的元素
            double imageWidth = Convert.ToDouble(width);
            double imageHeight = Convert.ToDouble(height);
            
            //#2.3分不同类型的图形来进行绘图
            //画直方图
            if (graphType == "Histogram")
            {
                //先把串转比特数组
                byte[] imageBytes = Convert.FromBase64String(result);
                float[] dot = new float[imageBytes.Length];
                int imgMaxDot = 0;
                float imgMaxValue = 0;
                for (int j = 0; j < imageBytes.Length; j++)
                {
                    dot[j] = imageBytes[j];
                    if (dot[j] > imgMaxValue)
                    {
                        imgMaxValue = dot[j];
                    }
                    imgMaxDot++;
                }
                Bitmap image = null;
                //使用背景画图
                if (title == "PLT.bmp" || title == "RBCH.bmp")
                {
                    image = CreateImage(title, imgMaxValue, dot, null);
                }
                else
                {
                    Dictionary<int, string> xshow = new Dictionary<int, string>();
                    if (imgClass == "RBC")
                    {
                        xshow.Add(10, "0");
                        xshow.Add(60, "50");
                        xshow.Add(110, "100");
                        xshow.Add(160, "150");
                        xshow.Add(210, "200");
                        xshow.Add(260, "250");
                        xshow.Add(310, "fL");
                    }
                    if (imgClass == "PLT")
                    {
                        xshow.Add(10, "0");
                        xshow.Add(50, "5");
                        xshow.Add(100, "10");
                        xshow.Add(150, "15");
                        xshow.Add(200, "20");
                        xshow.Add(250, "25");
                        xshow.Add(300, "fL");
                    }
                    //按十进制结果画图
                    Histogram histogram = new Histogram(label, title, imgMaxDot, imgMaxValue, foreColor, Convert.ToInt32(width), Convert.ToInt32(height), xshow);
                    histogram.Values = dot;
                    image = histogram.CreateImage();
                }
                //判断C盘trak是否存在
                string tmpPath = @"c:\trak\tmpMach";
                if (!Directory.Exists("C:\\trak"))
                {
                    Directory.CreateDirectory("C:\\trak"); //新建文件夹   
                    if (!Directory.Exists(tmpPath))
                    {
                        Directory.CreateDirectory(tmpPath); //新建文件夹   
                    }
                }
                //先删除临时目录里面的所有文件
                DeleteFolder(tmpPath);
                image.Save(tmpPath + "\\" + imgClass + epis + ".bmp");
                image.Dispose();
                string ftpPath = "";
                //FtpService ftp = GetFtpHelper(machID, dealProcess, out ftpPath);
                //上传图片
                //ftp.Upload(tmpPath + "\\" + imgClass + epis + ".bmp");
                //保存图片
                //SaveImg(machID, epis, imgClass, ftpPath.Split('^')[3] + imgClass + epis + ".bmp", dealProcess);
            }
            //散点图就是图片的Base64串表示,直接还原
            else if (graphType == "DiffPlot")
            {
                Bitmap image = null;
                try
                {
                    byte[] arr = Convert.FromBase64String(result);
                    MemoryStream ms = new MemoryStream(arr);
                    image = new Bitmap(ms);
                    ms.Dispose();
                    ms.Close();
                    Bitmap imgTMP = new Bitmap(image.Width, image.Height);
                    Graphics g = Graphics.FromImage(imgTMP);
                    g.DrawImage(image, 0, 0, image.Width, image.Height);
                    image.Dispose();
                    image = imgTMP;
                    //判断C盘trak是否存在
                    string tmpPath = @"c:\trak\tmpMach";
                    if (!Directory.Exists("C:\\trak"))
                    {
                        Directory.CreateDirectory("C:\\trak"); //新建文件夹   
                        if (!Directory.Exists(tmpPath))
                        {
                            Directory.CreateDirectory(tmpPath); //新建文件夹   
                        }
                    }
                    //先删除临时目录里面的所有文件
                    DeleteFolder(tmpPath);
                    //反转底色
                    GraphUtil.GrayReverse(image);
                    image.Save(tmpPath + "\\" + imgClass + epis + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp);
                    image.Dispose();
                    string ftpPath = "";
                    //FtpService ftp = GetFtpHelper(machID, dealProcess, out ftpPath);
                    //上传图片
                    //ftp.Upload(tmpPath + "\\" + imgClass + epis + ".bmp");
                    //保存图片
                    //SaveImg(machID, epis, imgClass, ftpPath.Split('^')[3] + imgClass + epis + ".bmp", dealProcess);
                }
                catch (Exception ex)
                {
                    throw new Exception("Base64String到图片转换失败\n异常:"+ex.Message);
                }
            }
            return true;
        }


        /// 清空指定的文件夹,但不删除文件夹
        /// </summary>
        /// <param name="dir"></param>
        public static void DeleteFolder(string dir)
        {
            foreach (string d in Directory.GetFileSystemEntries(dir))
            {
                if (File.Exists(d))
                {
                    FileInfo fi = new FileInfo(d);
                    if (fi.Attributes.ToString().IndexOf("ReadOnly") != -1)
                        fi.Attributes = FileAttributes.Normal;
                    File.Delete(d);//直接删除其中的文件  
                }
                else
                {
                    DirectoryInfo d1 = new DirectoryInfo(d);
                    if (d1.GetFiles().Length != 0)
                    {
                        DeleteFolder(d1.FullName);递归删除子文件夹
                    }
                    Directory.Delete(d);
                }
            }
        }

        /// <summary>
        /// 获得图片流
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public Stream GetImageStram(string name)
        {
            return this.GetType().Assembly.GetManifestResourceStream("iMedicalLISBCIMage.Image." + name);
        }

        /// <summary>
        /// 画图逻辑
        /// </summary>
        public Bitmap CreateImage(string bgName, float MaxValue, float[] Values, Bitmap imageold)
        {
            //#1.画坐标系,先简单画两条线,暂时不做细节
            Bitmap img = null;
            //#1.2获得画图句柄
            Graphics g = null;
            if (imageold != null)
            {
                img = imageold;
                g = Graphics.FromImage(img);
            }
            else
            {
                Image imgtmp = Image.FromStream(GetImageStram(bgName)) as Bitmap;
                img = new Bitmap(imgtmp.Width, imgtmp.Height);
                g = Graphics.FromImage(img);
                g.Clear(Color.White);
                //+抗锯齿
                g.SmoothingMode = SmoothingMode.AntiAlias;
                g.DrawImage(imgtmp, 0, 0, img.Width, img.Height);
            }

            int Height = img.Height;
            //#1.3偏移
            int x = 1;
            int y = 20;
            //画横纵坐标线
            Pen pen = new Pen(Color.Black);
            pen.Width = 2;
            //#3.开始进点的数据,进行绘图
            double radix = (img.Width - 30) * 1.0 / Values.Length;
            if (Values.Length == 256)
            {
                radix = radix * 2;
            }
            float preY = -1;
            int curindex = 0;
            double radiy = 1;
            if (MaxValue != 0)
            {
                radiy = (Height - 40) * 1.0 / MaxValue;
            }
            foreach (var d in Values)
            {
                if (preY == -1)
                {
                    pen = new Pen(Color.Black);
                    pen.Width = 1;
                }
                else
                {
                    pen = new Pen(Color.Black);
                    pen.Width = 1;
                    if (10 + x * radix > img.Width)
                    {
                        continue;
                    }
                    if (Height - d * radiy - y > img.Height || Height - d * radiy - y < 0)
                    {
                        continue;
                    }
                    g.DrawLine(pen, 10 + (int)(x * radix), Height - (int)(d * radiy) - y, 10 + (int)((x - 1) * radix), preY - y);
                }
                preY = Height - (int)(d * radiy);
                x += 1;
                curindex++;
            }
            return img;
        }
    }
}

直方图工具类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.Data;
using System.Drawing.Drawing2D;
using System.IO;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;


namespace LIS.Mach.ImageDeal
{
    class GraphUtil
    {
        /// <summary> 
        /// 图像翻转
        /// </summary>  
        /// <param name="img"></param>  
        /// <returns></returns>  
        public static Bitmap GrayReverse(Bitmap img)
        {
            //将Bitmap锁定到系统内存中,获得BitmapData
            Rectangle rect = new Rectangle(0, 0, img.Width, img.Height);
            BitmapData srcBmpData = img.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
            //位图中第一个像素的数据地址,它也可以看成是为图中的第一个扫描行
            IntPtr srcPtr = srcBmpData.Scan0;
            //将BitMap对象的信息存放到byte数组中
            int scanWidth = srcBmpData.Width * 3;
            int src_bytes = scanWidth * rect.Height;
            byte[] srcValues = new byte[src_bytes];
            //复制GRB信息到byte数组中
            Marshal.Copy(srcPtr, srcValues, 0, src_bytes);
            //所有颜色值反转
            for (int i = 0; i < src_bytes; i++)
            {
                srcValues[i] = (byte)(255 - srcValues[i]);
            }
            //byte数组数据返回到bitmapdata中
            Marshal.Copy(srcValues, 0, srcPtr, src_bytes);
            //解锁位图
            img.UnlockBits(srcBmpData);
            return img;
        }
    }

    #region 画直方图
    public class Histogram
    {
        //private Graphics objGraphics; //Graphics 类提供将对象绘制到显示设备的方法
        //private Bitmap objBitmap; //位图对象
        public List<string> strsKeys;
        private int fltHeight;
        private int fltWidth;
        private string strTitle;
        private string strLabel;
        private int intMaxDot;
        private float fltMaxValue;
        private Color corForeColor;
        private float[] fltsValues;

        /// <summary>
        /// 值,Y轴数据
        /// </summary>
        public float[] Values
        {
            set { fltsValues = value; }
            get { return fltsValues; }
        }

        /// <summary>
        /// 图像的宽度
        /// </summary>
        public int Width
        {
            set
            {
                if (value < 100)
                {
                    fltWidth = 100;
                }
                else
                {
                    fltWidth = value;
                }
            }
            get
            {
                if (fltWidth <= 100)
                {
                    return 100;
                }
                else
                {
                    return fltWidth;
                }
            }
        }

        /// <summary>
        /// 图像的高度
        /// </summary>
        public int Height
        {
            set
            {
                if (value < 100)
                {
                    fltHeight = 100;
                }
                else
                {
                    fltHeight = value;
                }
            }
            get
            {
                if (fltHeight <= 100)
                {
                    return 100;
                }
                else
                {
                    return fltHeight;
                }
            }
        }

        /// <summary>
        /// 标题
        /// </summary>
        public string Title
        {
            set { strTitle = value; }
            get { return strTitle; }
        }

        /// <summary>
        /// 标签
        /// </summary>
        public string Label
        {
            set { strLabel = value; }
            get { return strLabel; }
        }

        /// <summary>
        /// 最大点个数
        /// </summary>
        public int MaxDot
        {
            set { intMaxDot = value; }
            get { return intMaxDot; }

        }

        /// <summary>
        /// 最大值
        /// </summary>
        public float MaxValue
        {
            set { fltMaxValue = value; }
            get { return fltMaxValue; }
        }

        /// <summary>
        /// 线条颜色
        /// </summary>
        public Color ForeColor
        {
            set { corForeColor = value; }
            get { return corForeColor; }
        }

        /// <summary>
        /// x坐标显示
        /// </summary>
        private Dictionary<int, string> xshow = null;

        /// <summary>
        /// label , title, maxDot , maxValue, memo , foreColor , top , left , width , height
        /// </summary>
        /// <param name="label"></param>
        /// <param name="title"></param>
        /// <param name="maxDot"></param>
        /// <param name="maxValue"></param>
        /// <param name="foreColor"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        public Histogram(string label, string title, int maxDot, float maxValue, string foreColor, int width, int height, Dictionary<int, string> xShow = null)
        {
            Label = label;
            Title = title;
            MaxDot = maxDot;
            if (maxValue == 0)
            {
                maxValue = height;
            }
            MaxValue = maxValue;
            Width = width;
            Height = height;
            ForeColor = GetForeColor(foreColor);
            xshow = xShow;
        }

        /// <summary>
        /// 获得图片流
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public Stream GetImageStram(string name)
        {
            return this.GetType().Assembly.GetManifestResourceStream("LIS.Mach.ImageDeal.Image." + name);
        }

        /// <summary>
        /// 画图逻辑
        /// </summary>
        public Bitmap CreateImage()
        {
            //initial();
            //#1.画坐标系,先简单画两条线,暂时不做细节
            //#1.1创建空位图
            int imgHeight = Height + 80;
            int imgWidth = Width + 10;
            Bitmap img = new Bitmap(imgWidth, imgHeight);
            //#1.2获得画图句柄
            Graphics g = Graphics.FromImage(img);
            g.Clear(Color.White);
            //+抗锯齿
            g.SmoothingMode = SmoothingMode.AntiAlias;
            //#1.3偏移
            int x = 1;
            int y = -60;
            //画横纵坐标线
            Pen pen = new Pen(Color.Black);
            pen.Width = 2;
            g.DrawLine(pen, 10, Height - y, Width, Height - y);
            g.DrawLine(pen, 10, 10, 10, Height - y);
            //#2.画标题和标签
            Point pLabel = new Point((Width + 30) / 2, Height - y);
            Font myFont2 = new Font("宋体", 12, FontStyle.Regular);
            Brush bush2 = new SolidBrush(Color.Black);
            g.DrawString(Label, myFont2, bush2, pLabel);
            Point pTitle = new Point((Width + 30) / 2, 20);
            g.DrawString(Title, myFont2, bush2, pTitle);
            //#3.开始进点的数据,进行绘图
            float radix = 1;
            radix = Width / MaxDot;
            float preY = -1;
            int curindex = 0;
            float radiy = 1;
            radiy = Height / MaxValue;
            foreach (var d in Values)
            {

                if (preY == -1)
                {
                    pen = new Pen(Color.Black);
                    pen.Width = 1;
                }
                else
                {
                    pen = new Pen(Color.Black);
                    pen.Width = 1;
                    g.DrawLine(pen, 10 + x * radix, Height - d * radiy - y, 10 + (x - 1) * radix, preY - y);
                }
                preY = Height - d * radiy;
                x += 1;
                curindex++;
            }
            if (xshow != null)
            {
                StringFormat drawFormat = new StringFormat(StringFormatFlags.NoClip);
                drawFormat.Alignment = StringAlignment.Center;
                foreach (var xk in xshow.Keys)
                {
                    g.DrawLine(pen, xk, imgHeight - 18, xk, imgHeight - 22);
                    g.DrawString(xshow[xk], myFont2, bush2, xk, imgHeight - 20, drawFormat);
                }
            }
            return img;
        }

        /// <summary>
        /// 根据代码获取颜色
        /// </summary>
        /// <param name="foreColor"></param>
        /// <returns>
        ///foreColor:0=黑色,1=蓝色,2=绿色,3=青色,4=红色,5=洋红色,6=黄色,7=白色,8=灰色
        ///9=亮蓝色,10=亮绿色,11=亮青色,12=亮红色,13=亮洋红色,14=亮黄色,15=亮白色,
        /// </returns>
        private Color GetForeColor(string foreColor)
        {
            Color colorVal;
            switch (foreColor)
            {
                case "00":
                    colorVal = Color.Black;
                    break;
                default:
                    colorVal = Color.Black;
                    break;


            }
            return colorVal;
        }

        //初始化程序
        private void initial()
        {
            return;
        }
    }
    #endregion

    #region 画散点图
    /// <summary>
    /// 5diff散点图公共类,简单散点图,没有颜色
    /// 每128位一行,0画背景色,1画点数据
    /// </summary>
    public class Coulter5diff
    {
        /// <summary>
        /// 点数据用二进制表示
        /// </summary>
        private StringBuilder difPlot;
        private int fltHeight;
        private int fltWidth;
        private string strTitle;
        private string strLabel;
        /// <summary>
        /// 一行点个数
        /// </summary>
        int imgRowNum = 127;

        /// <summary>
        /// 点数据
        /// </summary>
        public StringBuilder DifPlot
        {
            set { difPlot = value; }
            get { return difPlot; }
        }

        /// <summary>
        /// 图像的宽度
        /// </summary>
        public int Width
        {
            set
            {
                if (value < 100)
                {
                    fltWidth = 100;
                }
                else
                {
                    fltWidth = value;
                }
            }
            get
            {
                if (fltWidth <= 100)
                {
                    return 100;
                }
                else
                {
                    return fltWidth;
                }
            }
        }

        /// <summary>
        /// 图像的高度
        /// </summary>
        public int Height
        {
            set
            {
                if (value < 100)
                {
                    fltHeight = 100;
                }
                else
                {
                    fltHeight = value;
                }
            }
            get
            {
                if (fltHeight <= 100)
                {
                    return 100;
                }
                else
                {
                    return fltHeight;
                }
            }
        }

        /// <summary>
        /// 标题
        /// </summary>
        public string Title
        {
            set { strTitle = value; }
            get { return strTitle; }
        }

        /// <summary>
        /// 标签
        /// </summary>
        public string Label
        {
            set { strLabel = value; }
            get { return strLabel; }
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        public Coulter5diff()
            : this("", "", "", 320, 640)
        {

        }

        /// <summary>
        /// 一个参数构造函数
        /// </summary>
        /// <param name="difPlot"></param>
        public Coulter5diff(string difPlot)
            : this(difPlot, "", "", 320, 640)
        {

        }

        /// <summary>
        /// 全参数构造函数
        /// </summary>
        /// <param name="difPlot">点数据</param>
        /// <param name="label">标签</param>
        /// <param name="title">标题</param>
        /// <param name="width">宽度</param>
        /// <param name="height">高度</param>
        public Coulter5diff(string difPlot, string label, string title, int height, int width)
        {
            Label = label;
            Title = title;
            Width = width;
            Height = height;
            this.DifPlot.Append(difPlot);
        }

        public Coulter5diff(StringBuilder difPlot, string label, string title, string height, string width)
        {
            this.difPlot = difPlot;
            this.Label = label;
            this.Title = title;
            this.Height = Convert.ToInt32(height);
            this.Width = Convert.ToInt32(width);
        }
        public Bitmap CreateImage()
        {
            //#1.画坐标系,先简单画两条线,暂时不做细节
            //#1.1创建空位图
            int imgHeight = Height + 10;
            int imgWidth = Width + 10;
            Bitmap img = new Bitmap(imgWidth, imgHeight);

            //#1.2获得画图句柄
            Graphics g = Graphics.FromImage(img);
            g.Clear(Color.White);
            //#1.3偏移
            int x = 1;
            int y = -60;
            //+抗锯齿
            g.SmoothingMode = SmoothingMode.AntiAlias;
            //#2.画标题和标签
            Point pLabel = new Point((Width + 30) / 2, Height - y);
            Font myFont2 = new Font("宋体", 12, FontStyle.Regular);
            Brush bush2 = new SolidBrush(Color.Black);
            g.DrawString(Label, myFont2, bush2, pLabel);
            Point pTitle = new Point((Width + 30) / 2, 20);
            g.DrawString(Title, myFont2, bush2, pTitle);

            //开始绘图咯
            int metaX = Width / 128;
            int metaY = Height / 128;
            int curX = 10;
            int curY = 10;
            for (int i = 0; i < difPlot.Length; i++)
            {
                int curRow = i / 127;
                int curCol = i % 127;
                curX = 10 + metaX * curCol;
                curY = 10 + metaY * curRow;
                Point point = new Point(curX, curY);
                //为0画背景图,1画红点图
                if (difPlot.ToString().Substring(i, 1) == "0")
                {
                    g.FillEllipse(Brushes.White, curX, curY, metaX, metaY);
                }
                else
                {
                    g.FillEllipse(Brushes.Red, curX, curY, metaX, metaY);
                }
            }

            return img;

        }

    }

    #endregion

}

调用绘图

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LIS.BLL.ImageCore;
using LIS.Mach.ImageDeal;
using System.IO;

namespace iMedicalLISBCIMage
{
    public partial class FrmMian : Form
    {
        public FrmMian()
        {
            InitializeComponent();
        }

        /// <summary>
        /// 生成RBC
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnRBC_Click(object sender, EventArgs e)
        {
            if (picShow.Image != null)
            {
                picShow.Image.Dispose();
            }
            //剔除检验IOC直接创建
            IDrawImage deal = new Imagebc6800();
            bool ret = deal.DrawImage("999", txtRBC.Text, "仪器", "", "", "Histogram#RBC#RBC######10#10#320#138", "");
            if (ret == true)
            {
                DirectoryInfo di = new DirectoryInfo("c:\\trak\\tmpMach");
                FileInfo[] fi = di.GetFiles("*.bmp");
                if (fi != null && fi.Length > 0)
                {
                    picShow.Image = Image.FromFile(fi[0].FullName);
                }
                MessageBox.Show(@"生成在C:\TRAK\tmpMach下!");
            }
            else
            {
                MessageBox.Show(ret.ToString());
            }
        }

        /// <summary>
        /// 生成PLT
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnPLT_Click(object sender, EventArgs e)
        {
            if (picShow.Image != null)
            {
                picShow.Image.Dispose();
            }
            //剔除检验IOC直接创建
            IDrawImage deal = new Imagebc6800();
            bool ret = deal.DrawImage("999", txtPLT.Text, "仪器", "", "", "Histogram#PLT#PLT######10#10#320#138", "");
            if (ret == true)
            {
                DirectoryInfo di = new DirectoryInfo("c:\\trak\\tmpMach");
                FileInfo[] fi = di.GetFiles("*.bmp");
                if (fi != null && fi.Length > 0)
                {
                    picShow.Image = Image.FromFile(fi[0].FullName);
                }
                MessageBox.Show(@"生成在C:\TRAK\tmpMach下!");
            }
            else
            {
                MessageBox.Show(ret.ToString());
            }
        }

        /// <summary>
        /// 生成DIFF
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDIFF_Click(object sender, EventArgs e)
        {
            if (picShow.Image != null)
            {
                picShow.Image.Dispose();
            }
            //剔除检验IOC直接创建
            IDrawImage deal = new Imagebc6800();
            bool ret = deal.DrawImage("999", txtDIFF.Text, "仪器", "", "", "DiffPlot#DIFF#######10#10#320#138", "");
            if (ret == true)
            {
                DirectoryInfo di = new DirectoryInfo("c:\\trak\\tmpMach");
                FileInfo[] fi = di.GetFiles("*.bmp");
                if (fi != null && fi.Length > 0)
                {
                    picShow.Image = Image.FromFile(fi[0].FullName);
                }
                MessageBox.Show(@"生成在C:\TRAK\tmpMach下!");
            }
            else
            {
                MessageBox.Show(ret.ToString());
            }
        }

        /// <summary>
        /// 生成Baso
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnBaso_Click(object sender, EventArgs e)
        {
            if (picShow.Image != null)
            {
                picShow.Image.Dispose();
            }
            //剔除检验IOC直接创建
            IDrawImage deal = new Imagebc6800();
            bool ret = deal.DrawImage("999", txtBaso.Text, "仪器", "", "", "DiffPlot#Baso#######10#10#320#138", "");
            if (ret == true)
            {
                DirectoryInfo di = new DirectoryInfo("c:\\trak\\tmpMach");
                FileInfo[] fi = di.GetFiles("*.bmp");
                if (fi != null && fi.Length > 0)
                {
                    picShow.Image = Image.FromFile(fi[0].FullName);
                }
                MessageBox.Show(@"生成在C:\TRAK\tmpMach下!");
            }
            else
            {
                MessageBox.Show(ret.ToString());
            }
        }
    }
}

RBC
数据串

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQECAgICAgICAwQFBgcJDBAUGyMuOkZWZnqQornO2+vx+//8/fbt4M3AsJyOfXBgUkc8MikiHBcSDw0MCgkICAcGBgUGBQUFBAQDAwMDAwMDAgIDAgICAgICAgICAgICAgICAwICAgICAgICAgICAQEBAQEBAQEBAQEBAQEBAQEBAQEBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==

PLT
数据串

AAADCRMjN05icn2AgoOIkJijrbW8wcnR2uHq8Pf8/P///ffy7ufe19DJwry5tK6noJuVjoeCenJsZ2NhYF5cWlZRTUhDPjo2Mi4sKiclJSQkJCQkJCQjIiIiISAeHBoYFhQTExMTExMSEhEQEBEREBAPDg0NDxAREhESEREREhQ=

DIFF

Baso

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小乌鱼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值