示例#1
0
        private void InitExamples()
        {
            textW = new TextW();
            imgW  = new ImgW();
            mouse = new Mouse();

            soloImg = new SoloImg();
            dirImg  = new DirImg();

            extensions = new Extension(".jpg", ".png", ".jpeg", ".bmp");
        }
示例#2
0
        public void AfterSelectFile(Extension extensions, DirImg dirImg, SoloImg soloImg)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string ext = Path.GetExtension(openFileDialog.FileName);
                if (extensions.AllowImageExt.Contains(ext))
                {
                    dirImg.IsFolder   = false;
                    soloImg.PathImage = openFileDialog.FileName;
                }
            }
        }
示例#3
0
        public void IfDirImg(Graphics g, DirImg dirImg, Mouse mouse, PictureBox pictureBox1, ImgW imgW)
        {
            foreach (Image image in dirImg.Images)
            {
                Counter.Count++;
                OriginCoordinate.X = (image.Width * mouse.X) / pictureBox1.Width;
                OriginCoordinate.Y = (image.Height * mouse.Y) / pictureBox1.Height;

                Bitmap b = new Bitmap(image.Width, image.Height);
                using (g = Graphics.FromImage(b))
                {
                    g.DrawImage(image, 0, 0, image.Width, image.Height);
                    g.DrawImage(imgW.ImgWatermark, OriginCoordinate.X, OriginCoordinate.Y, 85, 85);
                }
                b.Save(@"pictures with a watermark/Copy_" + Counter.Count.ToString() + ".bmp");
            }
        }
示例#4
0
        public void IfDirText(Graphics g, DirImg dirImg, Mouse mouse, PictureBox pictureBox1, TextW textW)
        {
            foreach (Image image in dirImg.Images)
            {
                Counter.Count++;
                OriginCoordinate.X = (image.Width * mouse.X) / pictureBox1.Width;
                OriginCoordinate.Y = (image.Height * mouse.Y) / pictureBox1.Height;

                Bitmap b = new Bitmap(image.Width, image.Height);
                using (g = Graphics.FromImage(b))
                {
                    g.DrawImage(image, 0, 0, image.Width, image.Height);
                    g.DrawString(textW.TextWatermark, new Font("Times New Roman", 25, FontStyle.Bold), Brushes.Black, OriginCoordinate.X, OriginCoordinate.Y);
                }
                b.Save(@"pictures with a watermark/Copy_" + Counter.Count.ToString() + ".bmp");
            }
        }
示例#5
0
        public void AfterSelectFolder(DirImg dirImg, Extension extensions, SoloImg soloImg)
        {
            FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();

            if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                dirImg.Images = new List <Image>();

                DirectoryInfo directoryInfo = new DirectoryInfo(folderBrowserDialog.SelectedPath);
                FileInfo[]    files         = directoryInfo.GetFiles();
                foreach (FileInfo file in files)
                {
                    string ext = Path.GetExtension(file.FullName);
                    if (extensions.AllowImageExt.Contains(ext))
                    {
                        dirImg.Images.Add(Image.FromFile(file.FullName));
                        soloImg.PathImage = file.FullName;
                    }
                }

                dirImg.IsFolder = true;
            }
        }