0

I am using this library for make some drawing but I would be able to check if the field is empty ( so no drawing is in the layout ).

Because I'm printing the drawable on a thermal printer and if someone make no drawable is just wastes the paper.

Here is my method onClick where I get the drawable from the layout and set it to a bitmap:

 parentView.setDrawingCacheEnabled(true);

 bitmap = Bitmap.createScaledBitmap(parentView.getDrawingCache(),510, 360, false);
 BitmapDrawable ob = new BitmapDrawable(getResources(), bitmap);
begiNNer
  • 128
  • 12
NiceToMytyuk
  • 3,644
  • 3
  • 39
  • 100

1 Answers1

1

BitmapCompat.getAllocationByteCount(bitmap) check size of bitmap before print. Most probably it could be zero approximately zero for empty drawable. Check it and pops dialog yes, no with a message like "seems like you print empty drawing". If user select yes print it. otherwise, cancel the operation

PushpikaWan
  • 2,437
  • 3
  • 14
  • 23