Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with image in Graphics.DrawImage

Status
Not open for further replies.

johnc83

Technical User
Jan 29, 2008
154
GB
Hi all,

I ma having troubling displaying images using PrintDocument. The images are originally big but I can't seem to resize them without distorting the image,

Does anyone know how I can add it and reduce the size by a percentage or something like that rather than by width and height.

He is an example of my code:

Code:
 Dim MyLogo As Image = Global.My_App.My.Resources.Resources.MyLogo
        e.Graphics.DrawImage(MyLogo, 50, 35, 88, 73)

Hope somone can help pls..

Thanks
John

.NET 2.0, Visual Studio 2005, SQL Server 2005 Express
 
I would suggest to use the width and height of the image and use a percentage to calculate the new width and height.

Say you want to shrink it 75 percent.

w=100
h=150

new_w=w-(w*.75)

new_h=h-(h*.75)

Note that you need to ensure the graphics unit on both are the same, The image could be in twips and the page in inches.
 
Thanks for the reply Zarkon,

the graphics.drawimage method only allows integers for resizing so the percentage may not have worked.

Looking on screen it seemed poor quality but now I have actually printed it off it seems not too bad so I think I'll just leave as is.

Thanks anyway

John

.NET 2.0, Visual Studio 2005, SQL Server 2005 Express
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top