public void CopyTo_Then_CopyFrom_WithOffset <TColor, TPacked>(TestImageFactory <TColor, TPacked> factory, ComponentOrder order)
            where TColor : struct, IPackedPixel <TPacked> where TPacked : struct, IEquatable <TPacked>

        {
            var srcImage = factory.Create();

            var color = default(TColor);

            color.PackFromBytes(255, 0, 0, 255);

            Fill(srcImage, new Rectangle(4, 4, 8, 8), color);

            var destImage = new Image <TColor, TPacked>(8, 8);

            using (var srcPixels = srcImage.Lock())
            {
                using (var area = new PixelArea <TColor, TPacked>(8, 8, order))
                {
                    srcPixels.CopyTo(area, 4, 4);

                    using (var destPixels = destImage.Lock())
                    {
                        destPixels.CopyFrom(area, 0, 0);
                    }
                }
            }

            factory.Utility.SourceFileOrDescription = order.ToString();
            factory.Utility.SaveTestOutputFile(destImage, "bmp");

            var expectedImage = new Image <TColor, TPacked>(8, 8).Fill(color);

            Assert.True(destImage.IsEquivalentTo(expectedImage));
        }
Beispiel #2
0
        [WithFileCollection(nameof(AllJpegFiles), PixelTypes.All)] // TODO: Turned off to be kind to AppVeyor, should I re-enable?
        //[WithFileCollection(nameof(AllJpegFiles), PixelTypes.Color | PixelTypes.Argb)]
        public void OpenJpeg_SaveBmp <TColor, TPacked>(TestImageFactory <TColor, TPacked> factory)
            where TColor : struct, IPackedPixel <TPacked> where TPacked : struct, IEquatable <TPacked>
        {
            var image = factory.Create();

            factory.Utility.SaveTestOutputFile(image, "bmp");
        }
Beispiel #3
0
        public void OpenBmp_SaveJpeg <TColor, TPacked>(TestImageFactory <TColor, TPacked> factory, JpegSubsample subSample, int quality)
            where TColor : struct, IPackedPixel <TPacked> where TPacked : struct, IEquatable <TPacked>
        {
            var image = factory.Create();

            var utility = factory.Utility;

            utility.TestName += "_" + subSample + "_Q" + quality;

            using (var outputStream = File.OpenWrite(utility.GetTestOutputFileName("jpg")))
            {
                var encoder = new JpegEncoder()
                {
                    Subsample = subSample,
                    Quality   = quality
                };

                image.Save(outputStream, encoder);
            }
        }
        public void CopyTo_Then_CopyFrom_OnFullImageRect <TColor, TPacked>(TestImageFactory <TColor, TPacked> factory, ComponentOrder order)
            where TColor : struct, IPackedPixel <TPacked> where TPacked : struct, IEquatable <TPacked>
        {
            var src = factory.Create();

            var dest = new Image <TColor, TPacked>(src.Width, src.Height);

            using (PixelArea <TColor, TPacked> area = new PixelArea <TColor, TPacked>(src.Width, src.Height, order))
            {
                using (var srcPixels = src.Lock())
                {
                    srcPixels.CopyTo(area, 0, 0);
                }

                using (var destPixels = dest.Lock())
                {
                    destPixels.CopyFrom(area, 0, 0);
                }
            }

            Assert.True(src.IsEquivalentTo(dest, false));
        }