Re: Problem Loading Image To Form Graphics Object -
09-23-2005
, 06:37 PM
Thanks for your reply.
Actually, that's what I tried originally. I pasted your code in just now and it's still giving me only a 3 square inch portion of the picture. It's like the graphics object has clipping bounds set automatically upon creation, and attempts to remove the clipping are so far ineffectual. The one thing that did change with your code is that the upper left corner of the picture now starts at the upper left corner of the form, but the picture is still clipped. And surprisingly, gr.Clip.MakeInfinite doesn't change that either.
"Michael Phillips, Jr." <mphillips53 (AT) nospam (DOT) jun0.c0m> wrote
DrawImage has many overloaded methods.
The one that you are using is saying start drawing the image
from the left corner (50,50) of your image to your form.
That is why it is cropped!
You want to draw the entire image. Try the following:
Dim rcSrc As new Rectangle ( 0, 0, img.Width, img.Height )
gr.DrawImage( img, rcSrc )
"Phil Galey" <pagaley (AT) starcalif (DOT) com.nospam> wrote
I'm trying to display a PNG on a form in my VB.NET application, but it will only display a cropped portion of the image. I'm using the following:
Dim gr As Graphics = Me.CreateGraphics
Dim img As Image = Bitmap.FromFile(<Path to PNG file>)
gr.DrawImage(img, CInt(50), CSng(50), CSng(img.Width), CSng(img.Height))
I've already found that the gr.SetClip is a dummy switch and ClipBounds is read-only. I also tried gr.Clip.MakeInfinite() and gr.Clip.MakeEmpty(), but again neither changed the observed clipping in any way.
Question:
How can I get the graphics object of the form to display the entire picture on the form, instead of only the top left 3 square inches of it?
Thanks. |