Esempio n. 1
0
        private Size calcNewSize(ImageWI iwi)
        {
            Size oldSize = ImageWorker.GetCurrentSize(iwi);

            logger.Debug("oldsize of image {0}:{1}", iwi.Name, oldSize);
            float ratio = oldSize.Width * 1f / oldSize.Height;
            Size  newSize;

            if (this.AbsoluteSizing)
            {
                newSize = new Size(this.SizeX, (int)(this.SizeX / ratio));
                logger.Debug("newsize (absolut) of image {0}:{1}", iwi.Name, newSize);
            }
            else
            {
                // suppose relativesizing
                newSize = new Size((int)(oldSize.Width * (this.SizePercent / 100f)), (int)(oldSize.Height * (this.SizePercent / 100f)));
                logger.Debug("newsize (percentage) of image {0}:{1}", iwi.Name, newSize);
            }
            return(newSize);
        }
Esempio n. 2
0
        public override bool Process(ImageWI iwi)
        {
            Size s        = ImageWorker.GetCurrentSize(iwi);
            Size tileSize = new Size();

            tileSize.Width  = s.Width / this.XSliceCount;
            tileSize.Height = s.Height / this.YSliceCount;
            int i = 0;

            for (int x = 0; x < this.XSliceCount; x++)
            {
                for (int y = 0; y < this.YSliceCount; y++)
                {
                    int      left  = x * tileSize.Width;
                    int      top   = y * tileSize.Height;
                    FIBITMAP aTile = FreeImage.Copy(iwi.ImageHandle, left, top, left + tileSize.Width, top + tileSize.Height);
                    ImageWorker.SaveJPGImageHandle(aTile, new FileInfo(iwi.CurrentFile.AugmentFilename(string.Format("_tile_{0:000}", i))));
                    i++;
                }
            }
            return(true);
        }