Support for multi-threaded environment, DNG format and EMF to WMF conversion with Aspose.Imaging for .NET 16.12

Share on FacebookTweet about this on TwitterShare on LinkedIn

We are pleased to announce the release of Aspose.Imaging for .NET 16.12. The major development in this release is support for exporting images in multi threaded environment. This release supports converting EMF metafile to WMF format. Support for DNG format has also been incorporated in this release.

Export Images in Multi Threaded Environment

Aspose.Imaging for .Net now supports exporting images in multi threaded environment. Aspose.Imaging for .Net ensure the optimized performance of operations during execution of code in multi-threaded environment. All imaging option classes (e.g. BmpOptions, TiffOptions, JpegOptions, etc.) in the Aspose.Imaging for .Net now implement IDisposable interface. Therefore it is a must that developer properly dispose off the imaging options class object in case Source property is set. Following code snippet demonstrates the said functionality.



string imageDataPath = "";

try
{
// Path & name of existing image.
imageDataPath = Path.GetTempFileName();

// Create the stream of the existing image file.   
using (FileStream fileStream = File.Create(imageDataPath))
{

        // Create an instance of BMP image option class.
        using (BmpOptions bmpOptions = new BmpOptions())
        {
            bmpOptions.BitsPerPixel = 32;

            // Set the source property of the imaging option class object.
            bmpOptions.Source = new StreamSource(fileStream);

            // Do processing. Following is the sample processing on the image. Un-comment to use it.
            //using (RasterImage image = (RasterImage)Image.Create(bmpOptions, 10, 10))
            //{
            //    Color[] pixels = new Color[4];
            //    for (int i = 0; i < 4; ++i)
            //    {
            //        pixels[i] = Color.FromArgb(40, 30, 20, 10);
            //    }
            //    image.SavePixels(new Rectangle(0, 0, 2, 2), pixels);
            //    image.Save();
            //}
        }
    }
}
finally 
{
    // Delete the file. This statement is in the final block because in any case this statement should execute to make it sure that resource is properly disposed off.
    File.Delete(imageDataPath);
}

Aspose.Imaging now supports SyncRoot property while working in multi-threaded environment. Developer can use this property to synchronize access to the source stream. Following code snippet demonstrates how the SyncRoot property can be used.


// Create an instance of Memory stream class.
using (MemoryStream memoryStream = new MemoryStream())
{
    // Create an instance of Stream container class and assign memory stream object.
    using (StreamContainer streamContainer = new StreamContainer(memoryStream))
    {
        // check if the access to the stream source is synchronized.
        lock (streamContainer.SyncRoot)
        {
            // do work
            // now access to source MemoryStream is synchronized
        }
    }
}

Converting EMF to WMF format

Using Aspose.Imaging for .Net developers can convert EMF to WMF format. Below code demonstrates how EMF meta file can be converted to WMF metafile format.


// List of existing EMF images. 
string path = @"";
string[] files = new string[] { "TestEmfRotatedText.emf", "TestEmfPlusFigures.emf", "TestEmfBezier.emf" };

// Loop for each file name.
foreach (string file in files)
{

    // Input file name & path.
    string filePath = Path.Combine(path, file);

    // Load the EMF image as image and convert it to MetaImage object.
    using (MetaImage image = (MetaImage)Image.Load(filePath))
    {
        // Convert the EMF image to WMF image by creating and passing WMF image options class object.
        image.Save(filePath + "_out.wmf", new WmfOptions());
    }
}

Support for DNG Image

Aspose.Imaging for .Net now supports the DNG (Digital Negative) image format (.dng). It is a publicly available archival format for the raw files generated by digital cameras. DNG helps ensure that photographers will be able to access their files in the future. Aspose.Imaging for .Net provides the DngImage class to load DNG files and same can be used to convert the DNG to raster formats. Below provided sample code demonstrate how to convert a DNG file to JPEG format.


//Declare variables to store file paths for input and output images.
string sourceFiles = "Path_to_source_folder\\Source\\HDR - 3c.dng";
string destPath = "Path_to_results_folder\\Results\\result.jpg";

// Create an instance of Image class and load an exiting DNG file.
// Convert the image to DngImage object.
using (DngImage image = (DngImage)Image.Load(sourceFiles))
{
    // Create an instance of JpegOptions class.
    // convert and save to disk in Jpeg file format.
    image.Save(destPath, new JpegOptions());
}

Enhancements

Following enhancements have been introduced in this release.

  • Process of reading PSD layers has been improved.

  • Processing of JPEG format images has been improved.

  • Processing of Dicom format images has been improved.

  • Functionality to convert WMF to PNG format has been improved.

  • Process of rendering images in PSD file has been improved.

  • processing of saving TIFF frames has been improved.

  • Compatibility of image saved using Aspose.Imaging on MS Windows 8 has been improved.

  • Process of reading JPEG pixels has been improved.

Please refer to the release notes of Aspose.Imaging for .NET 16.12 for a full view of improvements along with sample code snippets for newly added features. If you are planning to upgrade the API to the latest revision, we strongly suggest you to check the Public API Change section to know what has been changed in the public API since your current version.

Aspose.Imaging for .Net Resources

The resources, you may need to accomplish your tasks:

As always we appreciate your feedback so if you ever have anything to tell us about this release or anything else, please head to the Aspose.Imaging forum for a chat.