Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, lpInitData As DEVMODE) As Long
Declare Function DeleteDC Lib "gdi32" (ByVal hDC As Long) As Long
Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As Long, ByVal nIndex As Long) As Long
Sub GetFont(Picbuf As Control, CommonDialog As Control)
Function GetBlue(ByVal RGBColor As Long) As Integer
Dim ColorComponentValue As Integer
ColorComponentValue = RGBColor \ 65536
If ColorComponentValue < 0 Or ColorComponentValue > 255 Then
MsgBox "Assertion Falure:" + Chr(13) + "ColorComponentValue < 0 or > 255. Invalid value of:" + Str(ColorComponentValue)
End If
GetBlue = ColorComponentValue
End Function
Function GetColor(CommonDialog As Object) As Long
On Error GoTo Cancel_Click
CommonDialog.CancelError = True
CommonDialog.ShowColor
GetColor = CommonDialog.Color
Exit Function
Cancel_Click:
If Err.Number = 32755 Then
Exit Function
Else
MsgBox Err.Description
End If
End Function
Function getGreen(RGBColor As Long) As Integer
Dim ColorComponentValue As Integer
ColorComponentValue = (RGBColor And 65535) \ 256
If ColorComponentValue < 0 Or ColorComponentValue > 255 Then
MsgBox "Assertion Falure:" + Chr(13) + "ColorComponentValue < 0 or > 255. Invalid value of:" + Str(ColorComponentValue)
End If
getGreen = ColorComponentValue
End Function
Function getRed(RGBColor As Long) As Integer
Dim ColorComponentValue As Integer
ColorComponentValue = RGBColor And 255
If ColorComponentValue < 0 Or ColorComponentValue > 255 Then
MsgBox "Assertion Falure:" + Chr(13) + "ColorComponentValue < 0 or > 255. Invalid value of:" + Str(ColorComponentValue)
End If
getRed = ColorComponentValue
End Function
Sub ExitProgram()
End
End Sub
Function GetScreenColorDepth() As Integer
Const BitsPixel = 12
Dim TempDevMode As DEVMODE
Dim ColorDepth, hDC, RetVar As Integer
hDC = CreateDC("DISPLAY", "", "", TempDevMode)
ColorDepth = (GetDeviceCaps(hDC, BitsPixel))
RetVar = DeleteDC(hDC)
GetScreenColorDepth = ColorDepth
End Function
Sub LoadImage(Picbuf As Control, CommonDialog As Control)
CommonDialog.DialogTitle = "Load Image"
CommonDialog.Filter = "all files|*.*|picture files|*.bmp;*.dib;*.jpg;*.pcx;*.png;*.tga;*.tif;*.fif|BMP|*.bmp|DIB|*.dib|JPEG|*.jpg|PCX|*.pcx|PNG|*.png|Targa|*.tga|TIFF|*.tif|FIF|*.fif"
CommonDialog.FilterIndex = 2
CommonDialog.InitDir = App.Path + "\..\Images\"
On Error GoTo Cancel_Click
CommonDialog.CancelError = True
CommonDialog.ShowOpen
Picbuf.Filename = CommonDialog.Filename
Picbuf.Load
Exit Sub
Cancel_Click:
If Err.Number = 32755 Then
Exit Sub
Else
MsgBox Err.Description
End If
End Sub
Sub SaveImage(Picbuf As Control, CommonDialog As Control)