コード例 #1
0
ファイル: ImageWorker.cs プロジェクト: vsnicarevs/peninsula
        /// <summary>
        /// 整体处理图像(+1重载)
        /// </summary>
        /// <param name="rawValues">图像源数据</param>
        /// <param name="width">宽度</param>
        /// <param name="height">高度</param>
        /// <param name="iMagnify">放大倍数</param>
        /// <returns>处理后的图像</returns>
        public static Bitmap ImageDraw(byte[] rawValues, int width, int height, int iMagnify, Data data)
        {
            Bitmap bm = ToGrayBitmap(rawValues, width, height);
            Bitmap bmNew = new Bitmap(width, height);
            Color myColor;
            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    myColor = bm.GetPixel(i, j);
                    bmNew.SetPixel(i, j, myColor);
                }
            }
            bm = bmNew;
            myColor = Color.Yellow;
            for (int i = 0; i < data.BlackLine.Length; i++)
            {
                if (data.BlackL[i, 1] != 255 && data.BlackL[i, 0] != 255)
                {
                    bm.SetPixel(width - data.BlackL[i, 1] - 1, height - data.BlackL[i, 0] - 1, myColor);
                }
            }
            myColor = Color.Blue;
            for (int i = 0; i < data.BlackLine.Length; i++)
            {
                if (data.BlackR[i, 1] != 255 && data.BlackR[i, 0] != 255)
                {
                    bm.SetPixel(width - data.BlackR[i, 1] - 1, height - data.BlackR[i, 0] - 1, myColor);
                }
            }

            myColor = Color.Red;
            for (int i = 0; i < data.BlackLine.Length; i++)
            {
                if (data.BlackLine[i] != 255)
                {
                    bm.SetPixel(width - data.BlackLine[i] - 1, height - i - 1, myColor);
                }
            }

            bm = ImageStretch(bm, iMagnify);

            return bm;
        }
コード例 #2
0
ファイル: TextWorker.cs プロジェクト: vsnicarevs/peninsula
        public static Data ReadRestInfo(String _fileName, UInt16 _width, UInt16 _height, Boolean _needDecode)
        {
            Data d = new Data(_height);
            try
            {
                using (FileStream fs = File.OpenRead(_fileName))
                {
                    int startPos;
                    if (_needDecode)
                    {
                        startPos = _width * _height / 8;
                    }
                    else
                    {
                        startPos = _width * _height;
                    }
                    Byte[] data = new Byte[fs.Length - startPos];

                    fs.Seek(startPos, SeekOrigin.Begin);
                    fs.Read(data, 0, data.Length);

                    for (int i = 0; i < data.Length; i++)
                    {
                        if (i < _height * 2)
                        {
                            d.BlackR[i / 2, 0] = data[i];
                            d.BlackR[i / 2, 1] = data[i + 1];
                            i++;
                        }
                        else
                        {
                            if (i < _height * 4)
                            {
                                d.BlackL[i / 2 - _height, 0] = data[i];
                                d.BlackL[i / 2 - _height, 1] = data[i + 1];
                                i++;
                            }
                            else
                            {
                                if (i < _height * 5)
                                {
                                    d.BlackLine[i - _height * 4] = data[i];
                                }
                                else
                                {
                                    if (i < _height * 5 + 12)
                                    {
                                        d.A[0] = (Int32)(data[i] | (data[i + 1] << 8) | (data[i + 2] << 16) | (data[i + 3] << 24));
                                        i += 4;
                                        d.A[1] = (Int32)(data[i] | (data[i + 1] << 8) | (data[i + 2] << 16) | (data[i + 3] << 24));
                                        i += 4;
                                        d.A[2] = (Int32)(data[i] | (data[i + 1] << 8) | (data[i + 2] << 16) | (data[i + 3] << 24));
                                        i += 4;
                                    }
                                    else
                                    {
                                        if (i < _height * 5 + 24)
                                        {
                                            d.AT[0] = (Int16)(data[i] | (data[i + 1] << 8));
                                            i += 4;
                                            d.AT[1] = (Int16)(data[i] | (data[i + 1] << 8));
                                            i += 4;
                                            d.AT[2] = (Int16)(data[i] | (data[i + 1] << 8));
                                            i += 4;
                                        }
                                        else
                                        {
                                            if (i < _height * 5 + 28)
                                            {
                                                d.SPD = (Int32)(data[i] | (data[i + 1] << 8) | (data[i + 2] << 16) | (data[i + 3] << 24));
                                                i += 4;
                                            }
                                            else
                                            {
                                                if (i < _height * 5 + 32)
                                                {
                                                    d.SPT = (Int32)(data[i] | (data[i + 1] << 8) | (data[i + 2] << 16) | (data[i + 3] << 24));
                                                    i += 4;
                                                }
                                                else
                                                {
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                MessageSender.e = ex;
            }
            return d;
        }