←Select platform

ReadExtensions(string,int) Method

Summary
Loads extensions from the specified EXIF file.
Syntax
C#
VB
Objective-C
C++
public CodecsExtensionList ReadExtensions( 
   string fileName, 
   int pageNumber 
) 
Public Overloads Function ReadExtensions( _ 
   ByVal fileName As String, _ 
   ByVal pageNumber As Integer _ 
) As CodecsExtensionList 
- (nullable LTCodecsExtensionList *)readExtensionsFromFile:(NSString *)file  
                                                pageNumber:(NSInteger)pageNumber  
                                                     error:(NSError **)error 
public: 
CodecsExtensionList^ ReadExtensions(  
   String^ fileName, 
   int pageNumber 
)  

Parameters

fileName
The input file name.

pageNumber
1-based index of the page within the file that contains the extension.

Return Value

An CodecsExtensionList object that contains the extensions found in this file.

Remarks

Please note that not all Exif files have extensions.

Currently, this method works only with Exif files. Exif files can contain extra data stored as "FlashPix extensions". This method can be used to access this extra data. LEADTOOLS refers to this extra data as "extensions".

You must dispose the CodecsExtensionList returned from this method when you are done using it.

Example

This example will show detailed information on the streams present in the Exif file.

C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
 
 
void ExtensionsExample(string exifFileName) 
{ 
	RasterCodecs codecs = new RasterCodecs(); 
 
	string stampFileName = Path.Combine(LEAD_VARS.ImagesDir, "Extension.bmp"); 
	string audioFileNameTemplate = Path.Combine(LEAD_VARS.ImagesDir, "Extension{0}.wav"); 
 
	// Read the extensions from the file 
	Console.WriteLine("Reading the extensions from the exif file"); 
	CodecsExtensionList extensionList = codecs.ReadExtensions(exifFileName, 1); 
	if (extensionList != null) 
	{ 
		if ((extensionList.Flags & CodecsExtensionListFlags.Stamp) == CodecsExtensionListFlags.Stamp) 
		{ 
			Console.WriteLine("Stamp extension: Found, saving to {0}", stampFileName); 
			RasterImage stampImage = extensionList.CreateStamp(); 
			codecs.Save(stampImage, stampFileName, RasterImageFormat.Bmp, 24); 
			stampImage.Dispose(); 
		} 
		else 
			Console.WriteLine("Stamp extension: Not found"); 
 
		if ((extensionList.Flags & CodecsExtensionListFlags.Audio) == CodecsExtensionListFlags.Audio) 
		{ 
			Console.WriteLine("Audio extension: Found, saving ..."); 
			RasterNativeBuffer audioData; 
			int streamIndex = 0; 
 
			do 
			{ 
				audioData = extensionList.GetAudioData(streamIndex); 
				if (audioData.Data != IntPtr.Zero) 
				{ 
					string audioFileName = string.Format(audioFileNameTemplate, streamIndex); 
					Console.WriteLine("To {0}", audioFileName); 
					using (FileStream fs = File.Create(audioFileName)) 
					{ 
						byte[] data = new byte[audioData.Length]; 
						Marshal.Copy(audioData.Data, data, 0, (int)audioData.Length); 
						fs.Write(data, 0, (int)audioData.Length); 
					} 
 
					streamIndex++; 
				} 
			} 
			while (audioData.Data != IntPtr.Zero); 
 
			Console.WriteLine("{0} total audio streams found", streamIndex); 
		} 
		else 
			Console.WriteLine("Audio extension: Not found"); 
 
		CodecsExtension[] extensions = extensionList.GetExtensions(); 
		Console.WriteLine("Total number of extensions found in the file: {0}", extensions.Length); 
 
		for (int i = 0; i < extensions.Length; i++) 
		{ 
			CodecsExtension extension = extensions[i]; 
			Console.WriteLine(" {0}. Name: {1}, Clsid: {2}, UCDefault: {3}, DatLength: {4}", 
			   i, extension.Name, extension.Clsid, extension.UCDefault, extension.DataLength); 
		} 
 
		extensionList.Dispose(); 
	} 
	else 
		Console.WriteLine("No extensions were found in the file"); 
 
	codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS21\Resources\Images"; 
} 
Requirements

Target Platforms

Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Codecs Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.