示例#1
0
        /// <summary>
        /// Setup the base matrix so that the image is centered and scaled properly.
        /// </summary>
        private void getProperBaseMatrix(RotateBitmap bitmap, Matrix matrix)
        {
            float viewWidth = _width; //Width;
            float viewHeight = _height; //Height;

            float w = bitmap.Width;
            float h = bitmap.Height;
            int rotation = bitmap.Rotation;
            matrix.Reset();

            // We limit up-scaling to 2x otherwise the result may look bad if it's
            // a small icon.
            float widthScale = viewWidth / w; //Math.Min(viewWidth / w, 2.0f);
            float heightScale = viewHeight / h; //Math.Min(viewHeight / h, 2.0f);
            float scale = Math.Min(widthScale, heightScale);

            matrix.PostConcat(bitmap.GetRotateMatrix());
            matrix.PostScale(scale, scale);

            matrix.PostTranslate(
                (viewWidth - w * scale) / 2F,
                (viewHeight - h * scale) / 2F);
        }
示例#2
0
        internal void SetImageRotateBitmapResetBase(RotateBitmap bitmap, bool resetSupp)
        {
            int viewWidth = _width; //Width;

            if (viewWidth <= 0)
            {
                onLayoutRunnable = () =>
                {
                    SetImageRotateBitmapResetBase(bitmap, resetSupp);
                };

                return;
            }

            if (bitmap.Bitmap != null)
            {
                getProperBaseMatrix(bitmap, baseMatrix);
                setImageBitmap(bitmap.Bitmap, bitmap.Rotation);
            }
            else
            {
                baseMatrix.Reset();
                base.SetImageBitmap(null);
            }

            if (resetSupp)
            {
                suppMatrix.Reset();
            }
            ImageMatrix = GetImageViewMatrix();
            //this.maxZoom = CalculateMaxZoom();                        
        }