Bitmap Handling

Skip to first unread message


Sep 16, 2014, 10:28:06 AM9/16/14


Trying to convert some simple graphics handling from VB6 and am being
driven into a homicidal fury.

In VB6 I'd do something like:
PictureBox.Picture = PictureBox.Image
to fix the image into the picture box, the code below does create the
image in the picture box but when I try to do anything such as
GetPixel it crashes because the picturebox (pBox) is apparently empty
even though I can clearly see the image.

So how the hell do I fix the image in a VB.NET picture box?

This just illustrates my problem, it should skip over the message box
but it doesn't

I'm sure this is very simple but it shows what I hate most about
VB.NET: The Help is completely useless unless you already know the
answer as it tells you everything in minute detail except the things
you actually need to know which it seems to ignore.


needs PictureBox called "pBox"

Dim Brsh As New SolidBrush(Color.Black)
Dim pntSig As Graphics = pBox.CreateGraphics()
Dim Captn As String = "Test Text xyz"
Dim fnt As Font
Dim btMap As Bitmap

fnt = New Font("Times New Roman", 28, FontStyle.Italic)
pBox.Width = CreateGraphics.MeasureString(Captn, fnt).Width + 16
pBox.Height = CreateGraphics.MeasureString(Captn, fnt).Height + 16
pntSig.DrawString(Captn, fnt, Brsh, 8, 8)
btMap = CType(pBox.Image, Bitmap)

If IsNothing(btMap) Then MsgBox("Failed")

Reply all
Reply to author
0 new messages