Results 1 to 1 of 1

Thread: canvas load images (simple way)

  1. #1

    canvas load images (simple way)

    here I show a little example how to load images (pictures) in canvas (ui) mode:

       ' Empty GUI script created on 03-06-2013 12:58:08 by largo_winch  (thinAir)
     
    
     Uses "console", "ui"                 
     Begin Const
       %btnone=100
       %btntwo
       %bImage
       %bImage2
       %tAnimationTimer
     End Const
     
    
     Global hDlg As DWord
     
    
     Function TBMain() As Long
        Dialog New Pixels, 0, "Canvas LoadImage Test Code",-1,-1,450,350, %WS_OVERLAPPEDWINDOW To hDlg
        Control Add Button, hDlg, %btnone,"Load Image", 20,10,160,24
        Control Add Button, hDlg, %btntwo,"Load another Image", 220,10,160,24
        Control Add Canvas, hDlg, %bImage,"", 20,60,360,280
        'Control Add Canvas, hDlg, %bImage2,"", 20,140,160,220    
        Dialog Show Modal hDlg Call DlgProc
     End Function
     
    
     CallBack Function dlgProc()
        Local sImageSmall As String = APP_SourcePath+"Prometh2aa.bmp"
        Local sImageSmall2 As String = APP_SourcePath+"Alien1.bmp"
        Local sImageSmall3 As String = APP_SourcePath+"AlienBig1.bmp"
        Local w As Long, h As Long, hBMP As DWord
     
    
       Select Case CBMSG
     
    
         Case %WM_INITDIALOG
           Dialog Set Timer CBHNDL, %tAnimationTimer, 10, %NULL
           Control Add Canvas, CBHNDL, %bImage,"", 20, 70, w, h, %WS_BORDER
           Canvas_Attach (CBHNDL, %bImage, TRUE)
           Canvas_Scale Pixels   
           Canvas_BitmapRender(sImageSmall)                   
           '------------ alternative way of going fine ---------- '
           'Canvas_SetPos(10,100)
           'Canvas_BitmapRender(sImageSmall2)
            
           'Canvas_SetPos(50,120)
           'Canvas_BitmapRender(sImageSmall3)
           '------------ alternative way of going fine ---------- '
            
         Case %WM_TIMER
           Local tx, ty As Long
           Canvas_Attach(CBHNDL, %bImage, %TRUE)
           Canvas_Redraw     ' ! -- Important: Needs this to sync
          
         Case %WM_Command
           If CBWPARAM = %btnone Then        
             Canvas_SetPos(1,100)
             Canvas_BitmapRender(sImageSmall2)
           End If
            
           If CBWPARAM = %btntwo Then  
             Canvas_SetPos(100,20)
             Canvas_BitmapRender(sImageSmall3)       
           End If
            
         Case %WM_CLOSE
     
    
       End Select
     
    
     End Function
    

    bye, largo
    Attached Images Attached Images
    Attached Files Attached Files

Similar Threads

  1. Inserting a simple JPEG or BMP into a Canvas
    By MattW in forum thinBasic General
    Replies: 8
    Last Post: 17-01-2013, 15:46
  2. MadPulsar - see your images like never before
    By Petr Schreiber in forum TBGL Scripts and Projects
    Replies: 7
    Last Post: 15-11-2010, 21:36
  3. Replies: 6
    Last Post: 16-06-2010, 06:40
  4. load images examples don't work
    By sandyrepope in forum UI (User Interface)
    Replies: 2
    Last Post: 25-12-2007, 23:09

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •