home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Form1
- BorderStyle = 1 'Fixed Single
- Caption = "Color Replace"
- ClientHeight = 3135
- ClientLeft = 1185
- ClientTop = 1950
- ClientWidth = 5895
- Height = 3825
- Left = 1125
- LinkTopic = "Form1"
- LockControls = -1 'True
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 3135
- ScaleWidth = 5895
- Top = 1320
- Width = 6015
- Begin VB.Frame Frame1
- Caption = "Replacement Color"
- Height = 3015
- Left = 3720
- TabIndex = 0
- Top = 0
- Width = 2055
- Begin VB.CommandButton cmdColor
- BackColor = &H00008080&
- Caption = "Set Color"
- Height = 375
- Left = 120
- TabIndex = 1
- Top = 1560
- Width = 1815
- End
- Begin VB.Label lblBlue
- Caption = "lblBlue"
- Height = 255
- Left = 960
- TabIndex = 8
- Top = 1080
- Width = 735
- End
- Begin VB.Label lblGreen
- Caption = "lblGreen"
- Height = 255
- Left = 960
- TabIndex = 7
- Top = 720
- Width = 615
- End
- Begin VB.Label lblRed
- Caption = "lblRed"
- Height = 255
- Left = 960
- TabIndex = 6
- Top = 360
- Width = 615
- End
- Begin VB.Label Label1
- Caption = "Red:"
- Height = 255
- Left = 480
- TabIndex = 4
- Top = 360
- Width = 495
- End
- Begin VB.Label Label2
- Caption = "Green:"
- Height = 255
- Left = 360
- TabIndex = 3
- Top = 720
- Width = 495
- End
- Begin VB.Label Label3
- Caption = "Blue:"
- Height = 255
- Left = 480
- TabIndex = 2
- Top = 1080
- Width = 375
- End
- Begin VB.Shape Shape1
- FillStyle = 0 'Solid
- Height = 855
- Left = 120
- Top = 2040
- Width = 1815
- End
- End
- Begin ik32Lib.Picbuf Picbuf1
- Height = 3015
- Left = 120
- TabIndex = 5
- Top = 0
- Width = 3495
- _Version = 65536
- _ExtentX = 6165
- _ExtentY = 5318
- _StockProps = 253
- End
- Begin MSComDlg.CommonDialog CommonDialog1
- Left = 3000
- Top = 1800
- _Version = 65536
- _ExtentX = 847
- _ExtentY = 847
- _StockProps = 0
- End
- Begin VB.Menu mnuFile
- Caption = "&File"
- Begin VB.Menu mnuLoad
- Caption = "&Load Image..."
- End
- Begin VB.Menu mnuSave
- Caption = "&Save Image..."
- End
- Begin VB.Menu mnuSpacer
- Caption = "-"
- End
- Begin VB.Menu mnuExit
- Caption = "E&xit"
- Shortcut = ^X
- End
- End
- Begin VB.Menu mnuReload
- Caption = "&Reload"
- End
- Attribute VB_Name = "Form1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- 'Description: This code sets the color of the shape
- 'control to that of the rgb values selected
- Private Sub cmdColor_Click()
- Shape1.FillColor = GetColor(CommonDialog1)
- lblRed.Caption = Str$(getRed(Shape1.FillColor))
- lblGreen.Caption = Str$(getGreen(Shape1.FillColor))
- lblBlue.Caption = Str$(GetBlue(Shape1.FillColor))
- End Sub
- 'Description: This code sets properties for the Picbuf
- 'control
- Private Sub Form_Load()
- InitPicbuf Picbuf1, True, "marybeth.tif"
- Picbuf1.MousePointer = MPCross
- lblRed = 0
- lblGreen = 0
- lblBlue = 0
- End Sub
- 'Description: This code closes the program
- Private Sub mnuExit_Click()
- ExitProgram
- End Sub
- 'Description: This code loads an image using
- 'the common dialog box
- Private Sub mnuLoad_Click()
- LoadImage Picbuf1, CommonDialog1
- End Sub
- 'Description: This code simply reloads the image.
- Private Sub mnuReload_Click()
- Picbuf1.Load
- End Sub
- 'Description: This code saves an image using
- 'the common dialog box
- Private Sub mnuSave_Click()
- SaveImage Picbuf1, CommonDialog1
- End Sub
- 'Description: This code changes the color of the image,
- 'according to where the mouse is, and what color has
- 'been selected
- Private Sub Picbuf1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
- Dim SelectedColor, ChangeColor As Double, XPos, YPos As Integer
- ChangeColor = RGB(Val(lblRed), Val(lblGreen), Val(lblBlue))
- XPos = Picbuf1.ScreenToImageX(x / Screen.TwipsPerPixelX)
- YPos = Picbuf1.ScreenToImageY(y / Screen.TwipsPerPixelY)
- If XPos <> -1 And XPos < Picbuf1.Xresolution And YPos <> -1 And YPos < Picbuf1.Yresolution Then
- If Picbuf1.ColorDepth = 24 Then
- SelectedColor = Picbuf1.GetColor(XPos, YPos)
- Picbuf1.ColorReplace SelectedColor, SelectedColor, False, ChangeColor
- Else
- SelectedColor = Picbuf1.GetPalIndex(XPos, YPos)
- Picbuf1.SetPalColor SelectedColor, ChangeColor
- End If
- End If
- End Sub
-