Atalasoft
Welcome to Atalasoft Community Sign in | Join | Help
in

Bitonal image processing commands

Last post 03 Apr 2006, 2:50 PM by Steve Hawley. 2 replies.
Sort Posts: Previous Next
  •  03 Apr 2006, 1:37 PM 9870

    Bitonal image processing commands

    Does the documentation clearly state which commands only work on bitonal images? I've searched the documentation for "bitonal command" and found a couple of hits, but I want a definitive list (or a way to detect a specific filter's requirements, like InPlaceProcessing) so I can code and document accordingly.
  •  03 Apr 2006, 2:13 PM 9872 in reply to 9870

    Re: Bitonal image processing commands

    Does this make sense as a workaround?

    public static AtalaImage ToSupportedFormat( AtalaImage image, Atalasoft.Imaging.ImageProcessing.ImageCommand cmd )
    {
        if( cmd.IsPixelFormatSupported( image.PixelFormat ) )
            return image;
        else
            return image.GetChangedPixelFormat( cmd.SupportedPixelFormats[0] );
    }
  •  03 Apr 2006, 2:50 PM 9874 in reply to 9872

    Re: Bitonal image processing commands

    This is probably not an ideal solution as the first supported pixel format might not be the best one to translate to - be aware that you might be either throwing away information or adding in way too much.  You probably want to write a method like this:
    public static PixelFormat SelectBestAlternatePixelFormat(PixelFormat whatIHave, PixelFormat[] whatICanChooseFrom)
    {
    }

    Here's a code snippet I just put together which will list all commands in dotImage that support bitonal images:

    using System;
    using System.Reflection;
    using System.Runtime;
    using Atalasoft.Imaging;
    using Atalasoft.Imaging.ImageProcessing;

    namespace FindBitonalCommands
    {
        /// <summary>
        /// Summary description for Class1.
        /// </summary>
        class Class1
        {
            /// <summary>
            /// The main entry point for the application.
            /// </summary>
            [STAThread]
            static void Main(string[] args)
            {
                Assembly dotImage = Assembly.GetAssembly(typeof(AtalaImage));

                Type[] allTypes = dotImage.GetExportedTypes();
                Type[] emptyList = new Type[0];
                foreach (Type t in allTypes)
                {
                    if (!t.IsSubclassOf(typeof(Atalasoft.Imaging.ImageProcessing.ImageCommand)))
                        continue;
                    ConstructorInfo ctor = t.GetConstructor(emptyList);
                    if (ctor != null)
                    {
                        object obj = ctor.Invoke(null);
                        ImageCommand command = (ImageCommand)obj;
                        if (command.IsPixelFormatSupported(PixelFormat.Pixel1bppIndexed))
                        {
                            System.Console.WriteLine(command.GetType().Name);
                        }
                    }
                }
                System.Console.ReadLine();
            }
        }
    }


    Steve Hawley
    Architect & Exception Handler
    Atalasoft, Inc.
View as RSS news feed in XML