Example #1
0
 public static void SetScissorState(ScissorState value, bool intersectWithCurrent = false)
 {
     if (intersectWithCurrent && scissorState.Enable && value.Enable)
     {
         value.Bounds = (WindowRect)IntRectangle.Intersect((IntRectangle)value.Bounds, (IntRectangle)scissorState.Bounds);
     }
     ScissorState = value;
 }
Example #2
0
        public IBitmapImplementation Crop(IntRectangle cropArea)
        {
            var pixels = Bitmap.GetPixels(cropArea.A.X, cropArea.A.Y, cropArea.Width, cropArea.Height);
            var res    = new UnityEngine.Texture2D(cropArea.Width, cropArea.Height);

            res.SetPixels(pixels);
            return(new BitmapImplementation(res));
        }
Example #3
0
 public IBitmapImplementation Crop(IntRectangle cropArea)
 {
     return(new BitmapImplementation(
                AndroidBitmap.CreateBitmap(
                    Bitmap,
                    cropArea.Left,
                    cropArea.Top,
                    cropArea.Width,
                    cropArea.Height)));
 }
Example #4
0
 /// <summary>
 /// Creates a copy of the section of this bitmap defined by <see cref="IntRectangle"/> structure.
 /// </summary>
 /// <param name="cropArea">Defines the portion of this bitmap to copy.</param>
 /// <returns>The new bitmap that this method creates.</returns>
 /// <remarks>This method can not create empty bitmap. Section should be inside of the bitmap.</remarks>
 public Bitmap Crop(IntRectangle cropArea)
 {
     if (
         cropArea.Width <= 0 || cropArea.Height <= 0 ||
         cropArea.Left < 0 || cropArea.Top < 0 ||
         cropArea.Right > Width || cropArea.Bottom > Height)
     {
         throw new InvalidOperationException("Bitmap: Crop rectangle should be inside the image," +
                                             " and resulting bitmap should not be empty.");
     }
     if (cropArea.Width == Width && cropArea.Height == Height)
     {
         return(Clone());
     }
     CheckValidity();
     return(new Bitmap(implementation.Crop(cropArea)));
 }
Example #5
0
        public IBitmapImplementation Crop(IntRectangle cropArea)
        {
            var rect = new SD.Rectangle(cropArea.Left, cropArea.Top, cropArea.Width, cropArea.Height);

            return(new BitmapImplementation(Bitmap.Clone(rect, Bitmap.PixelFormat)));
        }
Example #6
0
 private bool IntersectRectangles(WindowRect a, WindowRect b, out WindowRect r)
 {
     r = (WindowRect)IntRectangle.Intersect((IntRectangle)a, (IntRectangle)b);
     return(r.Width > 0 && r.Height > 0);
 }
Example #7
0
        public IBitmapImplementation Crop(IntRectangle cropArea)
        {
            var rect = new CGRect(cropArea.Left, cropArea.Top, cropArea.Width, cropArea.Height);

            return(new BitmapImplementation(cgImage.WithImageInRect(rect)));
        }