//------------------------------------------------------------------------------------------------------------------------------------------------------------- public static void TimingTest() { int iterations = 30; bool doWrite = true; TimeSpan t1 = new TimeSpan(DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond); for (int i = 0; i < iterations; i++) { ImageProcessor.Test(doWrite); } TimeSpan t2 = new TimeSpan(DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond); for (int i = 0; i < iterations; i++) { ImageProcessorGDI.Test(doWrite); } TimeSpan t3 = new TimeSpan(DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, DateTime.Now.Millisecond); TimeSpan diff1 = t2.Subtract(t1); TimeSpan diff2 = t3.Subtract(t2); // string temp = ""; }
//------------------------------------------------------------------------------------------------------------------------------------------------------------- public static bool Test(bool writeToFile) { bool success = false; try { ImageProcessorGDI ipGDI = new ImageProcessorGDI(); MemoryStream ms = null; string dir = "C:\\Backups\\Photos_Testing_ImageResizing\\"; string photoPath = dir + "ImageResizeTest1.jpg"; success = ImageProcessorGDI.ResizeImage(photoPath, 1999, 1999, out ms); //_____ Convert this thumbnail image to a memory stream .... if (writeToFile) { Image im = Image.FromStream(ms); // byte[] targetBytes = ms.ToArray(); im.Save(dir + "OutputGDI_" + DateTimeInformation.GetCurrentDate("number") + "_" + DateTimeInformation.GetCurrentTime() + ".jpg", ImageFormat.Jpeg); // Finally - write this file back out .... // FileStream fs = new FileStream(, FileMode.Create); // fs.Write(targetBytes, 0, targetBytes.Length); //fs.Flush(); // fs.Close(); // if (targetBytes.Length > 0) { success = true; // } } else { if (ms != null && ms.Length > 0) { success = true; } } } catch (Exception ex) { Logger.LogError(5, "Problem resulted in crash in ImageProcessorGDI.Test(): " + ex.ToString()); // string temp = ""; } return(success); }