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

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Color Replace"
  5.    ClientHeight    =   3135
  6.    ClientLeft      =   1185
  7.    ClientTop       =   1950
  8.    ClientWidth     =   5895
  9.    Height          =   3825
  10.    Left            =   1125
  11.    LinkTopic       =   "Form1"
  12.    LockControls    =   -1  'True
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   3135
  16.    ScaleWidth      =   5895
  17.    Top             =   1320
  18.    Width           =   6015
  19.    Begin VB.Frame Frame1 
  20.       Caption         =   "Replacement Color"
  21.       Height          =   3015
  22.       Left            =   3720
  23.       TabIndex        =   0
  24.       Top             =   0
  25.       Width           =   2055
  26.       Begin VB.CommandButton cmdColor 
  27.          BackColor       =   &H00008080&
  28.          Caption         =   "Set Color"
  29.          Height          =   375
  30.          Left            =   120
  31.          TabIndex        =   1
  32.          Top             =   1560
  33.          Width           =   1815
  34.       End
  35.       Begin VB.Label lblBlue 
  36.          Caption         =   "lblBlue"
  37.          Height          =   255
  38.          Left            =   960
  39.          TabIndex        =   8
  40.          Top             =   1080
  41.          Width           =   735
  42.       End
  43.       Begin VB.Label lblGreen 
  44.          Caption         =   "lblGreen"
  45.          Height          =   255
  46.          Left            =   960
  47.          TabIndex        =   7
  48.          Top             =   720
  49.          Width           =   615
  50.       End
  51.       Begin VB.Label lblRed 
  52.          Caption         =   "lblRed"
  53.          Height          =   255
  54.          Left            =   960
  55.          TabIndex        =   6
  56.          Top             =   360
  57.          Width           =   615
  58.       End
  59.       Begin VB.Label Label1 
  60.          Caption         =   "Red:"
  61.          Height          =   255
  62.          Left            =   480
  63.          TabIndex        =   4
  64.          Top             =   360
  65.          Width           =   495
  66.       End
  67.       Begin VB.Label Label2 
  68.          Caption         =   "Green:"
  69.          Height          =   255
  70.          Left            =   360
  71.          TabIndex        =   3
  72.          Top             =   720
  73.          Width           =   495
  74.       End
  75.       Begin VB.Label Label3 
  76.          Caption         =   "Blue:"
  77.          Height          =   255
  78.          Left            =   480
  79.          TabIndex        =   2
  80.          Top             =   1080
  81.          Width           =   375
  82.       End
  83.       Begin VB.Shape Shape1 
  84.          FillStyle       =   0  'Solid
  85.          Height          =   855
  86.          Left            =   120
  87.          Top             =   2040
  88.          Width           =   1815
  89.       End
  90.    End
  91.    Begin ik32Lib.Picbuf Picbuf1 
  92.       Height          =   3015
  93.       Left            =   120
  94.       TabIndex        =   5
  95.       Top             =   0
  96.       Width           =   3495
  97.       _Version        =   65536
  98.       _ExtentX        =   6165
  99.       _ExtentY        =   5318
  100.       _StockProps     =   253
  101.    End
  102.    Begin MSComDlg.CommonDialog CommonDialog1 
  103.       Left            =   3000
  104.       Top             =   1800
  105.       _Version        =   65536
  106.       _ExtentX        =   847
  107.       _ExtentY        =   847
  108.       _StockProps     =   0
  109.    End
  110.    Begin VB.Menu mnuFile 
  111.       Caption         =   "&File"
  112.       Begin VB.Menu mnuLoad 
  113.          Caption         =   "&Load Image..."
  114.       End
  115.       Begin VB.Menu mnuSave 
  116.          Caption         =   "&Save Image..."
  117.       End
  118.       Begin VB.Menu mnuSpacer 
  119.          Caption         =   "-"
  120.       End
  121.       Begin VB.Menu mnuExit 
  122.          Caption         =   "E&xit"
  123.          Shortcut        =   ^X
  124.       End
  125.    End
  126.    Begin VB.Menu mnuReload 
  127.       Caption         =   "&Reload"
  128.    End
  129. Attribute VB_Name = "Form1"
  130. Attribute VB_Creatable = False
  131. Attribute VB_Exposed = False
  132. Option Explicit
  133. 'Description: This code sets the color of the shape
  134. 'control to that of the rgb values selected
  135. Private Sub cmdColor_Click()
  136.     Shape1.FillColor = GetColor(CommonDialog1)
  137.     lblRed.Caption = Str$(getRed(Shape1.FillColor))
  138.     lblGreen.Caption = Str$(getGreen(Shape1.FillColor))
  139.     lblBlue.Caption = Str$(GetBlue(Shape1.FillColor))
  140. End Sub
  141. 'Description: This code sets properties for the Picbuf
  142. 'control
  143. Private Sub Form_Load()
  144.     InitPicbuf Picbuf1, True, "marybeth.tif"
  145.     Picbuf1.MousePointer = MPCross
  146.     lblRed = 0
  147.     lblGreen = 0
  148.     lblBlue = 0
  149. End Sub
  150. 'Description: This code closes the program
  151. Private Sub mnuExit_Click()
  152.     ExitProgram
  153. End Sub
  154. 'Description: This code loads an image using
  155. 'the common dialog box
  156. Private Sub mnuLoad_Click()
  157.     LoadImage Picbuf1, CommonDialog1
  158. End Sub
  159. 'Description: This code simply reloads the image.
  160. Private Sub mnuReload_Click()
  161.     Picbuf1.Load
  162. End Sub
  163. 'Description: This code saves an image using
  164. 'the common dialog box
  165. Private Sub mnuSave_Click()
  166.     SaveImage Picbuf1, CommonDialog1
  167. End Sub
  168. 'Description: This code changes the color of the image,
  169. 'according to where the mouse is, and what color has
  170. 'been selected
  171. Private Sub Picbuf1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  172. Dim SelectedColor, ChangeColor As Double, XPos, YPos As Integer
  173. ChangeColor = RGB(Val(lblRed), Val(lblGreen), Val(lblBlue))
  174. XPos = Picbuf1.ScreenToImageX(x / Screen.TwipsPerPixelX)
  175. YPos = Picbuf1.ScreenToImageY(y / Screen.TwipsPerPixelY)
  176. If XPos <> -1 And XPos < Picbuf1.Xresolution And YPos <> -1 And YPos < Picbuf1.Yresolution Then
  177.     If Picbuf1.ColorDepth = 24 Then
  178.         SelectedColor = Picbuf1.GetColor(XPos, YPos)
  179.         Picbuf1.ColorReplace SelectedColor, SelectedColor, False, ChangeColor
  180.     Else
  181.         SelectedColor = Picbuf1.GetPalIndex(XPos, YPos)
  182.         Picbuf1.SetPalColor SelectedColor, ChangeColor
  183.     End If
  184. End If
  185. End Sub
  186.