コード例 #1
0
        public static void Transfer(GDIBITMAP src, SpanBitmap dst, SpanBitmap.Action2 action)
        {
            var rect = new Rectangle(0, 0, dst.Width, dst.Height);

            GDIPTR srcBits = null;

            try
            {
                srcBits = src.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, src.PixelFormat);

                var srcSpan = srcBits
                              .AsPointerBitmapDangerous()
                              .AsSpanBitmap()
                              .AsReadOnly();

                action(srcSpan, dst);
            }
            finally
            {
                if (srcBits != null)
                {
                    src.UnlockBits(srcBits);
                }
            }
        }
コード例 #2
0
        public static void Transfer(SpanBitmap src, GDIBITMAP dst, SpanBitmap.Action2 action)
        {
            src = src.AsReadOnly();

            var rect = new Rectangle(0, 0, dst.Width, dst.Height);

            GDIPTR dstBits = null;

            try
            {
                dstBits = dst.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadWrite, dst.PixelFormat);

                var dstSpan = dstBits
                              .AsPointerBitmapDangerous()
                              .AsSpanBitmap();

                action(src, dstSpan);
            }
            finally
            {
                if (dstBits != null)
                {
                    dst.UnlockBits(dstBits);
                }
            }
        }