Loading ...
Sorry, an error occurred while loading the content.

47155StrecchtBlt

Expand Messages
  • mrossi8888
    Nov 12, 2013

      Rod, I have this code I cannot figure out what is wrong with it.  If you could look at it I would appreciate it.

      Marc

      PS>  This is just the code that does not work.  I have more that works but didn't include it so you don't have to load the BMP's.

      Marc

       

      ' code start

      NOMAINWIN

      Menu #runner,"&Program", "&About", [whatabout]
      Menu #runner, "&Exit", "&Quit", [quit]
      ' LOADBMP,"big",  "big.bmp"
      dim alienboong(3,3)  ' alien ships are made in this array
      WindowWidth = 500
      WindowHeight = 700
      UpperLeftX=INT((DisplayWidth-WindowWidth)/2)
      UpperLeftY=INT((DisplayHeight-WindowHeight)/2)
      graphicbox #runner.score, 0, 0, 100, 30
      graphicbox #runner.totalnum, 400, 0, 100, 30
      open "Space Destroyer" for graphics_nf_nsb  as #runner
      print #runner, "trapclose [quit]"
      global energy
      global deadboong1
      global deadboong2

      global score
      global start
      varx = 235
      vary = 420
      energy = 4
      score = 0

      bx = 0
      by = 0
      start = 1

      ' open the dll file used for TransparentBlt
      open "msimg32.dll" for dll as #m


      print #runner, "down ; fill black"
      print #runner, "color white"
      for d = 1 to 700
      print #runner, "set ";int(rnd(0)*500);" ";int(rnd(0)*600)
      next d
      print #runner, "getbmp bmp 0 30 500 700"

              print #runner, "drawbmp bmp 30 350"

              unloadbmp "bmp"
               print #runner, "getbmp bmp 0 30 500 350"
      'loadbmp "total","total.bmp"

      print #runner.score, "place 10 20 ;\Energy=";energy
      print #runner.totalnum, "place 10 20 ;\Score=";score
      times = times + 1

           'sDC is our screen buffer, (DC handle to the graphicsbox)
           sDC=GetDC(hwnd(#runner))

           'mDC is a copy of the screen in memory
           mDC=CreateCompatibleDC(sDC)

          ' select our bmp graphic resource into the memory dc
          hBitmap=hbmp("bmp")

          oldBmp=SelectObject(mDC,hBitmap)

      ' draw initial ship
      timer 50,  [movement]

      [movement]
      ' move the background

      y = y - 1
      if y=abs(-700) then y=30

      call StretchBlt sDC,0,30,500,700,mDC,0,y,500,350  'destination x pos 'destination y pos destination width desired 'destination height desired
                                                'source 'x location to start from source 'y location to start from source 'width desired from source 'height desired from source 'dwRasterOperation
      wait

      Function GetDC(hWnd)
          CallDLL #user32, "GetDC",_
              hWnd As ulong,_  'window or control handle
              GetDC As ulong   'returns device context
          End Function

      Sub ReleaseDC hWnd, hDC
          CallDLL#user32,"ReleaseDC",_
              hWnd As ulong,_  'window or control handle
              hDC As ulong,_   'handle of DC to delete
              result As Long
          End Sub

      Function CreateCompatibleDC(hDC)
          CallDLL #gdi32,"CreateCompatibleDC",_
              hDC As ulong,_               'window DC
              CreateCompatibleDC As ulong  'memory DC
          End Function

      Sub DeleteDC hDC
          CallDLL #gdi32, "DeleteDC",_
          hDC As ulong,_   'memory DC to delete
          r As Boolean
          End Sub

      Sub StretchBlt hDCdest,x,y,w,h,hDCsrc,x2,y2,w2,h2
          CallDLL #gdi32, "SetStretchBltMode",_
              hDCdest As ulong,_       'device context
              _COLORONCOLOR As Long,_ 'color reduction mode
              RESULT As Long
          CallDLL #gdi32, "StretchBlt",_
              hDCdest As ulong,_   'destination
              x As Long,_         'destination x pos
              y As Long,_         'destination y pos
              w As Long,_         'destination width desired
              h As Long,_         'destination height desired
              hDCsrc As ulong,_    'source
              x2 As Long,_        'x location to start from source
              y2 As Long,_        'y location to start from source
              w2 As Long,_        'width desired from source
              h2 As Long,_        'height desired from source
              _SRCCOPY As long,_ 'dwRasterOperation
              RESULT As Boolean
          End Sub

      Sub TransparentBlt hDCdest,x,y,w,h,hDCsrc,x2,y2,w2,h2,crTransparent
          calldll #m, "TransparentBlt",_
              hDCdest As uLong,_  'destination
              x As Long,_         'destination x pos
              y As Long,_         'destination y pos
              w As Long,_         'destination width desired
              h As Long,_         'destination height desired
              hDCsrc As uLong,_    'source
              x2 As Long,_        'x location to start from source
              y2 As Long,_        'y location to start from source
              w2 As Long,_        'width desired from source
              h2 As Long,_        'height desired from source
              crTransparent as ulong,_ 'color to make transparent 0=Black
              result as boolean
          end sub


      Function SelectObject(hDC,hObject)
          CallDLL #gdi32,"SelectObject",_
              hDC As ulong,_        'memory device context
              hObject As long,_    'handle of object
              SelectObject As long 'returns previously selected object
          End Function

       

       

       

      wait
      [whatabout]


      notice "Space Destroyer" + chr$(13)  + chr$(13); "     By m f r   2013"


      wait
      [quit]
      unloadbmp "total"
      call ReleaseDC hwnd(#runner), gDC
      call DeleteDC mDC
      close #runner
      close #m
      end  ' end program

       

      ' code end

    • Show all 3 messages in this topic