locked
Urgent: Printing Images in scale RRS feed

  • Question

  • Okay,

    Simple, PrintDocument.PrintPage

    PrintPageEventArgs.Graphics

    Image (Bitmap);

    PageBounds are 0,0,152,100

    Image Size is 113,113

    If I use:

    e.Graphics.DrawImage(image, 0,0);

    it prints the precise scale, but it in the wrong location.  So far, everything I've done to "center" the image, prints the image WRONG.  Typically too big.

    I need to figure out what the DrawImage() is doing to turn that 113,113, into an image that is less than the e.PageBounds of 152,100;

    I would typically do: 

    X = ((pagewidth / 2) - (imagewidth / 2))
    Y = ((pageheight / 2) - (imageheight / 2))

    but since the "units" don't match the picture prints wrong.

    The "GraphicsUnit" of the e.Graphics is listed as Display, but the Image of course is listed as Pixels.  I'm assuming there is a difference in units.  I need to the conversion process to provide a Rectangle to DrawImage that centers the Image on the page in the appropriate (natural) scale (meaning I don't want to resize the image, just center it).

    Thanks

    Jaeden "Sifo Dyas" al'Raec Ruiner




    "Never Trust a computer. Your brain is smarter than any micro-chip."
    PS - Don't mark answers on other people's questions. There are such things as Vacations and Holidays which may reduce timely activity, and until the person asking the question can test your answer, it is not correct just because you think it is. Marking it correct for them often stops other people from even reading the question and possibly providing the real "correct" answer.

    Wednesday, April 8, 2015 9:55 PM

Answers

All replies

  • Please refer to this example.
    • Marked as answer by Fred Bao Saturday, April 25, 2015 9:46 AM
    Thursday, April 9, 2015 1:52 AM
    Answerer
  • Hello JaedenRuiner,

    If possible, you could post some images to show your exact issue

    >>I need to figure out what the DrawImage() is doing to turn that 113,113, into an image that is less than the e.PageBounds of 152,100;

    Since the .NET team opens the .NET resource, you could check the resource implemented for the DrawImage() method:

    http://referencesource.microsoft.com/#System.Drawing/commonui/System/Drawing/Graphics.cs,5333b3247c5d70a1

    Or you could check the link provided by cheong00.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, April 10, 2015 2:44 AM