Example #1
0
 /// <summary>Finish editing pixels in the surface.</summary>
 /// <remarks>
 /// Finish editing pixels in the surface. After this call, the surface's
 /// current pixels will be shown on the screen, but its content is lost,
 /// in particular there is no guarantee that the content of the Surface
 /// will remain unchanged when lockCanvas() is called again.
 /// </remarks>
 /// <param name="canvas">The Canvas previously returned by lockCanvas()</param>
 /// <seealso cref="lockCanvas()">lockCanvas()</seealso>
 /// <seealso cref="lockCanvas(android.graphics.Rect)"></seealso>
 public virtual void unlockCanvasAndPost(android.graphics.Canvas canvas)
 {
     if (mCanvas != null && canvas == mCanvas)
     {
         canvas.restoreToCount(mSaveCount);
         mSaveCount = 0;
         lock (mNativeWindowLock)
         {
             nUnlockCanvasAndPost(mNativeWindow, mCanvas);
         }
     }
 }
Example #2
0
        public override void draw(android.graphics.Canvas canvas)
        {
            int saveCount = canvas.save();

            android.graphics.drawable.AnimatedRotateDrawable.AnimatedRotateState st = mState;
            android.graphics.drawable.Drawable drawable = st.mDrawable;
            android.graphics.Rect bounds = drawable.getBounds();
            int   w  = bounds.right - bounds.left;
            int   h  = bounds.bottom - bounds.top;
            float px = st.mPivotXRel ? (w * st.mPivotX) : st.mPivotX;
            float py = st.mPivotYRel ? (h * st.mPivotY) : st.mPivotY;

            canvas.rotate(mCurrentDegrees, px + bounds.left, py + bounds.top);
            drawable.draw(canvas);
            canvas.restoreToCount(saveCount);
        }
Example #3
0
        public override void draw(android.graphics.Canvas canvas)
        {
            android.graphics.Rect  r     = getBounds();
            android.graphics.Paint paint = mShapeState.mPaint;
            int prevAlpha = paint.getAlpha();

            paint.setAlpha(modulateAlpha(prevAlpha, mShapeState.mAlpha));
            if (mShapeState.mShape != null)
            {
                // need the save both for the translate, and for the (unknown) Shape
                int count = canvas.save();
                canvas.translate(r.left, r.top);
                onDraw(mShapeState.mShape, canvas, paint);
                canvas.restoreToCount(count);
            }
            else
            {
                canvas.drawRect(r, paint);
            }
            // restore
            paint.setAlpha(prevAlpha);
        }
Example #4
0
 protected internal override void onDraw(android.graphics.Canvas canvas)
 {
     base.onDraw(canvas);
     if (mDrawable == null)
     {
         return;
     }
     // couldn't resolve the URI
     if (mDrawableWidth == 0 || mDrawableHeight == 0)
     {
         return;
     }
     // nothing to draw (empty bounds)
     if (mDrawMatrix == null && mPaddingTop == 0 && mPaddingLeft == 0)
     {
         mDrawable.draw(canvas);
     }
     else
     {
         int saveCount = canvas.getSaveCount();
         canvas.save();
         if (mCropToPadding)
         {
             int scrollX = mScrollX;
             int scrollY = mScrollY;
             canvas.clipRect(scrollX + mPaddingLeft, scrollY + mPaddingTop, scrollX + mRight -
                             mLeft - mPaddingRight, scrollY + mBottom - mTop - mPaddingBottom);
         }
         canvas.translate(mPaddingLeft, mPaddingTop);
         if (mDrawMatrix != null)
         {
             canvas.concat(mDrawMatrix);
         }
         mDrawable.draw(canvas);
         canvas.restoreToCount(saveCount);
     }
 }