Class that contains setting for the montage operation.
 public IntPtr Montage(IMagickImage image, IMontageSettings <QuantumType> settings)
 {
     using (INativeInstance settingsNative = MontageSettings.CreateInstance(settings))
     {
         IntPtr exception = IntPtr.Zero;
         IntPtr result;
         #if PLATFORM_AnyCPU
         if (OperatingSystem.Is64Bit)
         #endif
         #if PLATFORM_x64 || PLATFORM_AnyCPU
         result = NativeMethods.X64.MagickImageCollection_Montage(image.GetInstance(), settingsNative.Instance, out exception);
         #endif
         #if PLATFORM_AnyCPU
         else
         #endif
         #if PLATFORM_x86 || PLATFORM_AnyCPU
         result = NativeMethods.X86.MagickImageCollection_Montage(image.GetInstance(), settingsNative.Instance, out exception);
         #endif
         var magickException = MagickExceptionHelper.Create(exception);
         if (magickException == null)
         {
             return(result);
         }
         if (magickException is MagickErrorException)
         {
             if (result != IntPtr.Zero)
             {
                 Dispose(result);
             }
             throw magickException;
         }
         RaiseWarning(magickException);
         return(result);
     }
 }
 public IntPtr Montage(IMagickImage image, MontageSettings settings)
 {
     using (INativeInstance settingsNative = MontageSettings.CreateInstance(settings))
     {
         IntPtr exception = IntPtr.Zero;
         IntPtr result;
         #if PLATFORM_AnyCPU
         if (NativeLibrary.Is64Bit)
         #endif
         #if PLATFORM_x64 || PLATFORM_AnyCPU
         result = NativeMethods.X64.MagickImageCollection_Montage(image.GetInstance(), settingsNative.Instance, out exception);
         #endif
         #if PLATFORM_AnyCPU
         else
         #endif
         #if PLATFORM_x86 || PLATFORM_AnyCPU
         result = NativeMethods.X86.MagickImageCollection_Montage(image.GetInstance(), settingsNative.Instance, out exception);
         #endif
         MagickException magickException = MagickExceptionHelper.Create(exception);
         if (MagickExceptionHelper.IsError(magickException))
         {
             if (result != IntPtr.Zero)
             {
                 Dispose(result);
             }
             throw magickException;
         }
         RaiseWarning(magickException);
         return(result);
     }
 }
Example #3
0
        private MontageSettings CreateMontageSettings(XmlElement element)
        {
            if (element == null)
            {
                return(null);
            }
            MontageSettings result = new MontageSettings();

            result.BackgroundColor  = Variables.GetValue <MagickColor>(element, "backgroundColor");
            result.BorderColor      = Variables.GetValue <MagickColor>(element, "borderColor");
            result.BorderWidth      = Variables.GetValue <Int32>(element, "borderWidth");
            result.FillColor        = Variables.GetValue <MagickColor>(element, "fillColor");
            result.Font             = Variables.GetValue <String>(element, "font");
            result.FontPointsize    = Variables.GetValue <Int32>(element, "fontPointsize");
            result.FrameGeometry    = Variables.GetValue <MagickGeometry>(element, "frameGeometry");
            result.Geometry         = Variables.GetValue <MagickGeometry>(element, "geometry");
            result.Gravity          = Variables.GetValue <Gravity>(element, "gravity");
            result.Label            = Variables.GetValue <String>(element, "label");
            result.Shadow           = Variables.GetValue <Boolean>(element, "shadow");
            result.StrokeColor      = Variables.GetValue <MagickColor>(element, "strokeColor");
            result.TextureFileName  = Variables.GetValue <String>(element, "textureFileName");
            result.TileGeometry     = Variables.GetValue <MagickGeometry>(element, "tileGeometry");
            result.Title            = Variables.GetValue <String>(element, "title");
            result.TransparentColor = Variables.GetValue <MagickColor>(element, "transparentColor");
            return(result);
        }
Example #4
0
 internal static INativeInstance CreateInstance(MontageSettings instance)
 {
     if (instance == null)
     {
         return(NativeInstance.Zero);
     }
     return(instance.CreateNativeInstance());
 }
Example #5
0
 internal static INativeInstance CreateInstance(IMontageSettings <QuantumType>?instance)
 {
     if (instance is null)
     {
         return(NativeInstance.Zero);
     }
     return(MontageSettings.CreateNativeInstance(instance));
 }
Example #6
0
 private MontageSettings CreateMontageSettings(XmlElement element)
 {
   if (element == null)
     return null;
   MontageSettings result = new MontageSettings();
   result.BackgroundColor = Variables.GetValue<MagickColor>(element, "backgroundColor");
   result.BorderColor = Variables.GetValue<MagickColor>(element, "borderColor");
   result.BorderWidth = Variables.GetValue<Int32>(element, "borderWidth");
   result.FillColor = Variables.GetValue<MagickColor>(element, "fillColor");
   result.Font = Variables.GetValue<String>(element, "font");
   result.FontPointsize = Variables.GetValue<Int32>(element, "fontPointsize");
   result.FrameGeometry = Variables.GetValue<MagickGeometry>(element, "frameGeometry");
   result.Geometry = Variables.GetValue<MagickGeometry>(element, "geometry");
   result.Gravity = Variables.GetValue<Gravity>(element, "gravity");
   result.Label = Variables.GetValue<String>(element, "label");
   result.Shadow = Variables.GetValue<Boolean>(element, "shadow");
   result.StrokeColor = Variables.GetValue<MagickColor>(element, "strokeColor");
   result.TextureFileName = Variables.GetValue<String>(element, "textureFileName");
   result.TileGeometry = Variables.GetValue<MagickGeometry>(element, "tileGeometry");
   result.Title = Variables.GetValue<String>(element, "title");
   result.TransparentColor = Variables.GetValue<MagickColor>(element, "transparentColor");
   return result;
 }
Example #7
0
        ///<summary>
        /// Create a composite image by combining the images with the specified settings.
        ///</summary>
        ///<param name="settings">The settings to use.</param>
        ///<exception cref="MagickException"/>
        public MagickImage Montage(MontageSettings settings)
        {
            ThrowIfEmpty();

            Throw.IfNull("settings", settings);

            IntPtr images;

            try
            {
                AttachImages();
                if (!string.IsNullOrEmpty(settings.Label))
                {
                    _Images[0].Label = settings.Label;
                }
                images = _NativeInstance.Montage(_Images[0], settings);
            }
            finally
            {
                DetachImages();
            }

            using (MagickImageCollection collection = new MagickImageCollection())
            {
                collection.AddRange(MagickImage.CreateList(images, _Images[0].Settings));
                if (settings.TransparentColor != null)
                {
                    foreach (MagickImage image in collection)
                    {
                        image.Transparent(settings.TransparentColor);
                    }
                }

                return(collection.Merge());
            }
        }
        private IMagickImage ExecuteMontage(XmlElement element, IMagickImageCollection collection)
        {
            MontageSettings settings_ = CreateMontageSettings(element["settings"]);

            return(collection.Montage(settings_));
        }
    public void Test_Montage()
    {
      using (MagickImageCollection collection = new MagickImageCollection())
      {
        MontageSettings settings = new MontageSettings();
        settings.Geometry = new MagickGeometry(string.Format("{0}x{1}", 200, 200));
        settings.TileGeometry = new MagickGeometry(string.Format("{0}x", 2));

        ExceptionAssert.Throws<InvalidOperationException>(delegate ()
        {
          collection.Montage(settings);
        });

        for (int i = 0; i < 9; i++)
          collection.Add(Files.Builtin.Logo);

        using (MagickImage montageResult = collection.Montage(settings))
        {
          Assert.IsNotNull(montageResult);
          Assert.AreEqual(400, montageResult.Width);
          Assert.AreEqual(1000, montageResult.Height);
        }
      }
    }
 public IntPtr Montage(MagickImage image, MontageSettings settings)
 {
   using (INativeInstance settingsNative = MontageSettings.CreateInstance(settings))
   {
     IntPtr exception = IntPtr.Zero;
     IntPtr result;
     #if ANYCPU
     if (NativeLibrary.Is64Bit)
     #endif
     #if WIN64 || ANYCPU
     result = NativeMethods.X64.MagickImageCollection_Montage(MagickImage.GetInstance(image), settingsNative.Instance, out exception);
     #endif
     #if ANYCPU
     else
     #endif
     #if !WIN64 || ANYCPU
     result = NativeMethods.X86.MagickImageCollection_Montage(MagickImage.GetInstance(image), settingsNative.Instance, out exception);
     #endif
     MagickException magickException = MagickExceptionHelper.Create(exception);
     if (MagickExceptionHelper.IsError(magickException))
     {
       if (result != IntPtr.Zero)
         Dispose(result);
       throw magickException;
     }
     RaiseWarning(magickException);
     return result;
   }
 }
    public void Test_Montage()
    {
      using (MagickImageCollection images = new MagickImageCollection())
      {
        for (int i = 0; i < 9; i++)
          images.Add(Files.Builtin.Logo);

        MontageSettings ms = new MontageSettings();
        ms.Geometry = new MagickGeometry(string.Format("{0}x{1}", 200, 200));
        ms.TileGeometry = new MagickGeometry(string.Format("{0}x", 2));

        using (MagickImage montageResult = images.Montage(ms))
        {
          Assert.IsNotNull(montageResult);
          Assert.AreEqual(400, montageResult.Width);
          Assert.AreEqual(1000, montageResult.Height);
        }
      }
    }
Example #12
0
 internal static INativeInstance CreateInstance(MontageSettings instance)
 {
   if (instance == null)
     return NativeInstance.Zero;
   return instance.CreateNativeInstance();
 }
Example #13
0
 ///<summary>
 /// Create a composite image by combining the images with the specified settings.
 ///</summary>
 ///<param name="settings">The settings to use.</param>
 ///<exception cref="MagickException"/>
 public MagickImage Montage(MontageSettings settings)
 {
     Wrapper.MagickImage image = _Instance.Montage(GetImageInstances(), MontageSettings.GetInstance(settings));
     return(MagickImage.Create(image));
 }
Example #14
-25
        // Create single sized collage from image collection
        byte[] GenerateCollage(MagickImageCollection collection, int size)
        {
            MontageMode mode = MontageMode.Concatenate;

            MontageSettings settings = new MontageSettings(mode);
            settings.BackgroundColor = new MagickColor("#FFF");
            settings.Geometry = new MagickGeometry("1x1<");
            using (MagickImage result = collection.Montage(settings))
            {
                result.Format = MagickFormat.Png;
                result.Resize(new MagickGeometry(size));
                return result.ToByteArray();
            }
        }