Example #1
0
        private static void _PerformCopy(SpanBitmap src, ANDROIDBITMAP dst)
        {
            if (src.Info.IsEmpty)
            {
                return;
            }
            if (dst == null)
            {
                return;
            }

            if (dst.IsRecycled || !dst.IsMutable)
            {
                throw new ArgumentNullException(nameof(dst));
            }

            if (!TryGetBitmapInfo(dst.GetBitmapInfo(), dst.IsPremultiplied, out var nfo))
            {
                throw new Diagnostics.PixelFormatNotSupportedException((dst.GetBitmapInfo().Format, dst.Premultiplied), nameof(dst));
            }

            var ptr = dst.LockPixels();

            if (ptr == IntPtr.Zero)
            {
                throw new ArgumentNullException("lock", nameof(dst));
            }

            try { new PointerBitmap(ptr, nfo).AsSpanBitmap().SetPixels(0, 0, src); }
            finally { dst.UnlockPixels(); }
        }
Example #2
0
        public static bool CopyTo(ANDROIDBITMAP src, ref MemoryBitmap dst)
        {
            var info = src.GetBitmapInfo().ToInterop();

            var ptr = src.LockPixels();

            try { return(new PointerBitmap(ptr, info).CopyTo(ref dst)); }
            finally { src.UnlockPixels(); }
        }
Example #3
0
        public static void Mutate(ANDROIDBITMAP bmp, Action <PointerBitmap> pinContext)
        {
            System.Diagnostics.Debug.Assert(bmp != null);

            if (!TryGetBitmapInfo(bmp.GetBitmapInfo(), bmp.IsPremultiplied, out var info))
            {
                throw new Diagnostics.PixelFormatNotSupportedException(bmp.GetBitmapInfo(), nameof(bmp));
            }

            if (info.BitmapByteSize != bmp.ByteCount)
            {
                throw new InvalidOperationException("Byte Size mismatch");
            }

            var ptr = bmp.LockPixels();

            try { pinContext(new PointerBitmap(ptr, info, !bmp.IsMutable)); }
            finally { bmp.UnlockPixels(); }
        }
 public static Bitmap RotateBitmap(Bitmap source, float angle)
 {
     Matrix matrix = new Matrix ();
     matrix.SetRotate (angle);
     return Bitmap.CreateBitmap (source, 0, 0, (int)source.GetBitmapInfo ().Width, (int)source.GetBitmapInfo ().Height, matrix, true);
 }