Ejemplo n.º 1
0
        unsafe public void CopyPixels(Rectangle sourceArea, long cbStride, long cbBufferSize, IntPtr pbBuffer)
        {
            source.CopyPixels(sourceArea, cbStride, cbBufferSize, pbBuffer);

            Vector4 vb = vec0, vg = vec1, vr = vec2, vdiv = new Vector4(1f / byte.MaxValue);
            Vector4 vmin = Vector4.Zero, vmax = new Vector4(byte.MaxValue), vrnd = new Vector4(0.5f);
            float   fmax = vmax.X;
            int     chan = channels;

            for (int y = 0; y < sourceArea.Height; y++)
            {
                byte *ip = (byte *)pbBuffer + y * cbStride, ipe = ip + sourceArea.Width * chan;
                while (ip < ipe)
                {
                    var   v0 = new Vector4(ip[0], ip[1], ip[2], fmax) * vdiv;
                    float f0 = Vector4.Dot(v0, vb);
                    float f1 = Vector4.Dot(v0, vg);
                    float f2 = Vector4.Dot(v0, vr);

                    v0    = Vector4.Clamp(new Vector4(f0, f1, f2, 0f) * vmax + vrnd, vmin, vmax);
                    ip[0] = (byte)v0.X;
                    ip[1] = (byte)v0.Y;
                    ip[2] = (byte)v0.Z;

                    ip += chan;
                }
            }
        }
Ejemplo n.º 2
0
        unsafe public void CopyPixels(Rectangle sourceArea, long cbStride, long cbBufferSize, IntPtr pbBuffer)
        {
            source.CopyPixels(sourceArea, cbStride, cbBufferSize, pbBuffer);

            if (format.NumericRepresentation == PixelNumericRepresentation.Float)
            {
                copyPixelsFloat(sourceArea, cbStride, cbBufferSize, pbBuffer);
            }
            else if (format.NumericRepresentation == PixelNumericRepresentation.Fixed)
            {
                copyPixelsFixed(sourceArea, cbStride, cbBufferSize, pbBuffer);
            }
            else
            {
                copyPixelsByte(sourceArea, cbStride, cbBufferSize, pbBuffer);
            }
        }
Ejemplo n.º 3
0
 protected override void CopyPixelsInternal(WICRect prc, uint cbStride, uint cbBufferSize, IntPtr pbBuffer) => realSource.CopyPixels(prc.ToGdiRect(), cbStride, cbBufferSize, pbBuffer);