Announcement

Collapse
No announcement yet.

PB Bitmap to Windows DIB

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

  • PB Bitmap to Windows DIB

    I have recently learned that the PB bitmap format can not be passed between applications and DLLs. Does anyone know how to convert a PB bitmap to a Windows DIB and Windows DIB to PB Bitmap. I need to pass the in memory image between applications and DLLs. I would like some sample code that does this.

    Thanks

  • #2
    > need to pass the in memory image between applications and DLLs

    Passing data to a function located in a DLL within the same process is one thing, and fairly easliy accomplished, as a handle obtained by LoadImage() is valid anywhere within the process. However, if the GRAPHICS functions you are using (code not shown) work the same as do the rest of the "DDT family" functions, they are not useable except within the module in which the object was created.

    Passing a memory image between processes is a bit trickier. Assuming a cooperating process, it might be easiest to just pass a memory handle, or perhaps the name of a memory object and the cooperating program can then just manipulate the image data itself.

    If not a cooperating program, your best bet is probably to go back to the drawing board and see if you can find that Post-it(r) note on which you jotted down 'Plan B.'

    That said, I know there is code here to "Create DIB from bitmap handle" and vice-versa. try a full-text search on "CreateDIBSection" if 'subject' searches prove fruitless.
    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      It has been a couple of years or so since I needed to work with DIBS and PB Graphics. However, the key is to get the DC to the PB Graphics and go from there. In the forum there were quite a few posts on working with PB Graphics and DIBS after the PB Graphics were added. The code here, just illustrates a couple of DIB API's working with PB Graphics. It was a timing exercise, but the DIB principles are shown.

      Code:
      #COMPILER PBCC
      #COMPILE EXE
      #DIM ALL
      #CONSOLE OFF
      
      #INCLUDE "Win32API.inc"
      'DIBInfo() as BITMAPINFOHEADER
      %NUL = 0
      FUNCTION PBMAIN () AS LONG
          LOCAL hGW,hDC,hBM AS DWORD
          LOCAL MemStart AS DWORD
          DIM DI AS BITMAPINFO
          LOCAL lresult&,x&,bitvar$
          DIM qTime(1 TO 5)AS QUAD
      
      QueryPerformanceFrequency(qTime(5))
          GRAPHIC WINDOW "DIB-BITTY-DOO",250,250,480,480 TO hGW
          GRAPHIC ATTACH hGW, 0, REDRAW
          GRAPHIC FONT "Arial",10,1
          GRAPHIC GET DC TO hDC
          hBM =  GetCurrentObject(hDC, %OBJ_BITMAP)
          GRAPHIC COLOR %BLACK, %GREEN
          GRAPHIC CLEAR
          GRAPHIC REDRAW
          GRAPHIC SET POS (10, 10)
          GRAPHIC PRINT "This is the starting display, timing begins shortly ..."
          MemStart = GlobalUnlock(hDC)
          MemStart = GetLastError
          GRAPHIC SET POS (400, 10)
          GRAPHIC PRINT FORMAT$(MemStart)        '87 ???
          MemStart = GlobalLock(hDC)             '
          GRAPHIC SET POS (430, 10)
          GRAPHIC PRINT FORMAT$(MemStart)
          GRAPHIC REDRAW
      QueryPerformanceCounter(qTime(1))
          x& = 480 * 480
          DIM MyDIB(x&) AS DWORD 'will contain the pixel color data for the scanned lines
          'MS says: set first 6 members of BITMAPINFOHEADER before calling GetDIBits
          DI.bmiHeader.biSize = SIZEOF(BITMAPINFOHEADER)
          DI.bmiHeader.biWidth    = 480
          DI.bmiHeader.biHeight   = - 480
          DI.bmiHeader.biPlanes   = 1
          DI.bmiHeader.biBitCount = 32
          DI.bmiHeader.biCompression = %BI_RGB
          'Make the call
          lresult&   = GetDIBits(hDC,hBM,1,480,BYVAL VARPTR(MyDIB(1)),DI,%DIB_RGB_COLORS)
      QueryPerformanceCounter(qTime(2))
          'change the color to see the effect of writing back.
          GRAPHIC CLEAR %BLACK
          GRAPHIC COLOR %GREEN , %BLACK
          GRAPHIC SET POS (10,100)
          GRAPHIC PRINT  "Scan lines copied : "+ FORMAT$(lresult&)
          GRAPHIC REDRAW
          'write from a buffer to the bitmap
      QueryPerformanceCounter(qTime(3))
          lresult& = SetDIBits(hDC,hBM,1,480,BYVAL VARPTR(MyDIB(1)),DI,%DIB_RGB_COLORS)
          GRAPHIC REDRAW
      QueryPerformanceCounter(qTime(4))
          GRAPHIC SET POS  (10, 400)
          GRAPHIC PRINT  "Time for setup and call GetDIBits, sec = "+FORMAT$((qTime(2)-qTime(1))/qTime(5),"0.000000")
          GRAPHIC SET POS  (10, 430)
          GRAPHIC PRINT  "Time for setup and call SetDIBits, sec = "+FORMAT$((qTime(4)-qTime(3))/qTime(5),"0.000000")
          GRAPHIC REDRAW
      QueryPerformanceCounter(qTime(1))
          GRAPHIC GET BITS TO bitvar$
      QueryPerformanceCounter(qTime(2))
          GRAPHIC SET BITS bitvar$
      QueryPerformanceCounter(qTime(3))
          GRAPHIC SET POS  (10, 30)
          GRAPHIC PRINT  "Time for GRAPHIC GET BITS TO bitvar$, sec = "+FORMAT$((qTime(2)-qTime(1))/qTime(5),"0.000000")
          GRAPHIC SET POS  (10, 50)
          GRAPHIC PRINT  "Time for GRAPHIC SET BITS bitvar$, sec = "+FORMAT$((qTime(3)-qTime(2))/qTime(5),"0.000000")
          GRAPHIC REDRAW
          SLEEP 5000
          GRAPHIC WINDOW END
      END FUNCTION
      links with potentially more info, ideas and discussion:
      http://www.powerbasic.com/support/fo...ML/011437.html
      http://www.powerbasic.com/support/fo...ML/003104.html

      I know I have some more code where I had to work with DIB sections, etc. and PB Graphics, but at this moment have other matters pressing. I'll see if I can find some other examples later.
      Rick Angell

      Comment


      • #4
        MCM,
        Would your example of passing data between applications work? (Or was that only with applications you create yourself??)

        Just a thought...

        But like you said, the applications have to cooperative....if they are not, then there is a LOTTTTT to be worked out...if anything can work
        Engineer's Motto: If it aint broke take it apart and fix it

        "If at 1st you don't succeed... call it version 1.0"

        "Half of Programming is coding"....."The other 90% is DEBUGGING"

        "Document my code????" .... "WHYYY??? do you think they call it CODE? "

        Comment


        • #5
          Passing Data

          What I mean is is I load a BMP form a file with my application and I have a DLL that lets say does a Gausian Noise Filter on the BMP. I would expect to pass the BMP handle to the DLL so that the DLL and do the filter on the BMP and return a new handle for the new filtered BMP. With the way PB handles BMP the DLL will never get the BMP to filter. I will get a handle to nothing.

          Comment


          • #6
            Would your example of passing data between applications work? (Or was that only with applications you create yourself??)
            Huh?

            Of course it works, given cooperating applications!!

            Either you create the applications to cooperate, or someone else does.

            When applications are not cooperating, see my note above re "Plan B."

            MCM
            Michael Mattias
            Tal Systems (retired)
            Port Washington WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              What I mean is is I load a BMP form a file with my application and I have a DLL that lets say does a Gausian Noise Filter on the BMP. I would expect to pass the BMP handle to the DLL so that the DLL and do the filter on the BMP and return a new handle for the new filtered BMP. With the way PB handles BMP the DLL will never get the BMP to filter. I will get a handle to nothing.
              Then eschew the help offered by GRAPHICS BITMAP LOAD and use the LoadImage() function to obtain the handle.

              DDT giveth (ease of use) and DDT taketh away (handles usable only in module in which obtained unless otherwise documented; DDT operations against any object only valid in module in which handle was obtained).

              MCM
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment


              • #8
                Ease of use is nice. However when there is no way to do somthing that the language was clearly designed to do (i.e. Write DLLs). Then ease of use in not useful at the cost of fucntonality

                Comment


                • #9
                  Mark,

                  What compiler are you using?

                  Do you have code to show what you were trying to do?

                  Since the DLL is in the same memory space as your program, I 'd suspect you are leaving out something that would easily do the job you seek. If we are really talking about a loaded BMP, not the control/window handle where aa BMP is displayed ... which some have tried to use, then how are you accessing it. I.E. some code please. Have you perhaps thought about using GRAPHIC GET BITS, send to the DLL then GRAPHIC SET BITS to create your second BMP in the first place, then mod it and GRAPHIC GET BITS to send back? I'm a bit skeptical of not being able to use the BMP handle and DIB sections, as this has been done before.
                  Last edited by Richard Angell; 30 Sep 2008, 11:27 AM.
                  Rick Angell

                  Comment


                  • #10
                    >Then ease of use in not useful at the cost of fucntonality

                    Using your favorite search engine, enter: "Lunch" + "Free" + "No Such Thing"
                    Michael Mattias
                    Tal Systems (retired)
                    Port Washington WI USA
                    [email protected]
                    http://www.talsystems.com

                    Comment


                    • #11
                      Here's an illustration of the GRAPHICS GET/SET BITS for passing with a PB DLL and a PB EXE

                      DLL Code:

                      Code:
                      #COMPILE DLL "BMP_Processor.dll"
                      #DIM ALL
                      %USEMACROS = 1
                      #INCLUDE "Win32API.inc"
                      
                      GLOBAL ghInstance AS DWORD
                          
                      '-------------------------------------------------------------------------------
                      FUNCTION LIBMAIN (BYVAL hInstance   AS LONG, _
                                        BYVAL fwdReason   AS LONG, _
                                        BYVAL lpvReserved AS LONG) AS LONG
                      
                          SELECT CASE fwdReason
                      
                          CASE %DLL_PROCESS_ATTACH
                              ghInstance = hInstance
                              FUNCTION = 1   'success!
                          CASE %DLL_PROCESS_DETACH
                              FUNCTION = 1   'success!
                          CASE %DLL_THREAD_ATTACH
                              FUNCTION = 1   'success!
                          CASE %DLL_THREAD_DETACH
                              FUNCTION = 1   'success!
                          END SELECT
                      END FUNCTION
                      '------------------------------------------------------------------------------
                      FUNCTION FetchAndMark ALIAS "FetchAndMark" (BYREF sBMP1 AS STRING,BYREF sBMP2 AS STRING,BYVAL nWidth1 AS LONG,BYVAL nHeight1 AS LONG) EXPORT AS LONG
                          LOCAL hBmp2,hGWin AS DWORD
                          GRAPHIC BITMAP NEW nWidth1, nHeight1 TO hBmp2
                          GRAPHIC ATTACH hBMP2,0,REDRAW
                          GRAPHIC COLOR %WHITE,%WHITE
                          GRAPHIC CLEAR
                          GRAPHIC SET BITS sBMP1
                          'do the real work here....but for the demo just draw something ...
                          GRAPHIC ELLIPSE (1, 50) - (300, 300),%BLUE,%RED,6
                          GRAPHIC REDRAW
                          'get the string top pass back, could be only one string in/out as well
                          GRAPHIC GET BITS TO sBMP2
                          ' show the "proof"
                          GRAPHIC WINDOW "DLL View",100,100, nWidth1+20, nHeight1+20 TO hGWin
                          GRAPHIC ATTACH hGWin,0,REDRAW
                          GRAPHIC COLOR %WHITE,%WHITE
                          GRAPHIC CLEAR
                          GRAPHIC COPY hBMP2,0 TO (1,1),0
                          GRAPHIC REDRAW
                          SLEEP 2000
                          GRAPHIC WINDOW END
                          GRAPHIC ATTACH hBMP2,0
                          GRAPHIC BITMAP END
                          FUNCTION = LEN(sBMP2)
                      END FUNCTION
                      Exe Code:

                      Code:
                      #COMPILE EXE
                      #DIM ALL
                      #INCLUDE "Win32API.INC"
                      
                      DECLARE FUNCTION FetchAndMark LIB "BMP_Processor.dll" ALIAS "FetchAndMark" (BYREF sBMP1 AS STRING, _
                                                                                             BYREF sBMP2 AS STRING, _
                                                                                             BYVAL nWidth1 AS LONG, _
                                                                                             BYVAL nHeight1 AS LONG) AS LONG
                      FUNCTION PBMAIN () AS LONG
                          LOCAL hBmp,hBM,hGWin AS DWORD
                          LOCAL sBmp1,sBmp2 AS STRING
                          LOCAL hDC AS LONG
                          LOCAL nWidth&, nHeight&,result&
                          nWidth& = 640
                          nHeight& = 480
                          GRAPHIC BITMAP NEW nWidth&, nHeight& TO hBmp
                          GRAPHIC ATTACH hBmp,0,REDRAW
                          GRAPHIC COLOR %GREEN,%CYAN
                          GRAPHIC CLEAR
                          GRAPHIC ELLIPSE  (1, 1) - (600, 300),%BLACK,%RED,0
                          GRAPHIC ELLIPSE  (1, 100) - (600, 400),%GREEN,%RED,6
                          GRAPHIC REDRAW
                          GRAPHIC GET BITS TO sBmp1
                          'do a window to see the before
                          GRAPHIC WINDOW "EXE View",400,400, 700, 500 TO hGWin
                          GRAPHIC ATTACH hGWin,0,REDRAW
                          GRAPHIC COLOR %WHITE,%WHITE
                          GRAPHIC CLEAR
                          GRAPHIC COPY hBmp,0 TO (1,1)
                          GRAPHIC REDRAW
                      
                          result& = FetchAndMark(sBmp1,sBmp2,nWidth&, nHeight&)
                          SLEEP 1000
                          
                          GRAPHIC ATTACH hBmp,0,REDRAW
                          GRAPHIC CLEAR
                          GRAPHIC SET BITS sBmp2      'just verifying, but could put in second bmp
                          GRAPHIC REDRAW
                          
                          GRAPHIC ATTACH hGWin,0,REDRAW
                          GRAPHIC CLEAR
                          GRAPHIC COPY hBmp,0 TO (1,1)
                          GRAPHIC REDRAW
                          SLEEP 2000
                          GRAPHIC WINDOW END
                          GRAPHIC ATTACH hBmp,0
                          GRAPHIC BITMAP END
                      END FUNCTION
                      Rick Angell

                      Comment


                      • #12
                        Richard, Thanks but I already know how to do that the problem is that it may not be a PB application calling my DLL so I need to pass a real windows DIB.

                        Comment


                        • #13
                          Code:
                          FUNCTION MyFunction (hDIB AS LONG) EXPORT AS LONG
                           
                             iret =   SaveDibTotempFile(hDIB, szTempFile) 
                             GRAPHIC BITMAP LOAD  szTempFile,  h, w,  to hBMP 
                          
                             Cool stuff goes here using as many GRAPHIC commands 
                             as will float your boat. 
                             (hBMP was obtained in this module so GRAPHICS commands are valid here) 
                          
                          
                          ...
                             KILL szTempFile     ' puh-leeze clean up after yourself!!
                          I know there is code around here somewhere to save a hDIB to a BMP file.

                          MCM
                          Last edited by Michael Mattias; 30 Sep 2008, 03:59 PM.
                          Michael Mattias
                          Tal Systems (retired)
                          Port Washington WI USA
                          [email protected]
                          http://www.talsystems.com

                          Comment


                          • #14
                            Mark,

                            Here is a sample, no DLL with it, but still a sample that deals with getting a DIB section from a PB bitmap/window or control. Uses other GDI commands as well.

                            Code:
                            #COMPILE EXE
                            #STACK 1048576
                            #REGISTER NONE
                            #DIM ALL
                            #INCLUDE "Win32api.inc"
                            TYPE GraphicInfo
                                hndl    AS DWORD    'the handle of the dialog or bitmap
                                ID      AS LONG     'the ID of a graphic control or 0
                                ox      AS LONG     'the X origin for using the control or bitmap portion being used
                                oy      AS LONG     'the Y origin for using the control or bitmap portion being used
                                px      AS LONG     'the X extent from ox in pixels for the conttol ot bitmap portion being used
                                py      AS LONG     'the Y extent from oy in pixels for the conttol ot bitmap portion being used
                            END TYPE
                            
                            MACRO DegreesToRadians(dpDegrees) = (dpDegrees * 0.0174532925199433##)
                            'MACRO RadiansToDegrees(dpRadians) = (dpRadians * 57.29577951308232##)
                            '=========================================================================
                            SUB Polar2Rect (x#, y#, vector#, rad#)
                                x# = vector# * COS(rad#)
                                y# = vector# * SIN(rad#)
                            END SUB
                            '=========================================================================
                            FUNCTION Create_DIB_Section32(hDC AS LONG,pixwide AS LONG,pixhigh  AS LONG, _
                                                    pBits AS DWORD) AS LONG
                                LOCAL hBitmap AS LONG
                                LOCAL dibBitmapInfo AS BITMAPINFO
                            
                                ZeroMemory (VARPTR(dibBitmapInfo), SIZEOF(BITMAPINFO) )
                                dibBitmapInfo.bmiHeader.biSize = SIZEOF(BITMAPINFOHEADER)
                                dibBitmapInfo.bmiHeader.biWidth = pixwide
                                dibBitmapInfo.bmiHeader.biHeight = -pixhigh  'to orient same as PB
                                dibBitmapInfo.bmiHeader.biPlanes = 1
                                dibBitmapInfo.bmiHeader.biBitCount = 32
                                dibBitmapInfo.bmiHeader.biCompression = %BI_RGB
                                dibBitmapInfo.bmiHeader.biSizeImage = pixwide * pixhigh * 4
                                '    ( 4 * ((pixwide * nBitsPerPixel + 31) / 32) ) * pixhigh
                                hBitmap = CreateDIBSection( %NULL, _
                                                    dibBitmapInfo, %DIB_RGB_COLORS, _
                                                    BYVAL VARPTR(pBits), %NULL, 0 )
                            
                                FUNCTION = hBitmap
                            END FUNCTION
                            
                            '=========================================================================
                            SUB SpiralWipe (fx AS LONG,DG AS GraphicInfo, BYVAL wclr AS LONG, _
                                            BYVAL pBG AS GraphicInfo PTR, OPTIONAL BYVAL ddelay AS LONG)
                                'Spiralling Wipe Close and Open
                                'Note that this does a Scaling operation, setting the origin at the center of the DG graphic.
                                LOCAL mx&,my&,gx&,gy&,dx&,dy&
                                LOCAL i&,j&,x#, y#, vector#, radian_angle# , nsa#
                                LOCAL cBG AS GraphicInfo, mskxy AS RECT
                                LOCAL hDGDC,hMBMP,hMBMPDC,hBGDC,hDS,oldhGWDC AS DWORD
                                '
                                LOCAL bmx         AS DIBSECTION
                                LOCAL bmi         AS BITMAPINFO
                                LOCAL bmpFileHdr  AS BITMAPFILEHEADER
                                LOCAL bmpInfoHdr  AS BITMAPINFOHEADER
                                LOCAL pbbp AS DWORD
                                LOCAL pbp AS DWORD PTR
                                LOCAL bf AS BLENDFUNCTION
                                '----------------------------  Spiral Wipe  ---------------------------------------
                                GRAPHIC ATTACH DG.hndl,DG.id,REDRAW
                                GRAPHIC GET DC TO hDGDC
                                mx& = (DG.px +1)/2  : my& = (DG.py +1)/2
                                GRAPHIC SCALE (-mx&,my&)-(mx&,-my&)
                            
                                IF fx <> 2 THEN
                                    IF ddelay < 50 THEN ddelay = 50
                                    FOR i& = 0 TO 360 STEP 12
                                       nsa# = i& -1
                                       FOR vector# = 1 TO INT(SQR(mx&^2+my&^2)) STEP .1
                                           INCR nsa# : IF nsa# = 360 THEN nsa# = 0
                                           radian_angle# = DegreesToRadians(nsa#)
                                           Polar2Rect x#, y#, vector#, radian_angle#
                                           IF(x# >=-mx& AND x#<=mx&) AND (y#>=-my& AND y#<=my&) THEN
                                               GRAPHIC SET PIXEL  (x#, y#) , wclr
                                           END IF
                                       NEXT vector#
                                       GRAPHIC REDRAW
                                       IF ddelay > 0 THEN
                                           SLEEP ddelay
                                           DECR ddelay
                                       END IF
                                    NEXT i&
                                END IF
                                '---------------------------- Spiral Reveal ---------------------------------------
                                'The reveal process consumes more time as it is a composite process.
                                IF pBG <> %Null THEN       'if a replacement image is used, "unwipe to reveal it"
                                    IF fx <> 1 THEN
                                        cBG.hndl = @pBG.hndl : cBG.id = @pBG.id : cBG.ox = @pBG.ox : cBG.oy = @pBG.oy
                                        cBG.px = @pBG.px : cBG.py = @pBG.py
                                        mx& = (DG.px +1)/2  : my& = (DG.py +1)/2
                                        gx& =DG.px +1 : gy& =DG.py +1
                                        GRAPHIC ATTACH cBG.hndl,cBG.id
                                        GRAPHIC GET DC TO hBGDC
                            
                                        IF wclr = %WHITE THEN wclr = BGR(RGB(254,254,254))
                                        wclr =  BGR(wclr)
                                        GRAPHIC BITMAP NEW gx&,gy& TO hMBMP
                                        GRAPHIC ATTACH hMBMP,0
                                        GRAPHIC GET DC TO hMBMPDC
                                        hDS = Create_DIB_Section32(hDGDC,gx&,gy&,pbbp)
                                        oldhGWDC = SelectObject (hMBMPDC,hDS)
                                        GRAPHIC ATTACH hMBMP,0
                                        pbp = pbbp
                                        FOR i& =  1 TO gy&
                                            FOR j& =1 TO gx&
                                                @pbp=wclr
                                                INCR pbp
                                            NEXT j&
                                        NEXT i&
                                        GRAPHIC REDRAW
                                        FOR i& = 360 TO 0 STEP -12
                                           nsa# = i& -1
                                           BitBlt hDGDC,0,0,gx&,gy&,hBGDC,0,0,%SRCCOPY
                                           FOR vector# = 1 TO INT(SQR(mx&^2+my&^2)) STEP .01 '.1
                                               nsa#=nsa# +.1: IF nsa# = 360 THEN nsa# = 0
                                               radian_angle# = DegreesToRadians(nsa#)
                                               Polar2Rect x#, y#, vector#, radian_angle#
                                               IF(x# >=-mx& AND x#<=mx&) AND (y#>=-my& AND y#<=my&) THEN' iterate for
                                                   dx& = mx& + x# : IF dx& > 0 AND dx& < gx& THEN dx& = dx& * 4 ELSE dx& = 0
                                                   dy& = my& + y# : IF dy& > 0 AND dy& < gy& THEN dy& = dy& * gx& *4 ELSE dy& =0
                                                   pbp = pbbp + dx& + dy&
                                                   @pbp = %WHITE
                                               END IF
                                           NEXT vector#
                                           RedrawWindow hMBMP,BYVAL 0,0,%RDW_INTERNALPAINT
                                           TransparentBlt hDGDC,0,0,gx&,gy&,hMBMPDC,0,0,gx&,gy&, %WHITE
                                           GRAPHIC ATTACH DG.hndl,0
                                           GRAPHIC REDRAW
                                           IF ddelay > 0 THEN
                                               SLEEP ddelay
                                               DECR ddelay
                                           END IF
                                        NEXT i&
                                        BitBlt hDGDC,0,0,gx&,gy&,hBGDC,0,0,%SRCCOPY
                                        SelectObject hMBMPDC,oldhGWDC
                                        DeleteObject hDS
                                    END IF
                                END IF
                                GRAPHIC ATTACH DG.hndl,0 ,REDRAW
                            END SUB
                            '=========================================================================
                            'Demo program begins next
                            '=========================================================================
                            FUNCTION PBMAIN () AS LONG
                                LOCAL hGW,hGWDC,hBMP,hBMPDC AS DWORD
                                LOCAL r&,g&,b&,i&,j&,fx&,x#, y#, vector#, radian_angle# , nsa#,ppx&,ppy&
                            
                                STATIC DisplayGC,BgBMP, FgBMP AS GraphicInfo
                            
                            
                            
                                GRAPHIC BITMAP NEW 600,600 TO FgBMP.hndl
                                GRAPHIC ATTACH FgBMP.hndl,0, REDRAW
                                GRAPHIC GET CLIENT TO ppx&,ppy&
                                DECR ppx& :DECR ppy&
                                FgBMP.id=0 : FgBMP.ox=0 :FgBMP.oy=0
                                FgBMP.px=ppx& : FgBMP.py=ppy&
                                GRAPHIC COLOR %BLACK,%BLACK
                                GRAPHIC CLEAR
                                GRAPHIC SCALE (-300,300)-(300,-300)
                            
                                j& = 1
                                FOR i& = 0 TO 360 STEP 12
                                    nsa# = i& -1
                                    FOR vector# = 1 TO INT(SQR(2)*300) STEP .1
                                        INCR nsa# : IF nsa# = 360 THEN nsa# = 0
                                        radian_angle# = DegreesToRadians(nsa#)
                                        Polar2Rect x#, y#, vector#, radian_angle#
                                        IF(x# >=-300 AND x#<=300) AND (y#>=-300 AND y#<=300) THEN
                                            GRAPHIC SET PIXEL  (x#, y#) ,  VAL(REMAIN$(READ$(j&),"= "))
                                            INCR j& : IF j& > 138 THEN j& = 1
                                        END IF
                                    NEXT vector#
                                 NEXT i&
                                GRAPHIC REDRAW
                            
                                'bmp for simulation
                                 GRAPHIC BITMAP NEW 600,600 TO BgBMP.hndl
                                 GRAPHIC ATTACH BgBMP.hndl,0
                                 GRAPHIC GET CLIENT TO ppx&,ppy&
                                 DECR ppx& :DECR ppy&
                                 BgBMP.id=0 : BgBMP.ox=0 :BgBMP.oy=0
                                 BgBMP.px=ppx& : BgBMP.py=ppy&
                                 r&=0 : g&=255 : b& =0
                                 FOR i& = 0 TO 599
                                     IF i& MOD 3 = 0 THEN
                                         INCR r&
                                         DECR g&
                                         INCR b&
                                     END IF
                                     GRAPHIC LINE (0,i&)-(600,i&),RGB(r&,g&,b&)
                                 NEXT i&
                                 FOR i& = 1 TO 138
                                      j& = VAL(REMAIN$(READ$(i&),"= "))
                                     GRAPHIC ELLIPSE (i&,i&)-(300-i&,300-i&),j&
                                     GRAPHIC ELLIPSE (300+i&,300+i&)-(600-i&,600-i&),j&
                                     GRAPHIC ELLIPSE (600-i&,i&)-(300+i&,300-i&),j&
                                     GRAPHIC ELLIPSE (i&,600-i&)-(300-i&,300+i&),j&
                                 NEXT i&
                            
                                GRAPHIC WINDOW "Test Spiral Wipe:",200,200,600,600 TO hGW
                                GRAPHIC ATTACH hGW,0 ,REDRAW
                                GRAPHIC GET DC TO hGWDC
                                GRAPHIC GET CLIENT TO ppx&,ppy&
                                DECR ppx& :DECR ppy&    'because this program sets a 720 x 480 wide seceen format for NTSC video
                                DisplayGC.hndl=hGW : DisplayGC.id=0 : DisplayGC.ox=0 :DisplayGC.oy=0
                                DisplayGC.px=ppx& : DisplayGC.py=ppy&
                                GRAPHIC SCALE (-300,300)-(300,-300)
                                GRAPHIC COLOR %BLACK,%BLACK
                                GRAPHIC CLEAR
                                GRAPHIC COPY FgBMP.hndl, 0 TO (-300,300)
                                GRAPHIC REDRAW
                                SLEEP 1000
                                SpiralWipe 1,DisplayGC, %RED,0,0 '50
                                SpiralWipe 2,DisplayGC, %RED, BYVAL VARPTR(BgBMP),0 '25
                            
                                GRAPHIC WINDOW END
                                GRAPHIC ATTACH FgBMP.hndl,0
                                GRAPHIC BITMAP END
                                GRAPHIC ATTACH BgBMP.hndl,0
                                GRAPHIC BITMAP END
                            
                            
                                '
                            DATA %AliceBlue             = &HF0F8FF???
                            DATA %AntiqueWhite          = &HFAEBD7???
                            DATA %Aqua                  = &H00FFFF???
                            DATA %Aquamarine            = &H7FFFD4???
                            DATA %Azure                 = &HF0FFFF???
                            DATA %Beige                 = &HF5F5DC???
                            DATA %Bisque                = &HFFE4C4???
                            DATA %Black                = &H000000???
                            DATA %BlancheDalmond        = &HFFEBCD???
                            DATA %Blue                 = &H0000FF???
                            DATA %BlueViolet            = &H8A2BE2???
                            DATA %Brown                 = &HA52A2A???
                            DATA %Burlywood             = &HDEB887???
                            DATA %CadetBlue             = &H5F9EA0???
                            DATA %Chartreuse            = &H7FFF00???
                            DATA %Chocolate             = &HD2691E???
                            DATA %Coral                 = &HFF7F50???
                            DATA %CornflowerBlue        = &H6495ED???
                            DATA %Cornsilk              = &HFFF8DC???
                            DATA %Crimson               = &HDC143C???
                            DATA %Cyan                 = &H00FFFF???
                            DATA %DarkBlue              = &H00008B???
                            DATA %DarkCyan              = &H008B8B???
                            DATA %DarkGoldenrod         = &HB8860B???
                            DATA %DarkGray              = &HA9A9A9???
                            DATA %DarkGreen             = &H006400???
                            DATA %DarkKhaki             = &HBDB76B???
                            DATA %DarkMagenta           = &H8B008B???
                            DATA %DarkOliveGreen        = &H556B2F???
                            DATA %DarkOrange            = &HFF8C00???
                            DATA %DarkOrchid            = &H9932CC???
                            DATA %DarkRed               = &H8B0000???
                            DATA %DarkSalmon            = &HE9967A???
                            DATA %DarkSeagreen          = &H8DBC8F???
                            DATA %DarkSlateBlue         = &H483D8B???
                            DATA %DarkSlateGray         = &H2F4F4F???
                            DATA %DarkTurquoise         = &H00DED1???
                            DATA %DarkViolet            = &H9400D3???
                            DATA %DeepPink              = &HFF1493???
                            DATA %DeepSkyBlue           = &H00BFFF???
                            DATA %DimGray               = &H696969???
                            DATA %DodgerBlue            = &H1E90FF???
                            DATA %Firebrick             = &HB22222???
                            DATA %FloralWhite           = &HFFFAF0???
                            DATA %ForestGreen           = &H228B22???
                            DATA %Fuchsia               = &HFF00FF???
                            DATA %Gainsboro             = &HDCDCDC???
                            DATA %GhostWhite            = &HF8F8FF???
                            DATA %Gold                  = &HFFD700???
                            DATA %Goldenrod             = &HDAA520???
                            DATA %Gray                 = &H808080???
                            DATA %Green                = &H008000???
                            DATA %GreenYellow           = &HADFF2F???
                            DATA %Honeydew              = &HF0FFF0???
                            DATA %HotPink               = &HFF69B4???
                            DATA %IndianRed             = &HCD5C5C???
                            DATA %Indigo                = &H4B0082???
                            DATA %Ivory                 = &HFFFFF0???
                            DATA %Khaki                 = &HF0E68C???
                            DATA %Lavender              = &HE6E6FA???
                            DATA %LavenderBlush         = &HFFF0F5???
                            DATA %Lawngreen             = &H7CFC00???
                            DATA %LemonChiffon          = &HFFFACD???
                            DATA %LightBlue             = &HADD8E6???
                            DATA %LightCoral            = &HF08080???
                            DATA %LightCyan             = &HE0FFFF???
                            DATA %LightGoldenrodYellow  = &HFAFAD2???
                            DATA %LightGreen            = &H90EE90???
                            DATA %LightGrey             = &HD3D3D3???
                            DATA %LightPink             = &HFFB6C1???
                            DATA %LightSalmon           = &HFFA07A???
                            DATA %LightSeagreen         = &H20B2AA???
                            DATA %LightSkyBlue          = &H87CEFA???
                            DATA %LightSlateGray        = &H778899???
                            DATA %LightSteelBlue        = &HB0C4DE???
                            DATA %LightYellow           = &HFFFFE0???
                            DATA %Lime                  = &H00FF00???
                            DATA %LimeGreen             = &H32CD32???
                            DATA %Linen                 = &HFAF0E6???
                            DATA %Magenta              = &HFF00FF???
                            DATA %Maroon                = &H800000???
                            DATA %MediumAquamarine      = &H66CDAA???
                            DATA %MediumBlue            = &H0000CD???
                            DATA %MediumOrchid          = &HBA55D3???
                            DATA %MediumPurple          = &H9370DB???
                            DATA %MediumSeaGreen        = &H3CB371???
                            DATA %MediumSlateBlue       = &H7B68EE???
                            DATA %MediumSpringGreen     = &H00FA9A???
                            DATA %MediumTurquoise       = &H48D1CC???
                            DATA %MediumVioletRed       = &HC71585???
                            DATA %MidnightBlue          = &H191970???
                            DATA %MintCream             = &HF5FFFA???
                            DATA %MistyRose             = &HFFE4E1???
                            DATA %Moccasin              = &HFFE4B5???
                            DATA %NavajoWhite           = &HFFDEAD???
                            DATA %Navy                  = &H000080???
                            DATA %OldLace               = &HFDF5E6???
                            DATA %OliveDrab             = &H6B8E23???
                            DATA %Orange                = &HFFA500???
                            DATA %OrangeRed             = &HFF4500???
                            DATA %Orchid                = &HDA70D6???
                            DATA %PaleGoldenrod         = &HEEE8AA???
                            DATA %PaleGreen             = &H98FB98???
                            DATA %PaleTurquoise         = &HAFEEEE???
                            DATA %PaleVioletRed         = &HDB7093???
                            DATA %PapayaWhip            = &HFFEFD5???
                            DATA %PeachPuff             = &HFFDAB9???
                            DATA %Peru                  = &HCD853F???
                            DATA %Pink                  = &HFFC8CB???
                            DATA %Plum                  = &HDDA0DD???
                            DATA %PowderBlue            = &HB0E0E6???
                            DATA %Purple                = &H800080???
                            DATA %Red                  = &HFF0000???
                            DATA %RosyBrown             = &HBC8F8F???
                            DATA %RoyalBlue             = &H4169E1???
                            DATA %SaddleBrown           = &H8B4513???
                            DATA %Salmon                = &HFA8072???
                            DATA %SandyBrown            = &HF4A460???
                            DATA %SeaGreen              = &H2E8B57???
                            DATA %SeaShell              = &HFFF5EE???
                            DATA %Sienna                = &HA0522D???
                            DATA %Silver                = &HC0C0C0???
                            DATA %SkyBlue               = &H87CEEB???
                            DATA %SlateBlue             = &H6A5ACD???
                            DATA %Snow                  = &HFFFAFA???
                            DATA %SpringGreen           = &H00FF7F???
                            DATA %Steelblue             = &H4682B4???
                            DATA %Tan                   = &HD2B48C???
                            DATA %Teal                  = &H008080???
                            DATA %Thistle               = &HD8BFD8???
                            DATA %Tomato                = &HFF6347???
                            DATA %Turquoise             = &H40E0D0???
                            DATA %Violet                = &HEE82EE???
                            DATA %Wheat                 = &HF5DEB3???
                            DATA %White                = &HFFFFFF???
                            DATA %Whitesmoke            = &HF5F5F5???
                            DATA %Yellow               = &HFFFF00???
                            DATA %YellowGreen           = &H9ACD32???
                            END FUNCTION
                            Rick Angell

                            Comment

                            Working...
                            X