示例#1
0
        public void CropToVisible()
        {
            Vector2 OldOriginOffset = OriginOffset;

            //Move the HotSpot to 0, 0 so PPoint will work the way we want
            OriginOffset = new Vector2(0, 0);

            RectangleInt visibleBounds;

            GetVisibleBounds(out visibleBounds);

            if (visibleBounds.Width == Width &&
                visibleBounds.Height == Height)
            {
                OriginOffset = OldOriginOffset;
                return;
            }

            // check if the Not0Rect has any size
            if (visibleBounds.Width > 0)
            {
                ImageBuffer TempImage = new ImageBuffer();

                // set TempImage equal to the Not0Rect
                TempImage.Initialize(this, visibleBounds);

                // set the frame equal to the TempImage
                Initialize(TempImage);

                OriginOffset = new Vector2(-visibleBounds.Left + OldOriginOffset.x, -visibleBounds.Bottom + OldOriginOffset.y);
            }
            else
            {
                Deallocate();
            }
        }
示例#2
0
		public void CropToVisible()
		{
			Vector2 OldOriginOffset = OriginOffset;

			//Move the HotSpot to 0, 0 so PPoint will work the way we want
			OriginOffset = new Vector2(0, 0);

			RectangleInt visibleBounds;
			GetVisibleBounds(out visibleBounds);

			if (visibleBounds.Width == Width
				&& visibleBounds.Height == Height)
			{
				OriginOffset = OldOriginOffset;
				return;
			}

			// check if the Not0Rect has any size
			if (visibleBounds.Width > 0)
			{
				ImageBuffer TempImage = new ImageBuffer();

				// set TempImage equal to the Not0Rect
				TempImage.Initialize(this, visibleBounds);

				// set the frame equal to the TempImage
				Initialize(TempImage);

				OriginOffset = new Vector2(-visibleBounds.Left + OldOriginOffset.x, -visibleBounds.Bottom + OldOriginOffset.y);
			}
			else
			{
				Deallocate();
			}
		}