Resizing a PictureBox bitmap

A

active

Problem: The PictureBox display appears to have the image cut off. I.e.,
the image bottom does not display although the PictureBox has room for it.

It occurred to me that what was displayed was the same size as the
PictureBox was before it was resized. So I figured the bitmap was too small
and tried to increase it's size as shown below.

Two things: First it didn't fix the problem.

Secondly, I'm not sure I've done it correctly and further don't know to
finish the code (see the commented out code.

Any helpful suggestions would be appreciated:

Cal

PS The image was created by drawing strings.





Private Sub picData_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles picData.Resize

If Not ((g1 Is Nothing) Or (b1 Is Nothing)) Then

Dim g2 As Drawing.Graphics = picData.CreateGraphics

Dim b2 As Drawing.Bitmap = New Drawing.Bitmap(picData.Width, picData.Height,
g2)

g2.DrawImage(b2, 0, 0)

'g1.Dispose()

'b1.Dispose()

'g1 = g2

'b1 = b2

End If

End Sub
 
J

Josh Moody [MSFT]

I think what you want to do is instead of using a graphics object, just use
the picture box itself.

for example, do "PictureBox1.Image = b2" instead of trying to set the
graphics object itself. You shouldn't even have to do any resize events
then either, because the picturebox will handle all of that.

HTH

Josh Moody
VSU Team

--

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
--------------------
 
A

active

I use a graphics object to draw on a bitmap so that I can do
e.Graphics.DrawImage(b1, 0, 0)

in the pictutebox paint event. I believe I need to store the image
someplace for paint. The user draws the image (think Photoshop) so I can't
recreate it at will.

I don't have a good knowledge of this so I wonder if with the above, do you
still think I could do as you suggest??

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top