vbAccelerator - Contents of code file: frmColourisation.frm

VERSION 5.00
Begin VB.Form frmColourisation 
   Caption         =   "vbAccelerator Colourisation Demonstration"
   ClientHeight    =   4785
   ClientLeft      =   3945
   ClientTop       =   2880
   ClientWidth     =   7665
   BeginProperty Font 
      Name            =   "Tahoma"
      Size            =   8.25
      Charset         =   0
      Weight          =   400
      Underline       =   0   'False
      Italic          =   0   'False
      Strikethrough   =   0   'False
   EndProperty
   Icon            =   "frmColourisation.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   4785
   ScaleWidth      =   7665
   Begin VB.HScrollBar hscSaturation 
      Height          =   255
      LargeChange     =   32
      Left            =   4680
      Max             =   255
      SmallChange     =   16
      TabIndex        =   8
      Top             =   4320
      Value           =   100
      Width           =   1575
   End
   Begin VB.HScrollBar hscHue 
      Height          =   255
      LargeChange     =   32
      Left            =   4680
      Max             =   255
      SmallChange     =   16
      TabIndex        =   5
      Top             =   3960
      Value           =   100
      Width           =   1575
   End
   Begin VB.CommandButton cmdSource 
      Caption         =   "Load I&mage..."
      Height          =   435
      Left            =   60
      TabIndex        =   2
      Top             =   3900
      Width           =   1455
   End
   Begin VB.PictureBox picSource 
      Height          =   3435
      Left            =   60
      ScaleHeight     =   225
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   241
      TabIndex        =   1
      Top             =   420
      Width           =   3675
   End
   Begin VB.PictureBox picResult 
      Height          =   3435
      Left            =   3840
      ScaleHeight     =   225
      ScaleMode       =   3  'Pixel
      ScaleWidth      =   241
      TabIndex        =   0
      Top             =   420
      Width           =   3675
   End
   Begin VB.Label lblSaturation 
      Caption         =   "&Saturation"
      Height          =   255
      Left            =   3840
      TabIndex        =   10
      Top             =   4320
      Width           =   855
   End
   Begin VB.Label lblSaturationValue 
      Height          =   255
      Left            =   6360
      TabIndex        =   9
      Top             =   4320
      Width           =   675
   End
   Begin VB.Label lblHue 
      Caption         =   "&Hue"
      Height          =   255
      Left            =   3840
      TabIndex        =   7
      Top             =   3960
      Width           =   855
   End
   Begin VB.Label lblHueValue 
      Height          =   255
      Left            =   6360
      TabIndex        =   6
      Top             =   3960
      Width           =   675
   End
   Begin VB.Label lblSource 
      BackColor       =   &H80000010&
      Caption         =   " Source Image"
      ForeColor       =   &H80000014&
      Height          =   255
      Left            =   60
      TabIndex        =   4
      Top             =   60
      Width           =   3675
   End
   Begin VB.Label lblResult 
      BackColor       =   &H80000010&
      Caption         =   " Result"
      ForeColor       =   &H80000014&
      Height          =   255
      Left            =   3840
      TabIndex        =   3
      Top             =   60
      Width           =   3675
   End
End
Attribute VB_Name = "frmColourisation"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private m_cSourceImage As New cDIBSection
Private m_cColouriseImage As New cDIBSection
Private m_cColourise As New cColourise

Private Sub Process()
   lblHueValue.Caption = hscHue.value
   lblSaturationValue.Caption = hscSaturation.value
   m_cColourise.Hue = hscHue.value
   m_cColourise.Saturation = hscSaturation.value
   m_cColourise.Process m_cSourceImage, m_cColouriseImage
   picResult.Refresh
End Sub

Private Sub openImage(ByVal sFile As String)
   Dim sPic As StdPicture
   Set sPic = LoadPicture(sFile)
   m_cSourceImage.CreateFromPicture sPic
   picSource.Refresh
   m_cColouriseImage.Create m_cSourceImage.Width, m_cSourceImage.Height
   hscHue_Change
End Sub

Private Sub cmdSource_Click()
On Error GoTo ErrorHandler
   
   Dim c As New cCommonDialog
   Dim sFile As String
   If c.VBGetOpenFileName(sFile, Filter:="Picture Files
    (*.GIF;*.JPG;*.BMP)|*.GIF;*.JPG;*.BMP|All Files (*.*)|*.*",
    DefaultExt:="BMP", Owner:=Me.hwnd) Then
      openImage sFile
   End If
   Exit Sub

ErrorHandler:
   MsgBox "Problem getting source image: [" & Err.Description & "]",
    vbExclamation
   Exit Sub
End Sub


Private Sub Form_Load()
   
   Me.Show
   Me.Refresh
   
On Error GoTo ErrorHandler
   Dim sFile As String
   sFile = App.Path
   If (Right$(sFile, 1) <> "\") Then sFile = sFile & "\"
   sFile = sFile & "/home/VB/Code/vbMedia/Image_Processing/Colourisation/supercomputer.gif"
   openImage sFile
   Exit Sub
   
ErrorHandler:
   MsgBox "Problem getting source image: [" & Err.Description & "]",
    vbExclamation
   Exit Sub
End Sub

Private Sub hscHue_Change()
   Process
End Sub

Private Sub hscHue_Scroll()
   Process
End Sub

Private Sub hscSaturation_Change()
   Process
End Sub

Private Sub hscSaturation_Scroll()
   Process
End Sub

Private Sub picResult_Paint()
   m_cColouriseImage.PaintPicture picResult.hdc
End Sub

Private Sub picSource_Paint()
   m_cSourceImage.PaintPicture picSource.hdc
End Sub