Esempio n. 1
0
        private void LoadFile(string Filename)
        {
            BackgroundWorker bw1 = new BackgroundWorker();

            bw1.DoWork += (a, b) =>
            {
                getExifInfo(Filename);
            };
            bw1.RunWorkerAsync();

            BackgroundWorker bw2 = new BackgroundWorker();

            bw2.DoWork += (a, b) =>
            {
                LoadFiles(Filename);
            };
            bw2.RunWorkerAsync();

            BackgroundWorker bw3 = new BackgroundWorker();

            bw3.DoWork += (a, b) =>
            {
                Image  img      = Bitmap.FromFile(Filename);
                double percentw = (pBPhoto.Width.ToDouble() / img.Width.ToDouble()) * 100;
                double percenth = (pBPhoto.Height.ToDouble() / img.Height.ToDouble()) * 100;
                double percent  = Math.Min(percenth, percentw);
                pBPhoto.Image = ImageStuff.ScaleByPercent(ImageStuff.RotateImage(img), percent.ToInt());
            };
            bw3.RunWorkerAsync();
        }
Esempio n. 2
0
        private Image FixThumbnail(string strfilename)
        {
            Image img = Bitmap.FromFile(strfilename);

            if (img.PropertyItems.Any(x => x.Id == 20507))
            {
                PropertyItem pi    = img.PropertyItems.Where(x => x.Id == 20507).FirstOrDefault();
                byte[]       bytes = pi.Value;

                MemoryStream stream = new MemoryStream(bytes.Length);
                stream.Write(bytes, 0, bytes.Length);

                return(ImageStuff.ScaleByPercent(ImageStuff.RotateThumbImage(Image.FromStream(stream)), 50));
            }
            return(null);
        }