Leadtools.Codecs Namespace > RasterCodecs Class > ReadLoadResolutions Method : ReadLoadResolutions(String) Method |
public LeadSize[] ReadLoadResolutions( string fileName )
'Declaration Public Overloads Function ReadLoadResolutions( _ ByVal fileName As String _ ) As LeadSize()
'Usage Dim instance As RasterCodecs Dim fileName As String Dim value() As LeadSize value = instance.ReadLoadResolutions(fileName)
public LeadSize[] ReadLoadResolutions( string fileName )
function Leadtools.Codecs.RasterCodecs.ReadLoadResolutions(String)( fileName )
public: array<LeadSize>^ ReadLoadResolutions( String^ fileName )
A FlashPix, PhotoCD, ECW, JPEG 2000 or JBIG/JBIG2 file can contain more than one copy of the same image, each at a different physical resolution (width and height in pixels).
After you get the available resolutions, you can use any of the following to specify the one to be loaded:
For more information, refer to Implementing JBIG Features.
Private Sub ReadLoadResolutionsExample(ByVal jbigFileName As String) Dim codecs As RasterCodecs = New RasterCodecs() ' Get the number of resolutions (sizes) available in this file Dim resolution As LeadSize() = codecs.ReadLoadResolutions(jbigFileName) If resolution.Length > 0 Then Console.WriteLine("{0} resolutions available", resolution.Length) Dim i As Integer = 0 Do While i < resolution.Length Console.WriteLine("{0} by {1}", resolution(i).Width, resolution(i).Height) i += 1 Loop ' Set the size to load, the smallest size in this case */ codecs.Options.Jpeg2000.Load.J2kResolution = resolution(0) ' Get the info about the image to show its original size Dim info As CodecsImageInfo = codecs.GetInformation(jbigFileName, False) Console.WriteLine("Size of image according to GetInformation is {0} by {1}", info.Width, info.Height) ' Load the image, keeping the bits per pixel of the file Dim image As RasterImage = codecs.Load(jbigFileName) Console.WriteLine("Size of image loaded is {0} by {1}", image.Width, image.Height) image.Dispose() Else Console.WriteLine("No resolutions found") End If ' Clean up codecs.Dispose() End Sub
void ReadLoadResolutionsExample(string jbigFileName) { RasterCodecs codecs = new RasterCodecs(); // Get the number of resolutions (sizes) available in this file LeadSize[] resolution = codecs.ReadLoadResolutions(jbigFileName); if (resolution.Length > 0) { Console.WriteLine("{0} resolutions available", resolution.Length); for (int i = 0; i < resolution.Length; i++) Console.WriteLine("{0} by {1}", resolution[i].Width, resolution[i].Height); // Set the size to load, the smallest size in this case */ codecs.Options.Jpeg2000.Load.J2kResolution = resolution[0]; // Get the info in of the image to show its original size CodecsImageInfo info = codecs.GetInformation(jbigFileName, false); Console.WriteLine("Size of image according to GetInformation is {0} by {1}", info.Width, info.Height); // Load the image, keeping the bits per pixel of the file RasterImage image = codecs.Load(jbigFileName); Console.WriteLine("Size of image loaded is {0} by {1}", image.Width, image.Height); image.Dispose(); } else Console.WriteLine("No resolutions found"); // Clean up codecs.Dispose(); }
RasterCodecsExamples.prototype.ReadLoadResolutionsExample = function () { Tools.SetLicense(); with (Leadtools) { with (Leadtools.Codecs) { var jbigFileName = "Assets\\image1.jbg"; var codecs = new RasterCodecs(); var loadFile; // Get the number of resolutions (sizes) available in this file return Tools.AppInstallFolder().getFileAsync(jbigFileName) .then(function (loadFileX) { loadFile = loadFileX; return codecs.readLoadResolutionsAsync(LeadStreamFactory.create(loadFile)) }) .then(function (resolution) { return ReadResolutionAsync(resolution, codecs, loadFile) }) .then(function () { // Clean up codecs.close(); }); } } } function ReadResolutionAsync ( resolution, codecs, loadFile ) { with (Leadtools) { with (Leadtools.Codecs) { if (resolution.length > 0) { console.info(resolution.length, " resolutions available"); for (var i = 0; i < resolution.length; i++) console.info(resolution[i].width, " by ", resolution[i].height); // Set the size to load, the smallest size in this case */ codecs.options.jpeg2000.load.j2kResolution = resolution[0]; // Get the info in of the image to show its original size return codecs.getInformationAsync(LeadStreamFactory.create(loadFile), false, 1) .then(function (info) { console.info("Size of image according to GetInformation is ", info.width, " by ", info.height); // Load the image, keeping the bits per pixel of the file return codecs.loadAsync(LeadStreamFactory.create(loadFile)) }) .then(function (image) { console.info("Size of image loaded is ", image.width, " by ", image.height); image.close(); }); } else console.info("No resolutions found"); } } }
[TestMethod] public async Task ReadLoadResolutionsExample() { string jbigFileName = @"Assets\image1.jbg"; RasterCodecs codecs = new RasterCodecs(); try { // Get the number of resolutions (sizes) available in this file StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(jbigFileName); IList<LeadSize> resolution = await codecs.ReadLoadResolutionsAsync(LeadStreamFactory.Create(loadFile)); if (resolution.Count > 0) { Debug.WriteLine("{0} resolutions available", resolution.Count); for (int i = 0; i < resolution.Count; i++) Debug.WriteLine("{0} by {1}", resolution[i].Width, resolution[i].Height); // Set the size to load, the smallest size in this case */ codecs.Options.Jpeg2000.Load.J2kResolution = resolution[0]; // Get the info in of the image to show its original size CodecsImageInfo info = await codecs.GetInformationAsync(LeadStreamFactory.Create(loadFile), false, 1); Debug.WriteLine("Size of image according to GetInformation is {0} by {1}", info.Width, info.Height); // Load the image, keeping the bits per pixel of the file RasterImage image = await codecs.LoadAsync(LeadStreamFactory.Create(loadFile)); Debug.WriteLine("Size of image loaded is {0} by {1}", image.Width, image.Height); image.Dispose(); } else Debug.WriteLine("No resolutions found"); } catch (Exception ex) { string error = ""; RasterException rasterException = RasterException.FromHResult(ex.HResult); if (rasterException != null) error = rasterException.Message; else error = ex.Message; Debug.WriteLine(error); Assert.Fail(error); } // Clean up codecs.Dispose(); }
public void ReadLoadResolutionsExample(Stream inStreamJbig) { RasterCodecs codecs = new RasterCodecs(); // Get the number of resolutions (sizes) available in this file LeadSize[] resolution = codecs.ReadLoadResolutions(inStreamJbig); if(resolution.Length > 0) { Debug.WriteLine("{0} resolutions available", resolution.Length); for(int i = 0; i < resolution.Length; i++) Debug.WriteLine("{0} by {1}", resolution[i].Width, resolution[i].Height); // Set the size to load, the smallest size in this case */ codecs.Options.Jpeg2000.Load.J2kResolution = resolution[0]; // Get the info in of the image to show its original size CodecsImageInfo info = codecs.GetInformation(inStreamJbig, false); Debug.WriteLine("Size of image according to GetInformation is {0} by {1}", info.Width, info.Height); // Load the image, keeping the bits per pixel of the file RasterImage image = codecs.Load(inStreamJbig); Debug.WriteLine("Size of image loaded is {0} by {1}", image.Width, image.Height); image.Dispose(); } else Debug.WriteLine("No resolutions found"); }
Public Sub ReadLoadResolutionsExample(ByVal inStreamJbig As Stream)
Dim codecs As RasterCodecs = New RasterCodecs()
' Get the number of resolutions (sizes) available in this file
Dim resolution As LeadSize() = codecs.ReadLoadResolutions(inStreamJbig)
If resolution.Length > 0 Then
Debug.WriteLine("{0} resolutions available", resolution.Length)
Dim i As Integer = 0
Do While i < resolution.Length
Debug.WriteLine("{0} by {1}", resolution(i).Width, resolution(i).Height)
i += 1
Loop
' Set the size to load, the smallest size in this case */
codecs.Options.Jpeg2000.Load.J2kResolution = resolution(0)
' Get the info in of the image to show its original size
Dim info As CodecsImageInfo = codecs.GetInformation(inStreamJbig, False)
Debug.WriteLine("Size of image according to GetInformation is {0} by {1}", info.Width, info.Height)
' Load the image, keeping the bits per pixel of the file
Dim image As RasterImage = codecs.Load(inStreamJbig)
Debug.WriteLine("Size of image loaded is {0} by {1}", image.Width, image.Height)
image.Dispose()
Else
Debug.WriteLine("No resolutions found")
End If
End Sub
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2