Esempio n. 1
0
        public void PrintDrawable(Android.Content.Res.Resources res, int id)
        {
            try
            {
                int    maxWidth = GetDrawableMaxWidth();
                Bitmap image    = ScalingBitmap(res, id, maxWidth);

                if (image == null)
                {
                    return;
                }

                byte[] command = PrinterUtils.DecodeBitmap(image, heightParting);
                image.Recycle();

                try
                {
                    if (command != null)
                    {
                        Write(command);
                    }
                }
                catch (IOException e)
                {
                    throw new IOException(e.Message);
                }
            }
            catch (System.Exception ex)
            {
                throw new IOException(ex.Message);
            }
        }
Esempio n. 2
0
        public void PrintBitmap(Bitmap image)
        {
            int maxWidth = GetDrawableMaxWidth();

            Bitmap scalingImage = ScalingBitmap(image, maxWidth);

            if (scalingImage == null)
            {
                return;
            }

            byte[] command = PrinterUtils.DecodeBitmap(scalingImage, heightParting);

            scalingImage.Recycle();

            try
            {
                if (command != null)
                {
                    Write(command);
                }
            }
            catch (IOException e)
            {
                throw new IOException(e.Message);
            }
        }
Esempio n. 3
0
 public void SetFontSize(int size)
 {
     try
     {
         Write(PrinterUtils.FontSizeSetBig(size));
     }
     catch (System.Exception ex)
     {
         throw new IOException(ex.Message);
     }
 }
Esempio n. 4
0
 public void SetEmphasizedOff()
 {
     try
     {
         Write(PrinterUtils.EmphasizedOff());
     }
     catch (System.Exception ex)
     {
         throw new IOException(ex.Message);
     }
 }
Esempio n. 5
0
 public void SetAlignRight()
 {
     try
     {
         Write(PrinterUtils.AlignRight());
     }
     catch (System.Exception ex)
     {
         throw new IOException(ex.Message);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// 初始化
 /// </summary>
 public void Init()
 {
     try
     {
         bos = new ByteArrayOutputStream();
         Write(PrinterUtils.InitPrinter());
     }
     catch (System.Exception ex)
     {
         throw new IOException(ex.Message);
     }
 }
Esempio n. 7
0
        /// <summary>
        /// 获取图片数据流
        /// </summary>
        /// <param name="image"></param>
        /// <returns></returns>
        public List <byte[]> GetImageByte(Bitmap image)
        {
            int    maxWidth     = GetDrawableMaxWidth();
            Bitmap scalingImage = ScalingBitmap(image, maxWidth);

            if (scalingImage == null)
            {
                return(null);
            }
            List <byte[]> data = PrinterUtils.DecodeBitmapToDataList(image, heightParting);

            image.Recycle();
            return(data);
        }
Esempio n. 8
0
        /// <summary>
        /// 获取图片数据流
        /// </summary>
        /// <param name="drawable"></param>
        /// <returns></returns>
        public List <byte[]> GetImageByte(Android.Graphics.Drawables.Drawable drawable)
        {
            int    maxWidth = GetDrawableMaxWidth();
            Bitmap image    = ScalingDrawable(drawable, maxWidth);

            if (image == null)
            {
                return(null);
            }
            List <byte[]> data = PrinterUtils.DecodeBitmapToDataList(image, heightParting);

            image.Recycle();
            return(data);
        }
Esempio n. 9
0
 public void SetLineHeight(int height)
 {
     try
     {
         if (height >= 0 && height <= 255)
         {
             Write(PrinterUtils.PrintLineHeight((byte)height));
         }
     }
     catch (System.Exception ex)
     {
         throw new IOException(ex.Message);
     }
 }
Esempio n. 10
0
        /// <summary>
        /// 获取图片数据流
        /// </summary>
        /// <param name="res"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public List <byte[]> GetImageByte(Android.Content.Res.Resources res, int id)
        {
            int    maxWidth = GetDrawableMaxWidth();
            Bitmap image    = ScalingBitmap(res, id, maxWidth);

            if (image == null)
            {
                return(null);
            }

            List <byte[]> data = PrinterUtils.DecodeBitmapToDataList(image, heightParting);

            image.Recycle();
            return(data);
        }
Esempio n. 11
0
 public void FeedPaperCutPartial()
 {
     Write(PrinterUtils.FeedPaperCutPartial());
 }
Esempio n. 12
0
 public void PrintLineFeed()
 {
     Write(PrinterUtils.PrintLineFeed());
 }