Esempio n. 1
0
            private void resizePicture(FileInfo file, bool waterMark, Image logo, string type, Int32 width, Int32 height)
            {
                Image       image = Bitmap.FromFile(file.FullName);
                ResizeModel model = new ResizeModel();

                model.Source         = image;
                model.Position       = WatermarkPositions.Center;
                model.IsWartermarked = waterMark;
                if (waterMark && logo != null)
                {
                    model.IsWartermarked  = true;
                    model.ImageWartermark = logo;
                }
                model.ResizeType = ResizeTypes.Absolute;
                model.Width      = width;
                model.Height     = height;
                //DirectoryInfo destDir = file.Directory.CreateSubdirectory(type);
                //string destPath = destDir.FullName + "\\" + file.Name;
                string destPath = GetResizedFilePath(file, type);

                createParentDir(destPath);
                if (!File.Exists(destPath))
                {
                    Image destImage = PictureOperation.Resize(model);
                    PictureOperation.Save(destImage, destPath);
                }
            }
Esempio n. 2
0
        private void button_Logo_Click(object sender, EventArgs e)
        {
            /*
             * FileInfo f = new FileInfo("E:\\Personal\\lhl\\input\\img\\default\\Chrysanthemum.jpg");
             * this.label17.Text = this.GetResizedFilePath(f,"large");
             * return;*/
            string      sourceLogo = this.GetDefaultLogoPath("logo.png");
            Image       image      = Bitmap.FromFile(sourceLogo);
            ResizeModel model      = new ResizeModel();

            model.Source         = image;
            model.IsWartermarked = false;
            model.ResizeType     = ResizeTypes.Auto;
            model.Width          = 23;
            model.Height         = 6;
            Image  smallImage = PictureOperation.Resize(model);
            Bitmap pbitmap    = new Bitmap(smallImage);

            pbitmap.MakeTransparent(Color.White);
            string destLogo = this.GetDefaultLogoPath("logo-small.png");

            PictureOperation.Save(pbitmap, destLogo, ImgCodes.PNG, 100);

            image        = Bitmap.FromFile(sourceLogo);
            model.Source = image;
            model.Width  = 138;
            model.Height = 38;
            Image mediumImage = PictureOperation.Resize(model);

            pbitmap = new Bitmap(mediumImage);
            pbitmap.MakeTransparent(Color.White);
            destLogo = this.GetDefaultLogoPath("logo-medium.png");
            PictureOperation.Save(pbitmap, destLogo, ImgCodes.PNG, 100);

            image        = Bitmap.FromFile(sourceLogo);
            model.Source = image;
            model.Width  = 414;
            model.Height = 114;
            Image largeImage = PictureOperation.Resize(model);

            pbitmap = new Bitmap(largeImage);
            pbitmap.MakeTransparent(Color.White);
            destLogo = this.GetDefaultLogoPath("logo-large.png");
            PictureOperation.Save(pbitmap, destLogo, ImgCodes.PNG, 100);
        }