コード例 #1
0
ファイル: ImageIO.cs プロジェクト: larsbrubaker/agg-sharp
        private static Image <Rgba32> ImageBufferToImage32(IImageByte sourceImage)
        {
            var source         = sourceImage.GetBuffer();
            var invertedBuffer = new byte[source.Length];
            int index          = 0;

            for (int y = sourceImage.Height - 1; y >= 0; y--)
            {
                var line = sourceImage.GetBufferOffsetY(y);
                for (int x = 0; x < sourceImage.Width; x++)
                {
                    var pix = x * 4;
                    invertedBuffer[index++] = source[line + pix + 2];
                    invertedBuffer[index++] = source[line + pix + 1];
                    invertedBuffer[index++] = source[line + pix + 0];
                    invertedBuffer[index++] = source[line + pix + 3];
                }
            }

            var image2 = SixLabors.ImageSharp.Image.LoadPixelData <Rgba32>(invertedBuffer,
                                                                           sourceImage.Width,
                                                                           sourceImage.Height);

            return(image2);
        }
コード例 #2
0
ファイル: ImageIO.cs プロジェクト: Oblikovati/agg-sharp
        public static bool SaveImageData(string filename, IImageByte sourceImage)
        {
            try
            {
                using (var tgaSave = new MemoryStream())
                {
                    var source         = sourceImage.GetBuffer();
                    var invertedBuffer = new byte[source.Length];
                    int index          = 0;
                    for (int y = sourceImage.Height - 1; y >= 0; y--)
                    {
                        var line = sourceImage.GetBufferOffsetY(y);
                        for (int x = 0; x < sourceImage.Width; x++)
                        {
                            var pix = x * 4;
                            invertedBuffer[index++] = source[line + pix + 2];
                            invertedBuffer[index++] = source[line + pix + 1];
                            invertedBuffer[index++] = source[line + pix + 0];
                            invertedBuffer[index++] = source[line + pix + 3];
                        }
                    }

                    var image2 = SixLabors.ImageSharp.Image.LoadPixelData <Rgba32>(invertedBuffer,
                                                                                   sourceImage.Width,
                                                                                   sourceImage.Height);
                    image2.Save(filename);
                }

                return(true);
            }
            catch { }

            return(false);
        }
コード例 #3
0
ファイル: ImageProxy.cs プロジェクト: annafeldman/agg-sharp
 public int GetBufferOffsetY(int y)
 {
     return(linkedImage.GetBufferOffsetY(y));
 }