Displaying a PGM Picture Box on C++

PGM stands for "portable gray map," a grayscale image made up primarily of binary code and ASCII characters. PGM is a photo in its simplest form and is easily recognized by various programs. Display a PGM image in a C++ picture box by saving the image to your system and creating the picture box. Through a series of associations, you're able to create a C++ picture box and corresponding tooltip button that triggers the picture display.

Instructions

    • 1

      Bring up Visual Studio and select “File,” “New,” “Project,” and “Windows Form Application." Enter a name for the project in the “Name” field at the bottom of the screen. Click “Ok.” The “Forms” working area appears.

    • 2

      Enter “Picture Box” in the “Text” field located in the "Properties" box at the right side of the bottom of the screen. Select “Picture Box” from the list at the left of the screen to display a default picture box in the working area. Return to the "Properties" box at the screen's bottom right side and enter a size for the picture box in the “Size” field. Designate the border around the picture box by clicking on “Border Style” in the "Properties" box and selecting from the options provided in the drop-down menu.

    • 3

      Select “Button” from the list at the left of the screen to display a button beneath the picture box in the working area. Click and drag on the button to size and position it as desired. Enter any text to be displayed on the face of the button in the “Text” field located in the button properties dialog box at the bottom right of the screen.

    • 4

      Click on the working area just above or below the displayed button to view the code text editor. Select “Tooltip“ from the list at the left of the screen. Click just behind the open parenthesis at the end of the last code string. Right click and select “Tooltip 1” from the pop-up box. Right click and select “Active.” The “Active” designation is automatically placed in the code string. Space over one space and enter “=”, then space over one space and type “true” followed by a semicolon. Press "Return."

    • 5

      Right click and select “Tooltip 1,” right click and select “Set Tooltip,” right click and select “Picture box 1” to associate the tooltip with the picture box control. Space over one space and type open quote marks, “Image”, close quote marks, close parenthesis. Press “Return.”

    • 6

      Right click and select “Tooltip 1,” right click and select “Set Tooltip", right click and select “Button 1” to associate the tooltip and the button control text you’re about to enter. Space over one space and in quotes type: “Click to view an image” then type a close parenthesis. Press “Return.”

    • 7

      Click on the “Form 1 Design” tab at the top of the screen and select the “Open File Dialog” option in the list at the left of the screen. Return to the code text editor and place the cursor at the end of the last line of code. Right click and select “Open File Dialog 1,” right click and select “Show Dialog.” Type an open and close parenthesis followed by a semicolon. Press “Return.”

    • 8

      Right click and select “Picture Box 1,” right click and select “Load,” right click and select “Open File Dialog 1,” right click and select “File Name.” Type a close parenthesis followed by a semicolon. Press “Return.”

    • 9

      Select “Debug” at the top of the screen to double-check the coding. Fix any errors.

    • 10

      Switch back to the working area and view the picture box. Click on the button you created at the bottom of the picture box and bring up the system browse function. Select the PGM image you want to display in the picture box from the list of saved files. The picture is displayed in the picture box.

Related Searches:

References

Comments

Related Ads

Featured