Announcement

Collapse
No announcement yet.

Retrieve a bitmap but only part of it & save this part back to its place

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

  • Retrieve a bitmap but only part of it & save this part back to its place

    GRAPHIC (GET/SET) BITS (TO) Screen$ we all know from the help file ...

    Is there a handy way?

    Something like this
    GRAPHIC GET BITS(x&, y&, nWidth&, nHeight&) TO Screen$
    GRAPHIC SET BITS Screen$ TO (x&, y&, nWidth&, nHeight&)

    Thank you

  • #2
    No. But you can always use an intermediate bitmap

    '
    Code:
    GRAPHIC BITMAP NEW lWidth, lHeight TO hBmp2
    GRAPHIC ATTACH hBmp2,0
    GRAPHIC COPY hBMp1, 0, (lX,lY)-(lWidth, lHeight!) TO (0,0)
    GRAPHIC GET BITS hBmp2 TO sBits
    '.... Do something with the bits
    GRAPHIC SET BITS sBits TO hBmp2
    GRAPHIC ATTACH hBmp1
    GRAPHIC COPY hBMp2, 0, TO (lX,lY)
    'cleanup
    GRAPHIC ATTACH hBmp2
    GRAPHIC END hBmp2
    GRAPHIC ATTACH hBmp1
    '

    Comment


    • #3
      PBCC only

      GRAPHIC GET BITS(x&, y&, nWidth&, nHeight&) TO Screen$

      But in the meantime the screen change and I want to return only the stored part ...

      GRAPHIC SET BITS Screen$ TO (x&, y&, nWidth&, nHeight&)

      Do I have to do it through Bitmap New or can it be directly through the screen buffer?

      thanks for all

      Comment


      • #4
        Originally posted by Denis Gura View Post
        PBCC only

        GRAPHIC GET BITS(x&, y&, nWidth&, nHeight&) TO Screen$

        But in the meantime the screen change and I want to return only the stored part ...

        GRAPHIC SET BITS Screen$ TO (x&, y&, nWidth&, nHeight&)

        Do I have to do it through Bitmap New or can it be directly through the screen buffer?
        It doesn't matter whether you are working in PBCC or PBWIn.
        GRAPHIC GET/SET BITS work on whole bitmaps (not sections of a bitmap)

        But more importanly, neither the visible console screen nor the screen buffer (virtual screen) in a console application are bitmaps - they are not any type of graphic/image!
        You can't use any GRAPHIC statements with them.


        Comment


        • #5
          Are you sure directly manipulating bits (code not shown BTW) is the simplest way to do whatever it is you want to do?

          The GRAPHICS statements in PB/CC and PB/WIN provide a lot of tools. (Which some members - not me - use to produce some really cool effects)

          Why don't you describe - in English - what you are trying to accomplish?
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            Stu wrote > work on whole bitmaps - and "whole" is my problem, i mean only selected part to save / restore.

            Stuart, I also know that GRAPHICS statements works with GRAPHIC window not console ... (with console it is easier and quicker)

            I thought another syntax with PBCC and with PBWIN but I have overcome it. (GRAPHIC GET BITS to sBits vs GRAPHIC GET BITS hBmp2 TO sBits)

            Michael,

            simple steps

            something is in the window

            1) GRAPHIC GET BITS(x&, y&, nWidth&, nHeight&) TO Screen$ (my wish)
            .
            3) The window has changed its content !!!
            .
            5) GRAPHIC SET BITS Screen$ TO (x&, y&, nWidth&, nHeight&) (my wish)

            And to restore NOT the whole window(old content before step 3) only a part (after step 3 with stored part).

            thank you all

            Comment


            • #7
              Use GRAPHIC GET BITS to put whole graphic in string (DIB)
              Make 2 dimensional array, first 2 LONGs are X + 1 and Y + (if 0 based indexes)
              Make second DIB with new size and range of Xs and Ys
              GRAPHIC SET BITS with second DIB

              Cheers,
              Dale

              Comment


              • #8
                Forget about GRAPHIC SET/GET BITS. Just use GRAPHIC COPY to a memory bitmap (GRAPHIC BITMAP NEW w,h to tempbmp) and copy it back later when you need it, destroying the bitmap after you're done with it. Very much as Stuart provided in post # 2 but without the GRAPHIC SET/GET BITS.
                Rod
                In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

                Comment


                • #9
                  ...simple steps . The window has changed its content !!!
                  I must be missing something. If you change the contents of the window using any GDI drawing technique, Windows will repaint it (assuming your program is written correctly). And repainting only part of a window is something Windows automatically does, only repainting what needs repainting UNLESS THE PROGRAMMER TELLS IT TO REPAINT 'ALL'

                  BTW, Rodney is dead on right. Just use GRAPHIC COPY.

                  Oops..... something just occurred to me... are you trying to change the screen of another program?

                  PS: You could always show relevant code.
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment


                  • #10
                    Denis

                    See this code which you can adjust window coordinates to capture a portion of the window and then save this portion to the disk or to clipboard
                    https://forum.powerbasic.com/forum/u...678#post544678

                    Comment


                    • #11
                      Anne Thanks.

                      or this even from Bob

                      https://forum.powerbasic.com/forum/u...graphic-window

                      Comment

                      Working...
                      X