public static Drawable getDrawableWithNumber(Drawable baseDrawable, int number, int iconSize, Context context) { if (number < 0 || number > 9) { number = 0; } Drawable numberDrawable = context.Resources.getDrawable(R.drawable.number_round); if (numberDrawable == null) { return(baseDrawable); } int appIconShift = context.Resources.getDimensionPixelOffset(R.dimen.ord_app_icon_shift); Bitmap bitmap = Bitmap.createBitmap(iconSize, iconSize, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); int textSize = context.Resources.getDimensionPixelSize(R.dimen.number_icon_text_size); int textColor = context.Resources.getColor(R.color.fc_app_icon_number_color); TextDrawable textDrawable = new TextDrawable(number.ToString(), textSize, textColor); baseDrawable.setBounds(0, 0, iconSize, iconSize); baseDrawable.draw(canvas); numberDrawable.setBounds(iconSize - (appIconShift + numberDrawable.IntrinsicWidth), appIconShift, iconSize - (appIconShift), appIconShift + numberDrawable.IntrinsicHeight); numberDrawable.draw(canvas); textDrawable.setBounds(iconSize - (appIconShift + numberDrawable.IntrinsicWidth), appIconShift, iconSize - (appIconShift), appIconShift + numberDrawable.IntrinsicHeight); textDrawable.draw(canvas); return(new BitmapDrawable(context.Resources, bitmap)); }
protected internal override void dispatchDraw(android.graphics.Canvas canvas) { base.dispatchDraw(canvas); // Do nothing if there are no tabs. if (getTabCount() == 0) { return; } // If the user specified a custom view for the tab indicators, then // do not draw the bottom strips. if (!mDrawBottomStrips) { // Skip drawing the bottom strips. return; } android.view.View selectedChild = getChildTabViewAt(mSelectedTab); android.graphics.drawable.Drawable leftStrip = mLeftStrip; android.graphics.drawable.Drawable rightStrip = mRightStrip; leftStrip.setState(selectedChild.getDrawableState()); rightStrip.setState(selectedChild.getDrawableState()); if (mStripMoved) { android.graphics.Rect bounds = mBounds; bounds.left = selectedChild.getLeft(); bounds.right = selectedChild.getRight(); int myHeight = getHeight(); leftStrip.setBounds(System.Math.Min(0, bounds.left - leftStrip.getIntrinsicWidth( )), myHeight - leftStrip.getIntrinsicHeight(), bounds.left, myHeight); rightStrip.setBounds(bounds.right, myHeight - rightStrip.getIntrinsicHeight(), System.Math.Max (getWidth(), bounds.right + rightStrip.getIntrinsicWidth()), myHeight); mStripMoved = false; } leftStrip.draw(canvas); rightStrip.draw(canvas); }
protected internal override void onDraw(android.graphics.Canvas canvas) { android.graphics.drawable.Drawable drawable = mHorizontalDivider; if (drawable != null) { // If we have a horizontal divider to draw, draw it at the remembered positions java.util.ArrayList <android.graphics.Rect> rects = mHorizontalDividerRects; { for (int i = rects.size() - 1; i >= 0; i--) { drawable.setBounds(rects.get(i)); drawable.draw(canvas); } } } drawable = mVerticalDivider; if (drawable != null) { // If we have a vertical divider to draw, draw it at the remembered positions java.util.ArrayList <android.graphics.Rect> rects = mVerticalDividerRects; { for (int i = rects.size() - 1; i >= 0; i--) { drawable.setBounds(rects.get(i)); drawable.draw(canvas); } } } }
protected override void onDraw(android.graphics.Canvas canvas) { { var paint = new android.graphics.Paint(); paint.setStyle(android.graphics.Paint.Style.STROKE); //paint.setStyle(android.graphics.Paint.Style.FILL_AND_STROKE); //paint.setColor(android.graphics.Color.RED); //paint.setColor(android.graphics.Color.YELLOW); paint.setColor(color); paint.setTextSize(textSize); paint.setAlpha(alpha); var a = this.text().Split('\n'); a.WithEachIndex( (text, i) => { canvas.drawText(text, x, y + i * 24, paint); canvas.drawText(text, x + 2560 / 2, y + i * 24, paint); } ); } if (AtDraw != null) { AtDraw(canvas); } base.onDraw(canvas); }
public override void draw(android.graphics.Canvas canvas) { base.draw(canvas); if (mForeground != null) { android.graphics.drawable.Drawable foreground = mForeground; if (mForegroundBoundsChanged) { mForegroundBoundsChanged = false; android.graphics.Rect selfBounds = mSelfBounds; android.graphics.Rect overlayBounds = mOverlayBounds; int w = mRight - mLeft; int h = mBottom - mTop; if (mForegroundInPadding) { selfBounds.set(0, 0, w, h); } else { selfBounds.set(mPaddingLeft, mPaddingTop, w - mPaddingRight, h - mPaddingBottom); } int layoutDirection = getResolvedLayoutDirection(); android.view.Gravity.apply(mForegroundGravity, foreground.getIntrinsicWidth(), foreground .getIntrinsicHeight(), selfBounds, overlayBounds, layoutDirection); foreground.setBounds(overlayBounds); } foreground.draw(canvas); } }
/// <summary> /// To record a picture, call beginRecording() and then draw into the Canvas /// that is returned. /// </summary> /// <remarks> /// To record a picture, call beginRecording() and then draw into the Canvas /// that is returned. Nothing we appear on screen, but all of the draw /// commands (e.g. drawRect(...)) will be recorded. To stop recording, call /// endRecording(). At this point the Canvas that was returned must no longer /// be referenced, and nothing should be drawn into it. /// </remarks> public virtual android.graphics.Canvas beginRecording(int width, int height) { android.graphics.Canvas.NativeCanvas ni_1 = nativeBeginRecording(mNativePicture, width, height); mRecordingCanvas = new android.graphics.Picture.RecordingCanvas(this, ni_1); return(mRecordingCanvas); }
public static Drawable getDrawableWithNumber(Drawable baseDrawable, int number, int iconSize, Context context) { if (number < 0 || number > 9) { number = 0; } Drawable numberDrawable = context.Resources.getDrawable(R.drawable.number_round); if (numberDrawable == null) { return baseDrawable; } int appIconShift = context.Resources.getDimensionPixelOffset(R.dimen.ord_app_icon_shift); Bitmap bitmap = Bitmap.createBitmap(iconSize, iconSize, Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); int textSize = context.Resources.getDimensionPixelSize(R.dimen.number_icon_text_size); int textColor = context.Resources.getColor(R.color.fc_app_icon_number_color); TextDrawable textDrawable = new TextDrawable(number.ToString(), textSize, textColor); baseDrawable.setBounds(0, 0, iconSize, iconSize); baseDrawable.draw(canvas); numberDrawable.setBounds(iconSize - (appIconShift + numberDrawable.IntrinsicWidth), appIconShift, iconSize - (appIconShift), appIconShift + numberDrawable.IntrinsicHeight); numberDrawable.draw(canvas); textDrawable.setBounds(iconSize - (appIconShift + numberDrawable.IntrinsicWidth), appIconShift, iconSize - (appIconShift), appIconShift + numberDrawable.IntrinsicHeight); textDrawable.draw(canvas); return new BitmapDrawable(context.Resources, bitmap); }
/// <summary> /// To record a picture, call beginRecording() and then draw into the Canvas /// that is returned. /// </summary> /// <remarks> /// To record a picture, call beginRecording() and then draw into the Canvas /// that is returned. Nothing we appear on screen, but all of the draw /// commands (e.g. drawRect(...)) will be recorded. To stop recording, call /// endRecording(). At this point the Canvas that was returned must no longer /// be referenced, and nothing should be drawn into it. /// </remarks> public virtual android.graphics.Canvas beginRecording(int width, int height) { android.graphics.Canvas.NativeCanvas ni_1 = nativeBeginRecording(mNativePicture, width, height); mRecordingCanvas = new android.graphics.Picture.RecordingCanvas(this, ni_1); return mRecordingCanvas; }
protected internal override void onDraw(android.graphics.Canvas canvas) { base.onDraw(canvas); android.graphics.drawable.Drawable checkMarkDrawable = mCheckMarkDrawable; if (checkMarkDrawable != null) { int verticalGravity = getGravity() & android.view.Gravity.VERTICAL_GRAVITY_MASK; int height = checkMarkDrawable.getIntrinsicHeight(); int y = 0; switch (verticalGravity) { case android.view.Gravity.BOTTOM: { y = getHeight() - height; break; } case android.view.Gravity.CENTER_VERTICAL: { y = (getHeight() - height) / 2; break; } } int right = getWidth(); checkMarkDrawable.setBounds(right - mPaddingRight, y, right - mPaddingRight + mCheckMarkWidth , y + height); checkMarkDrawable.draw(canvas); } }
protected internal override void onDraw(android.graphics.Canvas canvas) { base.onDraw(canvas); android.graphics.drawable.Drawable buttonDrawable = mButtonDrawable; if (buttonDrawable != null) { int verticalGravity = getGravity() & android.view.Gravity.VERTICAL_GRAVITY_MASK; int height = buttonDrawable.getIntrinsicHeight(); int y = 0; switch (verticalGravity) { case android.view.Gravity.BOTTOM: { y = getHeight() - height; break; } case android.view.Gravity.CENTER_VERTICAL: { y = (getHeight() - height) / 2; break; } } buttonDrawable.setBounds(0, y, buttonDrawable.getIntrinsicWidth(), y + height); buttonDrawable.draw(canvas); } }
protected internal override void onDraw(android.graphics.Canvas canvas) { if (getWidth() == 0 || getHeight() == 0) { return; } if (mIsSplit) { if (mSplitBackground != null) { mSplitBackground.draw(canvas); } } else { if (mBackground != null) { mBackground.draw(canvas); } if (mStackedBackground != null && mIsStacked) { mStackedBackground.draw(canvas); } } }
public override void draw(android.graphics.Canvas canvas) { if (mScaleState.mDrawable.getLevel() != 0) { mScaleState.mDrawable.draw(canvas); } }
protected internal override void onDraw(android.graphics.Canvas canvas) { base.onDraw(canvas); bool changed = mChanged; if (changed) { mChanged = false; } int availableWidth = mRight - mLeft; int availableHeight = mBottom - mTop; int x = availableWidth / 2; int y = availableHeight / 2; android.graphics.drawable.Drawable dial = mDial; int w = dial.getIntrinsicWidth(); int h = dial.getIntrinsicHeight(); bool scaled = false; if (availableWidth < w || availableHeight < h) { scaled = true; float scale = System.Math.Min((float)availableWidth / (float)w, (float)availableHeight / (float)h); canvas.save(); canvas.scale(scale, scale, x, y); } if (changed) { dial.setBounds(x - (w / 2), y - (h / 2), x + (w / 2), y + (h / 2)); } dial.draw(canvas); canvas.save(); canvas.rotate(mHour / 12.0f * 360.0f, x, y); android.graphics.drawable.Drawable hourHand = mHourHand; if (changed) { w = hourHand.getIntrinsicWidth(); h = hourHand.getIntrinsicHeight(); hourHand.setBounds(x - (w / 2), y - (h / 2), x + (w / 2), y + (h / 2)); } hourHand.draw(canvas); canvas.restore(); canvas.save(); canvas.rotate(mMinutes / 60.0f * 360.0f, x, y); android.graphics.drawable.Drawable minuteHand = mMinuteHand; if (changed) { w = minuteHand.getIntrinsicWidth(); h = minuteHand.getIntrinsicHeight(); minuteHand.setBounds(x - (w / 2), y - (h / 2), x + (w / 2), y + (h / 2)); } minuteHand.draw(canvas); canvas.restore(); if (scaled) { canvas.restore(); } }
/// <summary>Call endRecording when the picture is built.</summary> /// <remarks> /// Call endRecording when the picture is built. After this call, the picture /// may be drawn, but the canvas that was returned by beginRecording must not /// be referenced anymore. This is automatically called if Picture.draw() or /// Canvas.drawPicture() is called. /// </remarks> public virtual void endRecording() { if (mRecordingCanvas != null) { mRecordingCanvas = null; nativeEndRecording(mNativePicture); } }
public override void draw(android.graphics.Canvas canvas, android.graphics.Paint paint) { canvas.save(); canvas.scale(mScaleX, mScaleY); canvas.drawPath(mPath, paint); canvas.restore(); }
public override void draw(android.graphics.Canvas canvas) { if (((int)(((uint)mState.mUseColor) >> 24)) != 0) { mPaint.setColor(mState.mUseColor); canvas.drawRect(getBounds(), mPaint); } }
/// <summary>Draw this picture on the canvas.</summary> /// <remarks> /// Draw this picture on the canvas. The picture may have the side effect /// of changing the matrix and clip of the canvas. /// </remarks> /// <param name="canvas">The picture is drawn to this canvas</param> public virtual void draw(android.graphics.Canvas canvas) { if (mRecordingCanvas != null) { endRecording(); } nativeDraw(canvas.mNativeCanvas, mNativePicture); }
/// <summary>Apply translation to the canvas that is necessary to draw the content.</summary> /// <remarks>Apply translation to the canvas that is necessary to draw the content.</remarks> public virtual void translateCanvas(android.graphics.Canvas canvas) { if (this.applicationScale == 1.5f) { float tinyOffset = 2.0f / (3 * 255); canvas.translate(tinyOffset, tinyOffset); } canvas.scale(this.applicationScale, this.applicationScale); }
protected internal override void onDraw(Canvas canvas) { base.onDraw(canvas); canvas.drawColor(Color.TRANSPARENT); foreach (Dot dot in results) { circlePaint.Color = dot.Color; canvas.drawCircle(dot.X * pixelsPrWidth, dot.Y * pixelsPrHeight, circleRadius, circlePaint); } }
public override void draw(android.graphics.Canvas canvas) { android.graphics.drawable.LayerDrawable.ChildDrawable[] array = mLayerState.mChildren; int N = mLayerState.mNum; { for (int i = 0; i < N; i++) { array[i].mDrawable.draw(canvas); } } }
protected override void onDraw(android.graphics.Canvas canvas) { (frameCanvas, frameWidth, frameHeight) = (canvas, canvas.getWidth(), canvas.getHeight()); paint.setColor(0x7FFF0000); drawCenter("Bluebonnet Demo", -4f); drawCenter("Android - C#", 4f); frameCallback(); }
public override void draw(android.graphics.Canvas canvas) { if (mCurrDrawable != null) { mCurrDrawable.draw(canvas); } if (mLastDrawable != null) { mLastDrawable.draw(canvas); } }
protected virtual void onDraw(android.graphics.drawable.shapes.Shape arg0, android.graphics.Canvas arg1, android.graphics.Paint arg2) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { @__env.CallVoidMethod(this.JvmHandle, global::android.graphics.drawable.ShapeDrawable._onDraw4201, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2)); } else { @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.graphics.drawable.ShapeDrawable.staticClass, global::android.graphics.drawable.ShapeDrawable._onDraw4201, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2)); } }
public override void draw(android.graphics.Canvas arg0) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { @__env.CallVoidMethod(this.JvmHandle, global::android.graphics.drawable.ColorDrawable._draw3902, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); } else { @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.graphics.drawable.ColorDrawable.staticClass, global::android.graphics.drawable.ColorDrawable._draw3902, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); } }
public virtual new void dispatchDraw(android.graphics.Canvas arg0) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { @__env.CallVoidMethod(this.JvmHandle, global::android.widget.TabWidget._dispatchDraw12043, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); } else { @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.widget.TabWidget.staticClass, global::android.widget.TabWidget._dispatchDraw12043, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); } }
public override void draw(android.graphics.Canvas arg0, java.lang.CharSequence arg1, int arg2, int arg3, float arg4, int arg5, int arg6, int arg7, android.graphics.Paint arg8) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { @__env.CallVoidMethod(this.JvmHandle, global::android.text.style.DynamicDrawableSpan._draw8249, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg3), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg4), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg5), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg6), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg7), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg8)); } else { @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.text.style.DynamicDrawableSpan.staticClass, global::android.text.style.DynamicDrawableSpan._draw8249, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg3), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg4), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg5), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg6), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg7), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg8)); } }
public int getScaledHeight(android.graphics.Canvas arg0) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { return(@__env.CallIntMethod(this.JvmHandle, global::android.graphics.Bitmap._getScaledHeight3112, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0))); } else { return(@__env.CallNonVirtualIntMethod(this.JvmHandle, global::android.graphics.Bitmap.staticClass, global::android.graphics.Bitmap._getScaledHeight3112, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0))); } }
protected override void onDraw(android.graphics.Canvas arg0) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { @__env.CallVoidMethod(this.JvmHandle, global::android.widget.ImageView._onDraw11458, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); } else { @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.widget.ImageView.staticClass, global::android.widget.ImageView._onDraw11458, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); } }
public virtual void drawLeadingMargin(android.graphics.Canvas arg0, android.graphics.Paint arg1, int arg2, int arg3, int arg4, int arg5, int arg6, java.lang.CharSequence arg7, int arg8, int arg9, bool arg10, android.text.Layout arg11) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { @__env.CallVoidMethod(this.JvmHandle, global::android.text.style.QuoteSpan._drawLeadingMargin8310, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg3), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg4), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg5), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg6), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg7), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg8), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg9), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg10), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg11)); } else { @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.text.style.QuoteSpan.staticClass, global::android.text.style.QuoteSpan._drawLeadingMargin8310, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg3), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg4), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg5), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg6), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg7), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg8), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg9), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg10), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg11)); } }
public virtual void applyToCanvas(android.graphics.Canvas arg0) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { @__env.CallVoidMethod(this.JvmHandle, global::android.graphics.Camera._applyToCanvas3171, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); } else { @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.graphics.Camera.staticClass, global::android.graphics.Camera._applyToCanvas3171, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0)); } }
public override void draw(android.graphics.Canvas arg0, android.graphics.Path arg1, android.graphics.Paint arg2, int arg3) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { @__env.CallVoidMethod(this.JvmHandle, global::android.text.BoringLayout._draw7611, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg3)); } else { @__env.CallNonVirtualVoidMethod(this.JvmHandle, global::android.text.BoringLayout.staticClass, global::android.text.BoringLayout._draw7611, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg3)); } }
protected override bool drawChild(android.graphics.Canvas arg0, android.view.View arg1, long arg2) { global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv; if (!IsClrObject) { return(@__env.CallBooleanMethod(this.JvmHandle, global::android.appwidget.AppWidgetHostView._drawChild968, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2))); } else { return(@__env.CallNonVirtualBooleanMethod(this.JvmHandle, global::android.appwidget.AppWidgetHostView.staticClass, global::android.appwidget.AppWidgetHostView._drawChild968, global::MonoJavaBridge.JavaBridge.ConvertToValue(arg0), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg1), global::MonoJavaBridge.JavaBridge.ConvertToValue(arg2))); } }
public override void draw(Canvas canvas) { Rect r = Bounds; Paint paint = mPaint; // only draw shape if it may affect output if (paint.Alpha != 0 || paint.Xfermode != null) { // canvas.drawRect(r, paint); Rect textBounds = TextBounds; canvas.drawText(mText, r.left + r.width() / 2, r.top + r.height() / 2 + textBounds.height() / 2, paint); } // restore }
/// <summary> /// Returns an immutable bitmap from subset of the source bitmap, /// transformed by the optional matrix. /// </summary> /// <remarks> /// Returns an immutable bitmap from subset of the source bitmap, /// transformed by the optional matrix. It is /// initialized with the same density as the original bitmap. /// </remarks> /// <param name="source">The bitmap we are subsetting</param> /// <param name="x">The x coordinate of the first pixel in source</param> /// <param name="y">The y coordinate of the first pixel in source</param> /// <param name="width">The number of pixels in each row</param> /// <param name="height">The number of rows</param> /// <param name="m">Optional matrix to be applied to the pixels</param> /// <param name="filter"> /// true if the source should be filtered. /// Only applies if the matrix contains more than just /// translation. /// </param> /// <returns>A bitmap that represents the specified subset of source</returns> /// <exception cref="System.ArgumentException"> /// if the x, y, width, height values are /// outside of the dimensions of the source bitmap. /// </exception> public static android.graphics.Bitmap createBitmap(android.graphics.Bitmap source , int x, int y, int width, int height, android.graphics.Matrix m, bool filter) { checkXYSign(x, y); checkWidthHeight(width, height); if (x + width > source.getWidth()) { throw new System.ArgumentException("x + width must be <= bitmap.width()"); } if (y + height > source.getHeight()) { throw new System.ArgumentException("y + height must be <= bitmap.height()"); } // check if we can just return our argument unchanged if (!source.isMutable() && x == 0 && y == 0 && width == source.getWidth() && height == source.getHeight() && (m == null || m.isIdentity())) { return source; } int neww = width; int newh = height; android.graphics.Canvas canvas = new android.graphics.Canvas(); android.graphics.Bitmap bitmap; android.graphics.Paint paint; android.graphics.Rect srcR = new android.graphics.Rect(x, y, x + width, y + height ); android.graphics.RectF dstR = new android.graphics.RectF(0, 0, width, height); android.graphics.Bitmap.Config newConfig = android.graphics.Bitmap.Config.ARGB_8888; android.graphics.Bitmap.Config config = source.getConfig(); // GIF files generate null configs, assume ARGB_8888 if (config != null) { switch (config) { case android.graphics.Bitmap.Config.RGB_565: { newConfig = android.graphics.Bitmap.Config.RGB_565; break; } case android.graphics.Bitmap.Config.ALPHA_8: { newConfig = android.graphics.Bitmap.Config.ALPHA_8; break; } case android.graphics.Bitmap.Config.ARGB_4444: case android.graphics.Bitmap.Config.ARGB_8888: default: { //noinspection deprecation newConfig = android.graphics.Bitmap.Config.ARGB_8888; break; } } } if (m == null || m.isIdentity()) { bitmap = createBitmap(neww, newh, newConfig, source.hasAlpha()); paint = null; } else { // not needed bool transformed = !m.rectStaysRect(); android.graphics.RectF deviceR = new android.graphics.RectF(); m.mapRect(deviceR, dstR); neww = Sharpen.Util.Round(deviceR.width()); newh = Sharpen.Util.Round(deviceR.height()); bitmap = createBitmap(neww, newh, transformed ? android.graphics.Bitmap.Config.ARGB_8888 : newConfig, transformed || source.hasAlpha()); canvas.translate(-deviceR.left, -deviceR.top); canvas.concat(m); paint = new android.graphics.Paint(); paint.setFilterBitmap(filter); if (transformed) { paint.setAntiAlias(true); } } // The new bitmap was created from a known bitmap source so assume that // they use the same density bitmap.mDensity = source.mDensity; canvas.setBitmap(bitmap); canvas.drawBitmap(source, srcR, dstR, paint); canvas.setBitmap(null); return bitmap; }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET: //ORIGINAL LINE: @Override public void onDraw(final android.graphics.Canvas canv) public override void onDraw(Canvas canv) { if (null == mOfficeLayout || null == mRenderUtil) { Log.w(TAG, "Tried to render empty office"); return; } foreach (OfficeThing thing in mOfficeLayout.ThingsBottomUp) { Bitmap thingBitmap = mRenderUtil.getBitmap(thing); //TODO: reimplement glow rendering // // If it's the selected thing, make it GLOW! // if (thing.getKey().equals(mSelectedThingKey)) { // thingBitmap = mRenderUtil.getGlowingBitmap(thing); // } // Draw furniture canv.drawBitmap(thingBitmap, modelToScreen(thing.Left), modelToScreen(thing.Top), DEFAULT_PAINT); // Draw desk label if (thing.Type.Equals("desk") && thing.Name != null) { // TODO: these offset numbers were empirically determined. Calculate them instead float centerX = modelToScreen(thing.Left) + 102; float centerY = modelToScreen(thing.Top) + 70; canv.save(); // TODO: OMG this is so hacky. Fix it. These numbers were empirically determined if (thing.Rotation == 180) { canv.rotate(-thing.Rotation, centerX, centerY - 10); } else if (thing.Rotation == 90) { canv.rotate(-thing.Rotation, centerX, centerY + 45); } else if (thing.Rotation == 270) { canv.rotate(-thing.Rotation, centerX - 40, centerY); } canv.drawText(thing.Name, centerX, centerY, DESK_LABEL_PAINT); canv.restore(); } } }
protected internal override void onDraw(Canvas canvas) { if (mFaces != null && mZoomRect != null) { // Prepare matrix mMatrix.reset(); mAspectRatio.reset(); mActualRect.set(0, 0, mPreviewSize.Width, mPreviewSize.Height); // First apply zoom (crop) rect. // Unlike the documentation, many device does not report final crop region. // So, here we calculate final crop region which takes account aspect ratio between crop region and preview size. { mRevisionZoomRect.set(mZoomRect); float left = mRevisionZoomRect.left; float top = mRevisionZoomRect.top; mRevisionZoomRect.offsetTo(0, 0); mAspectRatio.setRectToRect(mActualRect, mRevisionZoomRect, Matrix.ScaleToFit.CENTER); mAspectRatio.mapRect(mActualRect); mActualRect.offset(left, top); } mMatrix.postTranslate(-mActualRect.centerX(), -mActualRect.centerY()); // compensate mirror mMatrix.postScale(mFacing == SCameraCharacteristics.LENS_FACING_FRONT ? - 1 : 1, 1); // Then rotate and scale to UI size mMatrix.postRotate(mRotation); if (mOrientation == Configuration.ORIENTATION_LANDSCAPE) { mMatrix.postScale((float) Width / mActualRect.width(), (float) Height / mActualRect.height()); } else { mMatrix.postScale((float) Height / mActualRect.width(), (float) Width / mActualRect.height()); } mMatrix.postTranslate((float)Width / 2, (float)Height / 2); foreach (Face face in mFaces) { mBoundRect.set(face.Bounds); mMatrix.mapRect(mBoundRect); mPaint.Color = Color.BLUE; mPaint.StrokeWidth = 3; canvas.drawRect(mBoundRect, mPaint); { // Additional features may not supported. float[] point = new float[2]; mPaint.Color = Color.RED; mPaint.StrokeWidth = 10; if (face.LeftEyePosition != null) { mMatrix.mapPoints(point, new float[]{face.LeftEyePosition.x, face.LeftEyePosition.y}); canvas.drawPoint(point[0], point[1], mPaint); } if (face.RightEyePosition != null) { mMatrix.mapPoints(point, new float[]{face.RightEyePosition.x, face.RightEyePosition.y}); canvas.drawPoint(point[0], point[1], mPaint); } if (face.MouthPosition != null) { mMatrix.mapPoints(point, new float[]{face.MouthPosition.x, face.MouthPosition.y}); canvas.drawPoint(point[0], point[1], mPaint); } mPaint.Color = Color.YELLOW; mPaint.StrokeWidth = 3; mPaint.TextSize = 30; if (face.Id != Face.ID_UNSUPPORTED) { canvas.drawText(string.Format("ID:{0:D}, Score:{1:D}", face.Id, face.Score), mBoundRect.left, mBoundRect.top, mPaint); } else { canvas.drawText(string.Format("Score:{0:D}", face.Score), mBoundRect.left, mBoundRect.top, mPaint); } } } } }
protected internal override void onDraw(Canvas canvas) { // Setup gravity. if ((mGravity & GRAVITY_START) > 0) { mRect.set(0, mRect.top, mRect.width(), mRect.bottom); } else if ((mGravity & GRAVITY_TOP) > 0) { mRect.set(mRect.left, 0, mRect.right, mRect.height()); } else if ((mGravity & GRAVITY_END) > 0) { mRect.set(canvas.Width - mRect.width(), mRect.top, canvas.Width, mRect.bottom); } else if ((mGravity & GRAVITY_BOTTOM) > 0) { mRect.set(mRect.left, canvas.Height - mRect.height(), mRect.right, canvas.Height); } if ((mGravity & GRAVITY_CENTER) > 0) { mRect.set((canvas.Width / 2) - (mRect.width() / 2), (canvas.Height / 2) - (mRect.height() / 2), (canvas.Width / 2) - (mRect.width() / 2) + mRect.width(), (canvas.Height / 2) - (mRect.height() / 2) + mRect.height()); } else if ((mGravity & GRAVITY_CENTER_HORIZONTAL) > 0) { mRect.set((canvas.Width / 2) - (mRect.width() / 2), mRect.top, (canvas.Width / 2) - (mRect.width() / 2) + mRect.width(), mRect.bottom); } else if ((mGravity & GRAVITY_CENTER_VERTICAL) > 0) { mRect.set(mRect.left, (canvas.Height / 2) - (mRect.height() / 2), mRect.right, (canvas.Height / 2) - (mRect.height() / 2) + mRect.height()); } // Merge offset. mRect.offset(mOffset.x, mOffset.y); canvas.drawRect(mRect, mPaint); }
/// <summary> /// Just like /// <see cref="lockCanvas()">lockCanvas()</see> /// but allows specification of a dirty /// rectangle. Every pixel within that rectangle must be written; however /// pixels outside the dirty rectangle will be preserved by the next call /// to lockCanvas(). /// </summary> /// <param name="dirty">Area of the surface that will be modified.</param> /// <returns>A Canvas used to draw into the surface.</returns> /// <seealso cref="lockCanvas()"></seealso> /// <seealso cref="unlockCanvasAndPost(android.graphics.Canvas)"></seealso> public virtual android.graphics.Canvas lockCanvas(android.graphics.Rect dirty) { if (!isAvailable()) { return null; } if (mCanvas == null) { mCanvas = new android.graphics.Canvas(); } lock (mNativeWindowLock) { nLockCanvas(mNativeWindow, mCanvas, dirty); } mSaveCount = mCanvas.save(); return mCanvas; }
// If we are getting ready to gc after going to the background, well // we are back active so skip it. // If the window hasn't yet been added to the window manager, // and this guy didn't finish itself or start another activity, // then go ahead and add the window. // If the window has already been added, but during resume // we started another activity, then don't yet make the // window visible. // Get rid of anything left hanging around. // The window is now visible if it has been added, we are not // simply finishing, and we are not starting another activity. // If an exception was thrown when trying to resume, then // just end this activity. internal android.graphics.Bitmap createThumbnailBitmap(android.app.ActivityThread .ActivityClientRecord r) { android.graphics.Bitmap thumbnail = mAvailThumbnailBitmap; try { if (thumbnail == null) { int w = mThumbnailWidth; int h; if (w < 0) { android.content.res.Resources res = r.activity.getResources(); mThumbnailHeight = h = res.getDimensionPixelSize([email protected]_height ); mThumbnailWidth = w = res.getDimensionPixelSize([email protected]_width ); } else { h = mThumbnailHeight; } // On platforms where we don't want thumbnails, set dims to (0,0) if ((w > 0) && (h > 0)) { thumbnail = android.graphics.Bitmap.createBitmap(w, h, THUMBNAIL_FORMAT); thumbnail.eraseColor(0); } } if (thumbnail != null) { android.graphics.Canvas cv = mThumbnailCanvas; if (cv == null) { mThumbnailCanvas = cv = new android.graphics.Canvas(); } cv.setBitmap(thumbnail); if (!r.activity.onCreateThumbnail(thumbnail, cv)) { mAvailThumbnailBitmap = thumbnail; thumbnail = null; } cv.setBitmap(null); } } catch (System.Exception e) { if (!mInstrumentation.onException(r.activity, e)) { throw new java.lang.RuntimeException("Unable to create thumbnail of " + r.intent. getComponent().toShortString() + ": " + e.ToString(), e); } thumbnail = null; } return thumbnail; }