0

I have a location validation app that accesses prefetched map images, and allows a user to compare the map with current photo of a house at high resolution. The prefetched static maps are larger and designed to show context of the neighborhood, not the selected house. The Picturebox properties are 513x406 and its location is 724x127. When I display the map, I want to specify a centered fixed magnification, and keep the display within the picturebox. Here is my code to do the displays. I have tried every combination of zoom and stretch without success. This most recent try simply increased the size of the picturebox.

    SnippetDisplayOut.Show()
    SnippetDisplayOut.SizeMode = PictureBoxSizeMode.CenterImage
    SnippetDisplayOut.SizeMode = PictureBoxSizeMode.Zoom
    SnippetDisplayOut.Image = Image.FromFile(RGB_Snippetname, True)

    MapDisplayOut.Image = image2

    MapDisplayOut.Show()
    MapDisplayOut.SizeMode = PictureBoxSizeMode.Zoom
    MapDisplayOut.Size = New Size(800, 800)

    Me.DoubleBuffered = True
    MapDisplayOut.SizeMode = PictureBoxSizeMode.CenterImage
    MapDisplayOut.Image = FromFile(MapFileName, True)
Rfrank
  • 51
  • 5
  • PictureBox doesn't have the properties you need. Still okay as the basic control you need, but you have to use its Paint event so you can use the Graphics.DrawImage() overload you want. – Hans Passant Apr 12 '21 at 22:16
  • 1
    If you can use or *understand* C#, see the methods shown here: [Zoom and translate an Image from the mouse location](https://stackoverflow.com/a/61964222/7444103). The method you need is `OffsetScaledRectangleOnMousePosition()` which is used to zoom an Image using a specific point as the center of the *magnification* (see the animation). Of course it's not necessarily the *Mouse position*, that's just a reference point, you can pass any position to the method. It *collaborates* with other simplified methods that handle the Image scale coefficient and perform other transformations. – Jimi Apr 12 '21 at 23:01

0 Answers0