Beispiel #1
0
 public static IReadOnlyPixelBuffer <TPixel> ProjectRows <TPixel>(
     this IReadOnlyPixelBuffer <TPixel> pixels,
     PixelBufferProjectorCallback <TPixel> projector)
     where TPixel : unmanaged, IPixel
 {
     return(ProjectRows(pixels, ImagingConfig.Default, projector));
 }
        public static unsafe Bitmap ToBitmap(
            this IReadOnlyPixelBuffer pixels,
            Rectangle?sourceRectangle = null)
        {
            var srcRect = sourceRectangle ?? pixels.GetBounds();

            ImagingArgumentGuard.AssertRectangleInSource(pixels, srcRect, nameof(sourceRectangle));

            var srcType       = pixels.PixelType;
            var dstType       = VectorType.Get <Bgra32>();
            var convertPixels = Imaging.Image.GetConvertPixelsDelegate(srcType, dstType);
            int width         = srcRect.Width;
            int height        = srcRect.Height;

            var bitmap  = new Bitmap(width, height, PixelFormat.Format32bppArgb);
            var bmpRect = new System.Drawing.Rectangle(0, 0, width, height);
            var bmpData = bitmap.LockBits(bmpRect, ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb);

            try
            {
                for (int y = 0; y < bmpData.Height; y++)
                {
                    int srcX   = srcRect.X;
                    int srcY   = srcRect.Y + y;
                    int dstX   = 0;
                    int dstY   = y;
                    var dstPtr = (byte *)bmpData.Scan0 + dstY * bmpData.Stride;

                    var srcRow = pixels.GetPixelByteRowSpan(srcY)[srcX..];
Beispiel #3
0
 public static IReadOnlyPixelBuffer ProjectRows(this IReadOnlyPixelBuffer pixels,
                                                ImagingConfig imagingConfig, PixelBufferProjectorCallback projector)
 {
     if (projector == null)
     {
         throw new ArgumentNullException(nameof(projector));
     }
     return(projector.Invoke(new ReadOnlyPixelBufferContext(imagingConfig, pixels)));
 }
 public static Image <TPixel> ProcessBuffer <TPixel>(this IReadOnlyPixelBuffer <TPixel> pixels,
                                                     ImagingConfig imagingConfig, PixelBufferProcessorCallback <TPixel> processor)
     where TPixel : unmanaged, IPixel <TPixel>
 {
     if (processor == null)
     {
         throw new ArgumentNullException(nameof(processor));
     }
     return(processor.Invoke(new ReadOnlyPixelBufferContext <TPixel>(imagingConfig, pixels)));
 }
Beispiel #5
0
 public static IReadOnlyPixelBuffer ProjectRows(this IReadOnlyPixelBuffer pixels,
                                                PixelBufferProjectorCallback projector)
 {
     return(ProjectRows(pixels, ImagingConfig.Default, projector));
 }
 public static Image <TPixel> ProcessBuffer <TPixel>(this IReadOnlyPixelBuffer <TPixel> pixels,
                                                     PixelBufferProcessorCallback <TPixel> processor)
     where TPixel : unmanaged, IPixel <TPixel>
 {
     return(ProcessBuffer(pixels, ImagingConfig.Default, processor));
 }
 public static Image ProcessBuffer(this IReadOnlyPixelBuffer pixels,
                                   PixelBufferProcessorCallback processor)
 {
     return(ProcessBuffer(pixels, ImagingConfig.Default, processor));
 }
Beispiel #8
0
 public ReadOnlyImageFrame(IReadOnlyPixelBuffer <TPixel> pixels, int delay)
 {
     Pixels = pixels ?? throw new ArgumentNullException(nameof(pixels));
     Delay  = delay;
 }
 public ReadOnlyCropBuffer(IReadOnlyPixelBuffer pixels, Rectangle sourceRectangle)
 {
     Pixels          = pixels ?? throw new ArgumentNullException(nameof(pixels));
     SourceRectangle = sourceRectangle;
 }
 public ReadOnlyPixelBufferContext(IImagingConfig imagingConfig, IReadOnlyPixelBuffer <TPixel> pixels) :
     base(imagingConfig, pixels)
 {
 }