This project has moved and is read-only. For the latest updates, please go here.

Composite Image

May 13, 2014 at 5:32 PM
I have having a memory access error here and from what I can tell it is written correctly.
I am trying to take an image and put it on the badge image I have open in a certain location using the Geomerty.
                MagickGeometry photo = new MagickGeometry(0, 0, 1000,1000);
                MagickImage employeePhoto = new MagickImage(new System.Drawing.Bitmap(employeePictureBox.Image));

                DrawableCompositeImage drawEmployeePhoto = new DrawableCompositeImage(photo, employeePhoto);  // Memory Access error.

                badge.Draw(new Drawable[] { drawEmployeePhoto });
Any Ideas?
May 13, 2014 at 7:48 PM
This is most likely a bug in Magick.NET. Can you provide me with the 2 images so I can try to reproduce the problem. Do you have some example images that you can share publicly? If that is not possible you could also contact me trough Codeplex to send the images to me personally.
May 13, 2014 at 7:55 PM
Why would it be photo specific?
May 13, 2014 at 8:00 PM
Edited May 13, 2014 at 8:32 PM
I don't know if it is but it will make it easier for me to reproduce the problem. Can you provide me with the dimensions of the two images? Then I will give it a try with two of my images.

Edit: I can reproduce the problem and a fix for this will be available in the next release of Magick.NET.
May 13, 2014 at 9:13 PM
Sent you the photos in an email.
May 13, 2014 at 9:57 PM
Edited May 13, 2014 at 9:57 PM
Thank you for the images. The bug has been fixed and the code below is a workaround that uses MagickImage.Composite instead of DrawableCompositeImage
using (MagickImage badge = new MagickImage("BLANK_BADGE.png"))
  int left = 491;
  int height = 952;

  MagickGeometry offset = new MagickGeometry(left, 0, 0, 0);

  // This looks better but you probably don't need it.
    new DrawableFillColor(Color.White),
    new DrawableRectangle(left, 0, badge.Width, height));

  using (MagickImage employee = new MagickImage("Employee.jpg"))
    // Draw the photo
    employee.Resize(badge.Width - left, height);
    offset.Y = height - employee.Height;
    badge.Composite(employee, offset, CompositeOperator.Over);

    // Draw the employee number
      new DrawableFillColor(Color.Red),
      new DrawableFont("Verdana"),
      new DrawablePointSize(50),
      new DrawableTextAntialias(true),
      new DrawableText(180, 820, "1337"));

May 13, 2014 at 10:11 PM
Thanks for getting the library fixed.
The sample code was just a test of concept before it was implemented.