-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved handling of picture frames. Passes all tests now.
- Loading branch information
Showing
4 changed files
with
101 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System; | ||
using System.Drawing.Imaging; | ||
|
||
namespace Achamenes.ID3.Utils | ||
{ | ||
public class ImagingHelpers | ||
{ | ||
public static string ImageFormatToMimeType(ImageFormat imageFormat) | ||
{ | ||
foreach (ImageCodecInfo codec in ImageCodecInfo.GetImageDecoders()) | ||
{ | ||
if (codec.FormatID == imageFormat.Guid) | ||
{ | ||
return codec.MimeType; | ||
} | ||
} | ||
return "application/octet-stream"; | ||
} | ||
|
||
// Taken from http://www.java2s.com/Code/CSharp/File-Stream/ImageFormattoExtension.htm | ||
// And modified. | ||
public static string ImageFormatToExtension(ImageFormat imageFormat) | ||
{ | ||
if (imageFormat.Equals(ImageFormat.Bmp)) | ||
{ | ||
return "BMP"; | ||
} | ||
else if (imageFormat.Equals(ImageFormat.MemoryBmp)) | ||
{ | ||
return "BMP"; | ||
} | ||
else if (imageFormat.Equals(ImageFormat.Wmf)) | ||
{ | ||
return "EMF"; | ||
} | ||
else if (imageFormat.Equals(ImageFormat.Wmf)) | ||
{ | ||
return "WMF"; | ||
} | ||
else if (imageFormat.Equals(ImageFormat.Gif)) | ||
{ | ||
return "GIF"; | ||
} | ||
else if (imageFormat.Equals(ImageFormat.Jpeg)) | ||
{ | ||
return "JPG"; | ||
} | ||
else if (imageFormat.Equals(ImageFormat.Png)) | ||
{ | ||
return "PNG"; | ||
} | ||
else if (imageFormat.Equals(ImageFormat.Tiff)) | ||
{ | ||
return "TIF"; | ||
} | ||
else if (imageFormat.Equals(ImageFormat.Exif)) | ||
{ | ||
return "EXF"; | ||
} | ||
else if (imageFormat.Equals(ImageFormat.Icon)) | ||
{ | ||
return "ICO"; | ||
} | ||
return ""; | ||
} | ||
} | ||
} | ||
|