Click here to Skip to main content
15,921,062 members
Home / Discussions / C#
   

C#

 
GeneralAdding Recs to DB Pin
MrJJKoolJ3-Apr-04 4:52
MrJJKoolJ3-Apr-04 4:52 
GeneralLOC Question Pin
Brian Delahunty3-Apr-04 4:28
Brian Delahunty3-Apr-04 4:28 
GeneralRe: LOC Question Pin
Heath Stewart3-Apr-04 4:34
protectorHeath Stewart3-Apr-04 4:34 
GeneralRe: LOC Question Pin
Nick Parker3-Apr-04 4:39
protectorNick Parker3-Apr-04 4:39 
GeneralRe: LOC Question Pin
Brian Delahunty3-Apr-04 4:49
Brian Delahunty3-Apr-04 4:49 
GeneralRe: LOC Question Pin
Nick Parker3-Apr-04 4:37
protectorNick Parker3-Apr-04 4:37 
Generalmultiframe gif Pin
Stephane David3-Apr-04 1:40
Stephane David3-Apr-04 1:40 
GeneralRe: multiframe gif Pin
Heath Stewart3-Apr-04 4:29
protectorHeath Stewart3-Apr-04 4:29 
All the classes involved are an abstract implementation, meaning what works for one works for another (the classes used themselves, that is). If you want to know what EncoderParameters are supported, see this simple console app that I threw together quick:
using System;
using System.Collections;
using System.Drawing;
using System.Drawing.Imaging;
using System.Reflection;

public class Test
{
  static void Main(string[] args)
  {
    string fe = "gif";
    if (args.Length > 0) fe = args[0];

    ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
    ImageCodecInfo codec = null;
    foreach (ImageCodecInfo ci in codecs)
    {
      if (ci.FilenameExtension.ToLower().IndexOf(fe.ToLower()) >= 0)
      {
        codec = ci;
        break;
      }
    }

    if (codec == null)
    {
      Console.Error.WriteLine("No image codec found for extension " + fe);
      return;
    }

    Image img = new Bitmap(1, 1);
    EncoderParameters encparams = null;
    try
    {
      encparams = img.GetEncoderParameterList(codec.Clsid);
    }
    catch (NotImplementedException)
    {
      Console.Error.WriteLine("No encoder parameters supported for extension " + fe);
      return;
    }

    foreach (EncoderParameter encparam in encparams.Param)
    {
      string encname = GetEncoderName(encparam.Encoder.Guid);
      Console.WriteLine("{0}: {1}", encname, encparam.Type);
    }
  }

  static Hashtable encnames;
  static string GetEncoderName(Guid g)
  {
    if (encnames == null)
    {
      encnames = new Hashtable();

      Type t = typeof(Encoder);
      FieldInfo[] fields = t.GetFields(BindingFlags.Public | BindingFlags.Static);
      foreach (FieldInfo field in fields)
      {
        Encoder enc = (Encoder)field.GetValue(null);
        encnames[enc.Guid] = field.Name;
      }
    }

    return encnames[g] as string;
  }
}
If you run this, you'll see that the GIF image encoder doesn't even support any EncoderParameters, so you can just pass null.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: multiframe gif Pin
Stephane David3-Apr-04 5:06
Stephane David3-Apr-04 5:06 
GeneralRe: multiframe gif Pin
Heath Stewart3-Apr-04 6:09
protectorHeath Stewart3-Apr-04 6:09 
GeneralRe: multiframe gif Pin
Stephane David3-Apr-04 7:28
Stephane David3-Apr-04 7:28 
GeneralProblem using Device Handle with P/Invoke methods Pin
Tristan Rhodes3-Apr-04 0:46
Tristan Rhodes3-Apr-04 0:46 
GeneralRe: Problem using Device Handle with P/Invoke methods Pin
Heath Stewart3-Apr-04 3:33
protectorHeath Stewart3-Apr-04 3:33 
GeneralRe: Problem using Device Handle with P/Invoke methods Pin
Tristan Rhodes3-Apr-04 4:14
Tristan Rhodes3-Apr-04 4:14 
GeneralRe: Problem using Device Handle with P/Invoke methods Pin
Heath Stewart3-Apr-04 4:32
protectorHeath Stewart3-Apr-04 4:32 
GeneralRe: Problem using Device Handle with P/Invoke methods Pin
leppie3-Apr-04 6:35
leppie3-Apr-04 6:35 
GeneralShutting Down Windows Pin
Nagendra Kamath K2-Apr-04 23:32
Nagendra Kamath K2-Apr-04 23:32 
GeneralRe: Shutting Down Windows Pin
Dave Kreskowiak3-Apr-04 2:11
mveDave Kreskowiak3-Apr-04 2:11 
Questionhow to open and edit DICOM images and c# Pin
durukan2-Apr-04 22:45
durukan2-Apr-04 22:45 
AnswerRe: how to open and edit DICOM images and c# Pin
chrixian2-Apr-04 23:25
chrixian2-Apr-04 23:25 
AnswerRe: how to open and edit DICOM images and c# Pin
Dave Kreskowiak3-Apr-04 2:16
mveDave Kreskowiak3-Apr-04 2:16 
QuestionHow to Get Keyboard Control Pin
Member 6910892-Apr-04 19:44
Member 6910892-Apr-04 19:44 
AnswerRe: How to Get Keyboard Control Pin
Heath Stewart3-Apr-04 3:28
protectorHeath Stewart3-Apr-04 3:28 
GeneralBlock Size & Key Size - Crypto Algorithm Pin
Danial Cox2-Apr-04 19:04
Danial Cox2-Apr-04 19:04 
GeneralRe: Block Size & Key Size - Crypto Algorithm Pin
Heath Stewart3-Apr-04 3:24
protectorHeath Stewart3-Apr-04 3:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.