Kuo Kuo - 4 months ago 51
C++ Question

Zoom the picture within the picturebox of Visual Studio C++

I have a problem about zooming into the picture displayed in a picturebox

Picture Control
. The expected result is similar to the following link: A scrollable, zoomable, and scalable picture box. The picture is zoomed in within the picturebox. Note the picturebox is zoomed in.

However, this can be implemented in .NET Framework 2.0. I have searched some information on the Internet, but none used C/C++ Windows API of Visual Studio. How can I zoom a picture within a the picturebox
Picture Control
when I work on Windows Forms of Visual Studio C++ 2010. Thank you for anyone's reply.

Answer

Without any source code, it is difficult to comment. StackOverflow is for problem solving; we can troubleshoot your starting code and get it working and during the course of which we can also fine tune design.

Anyway, I would like to give some pointers:

  1. One or two picture boxes: entirely depends on your UI requirement.
  2. Showing full or partial region of an image: StretchBlt is a powerful API that can be used to achieve. See MSDN documentation for details.
  3. Which class to use for picture box: if MFC is being used, then derive a class from CStatic, overload the OnPaint() and use StretchBlt to paint the image.
  4. Classes to use for image: CBitmap, CImage, Gdiplus::Image.
    Each have their own pros and cons.
    If transparent images/PNGs are to be dealy with, better go for Gdiplus::Image. You can get enough info here:
    CBitmap
    CImage
    Gdiplus::Image

Hope this would give you some starter.