コード例 #1
0
ファイル: Form1.cs プロジェクト: bangush/csharp
        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();
        }
コード例 #2
0
ファイル: PhotoFileInfo.cs プロジェクト: bangush/csharp
        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);
        }