Click here to Skip to main content
15,748,330 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am converting a VB6 program to VB.NET. This program takes sign data from graphics programs and displays the sign in a picturebox and allow the user to select the different points around the Letters in the sign. I am drawing the sign but when I try and locate the points is where I am having a problem. Since the sign is drawn upside down and then flipped the points are not where I am clicking on the picture box. Can you provide any help so that when I click on a point on the letter the x and y are the same as what was loaded.

BillWoodruff 21-Dec-13 19:04pm    
Why not ... for the purpose of allowing the user to pick the points on the graphic content ... display the bitmap un-rotated, and un-flipped ?
jmbooher 25-Dec-13 9:50am    
If I did that the sign would then be presented to the customer upside down. This is software that operates a machine and the customer needs to be able to select a starting and ending point for each letter in the sign.

Assuming the image you have to work with is rotated on both x- and y- axes ... in other words, it's a "mirror image."

In C#: Button 'btnFlipXY, and PictureBox 'pbxImage on a Form. PictureBox 'SizeMode Property set to 'AutoSize
// required
using System.Drawing;

// Click EventHandler for 'btnFlipXY
private void btnFlipXY_Click(object sender, EventArgs e)
   Bitmap theImage = pbxImage.Image as Bitmap;
   pbxImage.Image = theImage;
Click the Button once and select the Points, and store the Points in whatever data-structure you've chosen. Click a second time, and the image is restored to its original orientation.

In VB.NET WinForms:
Private Sub btnFlipXY_Click(sender As Object, e As EventArgs) Handles btnFlipXY.Click

    Dim theImage
    theImage = pbxImage.Image

    pbxImage.Image = theImage

End Sub
This is the first time I have ever coded in VB, so I don't know why a conversion of the PictureBox.Image to Type 'Bitmap is not required in VB. A quick search on the web suggests this declaration would be better:
Dim theImage As New Bitmap(pbxImage.Image)
Share this answer
Sergey Alexandrovich Kryukov 22-Dec-13 0:24am    
5ed. I added my 5 cents and credited this answer.
First of all, please see my recent answer which should convince you not to use PictureBox: add elements on existing bitmap[^].

And to Solution 1 by Bill explains you what you can do with a bitmap. Of course, you can do a lot more. :-)

Share this answer
To rotate Image use this code on a button_click event:
pictureBox1 .Image.RotateFlip(RotateFlipType.Rotate90FlipNone)
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900