Codec specialized in images loaded using FreeImage.
The users implementing subclasses of ImageCodec are required to return a valid pointer to a ImageData class from the decode(...) function.
Наследование: Axiom.Media.ImageCodec
Пример #1
0
        public static void Initialize()
        {
            try
            {
                FI.FreeImage.ValidateAvailability();
            }
            catch
            {
                LogManager.Instance.Write("[ Warning ] No Freeimage found.");
                return;
            }

            LogManager.Instance.Write("FreeImage Version: {0}", FI.FreeImage.GetVersion());
            LogManager.Instance.Write(FI.FreeImage.GetCopyrightMessage());

            // Register codecs
            var sb = new StringBuilder();

            sb.Append(" Supported formats: ");
            var first = true;

            for (var i = 0; i < FI.FreeImage.GetFIFCount(); i++)
            {
                // Skip DDS codec since FreeImage does not have the option
                // to keep DXT data compressed, we'll use our own codec
                if ((FI.FREE_IMAGE_FORMAT)i == FI.FREE_IMAGE_FORMAT.FIF_DDS)
                {
                    continue;
                }

                var exts = FI.FreeImage.GetFIFExtensionList((FI.FREE_IMAGE_FORMAT)i);
                if (!first)
                {
                    sb.Append(",");
                }
                else
                {
                    first = false;
                }
                sb.Append(exts);

                // Pull off individual formats (separated by comma by FI)
                var extensions = exts.Split(',');
                foreach (var ext in extensions)
                {
                    // FreeImage 3.13 lists many formats twice: once under their own codec and
                    // once under the "RAW" codec, which is listed last. Avoid letting the RAW override
                    // the dedicated codec!
                    if (!CodecManager.Instance.IsCodecRegistered(ext))
                    {
                        var codec = new FreeImageCodec(ext, (FI.FREE_IMAGE_TYPE)i);
                        _codecList.Add(codec);
                        CodecManager.Instance.RegisterCodec(codec);
                    }
                }
            }

            LogManager.Instance.Write(sb.ToString());
            FI.FreeImageEngine.Message += new FI.OutputMessageFunction(_freeImageLoadErrorHandler);
        }
Пример #2
0
 /// <summary>
 ///    Called when the plugin is stopped.
 /// </summary>
 public void Shutdown()
 {
     FreeImageCodec.Shutdown();
 }
Пример #3
0
        /// <summary>
        ///    Called when the plugin is started.
        /// </summary>
        public void Initialize()
        {
            NativeLibraryLoader.CopyNativeDll("FreeImage", "FreeImage");

            FreeImageCodec.Initialize();
        }
Пример #4
0
		public static void Initialize()
		{
			if ( !FI.FreeImage.IsAvailable() )
			{
				LogManager.Instance.Write( "[ Warning ] No Freeimage found." );
				return;
			}

			LogManager.Instance.Write( "FreeImage Version: {0}", FI.FreeImage.GetVersion() );
			LogManager.Instance.Write( FI.FreeImage.GetCopyrightMessage() );

			// Register codecs
			var sb = new StringBuilder();
			sb.Append( " Supported formats: " );
			var first = true;
			for ( var i = 0; i < FI.FreeImage.GetFIFCount(); i++ )
			{
				// Skip DDS codec since FreeImage does not have the option 
				// to keep DXT data compressed, we'll use our own codec
				if ( (FI.FREE_IMAGE_FORMAT)i == FI.FREE_IMAGE_FORMAT.FIF_DDS )
				{
					continue;
				}

				var exts = FI.FreeImage.GetFIFExtensionList( (FI.FREE_IMAGE_FORMAT)i );
				if ( !first )
				{
					sb.Append( "," );
				}
				else
				{
					first = false;
				}
				sb.Append( exts );

				// Pull off individual formats (separated by comma by FI)
				var extensions = exts.Split( ',' );
				foreach ( var ext in extensions )
				{
					// FreeImage 3.13 lists many formats twice: once under their own codec and
					// once under the "RAW" codec, which is listed last. Avoid letting the RAW override
					// the dedicated codec!
					if ( !CodecManager.Instance.IsCodecRegistered( ext ) )
					{
						var codec = new FreeImageCodec( ext, (FI.FREE_IMAGE_TYPE)i );
						_codecList.Add( codec );
						CodecManager.Instance.RegisterCodec( codec );
					}
				}
			}

			LogManager.Instance.Write( sb.ToString() );
			FI.FreeImageEngine.Message += new FI.OutputMessageFunction( _freeImageLoadErrorHandler );
		}
Пример #5
0
 /// <summary>
 ///    Called when the plugin is started.
 /// </summary>
 public void Initialize()
 {
     FreeImageCodec.Initialize();
 }
Пример #6
0
		public static void Initialize()
		{
			if ( !FI.FreeImage.IsAvailable() )
			{
				LogManager.Instance.Write( "[ Warning ] No Freeimage found." );
				return;
			}

			LogManager.Instance.Write( "FreeImage Version: {0}", FI.FreeImage.GetVersion() );
			LogManager.Instance.Write( FI.FreeImage.GetCopyrightMessage() );

			StringBuilder sb = new StringBuilder();
			sb.Append( " Supported formats: " );
			bool first = true;
			for ( int i = 0; i < FI.FreeImage.GetFIFCount(); i++ )
			{
				if ( (FI.FREE_IMAGE_FORMAT)i == FI.FREE_IMAGE_FORMAT.FIF_DDS )
					continue;

				string exts = FI.FreeImage.GetFIFExtensionList( (FI.FREE_IMAGE_FORMAT)i );
				if ( !first )
				{
					sb.Append( "," );
				}
				else
					first = false;
				sb.Append( exts );
				// Pull off individual formats (separated by comma by FI)
				string[] extensions = exts.Split( ',' );
				foreach ( string extension in extensions )
				{
					// FreeImage 3.13 lists many formats twice: once under their own codec and
					// once under the "RAW" codec, which is listed last. Avoid letting the RAW override
					// the dedicated codec!
					if ( !CodecManager.Instance.IsCodecAviable( extension ) )
					{
						ImageCodec codec = new FreeImageCodec( extension, (FI.FREE_IMAGE_TYPE)i );
						_codecList.Add( codec );
						CodecManager.Instance.RegisterCodec( codec );
					}
				}

			}

			LogManager.Instance.Write( sb.ToString() );
			FI.FreeImageEngine.Message += new FI.OutputMessageFunction( FreeImageLoadErrorHandler );
		}