スキップしてメイン コンテンツに移動

投稿

C#: How to Read Image MetaData from System.Drawing.Imaging.PropertyItem

I have written simple debug code for printing out PropertyItems in System.Drawing.Image object. The key part of the code: mapping between Id property of PropertyItem and description of associated to the property item. decode PropertyItem value (byte array) to human readable format string The code itself will be shown at the bottom of this post. Below is a sample image which will be passed to the program and the corresponding output generated by the program. Property Item 1 Id: 0x10e Type: 2 Length: 17 bytes Type String: ASCII Descriotion: PropertyTagImageDescription Value : MetaData Example Property Item 2 Id: 0x131 Type: 2 Length: 7 bytes Type String: ASCII Descriotion: PropertyTagSoftwareUsed Value : Picasa Property Item 3 Id: 0x9000 Type: 7 Length: 4 bytes Type String: Undefined Descriotion: PropertyTagExifVer Value : Property Item 4 Id: 0xa002 Type: 4 Length: 4 bytes Type String: Long (3

C#: Extract Gif Frame Images From an Animated Gif Image

I wrote the post for extracting gif frame image from an animated gif image in Java - Java: Extract Gif Images From An Animated Gif Image . In this post, I have tried to do same thing in C# as well :D Code using System.Drawing; using System.Drawing.Imaging; namespace Utility { public class GifImageUtils { public static void SaveAnimatedGifFrames(string path, string outDir) { var gifImg = Image.FromFile(path); var dimension = new FrameDimension(gifImg.FrameDimensionsList[0]); int frameCount = gifImg.GetFrameCount(dimension); for (int i = 0; i < frameCount; i++) { gifImg.SelectActiveFrame(dimension, i); // create a frame image from the original source image - clone is mandatory var frame = (Image)gifImg.Clone(); frame.Save(outDir+"/"+i+".gif", ImageFormat.Gif); } } } } Exa

C#: Create Indexed PNG Using System.Windows.Media.BitmapSource with Pre-defined Palettes in BitmapPalettes Class

Creating Indexed PNG in C# In C#, there are mainly two namespaces to creating image... System.Drawing namespace System.Windows.Media namespace I've already written the post for creating indexed png using System.Drawing namespace classes - Create Indexed PNG Using C# .Net . So, in this post, I will show you how to create indexed png using classes under System.Windows.Media namespace. Preparation for Using Classes Under System.Windows.Media You need to add following dlls to your project reference in order to handle images using classes under System.Windows.Media. PresentationCore.dll Xaml.dll WindowsBase.dll Creating Palette Based Indexed Image If you would like to create indexed png, first of all, you should create color palette which can hold max 256 colors. Creating color palette is trivial. Please see the below example code: var colors = new List<Color>(); colors.Add(Color.FromRgb(255, 0, 0)); // 0 - red colors.Add(Color.FromRgb(0, 255, 0)); // 1 -

Java: Extract Gif Images From an Animated Gif Image

In this post, I will show you the code for extracting gif frame images from an animated gif image. I will show you two types of code: Simply extracting gif images stored in the original animated gif image Creating gif image by rendering and accumulating each gif frames stored in the original gif image Code for Extracting Gif Image From An Animated Gif Java Code package com.dukesoftware.utils.image; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; import javax.imageio.ImageReader; import javax.imageio.stream.ImageInputStream; public class GifImageUtils { public static void main(String[] args) throws IOException { String sourceGif = "c:/temp/SmallFullColourGIF.gif"; saveAnimatedGifFramePartsToImage(sourceGif, "c:/temp/gif_parts"); } public static void saveAnimatedGifFramePartsToImage(String input, String outDir) throws IOException { ImageReade