LEADTOOLS Support
Imaging
Imaging SDK Examples
HOW TO: Obtain the Extension for a specific Raster Format
#1
Posted
:
Tuesday, November 21, 2017 11:05:31 AM(UTC)
Groups: Registered, Tech Support, Administrators
Posts: 163
Was thanked: 9 time(s) in 9 post(s)
The RasterCodecs object contains several static classes which can be used to obtain information about an image. The RasterCodecs.GetExtension() static method can be used to obtain the typical file system extension for the specified format. Here's our documentation on the method.
RasterCodecs.GetExtension(RasterImageFormat)The command accepts as a parameter any of the values in the RasterImageFormat enumeration.
RasterImageFormatThe return value is a string representing the typical file extension, without the leading period. Note this code snippet:
Code:
string extension = RasterCodecs.GetExtension(RasterImageFormat.CcittGroup4);
The value of
extension would be "tif".
Here's a code snippet which displays all available extensions to the console.
Code:
RasterImageFormat[] allFormats = (RasterImageFormat[])Enum.GetValues(typeof(RasterImageFormat));
foreach (RasterImageFormat format in allFormats)
Console.WriteLine(
"RasterImageFormat:\t{0}\tExtension:\t{1}",
Enum.GetName(typeof(RasterImageFormat), format).PadRight(20),
RasterCodecs.GetExtension(format)
);
Edited by moderator Thursday, June 14, 2018 8:58:37 AM(UTC)
| Reason: Updated links to v20 and reformatted code
Nick Crook
Developer Support Engineer
LEAD Technologies, Inc.
1 user thanked Nick for this useful post.
LEADTOOLS Support
Imaging
Imaging SDK Examples
HOW TO: Obtain the Extension for a specific Raster Format
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.