I have a jpeg file that I am displaying in my Vb.NET application using picture box control
I have the word coordinate position of all these words present in the jpeg file.
Right now I am using the pictirebox sizemode as stretch mode. I am able to highlight the word at the correct position as per the code snippet attached below.
But, as per a new requirement, I can no longer go with stretch mode of picturebox. I have to use the zoom mode.
How do I adjust the "rect" coordinates now so that it highlights the words in zoom mode. I have tried many ways to adjust the coordinates but no success.
I appreciate any help on this.
Thanks in advance
' READ target image file
Dim origImage As New Bitmap(imageFileName)
Dim targetimage As Bitmap = New Bitmap(origImage, origImage.Width , origImage.Height )
PictBox_Target_Height_Ratio = PictureBox1.Height / targetimage.Height
PictBox_Target_Width_Ratio = PictureBox1.Width / targetimage.Width
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
Dim highlightColor As Color = Color.FromArgb(196, 255, 255, 0)
Dim brush As New SolidBrush(highlightColor)
Dim rect As New Rectangle(iLeft * PictBox_Target_Width_Ratio, iTop * PictBox_Target_Height_Ratio, (iRight - iLeft) * PictBox_Target_Width_Ratio, (iBottom - iTop) * PictBox_Target_Height_Ratio)