예제 #1
0
        static void ScaleImgAndSave(string inputImgFilename, float scale, PixelFarm.CpuBlit.Imaging.FreeTransform.InterpolationMode interpolation, string outputImgFilename)
        {
            PixelFarm.CpuBlit.Imaging.FreeTransform freeTx = new PixelFarm.CpuBlit.Imaging.FreeTransform();
            MemBitmap bmp = LoadImage(inputImgFilename);

            //freeTx.Interpolation = PixelFarm.CpuBlit.Imaging.FreeTransform.InterpolationMode.Bicubic;// PixelFarm.Agg.Imaging.FreeTransform.InterpolationMode.Bilinear;
            freeTx.Interpolation = interpolation;// PixelFarm.CpuBlit.Imaging.FreeTransform.InterpolationMode.Bilinear;
            //freeTx.SetFourCorners(
            //    new PixelFarm.VectorMath.PointF(0, 0),
            //    new PixelFarm.VectorMath.PointF(bmp.Width / 5, 0),
            //    new PixelFarm.VectorMath.PointF(bmp.Width / 5, bmp.Height / 5),
            //    new PixelFarm.VectorMath.PointF(0, bmp.Height / 5)
            //);

            freeTx.SetFourCorners(
                new PixelFarm.VectorMath.PointF(0, 0),
                new PixelFarm.VectorMath.PointF(bmp.Width * scale, 0),
                new PixelFarm.VectorMath.PointF(bmp.Width * scale, bmp.Height * scale),
                new PixelFarm.VectorMath.PointF(0, bmp.Height * scale)
                );


            using (MemBitmap transferBmp = freeTx.GetTransformedBitmap(bmp))
            {
                SaveImage(transferBmp, outputImgFilename);
            }
        }
예제 #2
0
        private void cmdFreeTransform_Click(object sender, EventArgs e)
        {
            PixelFarm.CpuBlit.Imaging.FreeTransform freeTx = new PixelFarm.CpuBlit.Imaging.FreeTransform();
            MemBitmap bmp = LoadImage("Samples\\lion1.png");

            freeTx.Interpolation = PixelFarm.CpuBlit.Imaging.FreeTransform.InterpolationMode.Bicubic;// PixelFarm.Agg.Imaging.FreeTransform.InterpolationMode.Bilinear;

            //freeTx.SetFourCorners(
            //    new PixelFarm.VectorMath.PointF(0, 0),
            //    new PixelFarm.VectorMath.PointF(bmp.Width / 5, 0),
            //    new PixelFarm.VectorMath.PointF(bmp.Width / 5, bmp.Height / 5),
            //    new PixelFarm.VectorMath.PointF(0, bmp.Height / 5)
            //);

            freeTx.SetFourCorners(
                new PixelFarm.VectorMath.PointF(0, 0),
                new PixelFarm.VectorMath.PointF(bmp.Width * 3, 0),
                new PixelFarm.VectorMath.PointF(bmp.Width * 3, bmp.Height * 3),
                new PixelFarm.VectorMath.PointF(0, bmp.Height * 3)
                );


            using (MemBitmap transferBmp = freeTx.GetTransformedBitmap(bmp))
            {
                SaveImage(transferBmp, "test01_tx" + freeTx.Interpolation + ".png");
            }

            pictureBox1.Image = null;
            if (_resultBmp != null)
            {
                _resultBmp.Dispose();
                _resultBmp = null;
            }
            pictureBox1.Image = _resultBmp = new Bitmap("test01_tx" + freeTx.Interpolation + ".png");
        }
예제 #3
0
        private void cmdFreeTransform_Click(object sender, EventArgs e)
        {
            PixelFarm.CpuBlit.Imaging.FreeTransform freeTx = new PixelFarm.CpuBlit.Imaging.FreeTransform();
            MemBitmap bmp = LoadImage("Samples\\lion1.png");

            freeTx.Interpolation = PixelFarm.CpuBlit.Imaging.FreeTransform.InterpolationMode.Bicubic;// PixelFarm.Agg.Imaging.FreeTransform.InterpolationMode.Bilinear;
            freeTx.SetFourCorners(
                new PixelFarm.VectorMath.PointF(0, 0),
                new PixelFarm.VectorMath.PointF(bmp.Width / 5, 0),
                new PixelFarm.VectorMath.PointF(bmp.Width / 5, bmp.Height / 5),
                new PixelFarm.VectorMath.PointF(0, bmp.Height / 5)
                );
            // freeTx.SetFourCorners(
            //    new PixelFarm.VectorMath.PointF(0, 0),
            //    new PixelFarm.VectorMath.PointF(bmp.Width * 4, 0),
            //    new PixelFarm.VectorMath.PointF(bmp.Width * 4, bmp.Height * 4),
            //    new PixelFarm.VectorMath.PointF(0, bmp.Height * 4)
            //);
            using (MemBitmap transferBmp = freeTx.GetTransformedBitmap(bmp))
            {
                SaveImage(transferBmp, "d:\\WImageTest\\test01_tx" + freeTx.Interpolation + ".png");
            }
        }