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

Notification

Icon
Error

Options
Go to last post Go to first unread
pauljdonohue  
#1 Posted : Tuesday, June 14, 2011 3:31:33 PM(UTC)
pauljdonohue

Rank: Newbie

Groups: Member
Joined: 9/12/2008(UTC)
Posts: 1


I need to produce a square thumbnail image. I'm using the WriteCropped method. When I first call AlignToSampleSize with my (square) Rectangle. It returns a non-square. Is it possible to use AlignToSampleSize and WriteCropped to force a square crop?
Dmitry.Obukhov  
#2 Posted : Wednesday, June 15, 2011 1:02:43 AM(UTC)
Dmitry.Obukhov

Rank: Advanced Member

Groups: Member
Joined: 5/29/2010(UTC)
Posts: 1,310

Thanks: 8 times
Was thanked: 111 time(s) in 111 post(s)
Hello Paul,
To crop image with square, you can use juts WriteCropped method defining x, y coordinates of left top corner, and crop size:
Code:

Aurigma.GraphicsMill.Codecs.LosslessJpegTransform losslessJpeg = new Aurigma.GraphicsMill.Codecs.LosslessJpegTransform(@"C:\1.jpg");
losslessJpeg.WriteCropped(@"c:\2.jpg", new System.Drawing.Rectangle(0,0,200,200));
losslessJpeg.Close();

or Crop method of Transforms class:
Code:

Aurigma.GraphicsMill.Bitmap bitmap = new Aurigma.GraphicsMill.Bitmap");
Aurigma.GraphicsMill.Codecs.JpegReader jpegReader = new Aurigma.GraphicsMill.Codecs.JpegReader(@"C:\1.jpg");
using (Aurigma.GraphicsMill.Codecs.IFrame frame = jpegReader.LoadFrame(0))
{
  frame.GetBitmap(bitmap);
}
bitmap.Transforms.Crop(new System.Drawing.Rectangle(0, 0, 200, 200));
Aurigma.GraphicsMill.Codecs.JpegEncoderOptions encoderOptions = new Aurigma.GraphicsMill.Codecs.JpegEncoderOptions(100, true);
bitmap.Save(@"C:\2.jpg", encoderOptions);

Best regards,
Dmitry Obukhov
Technical Support. Aurigma, Inc.
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.