Exemplo n.º 1
0
 static void DisplayImage(ImageInfo info, int count, Action<ImageInfo> displayFn, int duration)
 {
     int startTick = Environment.TickCount;
     info.ImageCount = count;
     info.PhaseStartTick[3] = startTick - info.ClockOffset;
     info.PhaseEndTick[3] = (duration > 0) ? startTick - info.ClockOffset + duration :
                                              Environment.TickCount - info.ClockOffset;
     displayFn(info);
 } 
Exemplo n.º 2
0
 static void ScaleImage(ImageInfo info)
 {
     int startTick = Environment.TickCount;
     var orig = info.OriginalImage;
     info.OriginalImage = null;
     const int scale = 200;
     var isLandscape = (orig.Width > orig.Height);
     var newWidth = isLandscape ? scale : scale * orig.Width / orig.Height;
     var newHeight = !isLandscape ? scale : scale * orig.Height / orig.Width;
     Bitmap bitmap = new Bitmap(orig, newWidth, newHeight);
     try
     {
         Bitmap bitmap2 = bitmap.AddBorder(15);
         try
         {
             bitmap2.Tag = orig.Tag;
             info.ThumbnailImage = bitmap2;
             info.PhaseStartTick[1] = startTick - info.ClockOffset;
             bitmap2 = null;
         }
         finally
         {
             if (bitmap2 != null) bitmap2.Dispose();
         }
     }
     finally
     {
         bitmap.Dispose();
         orig.Dispose();
     }
     info.PhaseEndTick[1] = Environment.TickCount - info.ClockOffset;
 }
Exemplo n.º 3
0
        static void FilterImage(ImageInfo info)
        {
            int startTick = Environment.TickCount;
            var sc = info.ThumbnailImage;
            info.ThumbnailImage = null;
            Bitmap bitmap = sc.AddNoise(GaussianNoiseAmount);

            try
            {
                bitmap.Tag = sc.Tag;
                info.FilteredImage = bitmap;
                info.PhaseStartTick[2] = startTick - info.ClockOffset;

                bitmap = null;
            }
            finally
            {
                if (bitmap != null) bitmap.Dispose();
                sc.Dispose();
            }
            info.PhaseEndTick[2] = Environment.TickCount - info.ClockOffset;
        }
Exemplo n.º 4
0
        static ImageInfo LoadImage(string fname, string sourceDir, int count, int clockOffset)
        {
            int startTick = Environment.TickCount;
            ImageInfo info = null;
            Bitmap bitmap = new Bitmap(Path.Combine(sourceDir, fname));
            try
            {
                bitmap.Tag = fname;

                info = new ImageInfo(count, fname, bitmap, clockOffset);
                info.PhaseStartTick[0] = startTick - clockOffset;
                bitmap = null;
            }
            finally
            {
                if (bitmap != null) bitmap.Dispose();
            }

            if (info != null) info.PhaseEndTick[0] = Environment.TickCount - clockOffset;
            return info;
        }