Пример #1
0
        BitmapSource TransformBitmap(RenderTargetBitmap source)
        {
            //.Mutate(x => x.get)
            //.Clone(x => x.Rotate(RotateMode.Rotate90));

            //sourceImage.Clone(x => x.Rotate(RotateMode.Rotate90));

            var buffer = new UInt32[source.PixelWidth * source.PixelHeight];

            source.CopyPixels(buffer, source.PixelWidth * 4, 0);

            var target = new UInt32[source.PixelWidth];

            for (var i = 0; i < source.PixelWidth; ++i)
            {
                var x = new Vector3();

                for (var j = 0; j < source.PixelHeight; ++j)
                {
                    uint packed = buffer[j * source.PixelWidth + i];

                    var pp = new Rgba32(packed);

                    if (pp.A != 255)
                    {
                        continue;
                    }

                    Rgb p = pp;

                    //if (packed != 0u) System.Diagnostics.Debugger.Break();

                    x = Vector3.Max(x, p.ToVector3());
                }

                target[i] = new Rgba32(x).PackedValue;
            }

            //return RenderTargetBitmap.Create(source.PixelWidth, source.PixelHeight, 96, 96, source.Format, source.Palette, buffer, source.PixelWidth * 4);
            return(RenderTargetBitmap.Create(source.PixelWidth, 1, 96, 96, source.Format, source.Palette, target, source.PixelWidth * 4));
        }