コード例 #1
0
    public void WhenWritingABlankCreatedJpegToAValidFileWriteAValidFile()
    {
        Image emptyImage = Image.Create(10, 10);

        ValidateCreatedImage(emptyImage, 10, 10);
        string tempFilePath = Path.ChangeExtension(Path.GetTempFileName(), ".jpg");

        Jpg.Write(emptyImage, tempFilePath);
        File.Delete(tempFilePath);
    }
コード例 #2
0
    public static void WhenAddingANegativeFilterToAJpegGiveAValidGreyScaledImage()
    {
        string filepath = SaveEmbeddedResourceToFile(SquareCatLogicalName);

        Image img1 = Jpg.Load(filepath);

        img1.ApplyMatrixMultiplier(ImageExtensions.NegativeMatrix);
        ValidateImageJpeg(img1, SquareCatLogicalName);
        Jpg.Write(img1, Path.GetTempPath() + "NegativeCat.jpg");
    }
コード例 #3
0
    public void WhenWritingABlankCreatedJpegToAValidStreamWriteAValidStream()
    {
        Image img = Image.Create(100, 100);

        using (MemoryStream stream = new MemoryStream())
        {
            Jpg.Write(img, stream);
            stream.Position = 0;
            Image img2 = Jpg.Load(stream);
            ValidateCreatedImage(img2, 100, 100);
        }
    }
コード例 #4
0
    public void WhenWritingAJpegFromFileToAValidStreamWriteAValidImage()
    {
        string filepath = SaveEmbeddedResourceToFile(SoccerCatLogicalName);
        Image  img      = Jpg.Load(filepath);

        using (MemoryStream stream = new MemoryStream())
        {
            Jpg.Write(img, stream);
            stream.Position = 0;
            Image img2 = Jpg.Load(stream);
            ValidateImageJpeg(img2, SoccerCatLogicalName);
        }
        File.Delete(filepath);
    }
コード例 #5
0
    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.Write(img, stream);
            stream.Position = 0;
            Image img2 = Jpg.Load(stream);
            ValidateCreatedImage(img, 40, 40);
        }
        File.Delete(filepath);
    }
コード例 #6
0
    //FIX Write
    private static void WriteFileJpegPerfTest(int numRuns)
    {
        //string dir = Path.GetTempPath();
        Image _thisjpgdog = Jpg.Load(jpegDogPath);

        for (int i = 0; i < numRuns; i++)
        {
            //make sure it's going
            if (i % 100 == 0)
            {
                Console.WriteLine("WriteJpegTest :" + i);
            }
            stopwatchSingleThread.Start();
            Jpg.Write(_thisjpgdog, Path.ChangeExtension(Path.GetTempFileName(), ".jpg"));
            stopwatchSingleThread.Stop();
        }
        _thisjpgdog.ReleaseStruct();
    }
コード例 #7
0
    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("WriteJpegTest :" + i);
            }

            using (MemoryStream stream = new MemoryStream())
            {
                stopwatchSingleThread.Start();
                Jpg.Write(_thisjpgcat, stream);
                stopwatchSingleThread.Stop();
            }
        }
        _thisjpgcat.ReleaseStruct();
    }