Esempio n. 1
0
            public override Color4 Read(int stride)
            {
                RGBAColor *src = FPData + Position;

                Position += stride;
                return(new Color4((float)src->R, (float)src->G, (float)src->B, (float)src->A));
            }
Esempio n. 2
0
            public override Color4 Read(int stride)
            {
                Debug.Assert(Position < Length);
                RGBAColor *src = FPData + Position;

                Position += stride;
                return(new Color4((float)src->A, (float)src->R, (float)src->G, (float)src->B));
            }
Esempio n. 3
0
            public override void Write(Color4 value, int stride)
            {
                RGBAColor *dst = FPDst + Position;

                dst->R    = value.R;
                dst->G    = value.G;
                dst->B    = value.B;
                dst->A    = value.A;
                Position += stride;
            }
Esempio n. 4
0
            public override void Write(Color4 value, int stride)
            {
                Debug.Assert(!Eos);
                RGBAColor *dst = FPDst + Position;

                dst->R    = value.Red;
                dst->G    = value.Green;
                dst->B    = value.Blue;
                dst->A    = value.Alpha;
                Position += stride;
            }
Esempio n. 5
0
    internal protected override sealed unsafe void Process(Bitmap bmp, RGBAColor *source, RGBAColor *destination, Rectangle region)
    {
        int[] indices = GetIndices(bmp, region);

        Parallel.For(0, indices.Length, i =>
        {
            int idx = indices[i];

            destination[idx] = ProcessColor(source[idx]);
        });
    }
Esempio n. 6
0
        /// <summary>
        /// Converts the specified BitmapPixels to grayscale.
        /// </summary>
        /// <param name="pixels">The BitmapPixels to convert.</param>
        public static void MakeGrayscal(BitmapPixels pixels)
        {
            unsafe
            {
                RGBAColor *color_ps = pixels.Pointer;

                byte new_pixel;
                for (int pixel = 0; pixel < pixels.Height * pixels.Width; pixel++, color_ps++)
                {
                    new_pixel = (byte)(color_ps->R * 0.2126 + color_ps->G * 0.7152 + color_ps->B * 0.0722);
                    *color_ps = new RGBAColor(new_pixel, new_pixel, new_pixel, color_ps->A); //set the new pixel using the existing alpha component
                }
            }
        }
Esempio n. 7
0
            protected override void Copy(RGBAColor[] source, int sourceIndex, int length, int stride)
            {
                fixed(RGBAColor *sourcePtr = source)
                {
                    RGBAColor *src = sourcePtr + sourceIndex;
                    RGBAColor *dst = FPDst + Position;

                    for (int i = 0; i < length; i++)
                    {
                        *dst = *(src++);
                        dst += stride;
                    }
                }
            }
Esempio n. 8
0
            protected override void Copy(RGBAColor[] destination, int destinationIndex, int length, int stride)
            {
                fixed(RGBAColor *destinationPtr = destination)
                {
                    RGBAColor *dst = destinationPtr + destinationIndex;
                    RGBAColor *src = FPData + Position;

                    for (int i = 0; i < length; i++)
                    {
                        *(dst++) = *src;
                        src     += stride;
                    }
                }
            }
Esempio n. 9
0
        public void Lock()
        {
            if (locked)
            {
                return;
            }

            bitmapData = bitmap.LockBits(bounds, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
            locked     = true;

            unsafe
            {
                pointer = (RGBAColor *)bitmapData.Scan0.ToPointer();
            }
        }
Esempio n. 10
0
        public void Unlock()
        {
            if (!locked)
            {
                return;
            }

            bitmap.UnlockBits(bitmapData);
            locked = false;

            unsafe
            {
                pointer = null;
            }
        }
Esempio n. 11
0
            protected override void Copy(Color4[] destination, int destinationIndex, int length, int stride)
            {
                fixed(Color4 *destinationPtr = destination)
                {
                    Color4 *   dst = destinationPtr + destinationIndex;
                    RGBAColor *src = FPData + Position;

                    for (int i = 0; i < length; i++)
                    {
                        dst->Red   = (float)src->R;
                        dst->Green = (float)src->G;
                        dst->Blue  = (float)src->B;
                        dst->Alpha = (float)src->A;
                        dst++;
                        src += stride;
                    }
                }
            }
Esempio n. 12
0
            protected override void Copy(Color4[] source, int sourceIndex, int length, int stride)
            {
                fixed(Color4 *sourcePtr = source)
                {
                    Color4 *   src = sourcePtr + sourceIndex;
                    RGBAColor *dst = FPDst + Position;

                    for (int i = 0; i < length; i++)
                    {
                        dst->R = src->Red;
                        dst->G = src->Green;
                        dst->B = src->Blue;
                        dst->A = src->Alpha;
                        src++;
                        dst += stride;
                    }
                }
            }
Esempio n. 13
0
        internal protected override unsafe void Process(Bitmap bmp, RGBAColor *p_top, RGBAColor *p_dest, Rectangle region)
        {
            if (bmp.Size != BaseLayer.Size)
            {
                throw new ArgumentException($"The top layer ('{nameof(bmp)}') must have the same dimensions as the base layer. The required dimensions are: {BaseLayer.Width}x{BaseLayer.Height}.", nameof(bmp));
            }

            int[]        indices = GetIndices(BaseLayer, region);
            BitmapLocker lck     = BaseLayer;
            BlendMode    mode    = Mode;

            lck.LockRGBAPixels((p_base, w, h) => Parallel.For(0, indices.Length, i =>
            {
                int idx = indices[i];

                p_dest[idx] = RGBAColor.Blend(p_base[idx], p_top[idx], mode);
            }));
        }
Esempio n. 14
0
 public Color4OutWriter(Color4OutStream stream, RGBAColor *pDst)
     : base(stream)
 {
     FPDst = pDst;
 }
Esempio n. 15
0
 public SlimDXColorInStreamReader(SlimDXColorInStream stream, RGBAColor *pData)
     : base(stream)
 {
     FPData = pData;
 }
Esempio n. 16
0
 public SlimDXColorOutWriter(SlimDXColorOutStream stream, RGBAColor *pDst)
     : base(stream)
 {
     FPDst = pDst;
 }
Esempio n. 17
0
 public Color4InStreamReader(Color4InStream stream, RGBAColor *pData)
     : base(stream)
 {
     FPData = pData;
 }
Esempio n. 18
0
 internal protected abstract void Process(Bitmap bmp, RGBAColor *source, RGBAColor *destination, Rectangle region);