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

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "Matrix Filter"
  5.    ClientHeight    =   3015
  6.    ClientLeft      =   1875
  7.    ClientTop       =   2310
  8.    ClientWidth     =   8295
  9.    Height          =   3795
  10.    Left            =   1815
  11.    LinkTopic       =   "Form1"
  12.    LockControls    =   -1  'True
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   3015
  16.    ScaleWidth      =   8295
  17.    ShowInTaskbar   =   0   'False
  18.    Top             =   1590
  19.    Width           =   8415
  20.    Begin VB.Frame Frame2 
  21.       Caption         =   "Matrix Filter"
  22.       Height          =   2895
  23.       Left            =   5040
  24.       TabIndex        =   37
  25.       Top             =   0
  26.       Width           =   3135
  27.       Begin VB.CommandButton Command6 
  28.          Caption         =   "-"
  29.          Height          =   255
  30.          Left            =   2280
  31.          TabIndex        =   51
  32.          Top             =   1920
  33.          Width           =   255
  34.       End
  35.       Begin VB.CommandButton Command5 
  36.          Caption         =   "+"
  37.          Height          =   255
  38.          Left            =   2040
  39.          TabIndex        =   50
  40.          Top             =   1920
  41.          Width           =   255
  42.       End
  43.       Begin VB.CommandButton Command4 
  44.          Caption         =   "-"
  45.          Height          =   255
  46.          Left            =   2280
  47.          TabIndex        =   49
  48.          Top             =   1200
  49.          Width           =   255
  50.       End
  51.       Begin VB.CommandButton Command3 
  52.          Caption         =   "+"
  53.          Height          =   255
  54.          Left            =   2040
  55.          TabIndex        =   48
  56.          Top             =   1200
  57.          Width           =   255
  58.       End
  59.       Begin VB.CommandButton Command2 
  60.          Caption         =   "-"
  61.          Height          =   255
  62.          Left            =   2280
  63.          TabIndex        =   47
  64.          Top             =   480
  65.          Width           =   255
  66.       End
  67.       Begin VB.CommandButton Command1 
  68.          Caption         =   "+"
  69.          Height          =   255
  70.          Left            =   2040
  71.          TabIndex        =   46
  72.          Top             =   480
  73.          Width           =   255
  74.       End
  75.       Begin VB.TextBox txtOffset 
  76.          Height          =   285
  77.          Left            =   2640
  78.          TabIndex        =   35
  79.          Top             =   1680
  80.          Width           =   375
  81.       End
  82.       Begin VB.TextBox txtNorm 
  83.          Height          =   285
  84.          Left            =   2640
  85.          TabIndex        =   34
  86.          Top             =   960
  87.          Width           =   375
  88.       End
  89.       Begin VB.TextBox txtScale 
  90.          Height          =   285
  91.          Left            =   2640
  92.          TabIndex        =   33
  93.          Top             =   240
  94.          Width           =   375
  95.       End
  96.       Begin VB.ComboBox cmbMatrixSize 
  97.          Height          =   315
  98.          Left            =   1080
  99.          TabIndex        =   7
  100.          Top             =   240
  101.          Width           =   615
  102.       End
  103.       Begin VB.TextBox txtMatrixArray 
  104.          Height          =   285
  105.          Index           =   24
  106.          Left            =   1560
  107.          TabIndex        =   32
  108.          Top             =   2400
  109.          Visible         =   0   'False
  110.          Width           =   255
  111.       End
  112.       Begin VB.TextBox txtMatrixArray 
  113.          Height          =   285
  114.          Index           =   23
  115.          Left            =   1560
  116.          TabIndex        =   27
  117.          Top             =   2040
  118.          Visible         =   0   'False
  119.          Width           =   255
  120.       End
  121.       Begin VB.TextBox txtMatrixArray 
  122.          Height          =   285
  123.          Index           =   22
  124.          Left            =   1560
  125.          TabIndex        =   22
  126.          Top             =   1680
  127.          Visible         =   0   'False
  128.          Width           =   255
  129.       End
  130.       Begin VB.TextBox txtMatrixArray 
  131.          Height          =   285
  132.          Index           =   21
  133.          Left            =   1560
  134.          TabIndex        =   17
  135.          Top             =   1320
  136.          Visible         =   0   'False
  137.          Width           =   255
  138.       End
  139.       Begin VB.TextBox txtMatrixArray 
  140.          Height          =   285
  141.          Index           =   20
  142.          Left            =   1560
  143.          TabIndex        =   12
  144.          Top             =   960
  145.          Visible         =   0   'False
  146.          Width           =   255
  147.       End
  148.       Begin VB.TextBox txtMatrixArray 
  149.          Height          =   285
  150.          Index           =   19
  151.          Left            =   1200
  152.          TabIndex        =   31
  153.          Top             =   2400
  154.          Visible         =   0   'False
  155.          Width           =   255
  156.       End
  157.       Begin VB.TextBox txtMatrixArray 
  158.          Height          =   285
  159.          Index           =   18
  160.          Left            =   1200
  161.          TabIndex        =   26
  162.          Top             =   2040
  163.          Visible         =   0   'False
  164.          Width           =   255
  165.       End
  166.       Begin VB.TextBox txtMatrixArray 
  167.          Height          =   285
  168.          Index           =   17
  169.          Left            =   1200
  170.          TabIndex        =   21
  171.          Top             =   1680
  172.          Visible         =   0   'False
  173.          Width           =   255
  174.       End
  175.       Begin VB.TextBox txtMatrixArray 
  176.          Height          =   285
  177.          Index           =   16
  178.          Left            =   1200
  179.          TabIndex        =   16
  180.          Top             =   1320
  181.          Visible         =   0   'False
  182.          Width           =   255
  183.       End
  184.       Begin VB.TextBox txtMatrixArray 
  185.          Height          =   285
  186.          Index           =   15
  187.          Left            =   1200
  188.          TabIndex        =   11
  189.          Top             =   960
  190.          Visible         =   0   'False
  191.          Width           =   255
  192.       End
  193.       Begin VB.TextBox txtMatrixArray 
  194.          Height          =   285
  195.          Index           =   14
  196.          Left            =   840
  197.          TabIndex        =   30
  198.          Top             =   2400
  199.          Visible         =   0   'False
  200.          Width           =   255
  201.       End
  202.       Begin VB.TextBox txtMatrixArray 
  203.          Height          =   285
  204.          Index           =   13
  205.          Left            =   840
  206.          TabIndex        =   25
  207.          Top             =   2040
  208.          Visible         =   0   'False
  209.          Width           =   255
  210.       End
  211.       Begin VB.TextBox txtMatrixArray 
  212.          Height          =   285
  213.          Index           =   12
  214.          Left            =   840
  215.          TabIndex        =   20
  216.          Top             =   1680
  217.          Width           =   255
  218.       End
  219.       Begin VB.TextBox txtMatrixArray 
  220.          Height          =   285
  221.          Index           =   11
  222.          Left            =   840
  223.          TabIndex        =   15
  224.          Top             =   1320
  225.          Width           =   255
  226.       End
  227.       Begin VB.TextBox txtMatrixArray 
  228.          Height          =   285
  229.          Index           =   10
  230.          Left            =   840
  231.          TabIndex        =   10
  232.          Top             =   960
  233.          Width           =   255
  234.       End
  235.       Begin VB.TextBox txtMatrixArray 
  236.          Height          =   285
  237.          Index           =   9
  238.          Left            =   480
  239.          TabIndex        =   29
  240.          Top             =   2400
  241.          Visible         =   0   'False
  242.          Width           =   255
  243.       End
  244.       Begin VB.TextBox txtMatrixArray 
  245.          Height          =   285
  246.          Index           =   8
  247.          Left            =   480
  248.          TabIndex        =   24
  249.          Top             =   2040
  250.          Visible         =   0   'False
  251.          Width           =   255
  252.       End
  253.       Begin VB.TextBox txtMatrixArray 
  254.          Height          =   285
  255.          Index           =   7
  256.          Left            =   480
  257.          TabIndex        =   19
  258.          Top             =   1680
  259.          Width           =   255
  260.       End
  261.       Begin VB.TextBox txtMatrixArray 
  262.          Height          =   285
  263.          Index           =   6
  264.          Left            =   480
  265.          TabIndex        =   14
  266.          Top             =   1320
  267.          Width           =   255
  268.       End
  269.       Begin VB.TextBox txtMatrixArray 
  270.          Height          =   285
  271.          Index           =   5
  272.          Left            =   480
  273.          TabIndex        =   9
  274.          Top             =   960
  275.          Width           =   255
  276.       End
  277.       Begin VB.TextBox txtMatrixArray 
  278.          Height          =   285
  279.          Index           =   4
  280.          Left            =   120
  281.          TabIndex        =   28
  282.          Top             =   2400
  283.          Visible         =   0   'False
  284.          Width           =   255
  285.       End
  286.       Begin VB.TextBox txtMatrixArray 
  287.          Height          =   285
  288.          Index           =   3
  289.          Left            =   120
  290.          TabIndex        =   23
  291.          Top             =   2040
  292.          Visible         =   0   'False
  293.          Width           =   255
  294.       End
  295.       Begin VB.TextBox txtMatrixArray 
  296.          Height          =   285
  297.          Index           =   2
  298.          Left            =   120
  299.          TabIndex        =   18
  300.          Top             =   1680
  301.          Width           =   255
  302.       End
  303.       Begin VB.TextBox txtMatrixArray 
  304.          Height          =   285
  305.          Index           =   1
  306.          Left            =   120
  307.          TabIndex        =   13
  308.          Top             =   1320
  309.          Width           =   255
  310.       End
  311.       Begin VB.TextBox txtMatrixArray 
  312.          Height          =   285
  313.          Index           =   0
  314.          Left            =   120
  315.          TabIndex        =   8
  316.          Top             =   960
  317.          Width           =   255
  318.       End
  319.       Begin VB.Label Label5 
  320.          Caption         =   "Offset:"
  321.          Height          =   255
  322.          Left            =   2040
  323.          TabIndex        =   42
  324.          Top             =   1680
  325.          Width           =   615
  326.       End
  327.       Begin VB.Label Label4 
  328.          Caption         =   "Norm:"
  329.          Height          =   255
  330.          Left            =   2040
  331.          TabIndex        =   41
  332.          Top             =   960
  333.          Width           =   495
  334.       End
  335.       Begin VB.Label Label3 
  336.          Caption         =   "Scale:"
  337.          Height          =   255
  338.          Left            =   2040
  339.          TabIndex        =   40
  340.          Top             =   240
  341.          Width           =   615
  342.       End
  343.       Begin VB.Label Label2 
  344.          Caption         =   "Matrix Array:"
  345.          Height          =   255
  346.          Left            =   120
  347.          TabIndex        =   39
  348.          Top             =   720
  349.          Width           =   975
  350.       End
  351.       Begin VB.Label Label1 
  352.          Caption         =   "Matrix Size:"
  353.          Height          =   255
  354.          Left            =   120
  355.          TabIndex        =   38
  356.          Top             =   240
  357.          Width           =   975
  358.       End
  359.    End
  360.    Begin VB.CommandButton cmdProcessImage 
  361.       Caption         =   "&Process Image"
  362.       Height          =   375
  363.       Left            =   3120
  364.       TabIndex        =   6
  365.       Top             =   2520
  366.       Width           =   1695
  367.    End
  368.    Begin VB.HScrollBar HScroll1 
  369.       Height          =   255
  370.       LargeChange     =   3
  371.       Left            =   3120
  372.       Max             =   10
  373.       Min             =   1
  374.       TabIndex        =   5
  375.       Top             =   2160
  376.       Value           =   1
  377.       Width           =   1455
  378.    End
  379.    Begin VB.Frame Frame1 
  380.       Caption         =   "Image Processor"
  381.       Height          =   2055
  382.       Left            =   3120
  383.       TabIndex        =   36
  384.       Top             =   0
  385.       Width           =   1695
  386.       Begin VB.OptionButton optProcessor 
  387.          Caption         =   "Matrix"
  388.          Height          =   255
  389.          Index           =   4
  390.          Left            =   120
  391.          TabIndex        =   4
  392.          Top             =   1680
  393.          Value           =   -1  'True
  394.          Width           =   1455
  395.       End
  396.       Begin VB.OptionButton optProcessor 
  397.          Caption         =   "Blur"
  398.          Height          =   255
  399.          Index           =   3
  400.          Left            =   120
  401.          TabIndex        =   3
  402.          Top             =   1320
  403.          Width           =   1455
  404.       End
  405.       Begin VB.OptionButton optProcessor 
  406.          Caption         =   "Extract Edges"
  407.          Height          =   255
  408.          Index           =   2
  409.          Left            =   120
  410.          TabIndex        =   2
  411.          Top             =   960
  412.          Width           =   1335
  413.       End
  414.       Begin VB.OptionButton optProcessor 
  415.          Caption         =   "Sharpen"
  416.          Height          =   255
  417.          Index           =   1
  418.          Left            =   120
  419.          TabIndex        =   1
  420.          Top             =   600
  421.          Width           =   1095
  422.       End
  423.       Begin VB.OptionButton optProcessor 
  424.          Caption         =   "Soften"
  425.          Height          =   255
  426.          Index           =   0
  427.          Left            =   120
  428.          TabIndex        =   0
  429.          Top             =   240
  430.          Width           =   1095
  431.       End
  432.    End
  433.    Begin ik32Lib.Picbuf PicbufOriginal 
  434.       Height          =   375
  435.       Left            =   2760
  436.       TabIndex        =   45
  437.       TabStop         =   0   'False
  438.       Top             =   720
  439.       Width           =   735
  440.       _Version        =   65536
  441.       _ExtentX        =   1296
  442.       _ExtentY        =   661
  443.       _StockProps     =   253
  444.    End
  445.    Begin ik32Lib.Picbuf PicbufVisible 
  446.       Height          =   2895
  447.       Left            =   120
  448.       TabIndex        =   44
  449.       TabStop         =   0   'False
  450.       Top             =   0
  451.       Width           =   2895
  452.       _Version        =   65536
  453.       _ExtentX        =   5106
  454.       _ExtentY        =   5106
  455.       _StockProps     =   253
  456.    End
  457.    Begin MSComDlg.CommonDialog CommonDialog1 
  458.       Left            =   2760
  459.       Top             =   1800
  460.       _Version        =   65536
  461.       _ExtentX        =   847
  462.       _ExtentY        =   847
  463.       _StockProps     =   0
  464.    End
  465.    Begin VB.Label lblScrollChange 
  466.       Caption         =   "1"
  467.       Height          =   255
  468.       Left            =   4680
  469.       TabIndex        =   43
  470.       Top             =   2160
  471.       Width           =   255
  472.    End
  473.    Begin VB.Menu mnuFile 
  474.       Caption         =   "&File"
  475.       Begin VB.Menu mnuLoad 
  476.          Caption         =   "&Load Image..."
  477.       End
  478.       Begin VB.Menu mnuSave 
  479.          Caption         =   "&Save Image..."
  480.       End
  481.       Begin VB.Menu mnuSpacer 
  482.          Caption         =   "-"
  483.       End
  484.       Begin VB.Menu mnuExit 
  485.          Caption         =   "E&xit"
  486.          Shortcut        =   ^X
  487.       End
  488.    End
  489.    Begin VB.Menu mnuReload 
  490.       Caption         =   "&Reload"
  491.    End
  492. Attribute VB_Name = "Form1"
  493. Attribute VB_Creatable = False
  494. Attribute VB_Exposed = False
  495. Option Explicit
  496. Public nSoften, nSharpen, nExtract As Integer
  497. 'Description: This code makes the 3x3 or 5x5 boxes
  498. 'visible according to which value is chosen
  499. Private Sub cmbMatrixSize_Click()
  500. Dim Index As Integer
  501. Select Case cmbMatrixSize.Text
  502.     Case "3"
  503.         'make 3x3 text boxes visible
  504.         For Index = 3 To 13 Step 5
  505.             txtMatrixArray(Index).Visible = False
  506.         Next
  507.         For Index = 4 To 14 Step 5
  508.             txtMatrixArray(Index).Visible = False
  509.         Next
  510.         For Index = 15 To 24
  511.             txtMatrixArray(Index).Visible = False
  512.         Next
  513.     Case "5"
  514.         'Make 5x5 text boxes visible
  515.         For Index = 3 To 13 Step 5
  516.             txtMatrixArray(Index).Visible = True
  517.         Next
  518.         For Index = 4 To 14 Step 5
  519.             txtMatrixArray(Index).Visible = True
  520.         Next
  521.         For Index = 15 To 24
  522.             txtMatrixArray(Index).Visible = True
  523.         Next
  524. End Select
  525. End Sub
  526. 'Description: This code determines which filter has
  527. 'been selected, and then performs that filter
  528. Private Sub cmdProcessImage_Click()
  529.     Dim nIndex, nIndex2 As Integer
  530.         
  531.     Select Case True
  532.         Case optProcessor(0).Value  'Soften
  533.             PicbufVisible.Soften nSoften
  534.         Case optProcessor(1).Value  'Sharpen
  535.             PicbufVisible.Sharpen nSharpen
  536.         Case optProcessor(2).Value  'Extract Edges
  537.             PicbufVisible.ExtractEdges nExtract
  538.         Case optProcessor(3).Value  'Blur
  539.             PicbufVisible.Blur
  540.         Case optProcessor(4).Value  'Matrix
  541.             'determine values for matrix array
  542.             If Val(cmbMatrixSize.Text) = 3 Then
  543.                 'determine for 3x3 matrix
  544.                 ReDim MatrixArray(0 To 2, 0 To 2) As Integer
  545.                 For nIndex = 0 To 2
  546.                     For nIndex2 = 0 To 2
  547.                         MatrixArray(nIndex, nIndex2) = Val(txtMatrixArray((nIndex * 5) + nIndex2).Text)
  548.                     Next
  549.                 Next
  550.             Else
  551.                 'determine for 5x5 matrix
  552.                 ReDim MatrixArray(0 To 4, 0 To 4) As Integer
  553.                 For nIndex = 0 To 4
  554.                     For nIndex2 = 0 To 4
  555.                        MatrixArray(nIndex, nIndex2) = Val(txtMatrixArray((nIndex * 5) + nIndex2).Text)
  556.                     Next
  557.                 Next
  558.             End If
  559.             'do matrix array filter
  560.             PicbufVisible.MatrixFilter Val(cmbMatrixSize.Text), MatrixArray(0, 0), Val(txtScale.Text), Val(txtNorm.Text), Val(txtOffset.Text)
  561.     End Select
  562. End Sub
  563. 'Description: This code increases the value of a
  564. 'text box.
  565. Private Sub Command1_Click()
  566.     txtScale.Text = Val(txtScale.Text) + 1
  567. End Sub
  568. 'Description: This code decreases the value of a
  569. 'text box.
  570. Private Sub Command2_Click()
  571.     txtScale.Text = Val(txtScale.Text) - 1
  572. End Sub
  573. 'Description: This code increases the value of a
  574. 'text box.
  575. Private Sub Command3_Click()
  576.   txtNorm.Text = Val(txtNorm.Text) + 1
  577. End Sub
  578. 'Description: This code decreases the value of a
  579. 'text box.
  580. Private Sub Command4_Click()
  581.     txtNorm.Text = Val(txtNorm.Text) - 1
  582.     If Val(txtNorm.Text) < -1 Then txtNorm.Text = -1
  583. End Sub
  584. 'Description: This code increases the value of a
  585. 'text box.
  586. Private Sub Command5_Click()
  587.   txtOffset.Text = Val(txtOffset.Text) + 1
  588. End Sub
  589. 'Description: This code decreases the value of a
  590. 'text box.
  591. Private Sub Command6_Click()
  592.     txtOffset.Text = Val(txtOffset.Text) - 1
  593. End Sub
  594. 'Description: Here we set all of the presets
  595. Private Sub Form_Load()
  596.     Dim loopIndex As Integer
  597.     'Set PicBuf properties
  598.     PicbufOriginal.Visible = False
  599.     InitPicbuf PicbufVisible, True
  600.     InitPicbuf PicbufOriginal, False, "winlogo1.bmp"
  601.     'Set values for soften, sharpen, and extract edges
  602.     'functions
  603.     nSoften = 1
  604.     nSharpen = 1
  605.     nExtract = 1
  606.     'Set default values for controls
  607.     optProcessor(0).Value = True
  608.     cmbMatrixSize.AddItem "3"
  609.     cmbMatrixSize.AddItem "5"
  610.     cmbMatrixSize.Text = "3"
  611.     For loopIndex = 0 To 24
  612.         txtMatrixArray(loopIndex).Text = 1
  613.     Next
  614.     txtScale.Text = 1
  615.     txtNorm.Text = -1
  616.     txtOffset.Text = 0
  617.     'Make matrix controls invisible
  618.     Form1.Width = 5020
  619. End Sub
  620. 'Description: This updates the values of certain
  621. 'filter information, according to which option
  622. 'button has been selected
  623. Private Sub HScroll1_Change()
  624.     'set value of label showing scroll bar value
  625.     lblScrollChange.Caption = HScroll1.Value
  626.     'determine which operation has been chosen, update
  627.     'the value for that operation according to scroll
  628.     'bar and text box values.
  629.     Select Case True
  630.         Case optProcessor(0).Value
  631.             nSoften = HScroll1.Value
  632.         Case optProcessor(1).Value
  633.             nSharpen = HScroll1.Value
  634.         Case optProcessor(2).Value
  635.             nExtract = HScroll1.Value
  636.     End Select
  637. End Sub
  638. 'Description: This exits the program
  639. Private Sub mnuExit_Click()
  640.     ExitProgram
  641. End Sub
  642. 'Description: This code uses the Common Dialog
  643. 'control to select a file name, and then loads it
  644. 'into the picbuf.
  645. Private Sub mnuLoad_Click()
  646.     LoadImage PicbufOriginal, CommonDialog1
  647. End Sub
  648. 'Description: This code loads the original image,
  649. 'which is stored in PicbufOriginal
  650. Private Sub mnuReload_Click()
  651.     PicbufOriginal_Change
  652.     nSoften = 1
  653.     nSharpen = 1
  654.     nExtract = 1
  655. End Sub
  656. 'Description: This code uses the Common Dialog
  657. 'control to select a file name, and then stores the
  658. 'image
  659. Private Sub mnuSave_Click()
  660.     SaveImage PicbufVisible, CommonDialog1
  661. End Sub
  662. 'Description: This section of code determines the
  663. 'values for softening, sharpening, and edge extraction.
  664. 'it also determines what is visible or enabled
  665. 'depending on which option button is chosen
  666. Private Sub optProcessor_Click(Index As Integer)
  667.     Select Case Index
  668.         Case 0
  669.             HScroll1.Enabled = True
  670.             HScroll1.Value = nSoften
  671.             lblScrollChange.Visible = True
  672.         Case 1
  673.             HScroll1.Enabled = True
  674.             HScroll1.Value = nSharpen
  675.             lblScrollChange.Visible = True
  676.         Case 2
  677.             HScroll1.Enabled = True
  678.             HScroll1.Value = nExtract
  679.             lblScrollChange.Visible = True
  680.         Case Is > 2
  681.             HScroll1.Enabled = False
  682.             lblScrollChange.Visible = False
  683.     End Select
  684.     If Index < 4 Then
  685.             Form1.Width = 5020
  686.         Else
  687.             Form1.Width = 8415
  688.     End If
  689. End Sub
  690. 'Description: This code copies an image from one
  691. 'picbuf to another.
  692. Private Sub PicbufOriginal_Change()
  693.     'copy original picbuf to edit picbuf
  694.     PicbufVisible.Picture = PicbufOriginal.Picture
  695.     PicbufVisible.Filename = PicbufOriginal.Filename
  696. End Sub
  697.