/// <summary>
        /// 从字库文件获取文字
        /// </summary>
        /// <param name="offset">偏移</param>
        /// <param name="isInverse">是否反色</param>
        /// <returns></returns>
        private ImageBuilder GetHzk(int offset, bool isInverse = false)
        {
            int colorWhite = Constants.COLOR_WHITE;
            int colorBlack = Constants.COLOR_BLACK;

            if (isInverse)
            {
                colorWhite = Constants.COLOR_BLACK;
                colorBlack = Constants.COLOR_WHITE;
            }
            for (int i = 0; i < 32; i++)
            {
                int t = _hzkBuf[offset + i];
                int k = i << 3;
                _wordPixels[k]     = (t & 0x80) != 0 ? colorBlack : colorWhite;
                _wordPixels[k | 1] = (t & 0x40) != 0 ? colorBlack : colorWhite;
                _wordPixels[k | 2] = (t & 0x20) != 0 ? colorBlack : colorWhite;
                _wordPixels[k | 3] = (t & 0x10) != 0 ? colorBlack : colorWhite;
                _wordPixels[k | 4] = (t & 0x08) != 0 ? colorBlack : colorWhite;
                _wordPixels[k | 5] = (t & 0x04) != 0 ? colorBlack : colorWhite;
                _wordPixels[k | 6] = (t & 0x02) != 0 ? colorBlack : colorWhite;
                _wordPixels[k | 7] = (t & 0x01) != 0 ? colorBlack : colorWhite;
            }
            _hzkBitmapBuilder.SetPixels(0, 0, 16, 16, ImageBuilderUtil.PixelsToBuffer(_wordPixels), 0, 16);
            return(_hzkBitmapBuilder);
        }
Beispiel #2
0
        /// <summary>
        /// 根据当前数据创建位图数组
        /// </summary>
        private void CreateBitmaps()
        {
            _bitmaps = new ImageBuilder[Number];

            int[] tmp     = new int[Width * Height];
            int   iOfData = 0;

            if (_transparent)
            {
                for (int i = 0; i < Number; i++)
                {
                    int cnt = 0, iOfTmp = 0;
                    for (int y = 0; y < Height; y++)
                    {
                        for (int x = 0; x < Width; x++)
                        {
                            if (((_data[iOfData] << cnt) & 0x80) != 0)
                            {
                                tmp[iOfTmp] = Constants.COLOR_TRANSP;
                            }
                            else
                            {
                                tmp[iOfTmp] = ((_data[iOfData] << cnt << 1) & 0x80) != 0 ?
                                              Constants.COLOR_BLACK : Constants.COLOR_WHITE;
                            }
                            ++iOfTmp;
                            cnt += 2;
                            if (cnt >= 8)
                            {
                                cnt = 0;
                                ++iOfData;
                            }
                        }

                        if (cnt > 0 && cnt <= 7)
                        {
                            cnt = 0;
                            ++iOfData;
                        }
                        if (iOfData % 2 != 0)
                        {
                            ++iOfData;
                        }
                    }
                    _bitmaps[i] = Context.GraphicsFactory.NewImageBuilder(ImageBuilderUtil.IntegerArrayToImageBytes(tmp, Width, Height), Width, Height);
                } // for mNumber
            }
            else
            { // 不透明
                for (int i = 0; i < Number; i++)
                {
                    int cnt = 0, iOfTmp = 0;
                    for (int y = 0; y < Height; y++)
                    {
                        for (int x = 0; x < Width; x++)
                        {
                            tmp[iOfTmp++] = ((_data[iOfData] << cnt) & 0x80) != 0 ? Constants.COLOR_BLACK
                                    : Constants.COLOR_WHITE;
                            if (++cnt >= 8)
                            {
                                cnt = 0;
                                ++iOfData;
                            }
                        }
                        if (cnt != 0)
                        { // 不足一字节的舍去
                            cnt = 0;
                            ++iOfData;
                        }
                    } // end for (int y = ...
                    _bitmaps[i] = Context.GraphicsFactory.NewImageBuilder(ImageBuilderUtil.IntegerArrayToImageBytes(tmp, Width, Height), Width, Height);
                }     // end for (int i = ...*/
            }         // end if
        }
Beispiel #3
0
        public void Init()
        {
            var canvas = Context.GraphicsFactory.NewCanvas();

            Paint paint = new Paint();

            paint.SetColor(Constants.COLOR_WHITE);
            paint.SetStyle(PaintStyle.FILL_AND_STROKE);

            if (bmpInformationBg == null)
            {
                bmpInformationBg = new ImageBuilder[5];
                for (int i = 0; i < 5; i++)
                {
                    bmpInformationBg[i] = Context.GraphicsFactory.NewImageBuilder(138, 23 + 16 * i);
                    canvas.SetBitmap(bmpInformationBg[i]);
                    canvas.DrawColor(Constants.COLOR_BLACK);
                    canvas.DrawRect(1, 1, 135, 20 + 16 * i, paint);
                    canvas.DrawRect(136, 0, 138, 3, paint);
                    canvas.DrawLine(0, 21 + 16 * i, 3, 21 + 16 * i, paint);
                    canvas.DrawLine(0, 22 + 16 * i, 3, 22 + 16 * i, paint);
                }
            }

            if (bmpSideFrame == null)
            {
                bmpSideFrame = Context.GraphicsFactory.NewImageBuilder(8, 96);
                canvas.SetBitmap(bmpSideFrame);
                canvas.DrawColor(Constants.COLOR_WHITE);
                paint.SetColor(Constants.COLOR_BLACK);
                for (int i = 0; i < 8; i += 2)
                {
                    canvas.DrawLine(i, 0, i, 96, paint);
                }
            }

            if (bmpTriangleCursor == null)
            {
                bmpTriangleCursor = Context.GraphicsFactory.NewImageBuilder(7, 13);
                canvas.SetBitmap(bmpTriangleCursor);
                canvas.DrawColor(Constants.COLOR_WHITE);
                for (int i = 0; i < 7; ++i)
                {
                    canvas.DrawLine(i, i, i, 13 - i, paint);
                }
            }

            if (imgSmallNum == null)
            {
                imgSmallNum = Context.LibData.GetImage(2, 5);
            }

            if (bmpChuandai == null)
            {
                bmpChuandai = Context.GraphicsFactory.NewImageBuilder(22, 39);
                int   b = Constants.COLOR_BLACK, w = Constants.COLOR_WHITE;
                int[] pixels =
                {
                    w, w, w, w, w, w, w, w, w, b, b, b, w, w, w, w, w, w, w, w, w, w,
                    w, w, w, b, b, w, w, b, b, b, b, b, b, b, b, b, b, b, b, b, w, w,
                    w, w, b, b, b, b, b, w, w, w, w, w, w, w, w, b, b, b, b, b, w, w,
                    w, w, b, b, w, w, w, b, b, b, w, w, b, b, b, w, w, w, b, b, w, w,
                    w, w, w, b, w, w, b, w, w, w, w, w, w, w, w, w, w, w, b, b, w, w,
                    w, w, w, b, w, w, b, b, b, b, b, b, b, b, b, b, b, w, w, w, w, w,
                    w, w, w, w, w, w, w, b, w, w, w, w, b, b, w, w, w, w, w, w, w, w,
                    w, w, w, w, w, w, b, b, b, b, b, b, b, b, b, b, b, b, b, b, b, b,
                    w, w, w, w, w, w, b, b, w, w, w, b, b, b, b, w, b, b, b, b, b, b,
                    w, w, w, w, w, w, w, w, w, b, b, b, b, b, b, w, w, w, b, b, b, w,
                    w, w, w, w, w, w, b, b, b, b, w, w, b, b, b, w, w, w, w, w, w, w,
                    b, b, b, b, b, b, b, b, w, w, w, w, b, b, b, w, w, w, w, w, w, w,
                    w, b, b, b, b, w, w, w, w, w, w, w, b, b, w, w, w, w, w, w, w, w,
                    w, w, w, w, w, w, w, w, b, b, b, b, b, b, w, w, w, w, w, w, w, w,
                    w, w, w, w, w, w, w, w, w, b, b, b, b, w, w, w, w, w, w, w, w, w,
                    w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w,
                    w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w,
                    w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w,
                    w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w,
                    w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w,
                    w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w,
                    w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w,
                    w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w,
                    w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w,
                    w, w, w, w, w, w, b, w, w, w, w, b, b, w, w, w, b, w, w, w, w, w,
                    w, w, w, b, b, b, b, b, b, b, w, b, b, w, w, b, b, w, w, w, w, w,
                    w, w, b, b, w, w, b, w, w, w, w, b, b, w, b, w, w, w, w, w, w, w,
                    w, w, b, b, b, b, b, b, b, b, b, b, b, b, b, b, b, b, w, w, w, w,
                    b, b, b, b, b, b, b, b, b, b, b, b, b, b, b, b, b, w, w, w, w, w,
                    w, w, w, b, b, b, b, b, b, b, w, b, b, w, b, b, w, w, w, w, w, w,
                    w, w, w, b, b, w, b, b, b, b, w, b, b, w, b, b, w, w, w, w, w, w,
                    w, w, w, b, w, b, b, w, w, b, w, w, b, w, b, b, w, w, w, w, w, w,
                    w, w, w, b, b, b, b, b, b, b, w, w, b, b, b, b, w, w, w, w, w, w,
                    w, w, w, b, b, b, b, b, b, b, w, w, b, b, b, w, w, w, w, w, w, w,
                    w, w, w, w, b, b, b, b, b, w, w, w, w, b, b, b, w, w, w, w, w, w,
                    b, b, b, b, b, w, w, w, w, b, b, b, b, b, b, b, b, b, b, w, w, w,
                    w, w, w, b, b, b, w, w, b, b, w, b, b, w, w, b, b, b, b, b, b, b,
                    w, w, b, b, w, w, w, w, w, w, b, w, w, w, w, w, b, b, b, b, b, w,
                    w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, w, b, b, w, w,
                };
                bmpChuandai.SetPixels(0, 0, 22, 39, ImageBuilderUtil.PixelsToBuffer(pixels), 0, 22);
            }
        }