public BitmapDrawable() { // Gravity.apply() sets this // These are scaled to match the target density. mBitmapState = new android.graphics.drawable.BitmapDrawable.BitmapState((android.graphics.Bitmap )null); }
public override android.graphics.drawable.Drawable mutate() { if (!mMutated && base.mutate() == this) { mBitmapState = new android.graphics.drawable.BitmapDrawable.BitmapState(mBitmapState ); mMutated = true; } return(this); }
internal BitmapState(android.graphics.drawable.BitmapDrawable.BitmapState bitmapState ) : this(bitmapState.mBitmap) { mChangingConfigurations = bitmapState.mChangingConfigurations; mGravity = bitmapState.mGravity; mTileModeX = bitmapState.mTileModeX; mTileModeY = bitmapState.mTileModeY; mTargetDensity = bitmapState.mTargetDensity; mPaint = new android.graphics.Paint(bitmapState.mPaint); mRebuildShader = bitmapState.mRebuildShader; }
/// <summary>Sets the repeat behavior of this drawable on both axis.</summary> /// <remarks> /// Sets the repeat behavior of this drawable on both axis. By default, the drawable /// does not repeat its bitmap. Using /// <see cref="android.graphics.Shader.TileMode.REPEAT">android.graphics.Shader.TileMode.REPEAT /// </see> /// or /// <see cref="android.graphics.Shader.TileMode.MIRROR">android.graphics.Shader.TileMode.MIRROR /// </see> /// the bitmap can be repeated (or tiled) if the bitmap /// is smaller than this drawable. /// </remarks> /// <param name="xmode">The X repeat mode for this drawable.</param> /// <param name="ymode">The Y repeat mode for this drawable.</param> /// <seealso cref="setTileModeX(android.graphics.Shader.TileMode)">setTileModeX(android.graphics.Shader.TileMode) /// </seealso> /// <seealso cref="setTileModeY(android.graphics.Shader.TileMode)"></seealso> public virtual void setTileModeXY(android.graphics.Shader.TileMode?xmode, android.graphics.Shader.TileMode ?ymode) { android.graphics.drawable.BitmapDrawable.BitmapState state = mBitmapState; if (state.mTileModeX != xmode || state.mTileModeY != ymode) { state.mTileModeX = xmode; state.mTileModeY = ymode; state.mRebuildShader = true; invalidateSelf(); } }
internal BitmapDrawable(android.graphics.drawable.BitmapDrawable.BitmapState state , android.content.res.Resources res) { mBitmapState = state; if (res != null) { mTargetDensity = res.getDisplayMetrics().densityDpi; } else { mTargetDensity = state.mTargetDensity; } setBitmap(state != null ? state.mBitmap : null); }
public override void draw(android.graphics.Canvas canvas) { android.graphics.Bitmap bitmap = mBitmap; if (bitmap != null) { android.graphics.drawable.BitmapDrawable.BitmapState state = mBitmapState; if (state.mRebuildShader) { android.graphics.Shader.TileMode?tmx = state.mTileModeX; android.graphics.Shader.TileMode?tmy = state.mTileModeY; if (tmx == null && tmy == null) { state.mPaint.setShader(null); } else { state.mPaint.setShader(new android.graphics.BitmapShader(bitmap, tmx == null ? android.graphics.Shader.TileMode .CLAMP : tmx, tmy == null ? android.graphics.Shader.TileMode.CLAMP : tmy)); } state.mRebuildShader = false; copyBounds(mDstRect); } android.graphics.Shader shader = state.mPaint.getShader(); if (shader == null) { if (mApplyGravity) { int layoutDirection = getResolvedLayoutDirectionSelf(); android.view.Gravity.apply(state.mGravity, mBitmapWidth, mBitmapHeight, getBounds (), mDstRect, layoutDirection); mApplyGravity = false; } canvas.drawBitmap(bitmap, null, mDstRect, state.mPaint); } else { if (mApplyGravity) { copyBounds(mDstRect); mApplyGravity = false; } canvas.drawRect(mDstRect, state.mPaint); } } }
/// <summary> /// Create an empty drawable, setting initial target density based on /// the display metrics of the resources. /// </summary> /// <remarks> /// Create an empty drawable, setting initial target density based on /// the display metrics of the resources. /// </remarks> public BitmapDrawable(android.content.res.Resources res) { mBitmapState = new android.graphics.drawable.BitmapDrawable.BitmapState((android.graphics.Bitmap )null); mBitmapState.mTargetDensity = mTargetDensity; }
public override android.graphics.drawable.Drawable mutate() { if (!mMutated && base.mutate() == this) { mBitmapState = new android.graphics.drawable.BitmapDrawable.BitmapState(mBitmapState ); mMutated = true; } return this; }