@Test public void handlesNoFonts() { PrintPreview printPreview = setupValidPrintPreview(false); Bitmap bitmap = printPreview.getScaledBitmap(RuntimeEnvironment.application); assertThat(bitmap).isNotNull(); }
public Bitmap getScaledBitmap(Context context) { cursor = VERTICAL_MARGIN; DisplayMetrics metrics = context.getResources().getDisplayMetrics(); Bitmap bitmap = getBitmap(); float pxPerMm = metrics.xdpi / 25.4f; int width = bitmap.getWidth(); float scale = (printerSettings.getPrintableWidth() * pxPerMm) / (float) width; return Bitmap.createScaledBitmap(bitmap, (int) (bitmap.getWidth() * scale), (int) (bitmap.getHeight() * scale), true); }
PrintPreview { public Bitmap getScaledBitmap(Context context) { cursor = VERTICAL_MARGIN; DisplayMetrics metrics = context.getResources().getDisplayMetrics(); Bitmap bitmap = getBitmap(); float pxPerMm = metrics.xdpi / 25.4f; int width = bitmap.getWidth(); float scale = (printerSettings.getPrintableWidth() * pxPerMm) / (float) width; return Bitmap.createScaledBitmap(bitmap, (int) (bitmap.getWidth() * scale), (int) (bitmap.getHeight() * scale), true); } }
PrintPreview { public Bitmap getScaledBitmap(Context context) { cursor = VERTICAL_MARGIN; DisplayMetrics metrics = context.getResources().getDisplayMetrics(); Bitmap bitmap = getBitmap(); float pxPerMm = metrics.xdpi / 25.4f; int width = bitmap.getWidth(); float scale = (printerSettings.getPrintableWidth() * pxPerMm) / (float) width; return Bitmap.createScaledBitmap(bitmap, (int) (bitmap.getWidth() * scale), (int) (bitmap.getHeight() * scale), true); } PrintPreview(PrintPayload printPayload, PrinterSettings printerSettings); }
PrintPreview { public Bitmap getScaledBitmap(Context context) { cursor = VERTICAL_MARGIN; DisplayMetrics metrics = context.getResources().getDisplayMetrics(); Bitmap bitmap = getBitmap(); float pxPerMm = metrics.xdpi / 25.4f; int width = bitmap.getWidth(); float scale = (printerSettings.getPrintableWidth() * pxPerMm) / (float) width; return Bitmap.createScaledBitmap(bitmap, (int) (bitmap.getWidth() * scale), (int) (bitmap.getHeight() * scale), true); } PrintPreview(PrintPayload printPayload, PrinterSettings printerSettings); Bitmap getBitmap(); Bitmap getScaledBitmap(Context context); byte[] getCompressedBitmap(); int determineHeight(); }
PrintPreview { public Bitmap getScaledBitmap(Context context) { cursor = VERTICAL_MARGIN; DisplayMetrics metrics = context.getResources().getDisplayMetrics(); Bitmap bitmap = getBitmap(); float pxPerMm = metrics.xdpi / 25.4f; int width = bitmap.getWidth(); float scale = (printerSettings.getPrintableWidth() * pxPerMm) / (float) width; return Bitmap.createScaledBitmap(bitmap, (int) (bitmap.getWidth() * scale), (int) (bitmap.getHeight() * scale), true); } PrintPreview(PrintPayload printPayload, PrinterSettings printerSettings); Bitmap getBitmap(); Bitmap getScaledBitmap(Context context); byte[] getCompressedBitmap(); int determineHeight();  }