Java Code Examples for android.graphics.Bitmap.getScaledWidth()

The following are Jave code examples for showing how to use getScaledWidth() of the android.graphics.Bitmap class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: BBSSDK-for-Android   File: SelectableRoundedImageView.java   Source Code and License Vote up 6 votes
public SelectableRoundedCornerDrawable(Bitmap bitmap, Resources r) {
	mbBitmap = bitmap;
	mmBitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);

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

	mmBitmapRect.set(0, 0, mmBitmapWidth, mmBitmapHeight);

	mmBitmapPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
	mmBitmapPaint.setStyle(Paint.Style.FILL);
	mmBitmapPaint.setShader(mmBitmapShader);

	mmBorderPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
	mmBorderPaint.setStyle(Paint.Style.STROKE);
	mmBorderPaint.setColor(mmBorderColor.getColorForState(getState(), DEFAULT_BORDER_COLOR));
	mmBorderPaint.setStrokeWidth(mmBorderWidth);
}
 
Example 2
Project: Expert-Android-Programming   File: SelectableRoundedImageView.java   Source Code and License Vote up 6 votes
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
Project: boohee_v5.6   File: SelectableRoundedImageView.java   Source Code and License Vote up 6 votes
public SelectableRoundedCornerDrawable(Bitmap bitmap, Resources r) {
    this.mBitmap = bitmap;
    this.mBitmapShader = new BitmapShader(bitmap, TileMode.CLAMP, TileMode.CLAMP);
    if (bitmap != null) {
        this.mBitmapWidth = bitmap.getScaledWidth(r.getDisplayMetrics());
        this.mBitmapHeight = bitmap.getScaledHeight(r.getDisplayMetrics());
    } else {
        this.mBitmapHeight = -1;
        this.mBitmapWidth = -1;
    }
    this.mBitmapRect.set(0.0f, 0.0f, (float) this.mBitmapWidth, (float) this.mBitmapHeight);
    this.mBitmapPaint = new Paint(1);
    this.mBitmapPaint.setStyle(Style.FILL);
    this.mBitmapPaint.setShader(this.mBitmapShader);
    this.mBorderPaint = new Paint(1);
    this.mBorderPaint.setStyle(Style.STROKE);
    this.mBorderPaint.setColor(this.mBorderColor.getColorForState(getState(), -16777216));
    this.mBorderPaint.setStrokeWidth(this.mBorderWidth);
}
 
Example 4
Project: sealtalk-android-master   File: SelectableRoundedImageView.java   Source Code and License Vote up 6 votes
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
Project: rongyunDemo   File: SelectableRoundedImageView.java   Source Code and License Vote up 6 votes
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 6
Project: FinalProject   File: RoundedImageView.java   Source Code and License Vote up 5 votes
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);
}