/// <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);
        }
Exemple #2
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);
            }
        }