Announcement

Collapse
No announcement yet.

how to copy small parts of a GRAPHIC WINDOW?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to copy small parts of a GRAPHIC WINDOW?

    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.

    What is the best way to do this?

  • #2
    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.

    Comment


    • #3
      Originally posted by Bob Zale View Post
      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?

      Comment


      • #4
        That simply is not correct. You really just need to read the doc and try it.

        Comment


        • #5
          Originally posted by Bob Zale View Post
          That simply is not correct. You really just need to read the doc and try it.
          Been doing that for 90 minutes!

          Encouraged by your generous remarks, I will persevere.

          Comment


          • #6
            Ah, the penny has just dropped. The "selected graphic target" does not have to be the one you are currently staring at.

            Comment


            • #7
              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

              Comment


              • #8
                The "selected graphic target" does not have to be the one you are currently staring at.
                Not always. Always it has to be the current GRAPHIC ATTACHed, which could be a BITMAP in memory you will GRAPHIC COPY to.
                Rick Angell

                Comment


                • #9
                  As in:

                  Code:
                  #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

                  Comment

                  Working...
                  X