Search in sources :

Example 1 with PrintHelper

use of android.support.v4.print.PrintHelper in project cw-omnibus by commonsguy.

the class MainActivity method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == IMAGE_REQUEST_ID && resultCode == Activity.RESULT_OK) {
        try {
            PrintHelper help = new PrintHelper(this);
            help.setScaleMode(PrintHelper.SCALE_MODE_FIT);
            help.printBitmap("Photo!", data.getData());
        } catch (FileNotFoundException e) {
            Log.e(getClass().getSimpleName(), "Exception printing bitmap", e);
        }
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) PrintHelper(android.support.v4.print.PrintHelper)

Example 2 with PrintHelper

use of android.support.v4.print.PrintHelper in project android_packages_apps_Gallery2 by LineageOS.

the class FilterShowActivity method print.

public void print() {
    Bitmap bitmap = MasterImage.getImage().getHighresImage();
    PrintHelper printer = new PrintHelper(this);
    printer.printBitmap("ImagePrint", bitmap);
}
Also used : Bitmap(android.graphics.Bitmap) PrintHelper(android.support.v4.print.PrintHelper)

Example 3 with PrintHelper

use of android.support.v4.print.PrintHelper in project android_packages_apps_Gallery2 by LineageOS.

the class AbstractGalleryActivity method printSelectedImage.

public void printSelectedImage(Uri uri) {
    if (uri == null) {
        return;
    }
    String printJobName = getLastPathSegment(uri);
    if (printJobName == null) {
        printJobName = DEFAULT_PRINT_JOB_NAME;
    }
    PrintHelper printer = new PrintHelper(this);
    try {
        printer.printBitmap(printJobName, uri);
    } catch (FileNotFoundException fnfe) {
        Log.e(TAG, "Error printing an image", fnfe);
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) PrintHelper(android.support.v4.print.PrintHelper)

Example 4 with PrintHelper

use of android.support.v4.print.PrintHelper in project Camera-Roll-Android-App by kollerlukas.

the class ItemActivity method printPhoto.

public void printPhoto() {
    if (!(albumItem instanceof Photo)) {
        Toast.makeText(this, R.string.error, Toast.LENGTH_SHORT).show();
        return;
    }
    PrintHelper photoPrinter = new PrintHelper(this);
    photoPrinter.setScaleMode(PrintHelper.SCALE_MODE_FIT);
    try {
        photoPrinter.printBitmap(albumItem.getPath(), albumItem.getUri(this));
    } catch (FileNotFoundException e) {
        Toast.makeText(this, "Error (FileNotFoundException)", Toast.LENGTH_SHORT).show();
        e.printStackTrace();
    }
}
Also used : FileNotFoundException(java.io.FileNotFoundException) Photo(us.koller.cameraroll.data.models.Photo) PrintHelper(android.support.v4.print.PrintHelper)

Example 5 with PrintHelper

use of android.support.v4.print.PrintHelper in project gh4a by slapperwan.

the class FileViewerActivity method handlePrintRequest.

@Override
protected boolean handlePrintRequest() {
    if (!FileUtils.isImage(mPath)) {
        return false;
    }
    String base64Data = mContent != null ? mContent.content() : null;
    if (base64Data == null) {
        return false;
    }
    byte[] decodedData = Base64.decode(base64Data, Base64.DEFAULT);
    Bitmap bitmap = BitmapFactory.decodeByteArray(decodedData, 0, decodedData.length);
    PrintHelper printHelper = new PrintHelper(this);
    printHelper.setScaleMode(PrintHelper.SCALE_MODE_FIT);
    printHelper.printBitmap(getDocumentTitle(), bitmap);
    return true;
}
Also used : Bitmap(android.graphics.Bitmap) PrintHelper(android.support.v4.print.PrintHelper)

Aggregations

PrintHelper (android.support.v4.print.PrintHelper)6 FileNotFoundException (java.io.FileNotFoundException)3 Bitmap (android.graphics.Bitmap)2 WriterException (com.google.zxing.WriterException)1 Photo (us.koller.cameraroll.data.models.Photo)1