Guidance
指路人
g.yi.org
software / rapidq / Examples / Audio & Video / Picview / PICVIEW.BAS

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'---------------------------------------------
'PICVIEW.BAS - A graphic viewer for Rapidq
'Shows JPG, GIF, BMP, PCX and other formats
'Uses nViewLib.dll as resource
'Freeware (c) 2003 by D. Folger
'---------------------------------------------
     $OPTIMIZE ON
     $TYPECHECK ON
     $INCLUDE "rapidq.inc"
     $OPTION ICON "Eye.ico"
     $RESOURCE ProgIcon AS "Eye.ico"
     $RESOURCE nview AS "nviewlib.dll"

     IF FILEEXISTS ("nviewlib.dll") = 0 THEN
      ExtractResource Resource(1),"nviewlib.dll"
     END IF

     DIM OrgWidth AS INTEGER
     DIM OrgHeight AS INTEGER
     DIM Factor AS SINGLE
     DIM Percent AS INTEGER
     DIM Full AS INTEGER, Adj AS INTEGER, Zoom AS INTEGER

     DECLARE FUNCTION NViewLibLoad LIB "NVIEWLIB" ALIAS "NViewLibLoad" _
      (FileName AS STRING, Progress AS INTEGER) AS INTEGER
     DECLARE SUB FormResize
     DECLARE SUB LoadFile
     DECLARE SUB ShowImage
     DECLARE SUB NewSize
     DECLARE SUB FullSize
     DECLARE SUB AdjustSize
     DECLARE SUB DirChange
     DECLARE SUB ZoomIn
     DECLARE SUB ZoomOut
     DECLARE SUB Minimize

     CREATE Form AS QFORM
      CAPTION = "PicView"
      Width = 560 : Height = 425
      IcoHandle = ProgIcon
      Center
      WndProc = Minimize
      CREATE Panel AS QPANEL
       Width = 180 : Height = 400
       BorderStyle = 1 : Align = 3
       CREATE Button1 AS QCOOLBTN
        Left = 20 : Top = 3
        Width = 25 : Height = 25
        CAPTION = "+" : ShowHint = 1
        Hint = "Zoom in"
        onClick = ZoomIn
       END CREATE
       CREATE Button2 AS QCOOLBTN
        Left = 55 : Top = 3
        Width = 25 : Height = 25
        CAPTION = "-" : ShowHint = 1
        Hint = "Zoom out"
        onClick = ZoomOut
       END CREATE
       CREATE Button3 AS QCOOLBTN
        Left = 90 : Top = 3
        Width = 25 : Height = 25
        CAPTION = "Full" : ShowHint = 1
        Hint = "Full size of image"
        onClick = FullSize
       END CREATE
       CREATE Button4 AS QCOOLBTN
        Left = 125 : Top = 3
        Width = 25 : Height = 25
        CAPTION = "Adj" : ShowHint = 1
        Hint = "Adjust image to window"
        onClick = AdjustSize
       END CREATE
       CREATE DirTree AS QDIRTREE
        Left = 2 : Top = 30 : Width = 170
        InitialDir = CURDIR$
        OnChange = DirChange
       END CREATE
       CREATE FileBox AS QFILELISTBOX
        Left = 2 : Top = 230
        Width = 170
        Mask = "*.JPG;*.PCX;*.GIF;*.BMP;*.DIB;*.RLE;*.TGA;*.JIF"
        ShowIcons = 1
        onClick = LoadFile
       END CREATE
      END CREATE
      CREATE ScrollBox AS QSCROLLBOX
       AutoScroll = 1 : Align = 5
       COLOR = &HFFFFFF
       CREATE Image AS QIMAGE
        AutoSize = 1
        Stretch = 1
       END CREATE
      END CREATE
      CREATE StatusBar AS QSTATUSBAR
       addPanels = "","",""
       Panel(0).Width = 70
       Panel(1).Width = 50
      END CREATE
      onResize = FormResize
     END CREATE
     Form.SHOWMODAL
'-------------
     SUB FormResize
'-------------
      DirTree.Height = Panel.Height / 2 - 30
      FileBox.Top = Panel.Height/2
      FileBox.Height = Panel.Height / 2 - 8
      IF Full THEN FullSize
      IF Adj THEN AdjustSize
      IF Zoom THEN NewSize
     END SUB
'----------
     SUB LoadFile
'----------
      Image.Handle = NViewLibLoad (FileBox.FileName, 0)
      OrgWidth = Image.Width : OrgHeight = Image.Height
      StatusBar.Panel(0).CAPTION = " " + STR$(OrgWidth) + "x" + STR$(OrgHeight)
      StatusBar.Panel(2).CAPTION = " " + _
       MID$(FileBox.FileName,RINSTR(FileBox.FileName,"\")+1)
      AdjustSize 'Choose what you
 'FullSize 'like to start with
     END SUB
'------------
     SUB ShowImage
'------------
      IF Image.Height > ScrollBox.Height THEN
       ScrollBox.VertPosition = ScrollBox.VertRange/2 - ScrollBox.Height/2
      ELSE
       Image.Top = ScrollBox.Height/2 - Image.Height / 2
      END IF
      IF Image.Width > ScrollBox.Width THEN
       ScrollBox.HorzPosition = ScrollBox.HorzRange/2 - ScrollBox.Width/2
      ELSE
       Image.Left = ScrollBox.Width/2 - Image.Width / 2
      END IF
      Image.Stretch = 1
      StatusBar.Panel(1).CAPTION = " " + STR$(Percent) + "%"
     END SUB
'----------
     SUB NewSize
'----------
      Image.Height = INT(OrgHeight * Factor)
      Image.Width = INT(OrgWidth * Factor)
      Zoom = 1 : Full = 0 : Adj = 0
      ShowImage
     END SUB
'-----------
     SUB FullSize
'-----------
      Image.Width = OrgWidth
      Image.Height = OrgHeight
      Percent = 100
      Full = 1 : Adj = 0 : Zoom = 0
      ShowImage
     END SUB
'----------
     SUB AdjustSize
'----------
      IF ScrollBox.Width > OrgWidth AND ScrollBox.Height > OrgHeight THEN
       Factor = 1
      ELSEIF OrgWidth > OrgHeight THEN
       Factor = (ScrollBox.Width -10) / OrgWidth
      ELSE
       Factor = (ScrollBox.Height - 10) / OrgHeight
      END IF
      Image.Width = INT(OrgWidth * Factor)
      Image.Height = INT(OrgHeight * Factor)
      Image.Stretch = 1
      Percent = Image.Width /(OrgWidth / 100)
      Adj = 1 : Full = 0 : Zoom = 0
      ShowImage
     END SUB
'------------
     SUB DirChange
'------------
      FileBox.Directory = DirTree.Directory
     END SUB
'-----------
     SUB ZoomIn
'-----------
      IF Percent = 300 THEN EXIT SUB
      IF Percent MOD 10 THEN
       INC Percent, 10 - (Percent MOD 10)
      ELSE
       INC Percent, 10
      END IF
      Factor = Percent / 100
      NewSize
     END SUB
'-----------
     SUB ZoomOut
'-----------
      IF Percent = 10 THEN EXIT SUB
      IF Percent MOD 10 THEN
       DEC Percent, (Percent MOD 10)
      ELSE
       DEC Percent, 10
      END IF
      Factor = Percent / 100
      NewSize
     END SUB
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Tue 2022-10-4  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-19 07:43:05