Ejemplo n.º 1
0
        public void Execute_ImageWithAlpha_AlphaIsRestored()
        {
            var tshirtFile = GetInputFile("tshirt_gray.jpg");

            var overlayFile = GetInputFile("flowers_van_gogh.jpg");

            using (var tshirtImage = new MagickImage(tshirtFile))
            {
                tshirtImage.Opaque(new MagickColor("#FEFEFE"), MagickColors.None);

                using (var overlayImage = new MagickImage(overlayFile))
                {
                    overlayImage.Crop(479, 479);

                    var script = new TshirtScript
                    {
                        Fit      = TshirtFit.Crop,
                        Blur     = 0,
                        Lighting = 0,
                        Sharpen  = 0
                    };

                    script.SetCoordinates(new MagickGeometry(275, 175, 130, 130));

                    using (var scriptOutput = script.Execute(tshirtImage, overlayImage))
                    {
                        AssertOutput(scriptOutput, "flowers_van_gogh_alpha.jpg");
                    }
                }
            }
        }
        public void Execute_ImageWithAlpha_AlphaIsRestored()
        {
            var tshirtFile = GetInputFile("tshirt_gray.jpg");
            /* LosslessCompress(tshirtFile); */

            var overlayFile = GetInputFile("flowers_van_gogh.jpg");

            /* LosslessCompress(overlayFile); */

            using (var tshirtImage = new MagickImage(tshirtFile))
            {
                tshirtImage.Opaque(MagickColors.White, MagickColors.None);

                using (var overlayImage = new MagickImage(overlayFile))
                {
                    overlayImage.Crop(479, 479);

                    var script = new TshirtScript();
                    script.Fit      = TshirtFit.Crop;
                    script.Blur     = 0;
                    script.Lighting = 0;
                    script.Sharpen  = 0;

                    script.SetCoordinates(new MagickGeometry(275, 175, 130, 130));

                    using (var scriptOutput = script.Execute(tshirtImage, overlayImage))
                    {
                        AssertOutput(scriptOutput, "flowers_van_gogh_alpha.jpg");
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public void SetCoordinates_GeometryNull_ThrowsException()
 {
     ExceptionAssert.ThrowsArgumentException <ArgumentNullException>("geometry", () =>
     {
         TshirtScript script = new TshirtScript();
         script.SetCoordinates(null);
     });
 }
Ejemplo n.º 4
0
 private static void AssertCoordinates(string paramName, PointD topLeft, PointD topRight, PointD bottomLeft, PointD bottomRight)
 {
     ExceptionAssert.ThrowsArgumentException <ArgumentOutOfRangeException>(paramName, () =>
     {
         using (MagickImage logo = Images.Logo)
         {
             TshirtScript script = new TshirtScript();
             script.SetCoordinates(topLeft, topRight, bottomLeft, bottomRight);
             script.Execute(logo, logo);
         }
     });
 }
Ejemplo n.º 5
0
        private void AssertInvalidOperation(string expectedMessage, Action <TshirtScript> initAction)
        {
            var script = new TshirtScript();

            using (var logo = new MagickImage(Images.Logo))
            {
                initAction(script);

                ExceptionAssert.Throws <InvalidOperationException>(expectedMessage, () =>
                {
                    script.SetCoordinates(_topLeft, _topRight, _bottomLeft, _bottomRight);
                    script.Execute(logo, logo);
                });
            }
        }
 private void Reset(TshirtScript script)
 {
     script.Reset();
     script.SetCoordinates(_TopLeft, _TopRight, _BottomLeft, _BottomRight);
 }