[Help]PictureBox Frame [Solved]

Posts 1–13 of 13 · Page 1 of 1
[Help]PictureBox Frame [Solved]
I have a picture in a picturebox. How do i draw a red border around it. Like a frame or something.
Use the square option? Its in toolbox, at the bottom
In shapes.
There should be line, ellipse and square i think.
ilikewater is correct. let me know if that doesnt work, i have a code based way
if ilikewater solution doesn't work, use this: (this is C#, sry i dont know VB )

Code:
Bitmap bitmap = (Bitmap)pictureBox.Image;

for (int x = 0; x < bitmap.Width; x += 1) // horizontal lines
{
     bitmap.SetPixel(x, 0, Color.Red); // top line
     bitmap.SetPixel(x, bitmap.Height - 1, Color.Red); // bottom line
}
for (int y = 0; y < bitmap.Height; y += 1) // vertical lines
{
     bitmap.SetPixel(0, y, Color.Red); // left line
     bitmap.SetPixel(bitmap.Width - 1, y, Color.Red); // right line
}

pictureBox.Image = (Image)bitmap;
this will change the border lines of the Picture Box image to red.
Quote Originally Posted by kilert View Post
if ilikewater solution doesn't work, use this: (this is C#, sry i dont know VB )

Code:
Bitmap bitmap = (Bitmap)pictureBox.Image;

for (int x = 0; x < bitmap.Width; x += 1) // horizontal lines
{
     bitmap.SetPixel(x, 0, Color.Red); // top line
     bitmap.SetPixel(x, bitmap.Height - 1, Color.Red); // bottom line
}
for (int y = 0; y < bitmap.Height; y += 1) // vertical lines
{
     bitmap.SetPixel(0, y, Color.Red); // left line
     bitmap.SetPixel(bitmap.Width - 1, y, Color.Red); // right line
}

pictureBox.Image = (Image)bitmap;
this will change the border lines of the Picture Box image to red.
Code:
Dim bitmap As Bitmap = DirectCast(pictureBox.Image, Bitmap)
For x As Integer = 0 To bitmap.Width - 1
    ' horizontal lines
    bitmap.SetPixel(x, 0, Color.Red)
    ' top line
        ' bottom line
    bitmap.SetPixel(x, bitmap.Height - 1, Color.Red)
Next
For y As Integer = 0 To bitmap.Height - 1
    ' vertical lines
    bitmap.SetPixel(0, y, Color.Red)
    ' left line
        ' right line
    bitmap.SetPixel(bitmap.Width - 1, y, Color.Red)
Next
pictureBox.Image = DirectCast(bitmap, Image)
Quote Originally Posted by Blubb1337 View Post
Code:
Dim bitmap As Bitmap = DirectCast(pictureBox.Image, Bitmap)
For x As Integer = 0 To bitmap.Width - 1
    ' horizontal lines
    bitmap.SetPixel(x, 0, Color.Red)
    ' top line
        ' bottom line
    bitmap.SetPixel(x, bitmap.Height - 1, Color.Red)
Next
For y As Integer = 0 To bitmap.Height - 1
    ' vertical lines
    bitmap.SetPixel(0, y, Color.Red)
    ' left line
        ' right line
    bitmap.SetPixel(bitmap.Width - 1, y, Color.Red)
Next
pictureBox.Image = DirectCast(bitmap, Image)
YaY C to VB converter
Quote Originally Posted by NextGen1 View Post


YaY C to VB converter
Quote Originally Posted by kilert View Post
if ilikewater solution doesn't work, use this: (this is C#, sry i dont know VB )

Code:
Bitmap bitmap = (Bitmap)pictureBox.Image;

for (int x = 0; x < bitmap.Width; x += 1) // horizontal lines
{
     bitmap.SetPixel(x, 0, Color.Red); // top line
     bitmap.SetPixel(x, bitmap.Height - 1, Color.Red); // bottom line
}
for (int y = 0; y < bitmap.Height; y += 1) // vertical lines
{
     bitmap.SetPixel(0, y, Color.Red); // left line
     bitmap.SetPixel(bitmap.Width - 1, y, Color.Red); // right line
}

pictureBox.Image = (Image)bitmap;
this will change the border lines of the Picture Box image to red.
i get *********ence exception.
Object reference not set to an instance of an object.
Do it manually with paint.net or photoshop.
Huh? Do you know what we're talking about??
Quote Originally Posted by Invidus View Post
Huh? Do you know what we're talking about??
Nope, I'm VB newbie.
So... what event did you put this code under??
nvm. i fixed it.

i placed a picturebox into another picturebox and change the backcolor of the second picturebox. works fine.
Posts 1–13 of 13 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us