public void WhenWritingABlankCreatedJpegToAValidStreamWriteToAValidStream() { Image img = Image.Create(100, 100); using (MemoryStream stream = new MemoryStream()) { Jpg.WriteToStream(img, stream); stream.Position = 0; Image img2 = Jpg.Load(stream); ValidateCreatedImage(img2, 100, 100); } }
public void WhenWritingAJpegFromFileToAValidStreamWriteAValidImage() { string filepath = SaveEmbeddedResourceToFile(SoccerCatLogicalName); Image img = Jpg.Load(filepath); using (MemoryStream stream = new MemoryStream()) { Jpg.WriteToStream(img, stream); stream.Position = 0; Image img2 = Jpg.Load(stream); ValidateImageJpeg(img2, SoccerCatLogicalName); } File.Delete(filepath); }
public void WhenWritingAResizedJpegToAValidStreamWriteAValidImage() { string filepath = SaveEmbeddedResourceToFile(SoccerCatLogicalName); Image img = Jpg.Load(filepath); using (MemoryStream stream = new MemoryStream()) { img = img.Resize(40, 40); ValidateCreatedImage(img, 40, 40); Jpg.WriteToStream(img, stream); stream.Position = 0; Image img2 = Jpg.Load(stream); ValidateCreatedImage(img, 40, 40); } File.Delete(filepath); }
private static void WriteStreamJpegPerfTest(int numRuns) { Image _thisjpgcat = Jpg.Load(jpegCatPath); for (int i = 0; i < numRuns; i++) { //make sure it's going if (i % 100 == 0) { Console.WriteLine("WriteStreamJpegTest :" + i); } using (MemoryStream stream = new MemoryStream()) { stopwatchSingleThread.Start(); Jpg.WriteToStream(_thisjpgcat, stream); stopwatchSingleThread.Stop(); } } _thisjpgcat.ReleaseStruct(); }