You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
Looking at the new GRAPHIC WINDOW stuff, I can copy a bitmap into the GW at a specified location using GRAPHIC COPY, but there is no complementary high-level way of exporting part (say a 50x50 rectangle) of the current GW to a bitmap.
You can do that using the GRAPHIC COPY statement. There are 3 syntax options available, the third is the one to use. The help file says:
You can copy a complete bitmap, or a portion of it, to the selected graphic target.
Right, but to stick with high-level GRAPHIC commands, one would have to pull out the bitmap for the whole GRAPHIC WINDOW - potentially huge - just to get the 50x50 portion of it?
Just in case anyone else was baffled by this problem:
Code:
#COMPILE EXE
#DIM ALL
FUNCTION PBMAIN () AS LONG
LOCAL hwina, hwTemp AS DWORD
LOCAL skey AS STRING
' create a GW and fill it with a hatch pattern
GRAPHIC WINDOW "", 200, 200, 400, 400 TO hwina
GRAPHIC ATTACH hwina, 0
GRAPHIC BOX (0,0) - (400,400), 0, -1, 0, 4
skey = ""
' create a temporary GW just big enough to hold the area to be copied
' but invisible
GRAPHIC WINDOW "", -100, -100, 50, 50 TO hwTemp
GRAPHIC ATTACH hwTemp, 0
' copy the area to the smaller GW
GRAPHIC COPY hwina, 0, (0,0) - (50, 50) TO (0, 0)
' reconnect to the big GW
GRAPHIC ATTACH hwina, 0
' reverse the hatching so the copied area will show up
GRAPHIC BOX (0,0) - (400,400), 0, -1, 0, 3
' copy it
GRAPHIC COPY hwTemp, 0, (0,0) - (50, 50) TO (300, 300)
' delete the smaller GW
GRAPHIC ATTACH hwTemp, 0
GRAPHIC WINDOW END
WHILE skey <> $ESC
GRAPHIC INKEY$ TO skey
WEND
END FUNCTION
#COMPILE EXE
#DIM ALL
FUNCTION PBMAIN () AS LONG
LOCAL hwina, hwTempBMP AS DWORD
LOCAL skey AS STRING
' create a GW and fill it with a hatch pattern
GRAPHIC WINDOW "", 200, 200, 400, 400 TO hwina
GRAPHIC ATTACH hwina, 0
GRAPHIC BOX (0,0) - (400,400), 0, -1, 0, 4
skey = ""
' create a temporary GW just big enough to hold the area to be copied
' but invisible
GRAPHIC BITMAP NEW 50, 50 TO hwTempBMP
GRAPHIC ATTACH hwTempBMP, 0
' copy the area to the smaller GW
GRAPHIC COPY hwina, 0, (0,0) - (50, 50) TO (0, 0)
' reconnect to the big GW
GRAPHIC ATTACH hwina, 0
' reverse the hatching so the copied area will show up
GRAPHIC BOX (0,0) - (400,400), 0, -1, 0, 3
' copy it
GRAPHIC COPY hwTempBMP, 0, (0,0) - (50, 50) TO (300, 300)
' delete the smaller GW
GRAPHIC ATTACH hwTempBMP, 0
GRAPHIC BITMAP END
WHILE skey <> $ESC
GRAPHIC INKEY$ TO skey
WEND
END FUNCTION
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment