コード例 #1
0
        public static AColor ColorAtPoint(this Bitmap bitmap, int x, int y, bool includeAlpha = false)
        {
            int pixel = bitmap.GetPixel(x, y);

            int red   = AColor.GetRedComponent(pixel);
            int blue  = AColor.GetBlueComponent(pixel);
            int green = AColor.GetGreenComponent(pixel);

            if (includeAlpha)
            {
                int alpha = AColor.GetAlphaComponent(pixel);
                return(AColor.Argb(alpha, red, green, blue));
            }
            else
            {
                return(AColor.Rgb(red, green, blue));
            }
        }
コード例 #2
0
        protected override void Draw(Canvas canvas, Rect bounds)
        {
            RectF arcBounds = mTempBounds;

            arcBounds.Set(bounds);
            arcBounds.Inset(mStrokeInset, mStrokeInset);
            mCurrentBounds.Set(arcBounds);

            int saveCount = canvas.Save();

            //draw circle trim
            float startAngle = (mStartTrim + mRotation) * 360;
            float endAngle   = (mEndTrim + mRotation) * 360;
            float sweepAngle = endAngle - startAngle;

            if (sweepAngle != 0)
            {
                mPaint.Color = new Color(mColor);
                mPaint.SetStyle(Paint.Style.Stroke);
                canvas.DrawArc(arcBounds, startAngle, sweepAngle, false, mPaint);
            }

            //draw water wave
            if (mWaveProgress < 1.0f)
            {
                var nColor = new Color(mColor);


                mPaint.Color = Color.Argb((int)(Color.GetAlphaComponent(mColor) * (1.0f - mWaveProgress)), Color.GetRedComponent(mColor), Color.GetGreenComponent(mColor), Color.GetBlueComponent(mColor));

                mPaint.SetStyle(Paint.Style.Stroke);
                float radius = Math.Min(arcBounds.Width(), arcBounds.Height()) / 2.0f;
                canvas.DrawCircle(arcBounds.CenterX(), arcBounds.CenterY(), radius * (1.0f + mWaveProgress), mPaint);
            }
            //draw ball bounce
            if (mPathMeasure != null)
            {
                mPaint.Color = new Color(mBallColor);
                mPaint.SetStyle(Paint.Style.Fill);
                canvas.DrawCircle(mCurrentPosition[0], mCurrentPosition[1], mSkipBallSize * mScale, mPaint);
            }

            canvas.RestoreToCount(saveCount);
        }
コード例 #3
0
        /// <summary> Determines the skin type of the specified bitmap. </summary>
        public static SkinType GetSkinType(Bitmap bmp)
        {
            if (bmp.Width == bmp.Height * 2)
            {
                return(SkinType.Type64x32);
            }
            else if (bmp.Width == bmp.Height)
            {
                // Minecraft alex skins have this particular pixel with alpha of 0.
                int scale = bmp.Width / 64;

                                #if !ANDROID
                int alpha = bmp.GetPixel(54 * scale, 20 * scale).A;
                                #else
                int alpha = AndroidColor.GetAlphaComponent(bmp.GetPixel(54 * scale, 20 * scale));
                                #endif
                return(alpha >= 127 ? SkinType.Type64x64 : SkinType.Type64x64Slim);
            }
            return(SkinType.Invalid);
        }