Example #1
0
        public unsafe void FlipBuffer(FlipMode flipMode)
        {
            PixelBuffer pb = new PixelBuffer(_width, _height);

            fixed(int *src = _buffer)
            {
                fixed(int *dest = pb.InternalBuffer)
                {
                    switch (flipMode)
                    {
                    default:
                    case FlipMode.FlipHorizontal:
                        FlipBufferHorizontal(src, dest);
                        break;

                    case FlipMode.FlipVertical:
                        FlipBufferVertical(src, dest);
                        break;

                    case FlipMode.FlipBoth:
                        FlipBufferBoth(src, dest);
                        break;
                    }
                }
            }

            fixed(int *src = pb.InternalBuffer)
            {
                fixed(int *dest = _buffer)
                {
                    CopyBuffer(dest, src, _pixelsCount);
                }
            }

            pb.Dispose();
        }
Example #2
0
 public virtual void Dispose()
 {
     pixelBuffer = null;
 }
Example #3
0
 protected PixelBufferRenderer(PixelBuffer pixelBuffer)
 {
     this.pixelBuffer          = pixelBuffer;
     _useTransparentBackground = false;
     _backColor = Color.Black;
 }
Example #4
0
 public PixelBufferGraphics(PixelBuffer pixelBuffer)
 {
     this.pixelBuffer = pixelBuffer;
 }
Example #5
0
 public unsafe void BlendSubBuffer(PixelBuffer subBuffer, int x, int y)
 {
     BlendSubBuffer(subBuffer.InternalBuffer, x, y, subBuffer.Width, subBuffer.Height);
 }
Example #6
0
        private unsafe void SetBufferRectBufferOutside(int[] srcBuffer, int x, int y, int width, int height)
        {
            int sx = 0;
            int sy = 0;
            int sw = width;
            int sh = height;

            if (x < 0)
            {
                sx  = -x;
                sw += x;
            }
            else if ((x + width) > _width)
            {
                sx = 0;
                sw = _width - x;
            }

            if (y < 0)
            {
                sy  = -y;
                sh += y;
            }
            else if ((y + height) > _height)
            {
                sy = 0;
                sh = _height - y;
            }

            if (sw <= 0 || sh <= 0)
            {
                return;
            }

            //TODO: problema con l'indice del pixel di un buffer senza istanza
            //
            //int[] blitBufferArray = new int[sw * sh];
            //fixed (int* src = srcBuffer)
            //{
            //    fixed (int* dest = blitBufferArray)
            //    {
            //        CopyBufferRect(dest, src, sx, sy, sw, sh);
            //    }
            //}
            PixelBuffer srcBufferHelper = new PixelBuffer(width, height, srcBuffer);
            PixelBuffer blitBufferArray = srcBufferHelper.GetSubBuffer(sx, sy, sw, sh);

            int fx = x;
            int fy = y;

            if (x < 0)
            {
                fx = 0;
            }
            if (y < 0)
                fy = 0;

            fixed(int *src = blitBufferArray.InternalBuffer)
            {
                fixed(int *dest = _buffer)
                {
                    SetBufferRectBuffer(dest, src, fx, fy, sw, sh);
                }
            }

            srcBufferHelper.Dispose();
            blitBufferArray.Dispose();
        }
Example #7
0
        private unsafe PixelBuffer GetSubBufferOutside(int x, int y, int width, int height)
        {
            PixelBuffer retBuff = new PixelBuffer(width, height);

            int sx = x;
            int sy = y;
            int sw = width;
            int sh = height;

            if (x < 0)
            {
                sx  = 0;
                sw += x;
            }
            else if ((x + width) > _width)
            {
                sw = _width - x;
            }

            if (y < 0)
            {
                sy  = 0;
                sh += y;
            }
            else if ((y + height) > _height)
            {
                sh = _height - y;
            }

            if (sw <= 0 || sh <= 0)
            {
                return(new PixelBuffer(width, height));
            }

            int defaultColor = 0;

            fixed(int *src = _buffer)
            {
                int index = this.GetPixelBytesIndex(sx, sy, _width);

                defaultColor = this.GetPixelColorByIndex(src, index);
            }

            fixed(int *dest = retBuff.InternalBuffer)
            {
                retBuff.SetBufferColor(dest, defaultColor);
            }

            using (PixelBuffer subBuff = this.GetSubBuffer(sx, sy, sw, sh))
            {
                int fx = 0;
                int fy = 0;
                if (x < 0)
                {
                    fx = -x;
                }
                if (y < 0)
                {
                    fy = -y;
                }

                retBuff.SetSubBuffer(subBuff, fx, fy);
            }

            return(retBuff);
        }
 public PixelBufferManagedRenderer(PixelBuffer pixelBuffer)
     : base(pixelBuffer)
 {
     this.UseTransparentBackground = true;
     this.backColorBrush           = new SolidBrush(Color.Black);
 }