Question

How to calculate Pixel position when zoom in or zoom out an image in c# ....

How to calculate Pixel position when zoom in or zoom out an image in c# . I have an application in c# that displayed image when I clicked with mouse at a point on the image it give the pixel value for that point (using e.x and e.y). now i zoom in or out the image. How to get the pixel of the same point in zoomed position on run time. (I don't want to click again at the same position after zoomed). zoom in by adding 0.2 to the current zoom and zoom out by subtracting 0.2 from the current zoom. Is there any procedure that give the correct pixel value on the original image?!

Homework Answers

Answer #1

Imports System.ComponentModel
Imports System.Drawing

'Public properties for the ZoomPictureBox
Partial Public Class ZoomPictureBox

   <Category("_ZoomPictureBox"), _
   Description("Enable dragging. Set to False if you implement other means of image scrolling.")> _
   Public Property EnableMouseDragging As Boolean
       Get
           Return _EnableMouseWheelDragging
       End Get
       Set(value As Boolean)
           _EnableMouseWheelDragging = value
       End Set
   End Property

   <Category("_ZoomPictureBox"), _
   Description("Enable mouse wheel zooming. Set to false e.g. if you control zooming with a TrackBar.")> _
   Public Property EnableMouseWheelZooming As Boolean
       Get
           Return _EnableMouseWheelZooming
       End Get
       Set(value As Boolean)
           _EnableMouseWheelZooming = True
       End Set
   End Property

   <Category("_ZoomPictureBox"), _
   Description("Image to display in the ZoomPictureBox.")> _
   Public Property Image() As Image
       Get
           Return _Image
       End Get
       Set(ByVal value As Image)
           _Image = value
           If value IsNot Nothing Then
               InitializeImage()
           Else
               _imageInitialized = False
           End If
       End Set
   End Property

<Browsable(False), _
Description("The bounding rectangle of the zoomed image relative to the control origin.")> _
Public ReadOnly Property ImageBounds() As Rectangle
Get
Return _ImageBounds
End Get
End Property

<Browsable(False), _
Description("Location of the top left corner of the zoomed image relative to the control origin.")> _
Public Property ImagePosition() As Point
Get
Return _ImageBounds.Location
End Get
Set(ByVal value As Point)
Me.Invalidate(_ImageBounds)
_ImageBounds.X = value.X
_ImageBounds.Y = value.Y
Me.Invalidate(_ImageBounds)
End Set
End Property

   <Category("_ZoomPictureBox"), _
Description("The maximum zoom magnification.")> _
Public Property MaximumZoomFactor As Double
       Get
           Return _MaximumZoomFactor
       End Get
       Set(value As Double)
           _MaximumZoomFactor = value
       End Set
   End Property

   <Category("_ZoomPictureBox"), _
   Description("Minimum height of the zoomed image in pixels.")> _
   Public Property MinimumImageHeight As Integer
       Get
           Return _MinimumImageHeight
       End Get
       Set(value As Integer)
           _MinimumImageHeight = value
       End Set
   End Property

   <Category("_ZoomPictureBox"), _
   Description("Minimum width of the zoomed image in pixels.")> _
   Public Property MinimumImageWidth As Integer
       Get
           Return _MinimumImageWidth
       End Get
       Set(value As Integer)
           _MinimumImageWidth = value
       End Set
   End Property

   <Category("_ZoomPictureBox"), _
   Description("Sets the responsiveness of zooming to the mouse wheel. Choose a lower value for faster zooming.")> _
   Public Property MouseWheelDivisor As Integer
       Get
           Return _MouseWheelDivisor
       End Get
       Set(value As Integer)
           _MouseWheelDivisor = value
       End Set
   End Property

   <Browsable(False), _
   Description("Linear size of the zoomed image as a fraction of that of the source Image.")> _
   Public Property ZoomFactor() As Double
       Get
           Return _ZoomFactor
       End Get
       Set(ByVal value As Double)
           _ZoomFactor = ValidateZoomFactor(value)
           If _imageInitialized Then
               Me.Invalidate(_ImageBounds)
               _ImageBounds = GetZoomedBounds()
               Me.Invalidate(_ImageBounds)
           End If
       End Set
   End Property

   <Category("_ZoomPictureBox"), _
DefaultValue(ZoomType.MousePosition), _
Description("Image zooming around the mouse position, image center or control center")> _
Public Property ZoomMode() As ZoomType
       Get
           Return _ZoomMode
       End Get
       Set(ByVal value As ZoomType)
           _ZoomMode = value
       End Set
   End Property

End Class

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
For this assignment, you will create a BPMN diagram to depict the business process to get...
For this assignment, you will create a BPMN diagram to depict the business process to get a home mortgage based on the following narrative. You can use either DrawIO or BizAgi to create the process drawing. For this process, you can assume that the loan is a refinance not a home purchase. There are some small differences in the process to refinance an existing mortgage than to get a new mortgage. In the following narrative, I'm explaining all of the...
I've posted this question like 3 times now and I can't seem to find someone that...
I've posted this question like 3 times now and I can't seem to find someone that is able to answer it. Please can someone help me code this? Thank you!! Programming Project #4 – Programmer Jones and the Temple of Gloom Part 1 The stack data structure plays a pivotal role in the design of computer games. Any algorithm that requires the user to retrace their steps is a perfect candidate for using a stack. In this simple game you...
Write a Python 3 program called “parse.py” using the template for a Python program that we...
Write a Python 3 program called “parse.py” using the template for a Python program that we covered in this module. Note: Use this mod7.txt input file. Name your output file “output.txt”. Build your program using a main function and at least one other function. Give your input and output file names as command line arguments. Your program will read the input file, and will output the following information to the output file as well as printing it to the screen:...
What is the first step in planning a presentation? Gather information Analyze the situation Practice Organize...
What is the first step in planning a presentation? Gather information Analyze the situation Practice Organize the information Select the right medium Flag this Question Question 21 pts Which of the following is one way you can be sure to speak slowly and distinctly to be better understood by an international audience? Repeat keywords and phrases Keep the message simple Communicate with body language Incorporate visual aids Articulate each word carefully Flag this Question Question 31 pts How do visuals...
what is the issue in Emaar case study ? (10marks) Emaar Properties specializes in creating value-added,...
what is the issue in Emaar case study ? (10marks) Emaar Properties specializes in creating value-added, master-planned communities that meet the full spectrum of lifestyle needs. Highlights include Downtown Dubai, the 500-acre mega-project including Burj Khalifa – the world’s tallest building, and The Dubai Mall—the world’s largest shopping and entertainment destination. Emaar is extending its expertise in developing master-planned communities internationally, and has established operations in the United Arab Emirates, Saudi Arabia, Syria, Jordan, Lebanon, Egypt, Morocco, India, Pakistan, Turkey,...
Homework Draw class diagrams for your HW4 - the Tetris Game shown below: Part 1: UML...
Homework Draw class diagrams for your HW4 - the Tetris Game shown below: Part 1: UML As a review, Here are some links to some explanations of UML diagrams if you need them. • https://courses.cs.washington.edu/courses/cse403/11sp/lectures/lecture08-uml1.pdf (Links to an external site.) • http://creately.com/blog/diagrams/class-diagram-relationships/ (Links to an external site.) • http://www.cs.bsu.edu/homepages/pvg/misc/uml/ (Links to an external site.) However you ended up creating the UML from HW4, your class diagram probably had some or all of these features: • Class variables: names, types, and...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...
Item 1 In the case below, the original source material is given along with a sample...
Item 1 In the case below, the original source material is given along with a sample of student work. Determine the type of plagiarism by clicking the appropriate radio button. Original Source Material Student Version There is a desperate need for theorists and researchers to generate and refine a new breed of learning-focused instructional design theoriesthat help educators and trainers to meet those needs, (i.e., that focus on learning and that foster development of initiative, teamwork, thinking skills, and diversity)....
Team 5 answer the questions What are 4 key things you learned about the topic from...
Team 5 answer the questions What are 4 key things you learned about the topic from reading their paper? How does the topic relate to you and your current or past job? Critique the paper in terms of the organization and quality. Incentive Systems             In this paper, we will focus primarily on financial rewards that companies use to attract, retain and motivate the brightest and most talented candidates in the labor market. By providing a reward system that...
Review the Robatelli's Pizzeria Case Study. Develop another internal controls system, but this time, in the...
Review the Robatelli's Pizzeria Case Study. Develop another internal controls system, but this time, in the purchases and fixed assets business areas. Prepare a 12- to 16-slide presentation describing the purchases and fixed assets business areas. Be sure to incorporate speaker notes as well as appropriate visuals, graphics, fonts, etc. Include any associated risk in these areas. Describe specific internal controls that include authorization of transactions, segregation of duties, adequate records and documentation, security of assets, and independent checks and...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT