Пример #1
0
        public void CopyPixels(ref WICRect prc, uint cbStride, uint cbBufferSize, byte[] pbBuffer)
        {
            //Log.Trace($"CopyPixels called: ({prc.X} {prc.Y} {prc.Width} {prc.Height}) Stride: {cbStride}, Size: {cbBufferSize}");

            try
            {
                //Log.Trace($"CopyPixels rgbmap {rgbmap.Width}, {rgbmap.Height}");
                CopyBGRA(ref prc, cbStride, cbBufferSize, pbBuffer);
                if (prc.Y + prc.Height == rgbmap.Height) rgbmap.Dispose();
                //Log.Trace("CopyPixels finished");
            }
            catch (Exception e)
            {
                Log.Error("CopyPixels failed: " + e);
                throw;
            }
        }
Пример #2
0
 public static IWICBitmap CreateBitmapFromSourceRect(this IWICImagingFactory imagingFactory, IWICBitmapSource pIBitmapSource, WICRect rect)
 {
     return(imagingFactory.CreateBitmapFromSourceRect(pIBitmapSource, rect.X, rect.Y, rect.Width, rect.Height));
 }
Пример #3
0
        unsafe void CopyBGRA(ref WICRect prc, uint cbStride, uint cbBufferSize, byte[] pbBuffer)
        {
            BuildRGB();

            fixed (byte* p = pbBuffer)
            {
                var dest = p;
                for (int y = prc.Y; y < prc.Y + prc.Height; y++)
                {
                    fixed (BGRA8* line = rgbmap.Values[y])
                    {
                        var src = (byte*)(line + prc.X);
                        int length = prc.Width * rgbmap.BytesPerPixel;
                        for (; length > 0; length--, dest++, src++) *dest = *src;
                    }
                }
            }
        }