Beispiel #1
0
        public void Resize(string source, string destination, string operation, int destW, int destH, int pointerX, int pointerY)
        {
            System.Drawing.Image image = System.Drawing.Image.FromFile(source);

            ResizeStrategyContext context;

            switch (operation.ToLower())
            {
            case "scew":
                context = new ResizeStrategyContext(new ScewResize());
                context.Resize(image, destination, destW, destH);
                break;

            case "keepaspect":
                context = new ResizeStrategyContext(new KeepAspectResize());
                context.Resize(image, destination, destW, destH);
                break;

            case "crop":
                context = new ResizeStrategyContext(new CropResize());
                context.Resize(image, destination, destW, destH, pointerX, pointerY);
                break;

            default:
                throw new Exception("Wrong file format chosen!");
            }
        }
Beispiel #2
0
        public void Resize(string source, string destination, string operation, int destW, int destH, int pointerX, int pointerY)
        {
            Image image = Image.FromFile(source);

            //implement context strategy from context using IMG object instead of source...
            ResizeStrategyContext context;

            switch (operation.ToLower())
            {
            case "scew":
                context = new ResizeStrategyContext(new ScewResize());
                context.Resize(image, destination, destW, destH);
                break;

            case "keepaspect":
                context = new ResizeStrategyContext(new KeepAspectResize());
                context.Resize(image, destination, destW, destH);
                break;

            case "crop":
                context = new ResizeStrategyContext(new CropResize());
                context.Resize(image, destination, destW, destH, pointerX, pointerY);
                break;

            default:
                throw new Exception("Wrong file format chosen!");
            }
        }