Doesn't exist?

This is a discussion on Doesn't exist? within the C# Programming forums, part of the General Programming Boards category; The type or namespace name 'GetEncoderInfo' does not exist in the namespace 'System.Drawing.Imaging' (are you missing an assembly reference?) Code: ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    16

    Doesn't exist?

    The type or namespace name 'GetEncoderInfo' does not exist in the namespace 'System.Drawing.Imaging' (are you missing an assembly reference?)

    Code:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Drawing;
    using System.Drawing.Imaging;
    
    ....
    ....
    ImageCodecInfo jpegCodec = GetEncoderInfo("image/jpeg");
    ....
    ....
    Last I checked, GetEncoderInfo is in System.Drawing.Imaging. What is the problem here?

    Edit: I do have System.Drawing referenced.
    Last edited by Llam4; 04-08-2007 at 08:01 PM.

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,138
    GetEncoderInfo is a method call. System.Drawing.Imaging is a namespace. A namespace doesn't contain methods, only classes contain methods. You are missing a classname.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    16
    Okay. Do you know which class GetEncoderInfo is in? Been over google and all codes are using it the same way I am.

  4. #4
    Registered User
    Join Date
    Apr 2007
    Posts
    16
    Last edited by Llam4; 04-08-2007 at 07:54 PM.

  5. #5
    Registered User
    Join Date
    Apr 2007
    Posts
    16
    Finished an alpha version. The quality is poor because I can't use GetEncoderInfo(), but it works great.

    It updates every 15 seconds with all of the programs of interest I'm running.
    http://processes.no-ip.org/Processes.jpg

  6. #6
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    I think you could use ImageCodecInfo.GetImageEncoders() and search the array for the encoder you're looking for.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  7. #7
    Registered User
    Join Date
    Apr 2007
    Posts
    16
    Code:
                EncoderParameter quality = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 100);
                EncoderParameters Params = new EncoderParameters(1);
                Params.Param[0] = quality;
                ImageCodecInfo[] myCodecs = ImageCodecInfo.GetImageEncoders();
                ImageCodecInfo jpegCodec = myCodecs[1];
    
    ->          WholeImage.Save(@"C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/Processes.jpg", jpegCodec, Params); // Problem code.
                WholeImage.Dispose();
    Code:
    System.ArgumentException was unhandled
      Message="Parameter is not valid."
      Source="System.Drawing"
      StackTrace:
           at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
           at ProgramList.CreateList.SaveImage() in C:\Documents and Settings\Ryan\My Documents\Visual Studio 2005\Projects\ProgramList\ProgramList\Program.cs:line 86
           at ProgramList.CreateList.ProcessImage() in C:\Documents and Settings\Ryan\My Documents\Visual Studio 2005\Projects\ProgramList\ProgramList\Program.cs:line 112
           at ProgramList.Program.Main(String[] args) in C:\Documents and Settings\Ryan\My Documents\Visual Studio 2005\Projects\ProgramList\ProgramList\Program.cs:line 122
           at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
           at System.Threading.ThreadHelper.ThreadStart()

  8. #8
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,138
    Enter GetEncoderInfo in Google and click the first MSDN link that pops up. The example on that page uses a custom method called GetEncoderInfo to do exactly what you need.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiler error in whitespace that doesn't even exist
    By beanroaster in forum C++ Programming
    Replies: 2
    Last Post: 09-09-2005, 10:27 PM
  2. namespace does not exist
    By scott27349 in forum C++ Programming
    Replies: 5
    Last Post: 04-18-2003, 08:48 PM
  3. Do aliens EXIST part 2
    By M Prime in forum A Brief History of Cprogramming.com
    Replies: 35
    Last Post: 06-24-2002, 03:40 PM
  4. How to check a directory is exist or not?
    By Unregistered in forum C++ Programming
    Replies: 6
    Last Post: 03-23-2002, 09:13 AM
  5. Checking that a file doesn't exist already
    By Gades in forum C Programming
    Replies: 2
    Last Post: 10-26-2001, 03:00 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21