Welcome Guest! You need to login or register to make posts.

Notification

Icon
Error

#gdi-plus-graphics

Options
Go to last post Go to first unread
JulianGrahame  
#1 Posted : Wednesday, January 14, 2009 11:51:50 PM(UTC)
JulianGrahame

Rank: Newbie

Groups: Member
Joined: 12/30/2008(UTC)
Posts: 4

Hi

The images we need to produce via our web page are to be printed on round objects. Therefore we need to provide our users with an easy way of aligning and cropping their uploaded images.

Basically I would like to use an elliptical marquee to designate the target crop area.

The actual crop would be rectangular but the elliptical marquee would define the height and width of the rectangle.

Is all this achievable using Graphics Mill? Are there any examples?

Thanks

JG

Edited by moderator Monday, May 28, 2012 8:33:28 PM(UTC)  | Reason: Not specified

Dmitry  
#2 Posted : Friday, January 16, 2009 4:33:53 PM(UTC)
Dmitry

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 8/3/2003(UTC)
Posts: 1,070

Thanks: 1 times
Was thanked: 12 time(s) in 12 post(s)
Hello,

The basic idea how to apply "ellipse" crop to the image is the following:
  1. Apply rectangular crop.
  2. Add ellipse mask to cropped image.
Here is small sample illustrating this approach:
Code:

// Crop rectangle
System.Drawing.Rectangle cropRect = new System.Drawing.Rectangle(300, 0, 500, 300);

// Source bitmap
Aurigma.GraphicsMill.Bitmap bmp = new Aurigma.GraphicsMill.Bitmap(@"D:\temp\source.jpg");

// Apply rectangular crop
bmp.Transforms.Crop(cropRect);

// Create ellipse mask and add it to the cropped bitmap
using (Aurigma.GraphicsMill.Bitmap alpha = new Aurigma.GraphicsMill.Bitmap(cropRect.Width, 
  cropRect.Height, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb))
{
    // Draw ellipse on the mask
    using (System.Drawing.Graphics gr = alpha.GetGdiplusGraphics())
    {
        gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
        gr.FillEllipse(new System.Drawing.SolidBrush(System.Drawing.Color.White), 
          new System.Drawing.Rectangle(0, 0, cropRect.Width, cropRect.Height));
    }
    alpha.ColorManagement.Convert(Aurigma.GraphicsMill.PixelFormat.Format8bppGrayScale);

    // Add the mask to cropeed bitmap
    bmp.Channels.AddAlpha(1.0f);
    bmp.Channels[bmp.Channels.AlphaChannelIndex] = alpha;
}

// Save the result
bmp.Save(@"d:\temp\EllipseCrop.png");
Sincerely yours,
Dmitry Sevostyanov

UserPostedImage Follow Aurigma on Twitter!
Fedor  
#3 Posted : Monday, July 3, 2017 1:20:02 AM(UTC)
Fedor

Rank: Advanced Member

Groups: Member, Administration, Moderator
Joined: 7/28/2003(UTC)
Posts: 1,550

Thanks: 5 times
Was thanked: 59 time(s) in 58 post(s)
Alternatively, you can use clipping path via the Graphics.ClippingPaths property.
Best regards,
Fedor Skvortsov
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.