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

Notification

Icon
Error

Options
Go to last post Go to first unread
Carlos  
#1 Posted : Wednesday, July 25, 2007 8:00:43 PM(UTC)
Carlos

Rank: Member

Groups: Member
Joined: 7/25/2007(UTC)
Posts: 3

Hi to all.

Is there any automatic way to crop the image when it's going to be printed so it'd fill the whole paper? In example, if we're going to print an image with an aspect ratio of 4:3 in a paper of 4x6" (10x15 cm), the ImageFitMode can fit the image to the paper so the whole image fits in the paper, appearing white margins because of the difference of aspect ratio. Is there any way to avoid this, so the image fills all the paper, cropping the parts of the image that don't fit in? The standard ImageFitMode.CropToFit doesn't suit us because we need the picture to be resized to fit in the paper.

This is a picture of an example:

UserPostedImage

Thanks for your time.

Alex Kon  
#2 Posted : Sunday, July 29, 2007 6:33:29 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups: Member
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hello Carlos,

Try to use ImageFitMode.ResizeToFill, I think that is what you need.

Carlos  
#3 Posted : Sunday, July 29, 2007 7:03:59 PM(UTC)
Carlos

Rank: Member

Groups: Member
Joined: 7/25/2007(UTC)
Posts: 3

Thanks, Alex, but the image posted in the example was made with ResizeToFill. What I want is to resize the picture (preserving the aspect ratio) so won't appear white bands at the sides. It's a crop fitting one side of the picture to the size of the paper and cutting out the parts that doesn't fits in.

Is there any way to make this when printing?

Thanks again.

Alex Kon  
#4 Posted : Monday, July 30, 2007 8:58:11 PM(UTC)
Alex Kon

Rank: Advanced Member

Groups: Member
Joined: 1/31/2005(UTC)
Posts: 458

Was thanked: 5 time(s) in 5 post(s)
Hello Carlos,

Yeap, it seems that we have some inconsistent behaviour with print modes. Here is small code snippet which produces the desired result. It prints image on the default printer without any margins.

Code:
private void button2_Click(object sender, EventArgs e)
{
	Aurigma.GraphicsMill.WinControls.ImagePrintDocument doc = new Aurigma.GraphicsMill.WinControls.ImagePrintDocument();
	doc.Source = new Aurigma.GraphicsMill.Bitmap(@"E:\Pictures\TestSamples\Jpeg\Large.jpg");
	doc.PlacementMode = Aurigma.GraphicsMill.WinControls.PlacementMode.SingleImage;
	doc.PrintOptions.ImageFitMode = Aurigma.GraphicsMill.WinControls.ImageFitMode.ResizeToFill;
	
	doc.QueryImage += new Aurigma.GraphicsMill.WinControls.QueryImageEventHandler(doc_QueryImage);

	doc.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0);
	doc.DefaultPageSettings.Landscape = false;
	
	doc.Print();
}

void doc_QueryImage(object sender, Aurigma.GraphicsMill.WinControls.QueryImageEventArgs e)
{
	Aurigma.GraphicsMill.WinControls.ImagePrintDocument doc = (Aurigma.GraphicsMill.WinControls.ImagePrintDocument)sender;

	e.PrintPlaceholder.Location = new Point(0, 0);
	e.PrintPlaceholder.Size = doc.DefaultPageSettings.Bounds.Size;	
}

Edited by user Monday, December 17, 2007 7:31:54 PM(UTC)  | Reason: Not specified

Carlos  
#5 Posted : Tuesday, July 31, 2007 8:21:00 PM(UTC)
Carlos

Rank: Member

Groups: Member
Joined: 7/25/2007(UTC)
Posts: 3

Thank you very much, Alex :)

This is exactly the effect I want.

Good bye and thanks again ;)

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.