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
NOMAINWIN
WindowWidth=660
WindowHeight=430
UpperLeftX=INT((DisplayWidth-WindowWidth)/2)
UpperLeftY=INT((DisplayHeight-WindowHeight)/2)
LOADBMP "couple", "him&her.bmp"
OPEN "Display" FOR GRAPHICS_nsb AS #d
PRINT #d, "trapclose [quit]"
PRINT #d, "DOWN"
PRINT #d, "PLACE 330 200"
PRINT #d, "DRAWBMP couple"
PRINT #d, "GETBMP her 225 100 125 135"
PRINT #d, "PLACE 20 20"
PRINT #d, "DRAWBMP her"
PRINT #d, "GETBMP him 350 40 125 135"
PRINT #d, "PLACE 20 200"
PRINT #d, "DRAWBMP him"
' If you wish to save the cropped images to the DefaultDir$
BMPSAVE "him", "him.bmp"
BMPSAVE "her", "her.bmp"
WAIT
[quit]
UNLOADBMP "couple"
UNLOADBMP "her"
UNLOADBMP "him"
CLOSE #d
END
I hope this will clear up some questions about background images and saving only a portion of the image.
Good luck to all!