Java Code Examples for android.graphics.Bitmap#getScaledHeight()

The following examples show how to use android.graphics.Bitmap#getScaledHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SelectableRoundedImageView.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
public SelectableRoundedCornerDrawable(Bitmap bitmap, Resources r) {
    mBitmap = bitmap;
    mBitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);

    if (bitmap != null) {
        mBitmapWidth = bitmap.getScaledWidth(r.getDisplayMetrics());
        mBitmapHeight = bitmap.getScaledHeight(r.getDisplayMetrics());
    } else {
        mBitmapWidth = mBitmapHeight = -1;
    }

    mBitmapRect.set(0, 0, mBitmapWidth, mBitmapHeight);

    mBitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBitmapPaint.setStyle(Paint.Style.FILL);
    mBitmapPaint.setShader(mBitmapShader);

    mBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBorderPaint.setStyle(Paint.Style.STROKE);
    mBorderPaint.setColor(mBorderColor.getColorForState(getState(), DEFAULT_BORDER_COLOR));
    mBorderPaint.setStrokeWidth(mBorderWidth);
}
 
Example 2
Source File: SelectableRoundedImageView.java    From Expert-Android-Programming with MIT License 6 votes vote down vote up
public SelectableRoundedCornerDrawable(Bitmap bitmap, Resources r) {
    mBitmap = bitmap;
    mBitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);

    if (bitmap != null) {
        mBitmapWidth = bitmap.getScaledWidth(r.getDisplayMetrics());
        mBitmapHeight = bitmap.getScaledHeight(r.getDisplayMetrics());
    } else {
        mBitmapWidth = mBitmapHeight = -1;
    }

    mBitmapRect.set(0, 0, mBitmapWidth, mBitmapHeight);

    mBitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBitmapPaint.setStyle(Paint.Style.FILL);
    mBitmapPaint.setShader(mBitmapShader);

    mBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBorderPaint.setStyle(Paint.Style.STROKE);
    mBorderPaint.setColor(mBorderColor.getColorForState(getState(), DEFAULT_BORDER_COLOR));
    mBorderPaint.setStrokeWidth(mBorderWidth);
}
 
Example 3
Source File: SelectableRoundedImageView.java    From sealtalk-android with MIT License 6 votes vote down vote up
public SelectableRoundedCornerDrawable(Bitmap bitmap, Resources r) {
    mBitmap = bitmap;
    mBitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);

    if (bitmap != null) {
        mBitmapWidth = bitmap.getScaledWidth(r.getDisplayMetrics());
        mBitmapHeight = bitmap.getScaledHeight(r.getDisplayMetrics());
    } else {
        mBitmapWidth = mBitmapHeight = -1;
    }

    mBitmapRect.set(0, 0, mBitmapWidth, mBitmapHeight);

    mBitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBitmapPaint.setStyle(Paint.Style.FILL);
    mBitmapPaint.setShader(mBitmapShader);

    mBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBorderPaint.setStyle(Paint.Style.STROKE);
    mBorderPaint.setColor(mBorderColor.getColorForState(getState(), DEFAULT_BORDER_COLOR));
    mBorderPaint.setStrokeWidth(mBorderWidth);
}
 
Example 4
Source File: RoundedImageView.java    From AndroidMaterialDesign with Apache License 2.0 6 votes vote down vote up
public SelectableRoundedCornerDrawable(Bitmap bitmap, Resources r) {
    mBitmap = bitmap;
    mBitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);

    if (bitmap != null) {
        mBitmapWidth = bitmap.getScaledWidth(r.getDisplayMetrics());
        mBitmapHeight = bitmap.getScaledHeight(r.getDisplayMetrics());
    } else {
        mBitmapWidth = mBitmapHeight = -1;
    }

    mBitmapRect.set(0, 0, mBitmapWidth, mBitmapHeight);

    mBitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBitmapPaint.setStyle(Paint.Style.FILL);
    mBitmapPaint.setShader(mBitmapShader);

    mBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBorderPaint.setStyle(Paint.Style.STROKE);
    mBorderPaint.setColor(mBorderColor.getColorForState(getState(), DEFAULT_BORDER_COLOR));
    mBorderPaint.setStrokeWidth(mBorderWidth);
}
 
Example 5
Source File: RoundedImageView.java    From ChatKit with Apache License 2.0 5 votes vote down vote up
private RoundedCornerDrawable(Bitmap bitmap, Resources r) {
    mBitmap = bitmap;
    mBitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);

    mBitmapWidth = bitmap.getScaledWidth(r.getDisplayMetrics());
    mBitmapHeight = bitmap.getScaledHeight(r.getDisplayMetrics());

    mBitmapRect.set(0, 0, mBitmapWidth, mBitmapHeight);

    mBitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mBitmapPaint.setStyle(Paint.Style.FILL);
    mBitmapPaint.setShader(mBitmapShader);
}
 
Example 6
Source File: IdentityPrintDocumentAdapter.java    From secure-quick-reliable-login with MIT License 4 votes vote down vote up
private void drawPage(PdfDocument.Page page) {
    SQRLStorage storage = SQRLStorage.getInstance(activity);
    Canvas canvas = page.getCanvas();
    int marginLeftRight = 35;
    int marginTop = 65;
    int lastBlockY = marginTop;

    TextPaint headlineTextPaint = new TextPaint();
    headlineTextPaint.setTextSize(16);
    headlineTextPaint.setFakeBoldText(true);

    TextPaint bodyTextPaint = new TextPaint();
    bodyTextPaint.setTextSize(12);

    TextPaint identityTextTextPaint = new TextPaint(bodyTextPaint);
    identityTextTextPaint.setTypeface(Typeface.MONOSPACE);
    identityTextTextPaint.setFakeBoldText(true);

    String identityTitle = "\"" + identityName + "\" SQRL Identity";

    lastBlockY += DocumentPrintUtils.drawTextBlock(
            canvas,
            identityTitle,
            Layout.Alignment.ALIGN_CENTER,
            headlineTextPaint,
            marginTop,
            marginLeftRight);

    lastBlockY += DocumentPrintUtils.drawTextBlock(
            canvas,
            activity.getString(R.string.print_identity_desc1),
            Layout.Alignment.ALIGN_NORMAL,
            bodyTextPaint,
            lastBlockY + 20,
            marginLeftRight) + 20;

    byte[] saveData;
    if(this.withoutPassword) {
        saveData = storage.createSaveDataWithoutPassword();
    } else {
        saveData = storage.createSaveData();
    }

    int canvasMiddle = canvas.getWidth() / 2;
    QrCode qrCode = QrCode.encodeBinary(saveData, QrCode.Ecc.MEDIUM);
    Bitmap bitmap = qrCode.toImage(3, 0);

    int bitmapWidth = bitmap.getScaledWidth(canvas);

    canvas.drawBitmap(bitmap, canvasMiddle - (bitmapWidth / 2), lastBlockY + 20, new Paint());

    lastBlockY += bitmap.getScaledHeight(canvas) + 20;

    lastBlockY += DocumentPrintUtils.drawTextBlock(
            canvas,
            activity.getString(R.string.print_identity_desc2),
            Layout.Alignment.ALIGN_NORMAL,
            bodyTextPaint,
            lastBlockY + 20,
            marginLeftRight) + 30;


    int i = 0;
    try {
        Utils.refreshStorageFromDb(activity);
        for (String identityTextBlock : storage.getVerifyingRecoveryBlock().split("\n")) {
            lastBlockY += DocumentPrintUtils.drawTextBlock(
                    canvas,
                    identityTextBlock,
                    Layout.Alignment.ALIGN_CENTER,
                    identityTextTextPaint,
                    lastBlockY + 3,
                    marginLeftRight) + 3;
            i++;
        }
    } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e);
    }

    DocumentPrintUtils.drawTextBlock(
            canvas,
            activity.getString(R.string.print_identity_desc3),
            Layout.Alignment.ALIGN_NORMAL,
            bodyTextPaint,
            lastBlockY + 20,
            marginLeftRight);

    DocumentPrintUtils.drawPrintPageFooter(activity, canvas);
}