Products | Support | Email a link to this topic. | Send comments on this topic. | Back to Introduction - All Topics | Help Version 19.0.8.30
|
Leadtools.Codecs Namespace > CodecsLoadOptions Class : Name Property |
public string Name {get; set;}
'Declaration
Public Property Name As String
'Usage
Dim instance As CodecsLoadOptions Dim value As String instance.Name = value value = instance.Name
public string Name {get; set;}
<br/>get_Name();<br/>set_Name(value);<br/>Object.defineProperty('Name');
Some file formats do not contain a well-defined file signature. This is especially true for document file formats (TXT, PST, etc.). LEADTOOLS can still detect the file format using the filename extension (ex. ".txt" or ".pst"). However, when loading files from memory streams (or if the extension of file on disk differs from the common one), the filename extension is not available. You can use this property to provide the RasterCodecs class with this information to use as a hint when loading the image data.
The value does not have to be the original file name, it can be any generic value such as "file.txt", RasterCodecs will then use the extension (in this case, .txt) as a hint if it cannot determine the file format from the data itself.
The value is not used and is ignored if the data contains image data with a well-defined file signature, such as TIFF, JPEG or PDF.
When loading a file from an HTTP stream, the MIME type is always available and the value can be passed to RasterCodecs.GetExtensionMimeType to obtain the extension to be used with Name. For example:
RasterCodecs rasterCodecs = new RasterCodecs();
WebRequest request = WebRequest.Create("http://myserver/mydata");
using (WebResponse response = request.GetResponse())
{
// Get the content type (MIME type)
string mimeType1 = request.ContentType;
// Get the corresponding file extension
String extension = RasterCodecs.GetMimeTypeExtension(mimeType);
// Use it as a hint to RasterCodecs when loading this image file
rasterCodecs.Options.Load.Name = "file." + extension;
// Now load the image from the stream
Stream stream = response.GetResponseStream();
rasterCodecs.Load(stream, 1);
}