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); } }
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); } }
public void SetFontSize(int size) { try { Write(PrinterUtils.FontSizeSetBig(size)); } catch (System.Exception ex) { throw new IOException(ex.Message); } }
public void SetEmphasizedOff() { try { Write(PrinterUtils.EmphasizedOff()); } catch (System.Exception ex) { throw new IOException(ex.Message); } }
public void SetAlignRight() { try { Write(PrinterUtils.AlignRight()); } catch (System.Exception ex) { throw new IOException(ex.Message); } }
/// <summary> /// 初始化 /// </summary> public void Init() { try { bos = new ByteArrayOutputStream(); Write(PrinterUtils.InitPrinter()); } catch (System.Exception ex) { throw new IOException(ex.Message); } }
/// <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); }
/// <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); }
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); } }
/// <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); }
public void FeedPaperCutPartial() { Write(PrinterUtils.FeedPaperCutPartial()); }
public void PrintLineFeed() { Write(PrinterUtils.PrintLineFeed()); }