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

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Mask Copy"
  5.    ClientHeight    =   3645
  6.    ClientLeft      =   1185
  7.    ClientTop       =   1965
  8.    ClientWidth     =   8685
  9.    Height          =   4425
  10.    Left            =   1125
  11.    LinkTopic       =   "Form1"
  12.    LockControls    =   -1  'True
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   3645
  16.    ScaleWidth      =   8685
  17.    Top             =   1245
  18.    Width           =   8805
  19.    Begin VB.CommandButton cmdDarken 
  20.       Caption         =   "&Darken"
  21.       Height          =   375
  22.       Left            =   7080
  23.       TabIndex        =   6
  24.       Top             =   3240
  25.       Width           =   1575
  26.    End
  27.    Begin VB.CommandButton cmdLighten 
  28.       Caption         =   "&Lighten"
  29.       Height          =   375
  30.       Left            =   5400
  31.       TabIndex        =   5
  32.       Top             =   3240
  33.       Width           =   1575
  34.    End
  35.    Begin VB.CommandButton cmdGridify 
  36.       Caption         =   "&Gridify"
  37.       Height          =   375
  38.       Left            =   3720
  39.       TabIndex        =   4
  40.       Top             =   3240
  41.       Width           =   1575
  42.    End
  43.    Begin VB.CommandButton cmdComposite 
  44.       Caption         =   "&Composite Images"
  45.       Height          =   375
  46.       Left            =   120
  47.       TabIndex        =   0
  48.       Top             =   3240
  49.       Width           =   1575
  50.    End
  51.    Begin ik32Lib.Picbuf PicbufDest 
  52.       Height          =   2895
  53.       Left            =   5880
  54.       TabIndex        =   9
  55.       Top             =   240
  56.       Width           =   2775
  57.       _Version        =   65536
  58.       _ExtentX        =   4895
  59.       _ExtentY        =   5106
  60.       _StockProps     =   253
  61.    End
  62.    Begin ik32Lib.Picbuf PicbufMask 
  63.       Height          =   2895
  64.       Left            =   3000
  65.       TabIndex        =   8
  66.       Top             =   240
  67.       Width           =   2775
  68.       _Version        =   65536
  69.       _ExtentX        =   4895
  70.       _ExtentY        =   5106
  71.       _StockProps     =   253
  72.    End
  73.    Begin ik32Lib.Picbuf PicbufSrc 
  74.       Height          =   2895
  75.       Left            =   120
  76.       TabIndex        =   7
  77.       Top             =   240
  78.       Width           =   2775
  79.       _Version        =   65536
  80.       _ExtentX        =   4895
  81.       _ExtentY        =   5106
  82.       _StockProps     =   253
  83.    End
  84.    Begin MSComDlg.CommonDialog CommonDialog1 
  85.       Left            =   3840
  86.       Top             =   0
  87.       _Version        =   65536
  88.       _ExtentX        =   847
  89.       _ExtentY        =   847
  90.       _StockProps     =   0
  91.    End
  92.    Begin VB.Label Label3 
  93.       Caption         =   "Destination:"
  94.       Height          =   255
  95.       Left            =   5880
  96.       TabIndex        =   3
  97.       Top             =   0
  98.       Width           =   1095
  99.    End
  100.    Begin VB.Label Label2 
  101.       Caption         =   "Mask:"
  102.       Height          =   255
  103.       Left            =   3000
  104.       TabIndex        =   2
  105.       Top             =   0
  106.       Width           =   1095
  107.    End
  108.    Begin VB.Label Label1 
  109.       Caption         =   "Source:"
  110.       Height          =   255
  111.       Left            =   120
  112.       TabIndex        =   1
  113.       Top             =   0
  114.       Width           =   1215
  115.    End
  116.    Begin VB.Menu mnuFile 
  117.       Caption         =   "&File"
  118.       Begin VB.Menu mnuLoadSource 
  119.          Caption         =   "Load &Source Image..."
  120.       End
  121.       Begin VB.Menu mnuLoadMask 
  122.          Caption         =   "Load &Mask Image..."
  123.       End
  124.       Begin VB.Menu mnuLoadDestination 
  125.          Caption         =   "Load &Destination Image..."
  126.       End
  127.       Begin VB.Menu mnuSaveDestinationAs 
  128.          Caption         =   "Save D&estination Image..."
  129.       End
  130.       Begin VB.Menu mnuSpacer 
  131.          Caption         =   "-"
  132.       End
  133.       Begin VB.Menu mnuExit 
  134.          Caption         =   "E&xit"
  135.          Shortcut        =   ^X
  136.       End
  137.    End
  138.    Begin VB.Menu mnuReload 
  139.       Caption         =   "&Reload"
  140.    End
  141. Attribute VB_Name = "Form1"
  142. Attribute VB_Creatable = False
  143. Attribute VB_Exposed = False
  144. 'Description: This code uses the MaskCopy method
  145. 'to composite two images together using a mask
  146. Private Sub cmdComposite_Click()
  147. Call PicbufDest.MaskCopy(PicbufSrc, PicbufMask)
  148. End Sub
  149. 'Description: This code darkens the destination image.
  150. Private Sub cmdDarken_Click()
  151.     PicbufSrc.Init 24, PicbufDest.Xresolution, PicbufDest.Yresolution, RGB(0, 0, 0)
  152.     PicbufMask.Init 24, PicbufDest.Xresolution, PicbufDest.Yresolution, RGB(75, 75, 75)
  153.     cmdComposite_Click
  154. End Sub
  155. 'Description: this code creates a grid, and then
  156. 'applies it to an image using the MaskCopy method
  157. Private Sub cmdGridify_Click()
  158.     Dim Color1, Color2 As Long, Index As Integer
  159.     ReDim scanline0(0 To PicbufDest.Xresolution) As Long
  160.     ReDim scanline1(0 To PicbufDest.Xresolution) As Long
  161.     'clear images from source and mask picbufs
  162.     PicbufSrc.Clear
  163.     PicbufMask.Clear
  164.     'initialize the source picbuf with a white image
  165.     Call PicbufSrc.Init(24, PicbufDest.Xresolution, PicbufDest.Yresolution, RGB(255, 255, 255))
  166.     'initialize white and black colors
  167.     Color1 = RGB(0, 0, 0)
  168.     Color2 = RGB(255, 255, 255)
  169.     For Index = LBound(scanline0) To UBound(scanline0)
  170.         If Index Mod 2 = 0 Then
  171.             scanline0(Index) = Color1
  172.             scanline1(Index) = Color2
  173.         Else
  174.             scanline0(Index) = Color2
  175.             scanline1(Index) = Color1
  176.         End If
  177.     Next
  178.     For Index = 0 To PicbufDest.Yresolution - 1
  179.         If Index Mod 10 = 0 Then
  180.             Call PicbufSrc.PutScanLine(Index, scanline0(0))
  181.         Else
  182.             Call PicbufSrc.PutScanLine(Index, scanline1(0))
  183.         End If
  184.     Next
  185.     PicbufMask.Assign False, PicbufSrc, False
  186.     PicbufMask.Negate
  187.     cmdComposite_Click
  188. End Sub
  189. 'Description: This code lightens the destination
  190. 'image using maskcopy.
  191. Private Sub cmdLighten_Click()
  192.     PicbufSrc.Init 24, PicbufDest.Xresolution, PicbufDest.Yresolution, RGB(255, 255, 255)
  193.     PicbufMask.Init 24, PicbufDest.Xresolution, PicbufDest.Yresolution, RGB(75, 75, 75)
  194.     cmdComposite_Click
  195. End Sub
  196. 'Description: Here we set all of the presets
  197. Private Sub Form_Load()
  198.     'init picbufs
  199.     InitPicbuf PicbufSrc, True, "Squirrel.bmp"
  200.     InitPicbuf PicbufMask, True, "Sqcutout.bmp"
  201.     InitPicbuf PicbufDest, True, "Balloon.bmp"
  202. End Sub
  203. 'Description: This code exits the program
  204. Private Sub mnuExit_Click()
  205.     ExitProgram
  206. End Sub
  207. 'Description: This code uses the Common Dialog
  208. 'control to determine a file name, and then loads
  209. 'the image into a picbuf
  210. Private Sub ikLoadDestination_Click()
  211.     LoadImage PicbufDest, CommonDialog1
  212. End Sub
  213. 'Description: This code uses the Common Dialog
  214. 'control to determine a file name, and then loads
  215. 'the image into a picbuf
  216. Private Sub mnuLoadDestination_Click()
  217.     LoadImage PicbufDest, CommonDialog1
  218. End Sub
  219. 'Description: This code uses the Common Dialog
  220. 'control to determine a file name, and then loads
  221. 'the image into a picbuf
  222. Private Sub mnuLoadMask_Click()
  223.     LoadImage PicbufMask, CommonDialog1
  224. End Sub
  225. 'Description: This code uses the Common Dialog
  226. 'control to determine a file name, and then loads
  227. 'the image into a picbuf
  228. Private Sub mnuLoadSource_Click()
  229.     LoadImage PicbufSrc, CommonDialog1
  230. End Sub
  231. 'Description: This code reloads all of the images.
  232. Private Sub mnuReload_Click()
  233.     PicbufSrc.Load
  234.     PicbufMask.Load
  235.     PicbufDest.Load
  236. End Sub
  237. 'Description: This code uses the Common Dialog
  238. 'control to determine a file name, and then stores
  239. 'the image.
  240. Private Sub mnuSaveDestinationAs_Click()
  241.     SaveImage PicbufDest, CommonDialog1
  242. End Sub
  243.