home *** CD-ROM | disk | FTP | other *** search
/ Mastering Visual Basic 5 / MasteringVisualBasic5.iso / olympus / ik32_15t / vb4.shr / GetPtln.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-08-07  |  9.7 KB  |  340 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Get/Put Line"
  5.    ClientHeight    =   2805
  6.    ClientLeft      =   2115
  7.    ClientTop       =   1965
  8.    ClientWidth     =   4785
  9.    Height          =   3585
  10.    Left            =   2055
  11.    LinkTopic       =   "Form1"
  12.    LockControls    =   -1  'True
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   187
  16.    ScaleMode       =   3  'Pixel
  17.    ScaleWidth      =   319
  18.    Top             =   1245
  19.    Width           =   4905
  20.    Begin VB.CommandButton cmdTransfer 
  21.       Caption         =   "&Transfer"
  22.       Height          =   375
  23.       Left            =   90
  24.       TabIndex        =   0
  25.       Top             =   2340
  26.       Width           =   1485
  27.    End
  28.    Begin ik32Lib.Picbuf PicbufDest 
  29.       Height          =   2265
  30.       Left            =   2430
  31.       TabIndex        =   2
  32.       Top             =   0
  33.       Width           =   2265
  34.       _Version        =   65536
  35.       _ExtentX        =   3995
  36.       _ExtentY        =   3995
  37.       _StockProps     =   253
  38.    End
  39.    Begin ik32Lib.Picbuf PicbufSrc 
  40.       Height          =   2265
  41.       Left            =   90
  42.       TabIndex        =   1
  43.       Top             =   0
  44.       Width           =   2265
  45.       _Version        =   65536
  46.       _ExtentX        =   3995
  47.       _ExtentY        =   3995
  48.       _StockProps     =   253
  49.       FileName        =   "D:\MAI\IMAGES\Boat.bmp"
  50.    End
  51.    Begin VB.Menu mnuFile 
  52.       Caption         =   "&File"
  53.       Begin VB.Menu mnuLoad1Bit 
  54.          Caption         =   "Load &1 Bit"
  55.       End
  56.       Begin VB.Menu mnuLoad4Bit 
  57.          Caption         =   "Load &4 Bit"
  58.       End
  59.       Begin VB.Menu mnuLoad8Bit 
  60.          Caption         =   "Load &8 Bit"
  61.       End
  62.       Begin VB.Menu mnuLoad24Bit 
  63.          Caption         =   "Load &24 Bit"
  64.       End
  65.       Begin VB.Menu mnuSpacer 
  66.          Caption         =   "-"
  67.       End
  68.       Begin VB.Menu mnuExit 
  69.          Caption         =   "E&xit"
  70.          Shortcut        =   ^X
  71.       End
  72.    End
  73.    Begin VB.Menu mnuOptions 
  74.       Caption         =   "&Options"
  75.       Begin VB.Menu mnuShowProgress 
  76.          Caption         =   "&Show Progress"
  77.          Checked         =   -1  'True
  78.       End
  79.    End
  80. Attribute VB_Name = "Form1"
  81. Attribute VB_Creatable = False
  82. Attribute VB_Exposed = False
  83. Dim Root As String
  84. 'Description: This code creates 1-bit, opposite
  85. 'images in the two picbufs.
  86. Sub Build1Bit()
  87.     ' setup the source
  88.     ReDim nLine(0 To picbufsrc.Width - 1) As Long
  89.     Dim i, j As Integer
  90.     ' setup the source
  91.     picbufsrc.Init 1, picbufsrc.Width, picbufsrc.Height, RGB(255, 255, 255)
  92.     For i = 0 To picbufsrc.Width - 1
  93.         nLine(i) = 0
  94.     Next i
  95.     For j = 0 To picbufsrc.Width - 1
  96.         picbufsrc.PutScanLine j, nLine(0)
  97.     Next j
  98.     ' setup the destination
  99.     PicbufDest.Init 1, PicbufDest.Width, PicbufDest.Height, RGB(255, 255, 255)
  100.     For i = 0 To PicbufDest.Width - 1
  101.         nLine(i) = 255
  102.     Next i
  103.     For j = 0 To PicbufDest.Width - 1
  104.         PicbufDest.PutScanLine j, nLine(0)
  105.     Next j
  106. End Sub
  107. 'Description: This code creates 24-bit, opposite
  108. 'images in the two picbufs.
  109. Sub Build24Bit()
  110.     ' setup the source
  111.     picbufsrc.Init 24, picbufsrc.Width, picbufsrc.Height, RGB(255, 255, 255)
  112.     ReDim nLine(0 To picbufsrc.Width - 1) As Long
  113.     Dim i, j, k As Integer
  114.     Dim inc As Integer
  115.     inc = 255 / picbufsrc.Height
  116.     k = 0
  117.     For j = 0 To picbufsrc.Height - 1
  118.         For i = 0 To picbufsrc.Width - 1
  119.             nLine(i) = RGB(k, k, k)
  120.         Next
  121.         
  122.         picbufsrc.PutScanLine j, nLine(0)
  123.         
  124.         k = k + inc
  125.         If k > 255 Then
  126.             k = 255
  127.         End If
  128.     Next j
  129.     ' setup the destination
  130.     PicbufDest.Init 24, PicbufDest.Width, PicbufDest.Height, RGB(255, 255, 255)
  131.     k = 255
  132.     For j = 0 To PicbufDest.Height - 1
  133.         For i = 0 To PicbufDest.Width - 1
  134.             nLine(i) = RGB(k, k, k)
  135.         Next i
  136.         
  137.         PicbufDest.PutScanLine j, nLine(0)
  138.         
  139.         k = k - inc
  140.         If k < 0 Then
  141.             k = 0
  142.         End If
  143.     Next j
  144. End Sub
  145. 'Description: This code creates 4-bit, opposite
  146. 'images in the two picbufs.
  147. Sub Build4Bit()
  148.     ' setup the source
  149.     picbufsrc.Init 4, picbufsrc.Width, PicbufDest.Width, RGB(255, 255, 255)
  150.     ReDim nLine(0 To picbufsrc.Width - 1) As Long
  151.     Dim LoopIndex, i, j, k As Integer
  152.     Dim inc As Integer
  153.     Dim palette(16) As Long
  154.     inc = 256 / 16
  155.     j = 0
  156.     For i = 1 To 16
  157.         palette(i) = RGB(j, j, j)
  158.         If j < 255 Then
  159.             j = j + inc
  160.         ElseIf j > 255 Then
  161.             j = 255
  162.         End If
  163.     Next i
  164.     picbufsrc.CreatePalette 16, palette(0), 0
  165.     inc = picbufsrc.Height / 16
  166.     For j = 0 To picbufsrc.Width - 1
  167.         Select Case j
  168.             Case Is < inc
  169.                 k = 0
  170.             Case Is < inc * 2
  171.                 k = 1
  172.             Case Is < inc * 3
  173.                 k = 2
  174.             Case Is < inc * 4
  175.                 k = 3
  176.             Case Is < inc * 5
  177.                 k = 4
  178.             Case Is < inc * 6
  179.                 k = 5
  180.             Case Is < inc * 7
  181.                 k = 6
  182.             Case Is < inc * 8
  183.                 k = 7
  184.             Case Is < inc * 9
  185.                 k = 8
  186.             Case Is < inc * 10
  187.                 k = 9
  188.             Case Is < inc * 11
  189.                 k = 10
  190.             Case Is < inc * 12
  191.                 k = 11
  192.             Case Is < inc * 13
  193.                 k = 12
  194.             Case Is < inc * 14
  195.                 k = 13
  196.             Case Is < inc * 15
  197.                 k = 14
  198.             Case Else
  199.                 k = 15
  200.         End Select
  201.         For i = 0 To picbufsrc.Width - 1
  202.             nLine(i) = k
  203.         Next i
  204.         picbufsrc.PutScanLine j, nLine(0)
  205.     Next j
  206.     ' setup the destination
  207.     PicbufDest.Init 4, PicbufDest.Width, PicbufDest.Height, RGB(255, 255, 255)
  208.     PicbufDest.CreatePalette 16, palette(1), 0
  209.     inc = PicbufDest.Height / 16
  210.     For j = 0 To PicbufDest.Width - 1
  211.         Select Case j
  212.             Case Is < inc
  213.                 k = 15
  214.             Case Is < inc * 2
  215.                 k = 14
  216.             Case Is < inc * 3
  217.                 k = 13
  218.             Case Is < inc * 4
  219.                 k = 12
  220.             Case Is < inc * 5
  221.                 k = 11
  222.             Case Is < inc * 6
  223.                 k = 10
  224.             Case Is < inc * 7
  225.                 k = 9
  226.             Case Is < inc * 8
  227.                 k = 8
  228.             Case Is < inc * 9
  229.                 k = 7
  230.             Case Is < inc * 10
  231.                 k = 6
  232.             Case Is < inc * 11
  233.                 k = 5
  234.             Case Is < inc * 12
  235.                 k = 4
  236.             Case Is < inc * 13
  237.                 k = 3
  238.             Case Is < inc * 14
  239.                 k = 2
  240.             Case Is < inc * 15
  241.                 k = 1
  242.             Case Else
  243.                 k = 0
  244.         End Select
  245.         For i = 0 To PicbufDest.Width - 1
  246.             nLine(i) = k
  247.         Next i
  248.         
  249.         PicbufDest.PutScanLine j, nLine(0)
  250.     Next j
  251. End Sub
  252. 'Description: This code creates 8-bit, opposite
  253. 'images in the two picbufs.
  254. Sub Build8Bit()
  255.     ' setup the source
  256.     picbufsrc.Init 8, picbufsrc.Width, picbufsrc.Height, RGB(255, 255, 255)
  257.     ReDim nLine(0 To picbufsrc.Width - 1) As Long
  258.     Dim i, j, k As Integer
  259.     Dim inc As Integer
  260.     Dim palette(256) As Long
  261.     inc = 256 / picbufsrc.Height
  262.     j = 0
  263.     For i = 0 To 255
  264.         palette(i) = RGB(j, j, j)
  265.         If j < 255 Then
  266.             j = j + inc
  267.         ElseIf j > 255 Then
  268.             j = 255
  269.         End If
  270.     Next i
  271.     picbufsrc.CreatePalette 255, palette(1), 0
  272.     For j = 0 To picbufsrc.Height - 1
  273.         For i = 0 To picbufsrc.Width - 1
  274.             nLine(i) = j
  275.         Next i
  276.         
  277.         picbufsrc.PutScanLine j, nLine(0)
  278.     Next j
  279.     ' setup the destination
  280.     PicbufDest.Init 8, PicbufDest.Width, PicbufDest.Height, RGB(255, 255, 255)
  281.     PicbufDest.CreatePalette 255, palette(1), 0
  282.     k = PicbufDest.Height
  283.     For j = 0 To PicbufDest.Width - 1
  284.         For i = 0 To PicbufDest.Width - 1
  285.             nLine(i) = k
  286.         Next i
  287.         
  288.         PicbufDest.PutScanLine j, nLine(0)
  289.         
  290.         k = k - 1
  291.     Next j
  292. End Sub
  293. 'Description: This code transfers the image from
  294. 'one picbuf to another.
  295. Private Sub cmdTransfer_Click()
  296.     Dim i As Integer
  297.     ReDim Line(picbufsrc.Width) As Long
  298.     For i = 0 To picbufsrc.Height - 1
  299.         picbufsrc.GetScanLine i, Line(1)
  300.         PicbufDest.PutScanLine i, Line(1)
  301.         If mnuShowProgress.Checked Then
  302.             DoEvents
  303.         End If
  304.     Next
  305. End Sub
  306. 'Description: This code sets picbuf properties,
  307. 'and sets up 24 bit images in the two picbufs.
  308. Private Sub Form_Load()
  309.     InitPicbuf picbufsrc, False
  310.     InitPicbuf PicbufDest, False
  311.     Build24Bit
  312. End Sub
  313. 'Description: This sub ends the program
  314. Private Sub mnuExit_Click()
  315.     ExitProgram
  316. End Sub
  317. 'Description: This code calls a sub to create two
  318. '1-bit images
  319. Private Sub mnuLoad1Bit_Click()
  320.     Build1Bit
  321. End Sub
  322. 'Description: This code calls a sub to create two
  323. '24-bit images
  324. Private Sub mnuLoad24Bit_Click()
  325.     Build24Bit
  326. End Sub
  327. 'Description: This code calls a sub to create two
  328. '4-bit images
  329. Private Sub mnuLoad4Bit_Click()
  330.     Build4Bit
  331. End Sub
  332. 'Description: This code calls a sub to create two
  333. '8-bit images
  334. Private Sub mnuLoad8Bit_Click()
  335.     Build8Bit
  336. End Sub
  337. Private Sub mnuShowProgress_Click()
  338.   mnuShowProgress.Checked = Not mnuShowProgress.Checked
  339. End Sub
  340.