CROPPING and SAVING Screen Graphics

General Computer Utilities
Posts: 56
Joined: Fri Jan 07, 2005 11:16 pm
Location: Currently living in Riverside, CA

CROPPING and SAVING Screen Graphics

Post by Welopez »

There have recently been several posts regarding taking a screen shot of the users display, then saving them as BMP images. I offer this small demo.

Last summer, my wife and I took a trip to Carmel by the Sea and, of course, took several pictures. The one I used for this demo was at the College of Sweets, where my wife was looking for some imported chocolates.

Included for this demo is one BMP image, him&her.bmp. It is loaded into the program and drawn to the screen. Then I used GETBMP to capture only her lovely face, and my not-so-lovely face, drawing them over the previous images to show you how it is done.

The images collected with GETBMP must be unloaded upon completion of the snippet, as must the background image.

The x and y coordinates tell the computer where to begin saving from the image, and the width and height coordinates tell the computer how much of the image to get.

The GETBMP images can be saved as separate images to disk, using the BMPSAVE commands. Simply un-rem those remarks from the program.

When playing around with your own images, remember to specify the correct size of the Window for Graphics, and the x y coordinates where drawing should begin.

When cropping only a portion, use the PLACE command to specify the starting point, and the width and height parameters to select your image. You may need to play around with these parameter several times, unless you have an eyeball calibrated in pixels.

Code: Select all



LOADBMP "couple", "him&her.bmp"

OPEN "Display" FOR GRAPHICS_nsb AS #d
PRINT #d, "trapclose [quit]"

PRINT #d, "PLACE 330 200"
PRINT #d, "DRAWBMP couple"
PRINT #d, "GETBMP her 225 100 125 135"
PRINT #d, "PLACE 20 20"
PRINT #d, "GETBMP him 350 40 125 135"
PRINT #d, "PLACE 20 200"

' If you wish to save the cropped images to the DefaultDir$
BMPSAVE "him", "him.bmp"
BMPSAVE "her", "her.bmp"

UNLOADBMP "couple"
You should save this code to a Project Folder, mine is named CropBMP. Download the attached background image, him&her.bmp and place it in the project folder. There is no need to load other images, they will be cropped from the background image.

I hope this will clear up some questions about background images and saving only a portion of the image.

Good luck to all!
You do not have the required permissions to view the files attached to this post.