-pulizia codice

This commit is contained in:
Demetrio Cassarino
2025-06-25 14:20:24 +02:00
parent 0a6195aa19
commit a753e2082c
32 changed files with 4348 additions and 5063 deletions
+8 -10
View File
@@ -1,5 +1,4 @@
Namespace My
Namespace My
' The following events are available for MyApplication:
'
@@ -10,32 +9,30 @@ Namespace My
' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
Partial Friend Class MyApplication
#Region "METHODS"
Private Sub MyApplication_Startup(sender As Object, e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
If e.CommandLine.Count > 0 Then
If e.CommandLine(0) = "0" Then
ModalitaNascosta = True
Else
'
End If
If e.CommandLine.Count > 1 Then MainModule.IndexProc = e.CommandLine(1)
ElseIf e.CommandLine.Count = 0 AndAlso ModalitaNascosta = False Then
MainModule.IndexProc = ""
End If
If e.CommandLine.Count > 1 Then MainModule.IndexProc = e.CommandLine(1)
End Sub
' METODO NON IN USO: DA RIMUOVERE (il processo è avviato una volta sola)
Private Sub MyApplication_StartupNextInstance(sender As Object, e As Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs) Handles Me.StartupNextInstance
If e.CommandLine.Count > 1 Then
MainModule.SpessLastra = Val(e.CommandLine(1))
End If
If e.CommandLine.Count > 2 Then
MainModule.SogliaPercentuale = Val(e.CommandLine(2))
End If
If e.CommandLine.Count > 3 Then
FrmMain.SetSearchMode(CInt(Val(e.CommandLine(3))))
Else
End If
If e.CommandLine.Count > 0 Then
@@ -60,10 +57,11 @@ Namespace My
FrmMain.RipetiThreshold()
End If
End If
End Sub
End Class
#End Region ' Methods
End Class
End Namespace
+57 -72
View File
@@ -20,95 +20,80 @@
'******************************************************************************/
Option Explicit On
Imports System.Runtime.InteropServices
Public Class CameraController
'// Camera model
Protected model As CameraModel
#Region "FIELDS & PROPERTIES"
'// Command processing
Protected processor As New Processor
'// Camera model
Protected model As CameraModel
'// Command processing
Protected processor As New Processor
#End Region ' Fields & Properties
'// Constractor
Public Sub New()
model = Nothing
End Sub
#Region "CONSTRUCTOR"
'// Destructor
Protected Overrides Sub Finalize()
End Sub
Public Sub New()
model = Nothing
End Sub
#End Region ' Constructor
Public Sub setCameraModel(ByVal model As CameraModel)
Me.model = model
End Sub
#Region "METHODS"
'// Destructor
Protected Overrides Sub Finalize()
End Sub
'// Start processor thread
Public Sub run()
Public Sub setCameraModel(ByVal model As CameraModel)
Me.model = model
End Sub
processor.start()
'// Start processor thread
Public Sub run()
processor.start()
'The communication with the camera begins
StoreAsync(New OpenSessionCommand(model))
'The communication with the camera begins
StoreAsync(New OpenSessionCommand(model))
End Sub
End Sub
Public Sub actionPerformed(ByVal strEvent As String, ByVal inObject As IntPtr)
If strEvent = "download" Then
End If
End Sub
Public Sub actionPerformed(ByVal strEvent As String)
If strEvent = "opensession" Then
'// Start communication with remote camera.
StoreAsync(New OpenSessionCommand(model))
ElseIf strEvent = "takepicture" Then
StoreAsync(New TakePictureCommand(model))
ElseIf strEvent = "close" Then
model.notifyObservers(clse)
processor.setCloseCommand(New CloseSessionCommand(model))
processor.stopTh()
processor.join()
End If
End Sub
Public Sub actionPerformed(ByVal strEvent As String, ByVal inObject As IntPtr)
If strEvent = "download" Then
'StoreAsync(New DownloadCommand(model, inObject)) '
End If
End Sub
Public Sub actionPerformed(ByVal strEvent As String, ByVal id As Integer, Optional ByVal data As Integer = 0)
If strEvent = "get" Then
StoreAsync(New GetPropertyCommand(model, id))
ElseIf strEvent = "set" Then
StoreAsync(New SetPropertyCommand(model, id, data))
ElseIf strEvent = "getlist" Then
StoreAsync(New GetPropertyDescCommand(model, id))
End If
End Sub
'// Receive a command
Protected Sub StoreAsync(ByVal command As Command)
If IsNothing(command) = False Then
processor.enqueue(command)
End If
End Sub
Public Sub actionPerformed(ByVal strEvent As String)
If strEvent = "opensession" Then
'// Start communication with remote camera.
StoreAsync(New OpenSessionCommand(model))
ElseIf strEvent = "takepicture" Then
StoreAsync(New TakePictureCommand(model))
ElseIf strEvent = "close" Then
model.notifyObservers(clse)
processor.setCloseCommand(New CloseSessionCommand(model))
processor.stopTh()
processor.join()
End If
End Sub
Public Sub actionPerformed(ByVal strEvent As String, ByVal id As Integer, Optional ByVal data As Integer = 0)
If strEvent = "get" Then
StoreAsync(New GetPropertyCommand(model, id))
ElseIf strEvent = "set" Then
StoreAsync(New SetPropertyCommand(model, id, data))
ElseIf strEvent = "getlist" Then
StoreAsync(New GetPropertyDescCommand(model, id))
End If
End Sub
'// Receive a command
Protected Sub StoreAsync(ByVal command As Command)
If IsNothing(command) = False Then
processor.enqueue(command)
End If
End Sub
#End Region ' Methods
End Class
+224 -229
View File
@@ -20,310 +20,305 @@
'******************************************************************************/
Option Explicit On
Imports System.Runtime.InteropServices
Public Class CameraModel
Inherits Observable
Inherits Observable
#Region "METHODS"
Protected camera As IntPtr
'// UIlock counter
Protected lockCount As Integer
'// Model name
Protected modelName As String
Protected camera As IntPtr
'// UIlock counter
Protected lockCount As Integer
'// Model name
Protected modelName As String
Protected ownerName As String
'// Parameters
Protected AEMode As Integer
Protected Av As Integer
Protected Tv As Integer
Protected Iso As Integer
Protected MeteringMode As Integer
Protected ExposureCompensation As Integer
Protected ImageQuality As Integer
Protected availableShot As Integer
'// Available parameter lists
Protected AEModeDesc As EdsPropertyDesc
Protected AvDesc As EdsPropertyDesc
Protected TvDesc As EdsPropertyDesc
Protected IsoDesc As EdsPropertyDesc
Protected MeteringModeDesc As EdsPropertyDesc
Protected ExposureCompensationDesc As EdsPropertyDesc
'// Parameters
Protected AEMode As Integer
Protected Av As Integer
Protected Tv As Integer
Protected Iso As Integer
Protected MeteringMode As Integer
Protected ExposureCompensation As Integer
Protected ImageQuality As Integer
Protected availableShot As Integer
'// Available parameter lists
Protected AEModeDesc As EdsPropertyDesc
Protected AvDesc As EdsPropertyDesc
Protected TvDesc As EdsPropertyDesc
Protected IsoDesc As EdsPropertyDesc
Protected MeteringModeDesc As EdsPropertyDesc
Protected ExposureCompensationDesc As EdsPropertyDesc
Protected ImageQualityDesc As EdsPropertyDesc
Protected IDBodyCAmera As String = ""
#End Region ' Methods
'// Constructor
Public Sub New(ByVal camera As IntPtr)
Me.lockCount = 0
Me.camera = camera
End Sub
#Region "CONSTRUCTOR"
'// Get a camera object
Public Function getCameraObject() As IntPtr
Return Me.camera
End Function
Public Sub New(ByVal camera As IntPtr)
Me.lockCount = 0
Me.camera = camera
End Sub
#End Region ' Constructor
'// -----------------------------------------------------------------
'// Stock parameters ---------------------------------------------
#Region "METHODS"
Private Sub setAEMode(ByVal value As Integer)
AEMode = value
End Sub
'// Get a camera object
Public Function getCameraObject() As IntPtr
Return Me.camera
End Function
Private Sub setTv(ByVal value As Integer)
Tv = value
End Sub
'// -----------------------------------------------------------------
'// Stock parameters ---------------------------------------------
Private Sub setAv(ByVal value As Integer)
Av = value
End Sub
Private Sub setAEMode(ByVal value As Integer)
AEMode = value
End Sub
Private Sub setIso(ByVal value As Integer)
Iso = value
End Sub
Private Sub setTv(ByVal value As Integer)
Tv = value
End Sub
Private Sub setMeteringMode(ByVal value As Integer)
MeteringMode = value
End Sub
Private Sub setAv(ByVal value As Integer)
Av = value
End Sub
Private Sub setExposureCompensation(ByVal value As Integer)
ExposureCompensation = value
End Sub
Private Sub setIso(ByVal value As Integer)
Iso = value
End Sub
Private Sub setMeteringMode(ByVal value As Integer)
MeteringMode = value
End Sub
Private Sub setExposureCompensation(ByVal value As Integer)
ExposureCompensation = value
End Sub
Private Sub setBodyIDEx(ByVal value As String)
IDBodyCAmera = value
End Sub
Private Sub setModelName(ByVal modelName As String)
modelName = modelName
End Sub
Private Sub setModelName(ByVal modelName As String)
modelName = modelName
End Sub
Private Sub setImageQuality(ByVal value As Integer)
ImageQuality = value
End Sub
'// -----------------------------------------------------------------
'// Give parameters ---------------------------------------------
'// -----------------------------------------------------------------
'// Give parameters ---------------------------------------------
Private Function getAEMode() As Integer
Return AEMode
End Function
Private Function getAEMode() As Integer
Return AEMode
End Function
Private Function getTv() As Integer
Return Tv
End Function
Private Function getTv() As Integer
Return Tv
End Function
Private Function getAv() As Integer
Return Av
End Function
Private Function getAv() As Integer
Return Av
End Function
Private Function getIso() As Integer
Return Iso
End Function
Private Function getIso() As Integer
Return Iso
End Function
Private Function getMeteringMode() As Integer
Return MeteringMode
End Function
Private Function getMeteringMode() As Integer
Return MeteringMode
End Function
Private Function getExposureCompensation() As Integer
Return ExposureCompensation
End Function
Private Function getExposureCompensation() As Integer
Return ExposureCompensation
End Function
Private Function getImageQuality() As Integer
Return ImageQuality
End Function
Private Function getImageQuality() As Integer
Return ImageQuality
End Function
Private Function getIDCamera() As String
Return IDBodyCAmera
End Function
'// -----------------------------------------------------------------
'// Give available parameter lists ----------------------------------
'// -----------------------------------------------------------------
'// Give available parameter lists ----------------------------------
Private Function getAEModeDesc() As EdsPropertyDesc
Return AEModeDesc
End Function
Private Function getAEModeDesc() As EdsPropertyDesc
Return AEModeDesc
End Function
Private Function getAvDesc() As EdsPropertyDesc
Return AvDesc
End Function
Private Function getAvDesc() As EdsPropertyDesc
Return AvDesc
End Function
Private Function getTvDesc() As EdsPropertyDesc
Return TvDesc
End Function
Private Function getTvDesc() As EdsPropertyDesc
Return TvDesc
End Function
Private Function getIsoDesc() As EdsPropertyDesc
Return IsoDesc
End Function
Private Function getIsoDesc() As EdsPropertyDesc
Return IsoDesc
End Function
Private Function getMeteringModeDesc() As EdsPropertyDesc
Return MeteringModeDesc
End Function
Private Function getMeteringModeDesc() As EdsPropertyDesc
Return MeteringModeDesc
End Function
Private Function getExposureCompensationDesc() As EdsPropertyDesc
Return ExposureCompensationDesc
End Function
Private Function getExposureCompensationDesc() As EdsPropertyDesc
Return ExposureCompensationDesc
End Function
Private Function getImageQualityDesc() As EdsPropertyDesc
Return ImageQualityDesc
End Function
Private Function getImageQualityDesc() As EdsPropertyDesc
Return ImageQualityDesc
End Function
'// -----------------------------------------------------------------
'// Stock available parameter lists ---------------------------------
'// -----------------------------------------------------------------
'// Stock available parameter lists ---------------------------------
Private Sub setAEModeDesc(ByVal desc As EdsPropertyDesc)
AEModeDesc = desc
End Sub
Private Sub setAEModeDesc(ByVal desc As EdsPropertyDesc)
AEModeDesc = desc
End Sub
Private Sub setAvDesc(ByVal desc As EdsPropertyDesc)
AvDesc = desc
End Sub
Private Sub setAvDesc(ByVal desc As EdsPropertyDesc)
AvDesc = desc
End Sub
Private Sub setTvDesc(ByVal desc As EdsPropertyDesc)
TvDesc = desc
End Sub
Private Sub setTvDesc(ByVal desc As EdsPropertyDesc)
TvDesc = desc
End Sub
Private Sub setIsoDesc(ByVal desc As EdsPropertyDesc)
IsoDesc = desc
End Sub
Private Sub setIsoDesc(ByVal desc As EdsPropertyDesc)
IsoDesc = desc
End Sub
Private Sub setMeteringModeDesc(ByVal desc As EdsPropertyDesc)
MeteringModeDesc = desc
End Sub
Private Sub setMeteringModeDesc(ByVal desc As EdsPropertyDesc)
MeteringModeDesc = desc
End Sub
Private Sub setExposureCompensationDesc(ByVal desc As EdsPropertyDesc)
ExposureCompensationDesc = desc
End Sub
Private Sub setExposureCompensationDesc(ByVal desc As EdsPropertyDesc)
ExposureCompensationDesc = desc
End Sub
Private Sub setImageQualityDesc(ByVal desc As EdsPropertyDesc)
ImageQualityDesc = desc
End Sub
Private Sub setImageQualityDesc(ByVal desc As EdsPropertyDesc)
ImageQualityDesc = desc
End Sub
'// Set a property <UInt32>
Public Sub setPropertyUInt32(ByVal propertyID As Integer, ByVal value As Integer)
Select Case propertyID
Case kEdsPropID_AEModeSelect
setAEMode(value)
Case kEdsPropID_Tv
setTv(value)
Case kEdsPropID_Av
setAv(value)
Case kEdsPropID_ISOSpeed
setIso(value)
Case kEdsPropID_MeteringMode
setMeteringMode(value)
Case kEdsPropID_ExposureCompensation
setExposureCompensation(value)
Case kEdsPropID_ImageQuality
'// Set a property <UInt32>
Public Sub setPropertyUInt32(ByVal propertyID As Integer, ByVal value As Integer)
Select Case propertyID
Case kEdsPropID_AEModeSelect
setAEMode(value)
Case kEdsPropID_Tv
setTv(value)
Case kEdsPropID_Av
setAv(value)
Case kEdsPropID_ISOSpeed
setIso(value)
Case kEdsPropID_MeteringMode
setMeteringMode(value)
Case kEdsPropID_ExposureCompensation
setExposureCompensation(value)
Case kEdsPropID_ImageQuality
setImageQuality(value)
End Select
End Sub
End Sub
'// Get a property <UInt32>
Public Function getPropertyUInt32(ByVal propertyID As Integer) As Integer
Dim value As Integer = &HFFFFFFFF
Select Case propertyID
Case kEdsPropID_AEModeSelect
value = getAEMode()
Case kEdsPropID_Tv
value = getTv()
Case kEdsPropID_Av
value = getAv()
Case kEdsPropID_ISOSpeed
value = getIso()
Case kEdsPropID_MeteringMode
value = getMeteringMode()
Case kEdsPropID_ExposureCompensation
value = getExposureCompensation()
Case kEdsPropID_ImageQuality
value = getImageQuality()
End Select
Return value
End Function
'// Get a property <UInt32>
Public Function getPropertyUInt32(ByVal propertyID As Integer) As Integer
Dim value As Integer = &HFFFFFFFF
Select Case propertyID
Case kEdsPropID_AEModeSelect
value = getAEMode()
Case kEdsPropID_Tv
value = getTv()
Case kEdsPropID_Av
value = getAv()
Case kEdsPropID_ISOSpeed
value = getIso()
Case kEdsPropID_MeteringMode
value = getMeteringMode()
Case kEdsPropID_ExposureCompensation
value = getExposureCompensation()
Case kEdsPropID_ImageQuality
value = getImageQuality()
End Select
Return value
End Function
'// Get a property <String>
Public Sub getPropertyString(ByVal propertyID As Integer, ByRef str As String)
Select Case propertyID
Case kEdsPropID_ProductName
'// Get a property <String>
Public Sub getPropertyString(ByVal propertyID As Integer, ByRef str As String)
Select Case propertyID
Case kEdsPropID_ProductName
str = modelName
Case kEdsPropID_OwnerName
str = ownerName
Case kEdsPropID_BodyIDEx
str = IDBodyCAmera
End Select
End Sub
End Sub
'// Set a property <String>
Public Sub setPropertyString(ByVal propertyID As Integer, ByVal str As String)
Select Case propertyID
'// Set a property <String>
Public Sub setPropertyString(ByVal propertyID As Integer, ByVal str As String)
Select Case propertyID
Case kEdsPropID_ProductName
modelName = str
Case kEdsPropID_OwnerName
ownerName = str
Case kEdsPropID_BodyIDEx
setBodyIDEx(str)
End Select
End Sub
End Sub
'// Set an available parameter list.
Public Sub setPropertyDesc(ByVal propertyID As Integer, ByVal desc As EdsPropertyDesc)
Select Case propertyID
Case kEdsPropID_AEModeSelect
setAEModeDesc(desc)
Case kEdsPropID_Tv
setTvDesc(desc)
Case kEdsPropID_Av
setAvDesc(desc)
Case kEdsPropID_ISOSpeed
setIsoDesc(desc)
Case kEdsPropID_MeteringMode
setMeteringModeDesc(desc)
Case kEdsPropID_ExposureCompensation
setExposureCompensationDesc(desc)
Case kEdsPropID_ImageQuality
setImageQualityDesc(desc)
End Select
End Sub
'// Set an available parameter list.
Public Sub setPropertyDesc(ByVal propertyID As Integer, ByVal desc As EdsPropertyDesc)
Select Case propertyID
Case kEdsPropID_AEModeSelect
setAEModeDesc(desc)
Case kEdsPropID_Tv
setTvDesc(desc)
Case kEdsPropID_Av
setAvDesc(desc)
Case kEdsPropID_ISOSpeed
setIsoDesc(desc)
Case kEdsPropID_MeteringMode
setMeteringModeDesc(desc)
Case kEdsPropID_ExposureCompensation
setExposureCompensationDesc(desc)
Case kEdsPropID_ImageQuality
setImageQualityDesc(desc)
End Select
End Sub
'// Get an available parameter list.
Public Function getPropertyDesc(ByVal propertyID As Integer) As EdsPropertyDesc
Dim desc As EdsPropertyDesc = Nothing
Select Case propertyID
Case kEdsPropID_AEModeSelect
desc = getAEModeDesc()
Case kEdsPropID_Tv
desc = getTvDesc()
Case kEdsPropID_Av
desc = getAvDesc()
Case kEdsPropID_ISOSpeed
desc = getIsoDesc()
Case kEdsPropID_MeteringMode
desc = getMeteringModeDesc()
Case kEdsPropID_ExposureCompensation
desc = getExposureCompensationDesc()
Case kEdsPropID_ImageQuality
desc = getImageQualityDesc()
End Select
Return desc
End Function
'// Get an available parameter list.
Public Function getPropertyDesc(ByVal propertyID As Integer) As EdsPropertyDesc
Dim desc As EdsPropertyDesc = Nothing
Select Case propertyID
Case kEdsPropID_AEModeSelect
desc = getAEModeDesc()
Case kEdsPropID_Tv
desc = getTvDesc()
Case kEdsPropID_Av
desc = getAvDesc()
Case kEdsPropID_ISOSpeed
desc = getIsoDesc()
Case kEdsPropID_MeteringMode
desc = getMeteringModeDesc()
Case kEdsPropID_ExposureCompensation
desc = getExposureCompensationDesc()
Case kEdsPropID_ImageQuality
desc = getImageQualityDesc()
End Select
Return desc
End Function
'// Check camera accessing flag.
'// Connected camera is not a legacy one, this method will be called.
Public Overridable Function isLegacy() As Boolean
Return False
End Function
'// Check camera accessing flag.
'// Connected camera is not a legacy one, this method will be called.
Public Overridable Function isLegacy() As Boolean
Return False
End Function
#End Region ' Methods
End Class
+12 -8
View File
@@ -20,18 +20,22 @@
'******************************************************************************/
Public Class CameraModelLegacy
Inherits CameraModel
Inherits CameraModel
'//Constructor
Public Sub New(ByVal camera As IntPtr)
MyBase.new(camera)
End Sub
#Region "CONSTRUCTOR"
Public Sub New(ByVal camera As IntPtr)
MyBase.New(camera)
End Sub
Public Overrides Function isLegacy() As Boolean
#End Region ' Constructor
Return True
#Region "METHODS"
End Function
Public Overrides Function isLegacy() As Boolean
Return True
End Function
#End Region ' Methods
End Class
-8
View File
@@ -229,18 +229,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>DepEmgu\Emgu.CV.UI.dll</HintPath>
</Reference>
<Reference Include="Emgu.CV" Condition="'$(Configuration)' == 'Release WinXP'">
<SpecificVersion>False</SpecificVersion>
<HintPath>DepEmguXP\Emgu.CV.dll</HintPath>
</Reference>
<Reference Include="Emgu.CV.UI" Condition="'$(Configuration)' == 'Release WinXP'">
<SpecificVersion>False</SpecificVersion>
<HintPath>DepEmguXP\Emgu.CV.UI.dll</HintPath>
</Reference>
<Reference Include="Emgu.Util" Condition="'$(Configuration)' == 'Release WinXP'">
<SpecificVersion>False</SpecificVersion>
<HintPath>DepEmguXP\Emgu.Util.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
+8 -6
View File
@@ -1,24 +1,26 @@
Public Class CfgForm
Private Sub BtnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOk.Click
#Region "EVENTS"
Private Sub BtnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOk.Click
Me.Hide()
End Sub
Private Sub BtnDisConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDisConnect.Click
'Camera.Disconnect()
'SetFormStatus()
End Sub
Private Sub BtnDisConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDisConnect.Click
End Sub
Private Sub BtnSetID_Click(sender As System.Object, e As System.EventArgs) Handles BtnSetID.Click
FrmMain.SetDefaultCamera()
End Sub
Private Sub CfgForm_Activated(sender As Object, e As System.EventArgs) Handles Me.Activated
End Sub
Private Sub BtnResetID_Click(sender As System.Object, e As System.EventArgs) Handles BtnResetID.Click
FrmMain.SetDefaultCamera(True)
FrmMain.Camera.Connect()
End Sub
#End Region ' Events
End Class
+20 -18
View File
@@ -20,33 +20,35 @@
'******************************************************************************/
Option Explicit On
Imports System.Runtime.InteropServices
Public Class CloseSessionCommand
Inherits Command
Inherits Command
Public Sub New(ByVal inModel As CameraModel)
MyBase.new(inModel)
End Sub
#Region "CONSTRUCTOR"
Public Sub New(ByVal inModel As CameraModel)
MyBase.New(inModel)
End Sub
'// Execute a command.
Overrides Function execute() As Boolean
Dim err As Integer = EDS_ERR_OK
#End Region ' Constructor
'// Open session with remote camera.
err = EdsCloseSession(MyBase.model.getCameraObject())
#Region "METHODS"
'// Execute a command.
Overrides Function execute() As Boolean
Dim err As Integer = EDS_ERR_OK
'// Notify Error.
If err <> EDS_ERR_OK Then
MyBase.model.notifyObservers(errr, err)
End If
Return True
'// Open session with remote camera.
err = EdsCloseSession(MyBase.model.getCameraObject())
End Function
'// Notify Error.
If err <> EDS_ERR_OK Then
MyBase.model.notifyObservers(errr, err)
End If
Return True
End Function
#End Region ' Methods
End Class
+32 -17
View File
@@ -20,35 +20,50 @@
'******************************************************************************/
Option Explicit On
Imports System.Runtime.InteropServices
Public Module commandName
' Command IDs
Public Const errr As Integer = 1 'errr
Public Const prog As Integer = 2 'prog
Public Const strt As Integer = 3 'strt
Public Const cplt As Integer = 4 'cplt
Public Const warn As Integer = 5 'warn
Public Const updt As Integer = 6 'updt
Public Const upls As Integer = 7 'upls
Public Const clse As Integer = 1 'close
#Region "FIELDS & PROPERTIES"
' Command IDs
Public Const errr As Integer = 1 'errr
Public Const prog As Integer = 2 'prog
Public Const strt As Integer = 3 'strt
Public Const cplt As Integer = 4 'cplt
Public Const warn As Integer = 5 'warn
Public Const updt As Integer = 6 'updt
Public Const upls As Integer = 7 'upls
Public Const clse As Integer = 1 'close
#End Region ' Fields & Properties
End Module
' Abstract command class.
' All command classes extends this one.
Public Class Command
Protected model As CameraModel
#Region "FIELDS & PROPERTIES"
Public Sub New(ByVal model As CameraModel)
Me.model = model
End Sub
Protected model As CameraModel
'// Execute a command.
#End Region ' Fields & Properties
#Region "CONSTRUCTOR"
Public Sub New(ByVal model As CameraModel)
Me.model = model
End Sub
#End Region ' Constructor
#Region "METHODS"
'// Execute a command.
Public Overridable Function execute() As Boolean
Return True
End Function
#End Region ' Methods
End Class
+89 -120
View File
@@ -24,154 +24,123 @@ Imports System.Runtime.InteropServices
Public Class GetPropertyCommand
Inherits Command
Inherits Command
Private propertyID As Integer
#Region "FIELDS & PROPERTIES"
Private propertyID As Integer
Public Sub New(ByVal model As CameraModel, ByVal propertyID As Integer)
MyBase.new(model)
Me.propertyID = propertyID
End Sub
#End Region ' Fields & Properties
'// Execute a command.
Public Overrides Function execute() As Boolean
#Region "CONSTRUCTOR"
Dim err As Integer = EDS_ERR_OK
Public Sub New(ByVal model As CameraModel, ByVal propertyID As Integer)
MyBase.New(model)
Me.propertyID = propertyID
End Sub
'//Get a property.
#End Region ' Constructor
err = getProperty(Me.propertyID)
#Region "METHODS"
'// Notify Error.
If err <> EDS_ERR_OK Then
'// Execute a command.
Public Overrides Function execute() As Boolean
Dim err As Integer = EDS_ERR_OK
'// Retry when the camera replys deviceBusy.
If (err & EDS_ERRORID_MASK) = EDS_ERR_DEVICE_BUSY Then
'//Get a property.
err = getProperty(Me.propertyID)
MyBase.model.notifyObservers(warn, err)
Return False
End If
MyBase.model.notifyObservers(errr, err)
End If
Return True
End Function
Private Function getProperty(ByVal id As Integer) As Integer
Dim err As Integer = EDS_ERR_OK
Dim dataType As EdsDataType = EdsDataType.kEdsDataType_Unknown
Dim dataSize As Integer = 0
If id = kEdsPropID_Unknown Then
'// If the propertyID is invalidID,
'// you should retry to get properties.
'// InvalidID is able to be published for the models elder than EOS30D.
If err = EDS_ERR_OK Then
err = getProperty(kEdsPropID_AEMode)
End If
If err = EDS_ERR_OK Then
err = getProperty(kEdsPropID_Tv)
End If
If err = EDS_ERR_OK Then
err = getProperty(kEdsPropID_Av)
End If
If err = EDS_ERR_OK Then
err = getProperty(kEdsPropID_ISOSpeed)
End If
If err = EDS_ERR_OK Then
err = getProperty(kEdsPropID_ImageQuality)
'// Notify Error.
If err <> EDS_ERR_OK Then
'// Retry when the camera replys deviceBusy.
If (err & EDS_ERRORID_MASK) = EDS_ERR_DEVICE_BUSY Then
MyBase.model.notifyObservers(warn, err)
Return False
End If
MyBase.model.notifyObservers(errr, err)
End If
Return True
End Function
Private Function getProperty(ByVal id As Integer) As Integer
Dim err As Integer = EDS_ERR_OK
Dim dataType As EdsDataType = EdsDataType.kEdsDataType_Unknown
Dim dataSize As Integer = 0
If id = kEdsPropID_Unknown Then
'// If the propertyID is invalidID,
'// you should retry to get properties.
'// InvalidID is able to be published for the models elder than EOS30D.
If err = EDS_ERR_OK Then
err = getProperty(kEdsPropID_AEMode)
End If
If err = EDS_ERR_OK Then
err = getProperty(kEdsPropID_Tv)
End If
If err = EDS_ERR_OK Then
err = getProperty(kEdsPropID_Av)
End If
If err = EDS_ERR_OK Then
err = getProperty(kEdsPropID_ISOSpeed)
End If
If err = EDS_ERR_OK Then
err = getProperty(kEdsPropID_ImageQuality)
End If
If err = EDS_ERR_OK Then
err = getProperty(kEdsPropID_BodyIDEx)
End If
If err = EDS_ERR_OK Then
err = getProperty(kEdsPropID_OwnerName)
End If
Return err
End If
Return err
End If
'// Get propertysize.
If err = EDS_ERR_OK Then
err = EdsGetPropertySize(MyBase.model.getCameraObject(), id, 0, dataType, dataSize)
End If
'// Get propertysize.
If err = EDS_ERR_OK Then
If err = EDS_ERR_OK Then
Dim data As Integer
err = EdsGetPropertySize( _
MyBase.model.getCameraObject(), _
id, _
0, _
dataType, _
dataSize)
If dataType = EdsDataType.kEdsDataType_UInt32 Then
'// Get a property.
Dim ptr As IntPtr = Marshal.AllocHGlobal(dataSize)
End If
If err = EDS_ERR_OK Then
Dim data As Integer
If dataType = EdsDataType.kEdsDataType_UInt32 Then
'// Get a property.
Dim ptr As IntPtr = Marshal.AllocHGlobal(dataSize)
err = EdsGetPropertyData(MyBase.model.getCameraObject(), _
id, _
0, _
dataSize, _
ptr)
data = Marshal.PtrToStructure(ptr, GetType(Integer))
Marshal.FreeHGlobal(ptr)
If err = EDS_ERR_OK Then
MyBase.model.setPropertyUInt32(id, data)
End If
err = EdsGetPropertyData(MyBase.model.getCameraObject(), id, 0, dataSize, ptr)
data = Marshal.PtrToStructure(ptr, GetType(Integer))
Marshal.FreeHGlobal(ptr)
If err = EDS_ERR_OK Then
MyBase.model.setPropertyUInt32(id, data)
End If
End If
If dataType = EdsDataType.kEdsDataType_String Then
Dim str As String 'char[EDS_MAX_NAME]
Dim ptr As IntPtr = Marshal.AllocHGlobal(EDS_MAX_NAME)
If dataType = EdsDataType.kEdsDataType_String Then
'// Get a property.
err = EdsGetPropertyData(MyBase.model.getCameraObject(), id, 0, dataSize, ptr)
str = Marshal.PtrToStringAnsi(ptr)
Marshal.FreeHGlobal(ptr)
Dim str As String 'char[EDS_MAX_NAME]
Dim ptr As IntPtr = Marshal.AllocHGlobal(EDS_MAX_NAME)
'// Get a property.
err = EdsGetPropertyData(MyBase.model.getCameraObject(), _
id, _
0, _
dataSize, _
ptr)
str = Marshal.PtrToStringAnsi(ptr)
Marshal.FreeHGlobal(ptr)
'// Stock the property .
If err = EDS_ERR_OK Then
MyBase.model.setPropertyString(id, str)
End If
'// Stock the property .
If err = EDS_ERR_OK Then
MyBase.model.setPropertyString(id, str)
End If
End If
End If
End If
'// Notify updating.
If err = EDS_ERR_OK Then
MyBase.model.notifyObservers(updt, id)
End If
Return err
End Function
'// Notify updating.
If err = EDS_ERR_OK Then
MyBase.model.notifyObservers(updt, id)
End If
Return err
End Function
#End Region ' Methods
End Class
+61 -71
View File
@@ -20,100 +20,90 @@
'******************************************************************************/
Option Explicit On
Imports System.Runtime.InteropServices
Public Class GetPropertyDescCommand
Inherits Command
Private propertyID As Integer
#Region "FIELDS & PROPERTIES"
Private propertyID As Integer
Public Sub New(ByVal model As CameraModel, ByVal propertyID As Integer)
#End Region ' Fields & Properties
#Region "CONSTRUCTOR"
Public Sub New(ByVal model As CameraModel, ByVal propertyID As Integer)
MyBase.new(model)
Me.propertyID = propertyID
End Sub
#End Region ' Constructor
'// Execute a command.
Overrides Function execute() As Boolean
#Region "METHODS"
Dim err As Integer = EDS_ERR_OK
'// Execute a command.
Overrides Function execute() As Boolean
Dim err As Integer = EDS_ERR_OK
'//Get an available property list.
err = getPropertyDesc(Me.propertyID)
'//Get an available property list.
err = getPropertyDesc(Me.propertyID)
'// Notify Error.
If err <> EDS_ERR_OK Then
'// Retry when the camera replys deviceBusy.
If (err & EDS_ERRORID_MASK) = EDS_ERR_DEVICE_BUSY Then
MyBase.model.notifyObservers(warn, err)
Return False
End If
'// Notify Error.
If err <> EDS_ERR_OK Then
MyBase.model.notifyObservers(errr, err)
End If
'// Retry when the camera replys deviceBusy.
If (err & EDS_ERRORID_MASK) = EDS_ERR_DEVICE_BUSY Then
Return True
End Function
MyBase.model.notifyObservers(warn, err)
Private Function getPropertyDesc(ByVal id As Integer) As Integer
Dim err As Integer = EDS_ERR_OK
Dim propertyDesc As New EdsPropertyDesc
Return False
If id = kEdsPropID_Unknown Then
'// If the propertyID is invalidID,
'// you should retry to get available property lists.
'// InvalidID is able to be published for the models elder than EOS30D.
End If
If err = EDS_ERR_OK Then
err = getPropertyDesc(kEdsPropID_AEMode)
End If
If err = EDS_ERR_OK Then
err = getPropertyDesc(kEdsPropID_Tv)
End If
If err = EDS_ERR_OK Then
err = getPropertyDesc(kEdsPropID_Av)
End If
If err = EDS_ERR_OK Then
err = getPropertyDesc(kEdsPropID_ISOSpeed)
End If
Return err
End If
MyBase.model.notifyObservers(errr, err)
'// Get available property lists.
If err = EDS_ERR_OK Then
err = EdsGetPropertyDesc(MyBase.model.getCameraObject(), id, propertyDesc)
End If
End If
Return True
'// Stock the available property list.
If err = EDS_ERR_OK Then
MyBase.model.setPropertyDesc(id, propertyDesc)
End If
End Function
'// Notify updating.
If err = EDS_ERR_OK Then
MyBase.model.notifyObservers(upls, id)
End If
Return err
End Function
Private Function getPropertyDesc(ByVal id As Integer) As Integer
Dim err As Integer = EDS_ERR_OK
Dim propertyDesc As New EdsPropertyDesc
If id = kEdsPropID_Unknown Then
'// If the propertyID is invalidID,
'// you should retry to get available property lists.
'// InvalidID is able to be published for the models elder than EOS30D.
If err = EDS_ERR_OK Then
err = getPropertyDesc(kEdsPropID_AEMode)
End If
If err = EDS_ERR_OK Then
err = getPropertyDesc(kEdsPropID_Tv)
End If
If err = EDS_ERR_OK Then
err = getPropertyDesc(kEdsPropID_Av)
End If
If err = EDS_ERR_OK Then
err = getPropertyDesc(kEdsPropID_ISOSpeed)
End If
Return err
End If
'// Get available property lists.
If err = EDS_ERR_OK Then
err = EdsGetPropertyDesc(MyBase.model.getCameraObject(), _
id, _
propertyDesc)
End If
'// Stock the available property list.
If err = EDS_ERR_OK Then
MyBase.model.setPropertyDesc(id, propertyDesc)
End If
'// Notify updating.
If err = EDS_ERR_OK Then
MyBase.model.notifyObservers(upls, id)
End If
Return err
End Function
#End Region ' Methods
End Class
+32 -38
View File
@@ -23,56 +23,50 @@ Option Explicit On
Imports System.Runtime.InteropServices
Public Class OpenSessionCommand
Inherits Command
Inherits Command
Public Sub New(ByVal model As CameraModel)
MyBase.new(model)
End Sub
#Region "CONSTRUCTOR"
'// Execute a command.
Public Overrides Function execute() As Boolean
Public Sub New(ByVal model As CameraModel)
MyBase.New(model)
End Sub
Dim err As Integer = EDS_ERR_OK
Dim locked As Boolean = False
#End Region ' Constructor
'// Open session with remote camera.
err = EdsOpenSession(MyBase.model.getCameraObject())
#Region "METHODS"
'// Execute a command.
Public Overrides Function execute() As Boolean
Dim err As Integer = EDS_ERR_OK
Dim locked As Boolean = False
'Preservation ahead is set to PC
If err = EDS_ERR_OK Then
'// Open session with remote camera.
err = EdsOpenSession(MyBase.model.getCameraObject())
Dim saveTo As Integer = EdsSaveTo.kEdsSaveTo_Host
err = EdsSetPropertyData(MyBase.model.getCameraObject(), kEdsPropID_SaveTo, 0, Marshal.SizeOf(saveTo), saveTo)
'Preservation ahead is set to PC
If err = EDS_ERR_OK Then
Dim saveTo As Integer = EdsSaveTo.kEdsSaveTo_Host
End If
err = EdsSetPropertyData(MyBase.model.getCameraObject(), kEdsPropID_SaveTo, 0, Marshal.SizeOf(saveTo), saveTo)
End If
If err = EDS_ERR_OK Then
Dim capacity As EdsCapacity
capacity.numberOfFreeClusters = &H7FFFFFFF
capacity.bytesPerSector = &H1000
capacity.reset = 1
err = EdsSetCapacity(MyBase.model.getCameraObject(), capacity)
End If
If err = EDS_ERR_OK Then
'Notification of error
If err < EDS_ERR_OK Then
MyBase.model.notifyObservers(errr, err)
End If
Dim capacity As EdsCapacity
capacity.numberOfFreeClusters = &H7FFFFFFF
capacity.bytesPerSector = &H1000
capacity.reset = 1
Return True
End Function
err = EdsSetCapacity(MyBase.model.getCameraObject(), capacity)
End If
'Notification of error
If err < EDS_ERR_OK Then
'CameraEvent e("error", &err);
MyBase.model.notifyObservers(errr, err)
End If
Return True
End Function
#End Region ' Methods
End Class
+32 -33
View File
@@ -23,52 +23,51 @@ Option Explicit On
Imports System.Runtime.InteropServices
Public Class SaveSettingCommand
Inherits Command
Inherits Command
Private saveTo As EdsSaveTo
#Region "FIELDS & PROPERTIES"
Public Sub New(ByVal model As CameraModel, ByVal saveTo As EdsSaveTo)
MyBase.new(model)
saveTo = saveTo
End Sub
Private saveTo As EdsSaveTo
#End Region ' Fields & Properties
'// Execute a command.
Public Overrides Function execute() As Boolean
#Region "CONSTRUCTOR"
Dim err As Integer = EDS_ERR_OK
Public Sub New(ByVal model As CameraModel, ByVal saveTo As EdsSaveTo)
MyBase.New(model)
saveTo = saveTo
End Sub
#End Region ' Constructor
'//Set destination of file save.
#Region "METHODS"
Dim ptr As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(Me.saveTo))
Marshal.StructureToPtr(Me.saveTo, ptr, False)
'// Execute a command.
Public Overrides Function execute() As Boolean
Dim err As Integer = EDS_ERR_OK
err = EdsSetPropertyData(MyBase.model.getCameraObject(), _
kEdsPropID_SaveTo, 0, Marshal.SizeOf(Me.saveTo), Me.saveTo)
'//Set destination of file save.
Dim ptr As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(Me.saveTo))
Marshal.FreeHGlobal(ptr)
Marshal.StructureToPtr(Me.saveTo, ptr, False)
err = EdsSetPropertyData(MyBase.model.getCameraObject(), kEdsPropID_SaveTo, 0, Marshal.SizeOf(Me.saveTo), Me.saveTo)
Marshal.FreeHGlobal(ptr)
'// Notify Error.
If err <> EDS_ERR_OK Then
'// Retry when the camera replys deviceBusy.
If err = EDS_ERR_DEVICE_BUSY Then
MyBase.model.notifyObservers(warn, err)
Threading.Thread.Sleep(500)
Return False
End If
MyBase.model.notifyObservers(errr, err)
End If
Return True
End Function
'// Notify Error.
If err <> EDS_ERR_OK Then
'// Retry when the camera replys deviceBusy.
If err = EDS_ERR_DEVICE_BUSY Then
MyBase.model.notifyObservers(warn, err)
Threading.Thread.Sleep(500)
Return False
End If
MyBase.model.notifyObservers(errr, err)
End If
Return True
End Function
#End Region ' Methods
End Class
+31 -28
View File
@@ -20,50 +20,53 @@
'******************************************************************************/
Option Strict Off
Option Explicit On
Option Explicit On
Imports System.Runtime.InteropServices
Public Class SetPropertyCommand
Inherits Command
Inherits Command
Private propertyID As Integer
Private data As Integer
#Region "FIELDS & PROPERTIES"
Private propertyID As Integer
Private data As Integer
Public Sub New(ByVal model As CameraModel, ByVal propertyID As Integer, ByVal data As Integer)
MyBase.new(model)
Me.propertyID = propertyID
Me.data = data
End Sub
#End Region ' Fields & Properties
'// Execute a command.
Public Overrides Function execute() As Boolean
#Region "CONSTRUCTOR"
Dim err As Integer = EDS_ERR_OK
Public Sub New(ByVal model As CameraModel, ByVal propertyID As Integer, ByVal data As Integer)
MyBase.New(model)
Me.propertyID = propertyID
Me.data = data
End Sub
'// Stock the property.
#End Region ' Constructor
err = EdsSetPropertyData(MyBase.model.getCameraObject(), Me.propertyID, 0, Marshal.SizeOf(Me.data), Me.data)
#Region "METHODS"
'// Execute a command.
Public Overrides Function execute() As Boolean
Dim err As Integer = EDS_ERR_OK
'// Notify Error.
If err <> EDS_ERR_OK Then
'// Retry when the camera replys deviceBusy.
If err = EDS_ERR_DEVICE_BUSY Then
'// Stock the property.
err = EdsSetPropertyData(MyBase.model.getCameraObject(), Me.propertyID, 0, Marshal.SizeOf(Me.data), Me.data)
MyBase.model.notifyObservers(warn, err)
'// Notify Error.
If err <> EDS_ERR_OK Then
'// Retry when the camera replys deviceBusy.
If err = EDS_ERR_DEVICE_BUSY Then
MyBase.model.notifyObservers(warn, err)
Return False
End If
MyBase.model.notifyObservers(errr, err)
End If
Return False
End If
Return True
End Function
MyBase.model.notifyObservers(errr, err)
End If
Return True
End Function
#End Region ' Methods
End Class
+24 -29
View File
@@ -20,43 +20,38 @@
'******************************************************************************/
Public Class TakePictureCommand
Inherits Command
Inherits Command
Public Sub New(ByVal model As CameraModel)
MyBase.new(model)
End Sub
#Region "CONSTRUCTOR"
'// Execute a command.
Public Overrides Function execute() As Boolean
Public Sub New(ByVal model As CameraModel)
MyBase.New(model)
End Sub
Dim err As Integer = EDS_ERR_OK
#End Region ' Constructor
'// Take a picture.
err = EdsSendCommand(MyBase.model.getCameraObject(), EdsCameraCommand.kEdsCameraCommand_PressShutterButton, EdsShutterButton.kEdsCameraCommand_ShutterButton_Completely)
EdsSendCommand(MyBase.model.getCameraObject(), EdsCameraCommand.kEdsCameraCommand_PressShutterButton, EdsShutterButton.kEdsCameraCommand_ShutterButton_OFF)
#Region "METHODS"
'// Execute a command.
Public Overrides Function execute() As Boolean
Dim err As Integer = EDS_ERR_OK
'// Take a picture.
err = EdsSendCommand(MyBase.model.getCameraObject(), EdsCameraCommand.kEdsCameraCommand_PressShutterButton, EdsShutterButton.kEdsCameraCommand_ShutterButton_Completely)
EdsSendCommand(MyBase.model.getCameraObject(), EdsCameraCommand.kEdsCameraCommand_PressShutterButton, EdsShutterButton.kEdsCameraCommand_ShutterButton_OFF)
'// Notify Error.
If err <> EDS_ERR_OK Then
'// Do not retry when the camera replys deviceBusy.
If err = EDS_ERR_DEVICE_BUSY Then
MyBase.model.notifyObservers(warn, err)
Return True
End If
End If
Return True
End Function
'// Notify Error.
If err <> EDS_ERR_OK Then
'// Do not retry when the camera replys deviceBusy.
If err = EDS_ERR_DEVICE_BUSY Then
MyBase.model.notifyObservers(warn, err)
Return True
End If
'MyBase.model.notifyObservers(errr, err)
End If
Return True
End Function
#End Region ' Methods
End Class
+1200 -1207
View File
File diff suppressed because it is too large Load Diff
+10 -3
View File
@@ -1,15 +1,22 @@
Public Class FrmScelta
#Region "EVENTS"
Private Sub BtnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOk.Click
Me.Hide()
End Sub
Private Sub FrmScelta_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
LbSpessLastra.Text = Format(SpessLastra, "0") & " mm"
End Sub
Private Sub LbSpessLastra_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LbSpessLastra.Click
Private Sub LbSpessLastra_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LbSpessLastra.Click
NumPad.Text = Format(SpessLastra, "0") ' la stringa di uscita
NumPad.ShowDialog()
SpessLastra = Convert.ToDouble(NumPad.Text)
LbSpessLastra.Text = Format(SpessLastra, "0.0") & " mm"
End Sub
End Sub
#End Region ' Events
End Class
+9
View File
@@ -74,6 +74,7 @@ Partial Class FrmMain
Me.BtnAbortDefAree = New System.Windows.Forms.Button()
Me.BtnSaveAree = New System.Windows.Forms.Button()
Me.ImageControl1 = New ImageControl()
Me.ComboBoxCamera = New System.Windows.Forms.ComboBox()
Me.GBImgFromCam.SuspendLayout()
Me.GBCorrected.SuspendLayout()
Me.GBCalibration.SuspendLayout()
@@ -419,10 +420,17 @@ Partial Class FrmMain
Me.ImageControl1.ZoomFactor = 1.0R
Me.ImageControl1.ZoomOnMouseWheel = True
'
'ComboBoxCamera
'
Me.ComboBoxCamera.FormattingEnabled = True
resources.ApplyResources(Me.ComboBoxCamera, "ComboBoxCamera")
Me.ComboBoxCamera.Name = "ComboBoxCamera"
'
'FrmMain
'
resources.ApplyResources(Me, "$this")
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.Controls.Add(Me.ComboBoxCamera)
Me.Controls.Add(Me.GBDefAree)
Me.Controls.Add(Me.StatusStrip1)
Me.Controls.Add(Me.ToolStrip1)
@@ -500,4 +508,5 @@ Partial Class FrmMain
Friend WithEvents BtnVentosa As System.Windows.Forms.Button
Friend WithEvents BtnExpT As System.Windows.Forms.Button
Friend WithEvents BtnStone As System.Windows.Forms.Button
Friend WithEvents ComboBoxCamera As ComboBox
End Class
+441 -282
View File
File diff suppressed because it is too large Load Diff
+680 -894
View File
File diff suppressed because it is too large Load Diff
-5
View File
@@ -1,8 +1,3 @@
Imports System.IO
Imports System.IO.Path
Imports System.Drawing
Imports System.Windows.Forms
Public Class FrmStart
End Class
+281 -316
View File
@@ -1,80 +1,52 @@
Imports System.Drawing.Imaging
Imports System.Drawing.Font
<System.Runtime.InteropServices.ComVisible(False)> _
<System.Runtime.InteropServices.ComVisible(False)>
Public Class DrawingBoard
'Public Events
Public Event SetScrollPositions()
Public Event PointSelected(n As Integer)
Public Event PointUnselected()
#Region "FIELDS & PROPERTIES"
'Member Variables
Private m_PanButton As System.Windows.Forms.MouseButtons = Windows.Forms.MouseButtons.Middle
Private m_EditButton As System.Windows.Forms.MouseButtons = Windows.Forms.MouseButtons.Left
Private m_OriginalImage As System.Drawing.Bitmap
Private m_StartPoint As System.Drawing.Point
Private m_Origin As New System.Drawing.Point(0, 0)
Private SrcRect As System.Drawing.Rectangle
Private DestRect As System.Drawing.Rectangle
Private m_ZoomOnMouseWheel As Boolean = True
Private m_ZoomFactor As Double = 1.0
Private m_ApparentImageSize As New Size(0, 0)
Private m_DrawWidth As Integer
Private m_DrawHeight As Integer
Private m_centerpoint As Point
Private m_PanMode As Boolean = True
Private m_StretchImageToFit As Boolean = False
Private m_Select_Rect As Rectangle
Private m_Select_Pen As New Pen(Color.Blue, 2) ' Pen used to indicate a selection on the image (zoom window)
Private EndPoint As Point ' for pan and box-zoom
' 4 punti di precalibrazione
Private m_pCaliCorner() As System.Drawing.Point
Private m_pCaliCornerH() As System.Drawing.Point
' per la calibrazione delle altezze
' per ora lo tengo
Private m_nPuntiCaliH As Integer
Private m_pCaliH() As System.Drawing.Point
Private m_bVisPuntiCaliH As Boolean
Private m_bVisPuntiCorner As Boolean
Private m_bPointSelected As Integer
Private m_isel As Integer, m_jsel As Integer
Private m_bCkRow As Boolean, m_bCkCol As Boolean
Private m_MouseEnabled As Boolean
Private Const std_radius As Integer = 40
Private Const small_radius As Integer = 30
Private Const dA_radius As Integer = 20
'Private m_MousePosImg As PointF
Private Enum ptype
PuntoCorner
PuntoCaliH
PuntoArea ' area generica
End Enum
Private m_ptypesel As ptype
'Public Events
Public Event SetScrollPositions()
Public Event PointSelected(n As Integer)
Public Event PointUnselected()
Event NewMousePosImage(pm As PointF)
'Member Variables
Private m_EditButton As System.Windows.Forms.MouseButtons = Windows.Forms.MouseButtons.Left
Private m_StartPoint As System.Drawing.Point
Private SrcRect As System.Drawing.Rectangle
Private DestRect As System.Drawing.Rectangle
Private m_DrawWidth As Integer
Private m_DrawHeight As Integer
Private m_centerpoint As Point
Private m_Select_Pen As New Pen(Color.Blue, 2) ' Pen used to indicate a selection on the image (zoom window)
Private EndPoint As Point ' for pan and box-zoom
' 4 punti di precalibrazione
Private m_pCaliCorner() As System.Drawing.Point
Private m_pCaliCornerH() As System.Drawing.Point
' per la calibrazione delle altezze
' per ora lo tengo
Private m_nPuntiCaliH As Integer
Private m_pCaliH() As System.Drawing.Point
Private m_bPointSelected As Integer
Private m_isel As Integer, m_jsel As Integer
Private Const std_radius As Integer = 40
Private Const small_radius As Integer = 30
Private Const dA_radius As Integer = 20
Private m_ptypesel As ptype
' gestione aree lastra (checkEsposizione, CheckStone, Def Ventosa)
' uso un'area generica rettangolare
Private m_bVisAreaGen As Boolean
Private m_pArea(3) As System.Drawing.Point
#Region "Public/Private Shadows"
Private m_OriginalImage As System.Drawing.Bitmap
Public Shadows Property Image() As System.Drawing.Image
Get
Return m_OriginalImage
@@ -86,7 +58,6 @@ Public Class DrawingBoard
m_ApparentImageSize = New Size(0, 0)
m_ZoomFactor = 1
GC.Collect()
'GC.GetTotalMemory(True)
End If
If Value Is Nothing Then
@@ -96,10 +67,6 @@ Public Class DrawingBoard
End If
GC.Collect()
'Dim totalmem As Long = GC.GetTotalMemory(False)
'Dim r As New Rectangle(0, 0, Value.Width, Value.Height)
m_OriginalImage = Value
Me.Invalidate()
End Set
@@ -125,8 +92,7 @@ Public Class DrawingBoard
End Set
End Property
#End Region
Private m_bVisPuntiCorner As Boolean
Public Property VisPuntiCorner() As Boolean
Get
Return m_bVisPuntiCorner
@@ -135,6 +101,8 @@ Public Class DrawingBoard
m_bVisPuntiCorner = value
End Set
End Property
Private m_bVisPuntiCaliH As Boolean
Public Property VisPuntiCaliH() As Boolean
Get
Return m_bVisPuntiCaliH
@@ -143,16 +111,22 @@ Public Class DrawingBoard
m_bVisPuntiCaliH = value
End Set
End Property
Private m_bCkRow As Boolean
Public WriteOnly Property CkRow() As Boolean
Set(ByVal value As Boolean)
m_bCkRow = value
End Set
End Property
Private m_bCkCol As Boolean
Public WriteOnly Property CkCol() As Boolean
Set(ByVal value As Boolean)
m_bCkCol = value
End Set
End Property
Private m_MouseEnabled As Boolean
Public Property MouseEnaBled() As Boolean
Get
Return m_MouseEnabled
@@ -164,6 +138,8 @@ Public Class DrawingBoard
End If
End Set
End Property
Private m_bVisAreaGen As Boolean
Public Property VisAreaGen() As Boolean
Get
Return m_bVisAreaGen
@@ -173,9 +149,114 @@ Public Class DrawingBoard
End Set
End Property
Private m_PanButton As System.Windows.Forms.MouseButtons = Windows.Forms.MouseButtons.Middle
Public Property PanButton() As System.Windows.Forms.MouseButtons
Get
Return m_PanButton
End Get
Set(ByVal value As System.Windows.Forms.MouseButtons)
m_PanButton = value
End Set
End Property
Private m_ZoomOnMouseWheel As Boolean = True
Public Property ZoomOnMouseWheel() As Boolean
Get
Return m_ZoomOnMouseWheel
End Get
Set(ByVal value As Boolean)
m_ZoomOnMouseWheel = value
End Set
End Property
#Region "Protected Overrides"
Private m_ZoomFactor As Double = 1.0
Public Property ZoomFactor() As Double
Get
Return m_ZoomFactor
End Get
Set(ByVal value As Double)
m_ZoomFactor = value
If m_ZoomFactor > 15 Then m_ZoomFactor = 15
If m_ZoomFactor < 0.05 Then m_ZoomFactor = 0.05
If Not m_OriginalImage Is Nothing Then
m_ApparentImageSize.Height = m_OriginalImage.Height * m_ZoomFactor
m_ApparentImageSize.Width = m_OriginalImage.Width * m_ZoomFactor
ComputeDrawingArea()
CheckBounds()
End If
Me.Invalidate()
End Set
End Property
Private m_Origin As New System.Drawing.Point(0, 0)
Public Property Origin() As System.Drawing.Point
Get
Return m_Origin
End Get
Set(ByVal value As System.Drawing.Point)
m_Origin = value
Me.Invalidate()
End Set
End Property
Private m_ApparentImageSize As New Size(0, 0)
Public ReadOnly Property ApparentImageSize() As System.Drawing.Size
Get
Return m_ApparentImageSize
End Get
End Property
Private m_PanMode As Boolean = True
Public Property PanMode() As Boolean
Get
Return m_PanMode
End Get
Set(ByVal value As Boolean)
m_PanMode = value
End Set
End Property
Private m_StretchImageToFit As Boolean = False
Public Property StretchImageToFit() As Boolean
Get
Return m_StretchImageToFit
End Get
Set(ByVal value As Boolean)
m_StretchImageToFit = value
Me.Invalidate()
End Set
End Property
Private m_Select_Rect As Rectangle
Private Property Selected_Rectangle() As Rectangle
Get
Return m_Select_Rect
End Get
Set(ByVal Value As Rectangle)
m_Select_Rect = Value
Me.Invalidate()
End Set
End Property
#End Region ' Fields & Properties
#Region "CONSTRUCTOR"
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
Me.SetStyle(ControlStyles.DoubleBuffer, True)
ReDim m_pCaliH(4)
ReDim m_pCaliCorner(4)
ReDim m_pCaliCornerH(4)
End Sub
#End Region ' Constructor
#Region "METHODS"
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
e.Graphics.Clear(Me.BackColor)
@@ -189,10 +270,6 @@ Public Class DrawingBoard
MyBase.OnSizeChanged(e)
End Sub
#End Region
#Region "Public Properties"
Public Sub ZoomIn()
ZoomImage(True)
End Sub
@@ -219,12 +296,11 @@ Public Class DrawingBoard
CheckBounds()
End Sub
Private Sub ZoomImage(ByVal ZoomIn As Boolean, origin As Point)
Private Sub ZoomImage(ByVal ZoomIn As Boolean, origin As Point)
ZoomImage(ZoomIn)
Return
' tentativo di zoommare sul punto del mouse
' Get center point
m_centerpoint.X = m_Origin.X + SrcRect.Width / 2
@@ -251,20 +327,12 @@ Public Class DrawingBoard
Cursor = Cursors.WaitCursor
If m_OriginalImage Is Nothing Then Exit Sub
' This is the color matrix to invert the image colors.
Dim cm As ColorMatrix = New ColorMatrix(New Single()() _
{New Single() {-1, 0, 0, 0, 0}, _
New Single() {0, -1, 0, 0, 0}, _
New Single() {0, 0, -1, 0, 0}, _
New Single() {0, 0, 0, 1, 0}, _
New Single() {1, 1, 1, 1, 1}})
Dim cm As ColorMatrix = New ColorMatrix(New Single()() {New Single() {-1, 0, 0, 0, 0}, New Single() {0, -1, 0, 0, 0}, New Single() {0, 0, -1, 0, 0}, New Single() {0, 0, 0, 1, 0}, New Single() {1, 1, 1, 1, 1}})
Dim ImageAttributes As New ImageAttributes()
ImageAttributes.SetColorMatrix(cm)
Dim g As Graphics
g = Graphics.FromImage(m_OriginalImage)
Dim g As Graphics = Graphics.FromImage(m_OriginalImage)
Dim rc As New Rectangle(0, 0, m_OriginalImage.Width, m_OriginalImage.Height)
ImageAttributes.SetColorMatrix(cm)
g.DrawImage(m_OriginalImage, rc, 0, 0, m_OriginalImage.Width, m_OriginalImage.Height, GraphicsUnit.Pixel, ImageAttributes)
Me.Invalidate()
@@ -275,77 +343,6 @@ Public Class DrawingBoard
End Try
End Sub
Public Property PanButton() As System.Windows.Forms.MouseButtons
Get
Return m_PanButton
End Get
Set(ByVal value As System.Windows.Forms.MouseButtons)
m_PanButton = value
End Set
End Property
Public Property ZoomOnMouseWheel() As Boolean
Get
Return m_ZoomOnMouseWheel
End Get
Set(ByVal value As Boolean)
m_ZoomOnMouseWheel = value
End Set
End Property
Public Property ZoomFactor() As Double
Get
Return m_ZoomFactor
End Get
Set(ByVal value As Double)
m_ZoomFactor = value
If m_ZoomFactor > 15 Then m_ZoomFactor = 15
If m_ZoomFactor < 0.05 Then m_ZoomFactor = 0.05
If Not m_OriginalImage Is Nothing Then
m_ApparentImageSize.Height = m_OriginalImage.Height * m_ZoomFactor
m_ApparentImageSize.Width = m_OriginalImage.Width * m_ZoomFactor
ComputeDrawingArea()
CheckBounds()
End If
Me.Invalidate()
End Set
End Property
Public Property Origin() As System.Drawing.Point
Get
Return m_Origin
End Get
Set(ByVal value As System.Drawing.Point)
m_Origin = value
Me.Invalidate()
End Set
End Property
Public ReadOnly Property ApparentImageSize() As System.Drawing.Size
Get
Return m_ApparentImageSize
End Get
End Property
Public Property PanMode() As Boolean
Get
Return m_PanMode
End Get
Set(ByVal value As Boolean)
m_PanMode = value
End Set
End Property
Public Property StretchImageToFit() As Boolean
Get
Return m_StretchImageToFit
End Get
Set(ByVal value As Boolean)
m_StretchImageToFit = value
Me.Invalidate()
End Set
End Property
Public Sub fittoscreen()
Me.StretchImageToFit = False
Me.Origin = New Point(0, 0)
@@ -353,18 +350,6 @@ Public Class DrawingBoard
ZoomFactor = Math.Min(ClientSize.Width / m_OriginalImage.Width, ClientSize.Height / m_OriginalImage.Height)
End Sub
#End Region
Private Property Selected_Rectangle() As Rectangle
Get
Return m_Select_Rect
End Get
Set(ByVal Value As Rectangle)
m_Select_Rect = Value
Me.Invalidate()
End Set
End Property
Private Sub Draw_Rectangle(ByVal e As System.Windows.Forms.MouseEventArgs)
If (New Rectangle(0, 0, ClientSize.Width, ClientSize.Height)).Contains(PointToClient(Windows.Forms.Cursor.Position)) Then
Dim Width As Integer = System.Math.Abs(m_StartPoint.X - e.X)
@@ -405,7 +390,6 @@ Public Class DrawingBoard
Dim ix As Integer, iy As Integer
Dim ix2 As Integer, iy2 As Integer
If m_bVisPuntiCorner Then
For i = 0 To 3
ix = -m_Origin.X * m_ZoomFactor + m_pCaliCorner(i).X * m_ZoomFactor - std_radius
@@ -428,7 +412,6 @@ Public Class DrawingBoard
Next
End If
If m_bVisPuntiCaliH Then
Dim raggio As Integer
For i = 0 To 3
@@ -436,7 +419,6 @@ Public Class DrawingBoard
ix = -m_Origin.X * m_ZoomFactor + m_pCaliH(i).X * m_ZoomFactor - raggio
iy = -m_Origin.Y * m_ZoomFactor + m_pCaliH(i).Y * m_ZoomFactor - raggio
g.DrawArc(Pens.Beige, ix, iy, raggio * 2, raggio * 2, 0, 360)
Next
For i = 0 To 2 Step 2
ix = -m_Origin.X * m_ZoomFactor + m_pCaliH(i).X * m_ZoomFactor
@@ -445,10 +427,8 @@ Public Class DrawingBoard
iy2 = -m_Origin.Y * m_ZoomFactor + m_pCaliH(i + 1).Y * m_ZoomFactor
g.DrawLine(Pens.Beige, ix, iy, ix2, iy2)
Next
End If
If m_bVisAreaGen Then
' 4 cerchi
For i = 0 To 3 Step 2
@@ -468,18 +448,10 @@ Public Class DrawingBoard
Next
End If
RaiseEvent SetScrollPositions()
End Sub
Private Sub ComputeDrawingArea()
'm_DrawHeight = Me.Height / m_ZoomFactor
'm_DrawWidth = Me.Width / m_ZoomFactor
m_DrawHeight = ClientSize.Height / m_ZoomFactor
m_DrawWidth = ClientSize.Width / m_ZoomFactor
End Sub
@@ -487,11 +459,14 @@ Public Class DrawingBoard
Private Sub ImageViewer_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
If m_OriginalImage Is Nothing Then Exit Sub
If Not m_MouseEnabled Then Exit Sub
EndPoint = Nothing
Selected_Rectangle = Nothing
Dim i As Integer, previusSelection As Integer
Dim previusPtypeSel As ptype
Dim px As Double, py As Double
'Set the start point. This is used for panning and zooming so we always set it.
m_StartPoint = New Point(e.X, e.Y)
previusSelection = m_bPointSelected
@@ -537,40 +512,39 @@ Public Class DrawingBoard
m_ptypesel = ptype.PuntoArea
End If
Next
End If
' l'evento interessa solo per i punto corner
If (previusSelection <> 0 AndAlso m_bPointSelected = 0) OrElse
(previusPtypeSel = ptype.PuntoCorner AndAlso m_ptypesel <> ptype.PuntoCorner) Then
RaiseEvent PointUnselected()
End If
Me.Focus()
End Sub
Private Sub ImageViewer_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If m_OriginalImage Is Nothing Then Exit Sub
Dim Px As Single, Py As Single
Px = e.X
Py = e.Y
If Px > ClientSize.Width Then
Px = ClientSize.Width
End If
If Py > ClientSize.Height Then
Py = ClientSize.Height
End If
If e.X < 0 Then Px = 0
If e.Y < 0 Then Py = 0
If e.Button = m_PanButton OrElse e.Button = m_EditButton Then
Dim DeltaX As Integer, DeltaY As Integer
If PanMode Then
DeltaX = (m_StartPoint.X - Px) / m_ZoomFactor
DeltaY = (m_StartPoint.Y - Py) / m_ZoomFactor
@@ -578,6 +552,7 @@ Public Class DrawingBoard
If (DeltaX <> 0) Then
m_StartPoint.X = m_StartPoint.X - DeltaX * m_ZoomFactor 'e.X
End If
If (DeltaY <> 0) Then
m_StartPoint.Y = m_StartPoint.Y - DeltaY * m_ZoomFactor 'e.Y
End If
@@ -586,7 +561,6 @@ Public Class DrawingBoard
DeltaY = (m_StartPoint.Y - Py)
End If
If m_bPointSelected And PanMode AndAlso e.Button = m_EditButton Then
If m_ptypesel = ptype.PuntoCorner Then
If m_bPointSelected = 2 Then
@@ -604,21 +578,17 @@ Public Class DrawingBoard
m_pCaliH(m_isel).X = m_pCaliH(m_isel).X - DeltaX
m_pCaliH(m_isel).Y = m_pCaliH(m_isel).Y - DeltaY
ElseIf m_ptypesel = ptype.PuntoArea Then
If m_isel = 0 Then
For i As Integer = 0 To 3
m_pArea(i).X = m_pArea(i).X - DeltaX
m_pArea(i).Y = m_pArea(i).Y - DeltaY
Next
ElseIf m_isel = 2 Then
m_pArea(1).X = m_pArea(1).X - DeltaX
m_pArea(2).X = m_pArea(1).X
m_pArea(2).Y = m_pArea(2).Y - DeltaY
m_pArea(3).Y = m_pArea(2).Y
End If
End If
Me.Invalidate()
Exit Sub
@@ -646,173 +616,166 @@ Public Class DrawingBoard
'ix = (pimg.x-m_Origin.X)*m_ZoomFactor
'(pimg.x-m_Origin.X) = ix/m_ZoomFactor
pimg.X = m_Origin.X + e.X / m_ZoomFactor
pimg.Y = m_Origin.Y + e.Y / m_ZoomFactor
RaiseEvent NewMousePosImage(pimg)
End If
End Sub
Private Sub CheckBounds()
If m_OriginalImage Is Nothing Then Exit Sub
'Make sure we don't go out of bounds
If m_Origin.X < 0 Then m_Origin.X = 0
If m_Origin.Y < 0 Then m_Origin.Y = 0
Private Sub CheckBounds()
If m_OriginalImage Is Nothing Then Exit Sub
'Make sure we don't go out of bounds
If m_Origin.X < 0 Then m_Origin.X = 0
If m_Origin.Y < 0 Then m_Origin.Y = 0
If m_Origin.X > m_OriginalImage.Width - (ClientSize.Width / m_ZoomFactor) Then
m_Origin.X = m_OriginalImage.Width - (ClientSize.Width / m_ZoomFactor)
End If
If m_Origin.Y > m_OriginalImage.Height - (ClientSize.Height / m_ZoomFactor) Then
m_Origin.Y = m_OriginalImage.Height - (ClientSize.Height / m_ZoomFactor)
End If
If m_Origin.X > m_OriginalImage.Width - (ClientSize.Width / m_ZoomFactor) Then
m_Origin.X = m_OriginalImage.Width - (ClientSize.Width / m_ZoomFactor)
End If
If m_Origin.X < 0 Then m_Origin.X = 0
If m_Origin.Y < 0 Then m_Origin.Y = 0
End Sub
Private Sub CheckPointBounds()
If m_OriginalImage Is Nothing Then Exit Sub
If m_Origin.Y > m_OriginalImage.Height - (ClientSize.Height / m_ZoomFactor) Then
m_Origin.Y = m_OriginalImage.Height - (ClientSize.Height / m_ZoomFactor)
End If
'Make sure we don't go out of bounds
If m_pCaliCorner(m_isel).X < 0 Then m_pCaliCorner(m_isel).X = 0
If m_pCaliCorner(m_isel).Y < 0 Then m_pCaliCorner(m_isel).Y = 0
If m_pCaliCorner(m_isel).X > m_OriginalImage.Width - (ClientSize.Width / m_ZoomFactor) Then
m_pCaliCorner(m_isel).X = m_OriginalImage.Width - (ClientSize.Width / m_ZoomFactor)
End If
If m_pCaliCorner(m_isel).Y > m_OriginalImage.Height Then ' - (ClientSize.Height / m_ZoomFactor) Then
m_pCaliCorner(m_isel).Y = m_OriginalImage.Height '- (ClientSize.Height / m_ZoomFactor)
End If
If m_Origin.X < 0 Then m_Origin.X = 0
If m_Origin.Y < 0 Then m_Origin.Y = 0
End Sub
Private Sub CheckPointBounds()
If m_OriginalImage Is Nothing Then Exit Sub
'Make sure we don't go out of bounds
If m_pCaliCorner(m_isel).X < 0 Then m_pCaliCorner(m_isel).X = 0
If m_pCaliCorner(m_isel).Y < 0 Then m_pCaliCorner(m_isel).Y = 0
If m_pCaliCorner(m_isel).X > m_OriginalImage.Width - (ClientSize.Width / m_ZoomFactor) Then
m_pCaliCorner(m_isel).X = m_OriginalImage.Width - (ClientSize.Width / m_ZoomFactor)
End If
If m_pCaliCorner(m_isel).Y > m_OriginalImage.Height Then ' - (ClientSize.Height / m_ZoomFactor) Then
m_pCaliCorner(m_isel).Y = m_OriginalImage.Height '- (ClientSize.Height / m_ZoomFactor)
End If
' anche per i punti area
If m_pArea(m_isel).X < 0 Then m_pArea(m_isel).X = 0
If m_pArea(m_isel).Y < 0 Then m_pArea(m_isel).Y = 0
If m_pArea(m_isel).X > m_OriginalImage.Width - (ClientSize.Width / m_ZoomFactor) Then
m_pArea(m_isel).X = m_OriginalImage.Width - (ClientSize.Width / m_ZoomFactor)
End If
If m_pArea(m_isel).Y > m_OriginalImage.Height Then ' - (ClientSize.Height / m_ZoomFactor) Then
m_pArea(m_isel).Y = m_OriginalImage.Height '- (ClientSize.Height / m_ZoomFactor)
End If
End Sub
Private Sub DrawingBoard_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
If m_OriginalImage Is Nothing Then Exit Sub
If Not PanMode Then
EndPoint = New Point(e.X, e.Y)
If Selected_Rectangle = Nothing Then Exit Sub
ZoomSelection()
PanMode = True
End If
End Sub
Private Sub ZoomSelection()
If m_OriginalImage Is Nothing Then Exit Sub
End Sub
Try
Dim NewOrigin As New Point(CInt(Me.Origin.X + (Selected_Rectangle.X / ZoomFactor)), Me.Origin.Y + (Selected_Rectangle.Y / ZoomFactor))
Dim NewFactor As Double
Private Sub DrawingBoard_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
If m_OriginalImage Is Nothing Then Exit Sub
If Not PanMode Then
EndPoint = New Point(e.X, e.Y)
If Selected_Rectangle = Nothing Then Exit Sub
ZoomSelection()
PanMode = True
End If
End Sub
If Selected_Rectangle.Width > Selected_Rectangle.Height Then
NewFactor = (ClientSize.Width / (Selected_Rectangle.Width / ZoomFactor))
Else
NewFactor = (ClientSize.Height / (Selected_Rectangle.Height / ZoomFactor))
End If
Private Sub ZoomSelection()
If m_OriginalImage Is Nothing Then Exit Sub
Try
Me.Origin = NewOrigin
Me.ZoomFactor = NewFactor
Catch ex As Exception
Throw ex
End Try
Selected_Rectangle = Nothing
End Sub
Dim NewOrigin As New Point(CInt(Me.Origin.X + (Selected_Rectangle.X / ZoomFactor)), _
Me.Origin.Y + (Selected_Rectangle.Y / ZoomFactor))
Dim NewFactor As Double
If Selected_Rectangle.Width > Selected_Rectangle.Height Then
NewFactor = (ClientSize.Width / (Selected_Rectangle.Width / ZoomFactor))
Else
NewFactor = (ClientSize.Height / (Selected_Rectangle.Height / ZoomFactor))
End If
Me.Origin = NewOrigin
Me.ZoomFactor = NewFactor
Catch ex As Exception
Throw ex
End Try
Selected_Rectangle = Nothing
End Sub
Private Sub ImageViewer_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
If Not ZoomOnMouseWheel Then Exit Sub
'set new zoomfactor
If e.Delta > 0 Then
Private Sub ImageViewer_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel
If Not ZoomOnMouseWheel Then Exit Sub
'set new zoomfactor
If e.Delta > 0 Then
ZoomImage(True, e.Location)
ElseIf e.Delta < 0 Then
ZoomImage(False, e.Location)
End If
End Sub
End Sub
Public Sub RotateFlip(ByVal RotateFlipType As System.Drawing.RotateFlipType)
If m_OriginalImage Is Nothing Then Exit Sub
m_OriginalImage.RotateFlip(RotateFlipType)
Me.Invalidate()
End Sub
Public Sub RotateFlip(ByVal RotateFlipType As System.Drawing.RotateFlipType)
If m_OriginalImage Is Nothing Then Exit Sub
m_OriginalImage.RotateFlip(RotateFlipType)
Me.Invalidate()
End Sub
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
Private Sub DrawingBoard_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
Me.ComputeDrawingArea()
If Me.StretchImageToFit Then Me.Invalidate()
End Sub
' Add any initialization after the InitializeComponent() call.
Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
Me.SetStyle(ControlStyles.DoubleBuffer, True)
ReDim m_pCaliH(4)
ReDim m_pCaliCorner(4)
ReDim m_pCaliCornerH(4)
End Sub
Private Sub DrawingBoard_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub DrawingBoard_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
Me.ComputeDrawingArea()
If Me.StretchImageToFit Then Me.Invalidate()
End Sub
Public Sub SetPuntoCorner(ByVal i As Integer, ByVal x As Double, ByVal y As Double)
If i >= 0 And i < 4 Then
m_pCaliCorner(i).X = x
m_pCaliCorner(i).Y = y
End If
End Sub
Private Sub DrawingBoard_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Public Sub SetPuntoCornerH(ByVal i As Integer, ByVal x As Double, ByVal y As Double)
If i >= 0 And i < 4 Then
m_pCaliCornerH(i).X = x
m_pCaliCornerH(i).Y = y
End If
End Sub
End Sub
Public Sub SetPuntoCorner(ByVal i As Integer, ByVal x As Double, ByVal y As Double)
If i >= 0 And i < 4 Then
m_pCaliCorner(i).X = x
m_pCaliCorner(i).Y = y
End If
End Sub
Public Sub SetPuntoCornerH(ByVal i As Integer, ByVal x As Double, ByVal y As Double)
If i >= 0 And i < 4 Then
m_pCaliCornerH(i).X = x
m_pCaliCornerH(i).Y = y
End If
End Sub
Public Sub SetPuntoH(ByVal i As Integer, ByVal x As Double, ByVal y As Double)
If i >= 0 And i < 4 Then
m_pCaliH(i).X = x
m_pCaliH(i).Y = y
End If
End Sub
Public Function GetXCorner(ByVal i As Integer) As Integer
GetXCorner = m_pCaliCorner(i).X
End Function
Public Function GetYCorner(ByVal i As Integer) As Integer
GetYCorner = m_pCaliCorner(i).Y
End Function
Public Function GetXCornerH(ByVal i As Integer) As Integer
GetXCornerH = m_pCaliCornerH(i).X
End Function
Public Function GetYCornerH(ByVal i As Integer) As Integer
GetYCornerH = m_pCaliCornerH(i).Y
End Function
Public Function GetXHpx(ByVal i As Integer) As Integer
GetXHpx = m_pCaliH(i).X
End Function
Public Function GetYHpx(ByVal i As Integer) As Integer
GetYHpx = m_pCaliH(i).Y
End Function
Public Sub SetPuntoH(ByVal i As Integer, ByVal x As Double, ByVal y As Double)
If i >= 0 And i < 4 Then
m_pCaliH(i).X = x
m_pCaliH(i).Y = y
End If
End Sub
Public Function GetXCorner(ByVal i As Integer) As Integer
GetXCorner = m_pCaliCorner(i).X
End Function
Public Function GetYCorner(ByVal i As Integer) As Integer
GetYCorner = m_pCaliCorner(i).Y
End Function
Public Function GetXCornerH(ByVal i As Integer) As Integer
GetXCornerH = m_pCaliCornerH(i).X
End Function
Public Function GetYCornerH(ByVal i As Integer) As Integer
GetYCornerH = m_pCaliCornerH(i).Y
End Function
Public Function GetXHpx(ByVal i As Integer) As Integer
GetXHpx = m_pCaliH(i).X
End Function
Public Function GetYHpx(ByVal i As Integer) As Integer
GetYHpx = m_pCaliH(i).Y
End Function
Public Sub SetPuntoArea(ByVal i As Integer, ByVal x As Double, ByVal y As Double)
If i >= 0 And i < 4 Then
m_pArea(i).X = x
m_pArea(i).Y = y
End If
End Sub
Public Sub SetArea(x1 As Double, y1 As Double, x2 As Double, y2 As Double)
m_pArea(0).X = x1
m_pArea(0).Y = y1
@@ -839,5 +802,7 @@ Public Class DrawingBoard
y2 = m_pArea(2).Y
End Sub
#End Region ' Methods
End Class
+196 -189
View File
@@ -1,182 +1,190 @@
<System.Runtime.InteropServices.ComVisible(False)> _
<System.Runtime.InteropServices.ComVisible(False)>
Public Class ImageControl
#Region "FIELDS & PROPERTIES"
Public Event PointSelected(n As Integer)
Public Event PointUnselected()
Public Event NewMousePosImage(pima As PointF)
Private m_ScrollVisible As Boolean = True
Private m_ScrollVisible As Boolean = True
Public Property ScrollbarsVisible() As Boolean
Get
Return m_ScrollVisible
End Get
Set(ByVal value As Boolean)
m_ScrollVisible = value
Me.HScrollBar1.Visible = value
Me.VScrollBar1.Visible = value
If value = False Then
Me.DrawingBoard1.Dock = DockStyle.Fill
Else
Me.DrawingBoard1.Dock = DockStyle.None
Me.DrawingBoard1.Location = New Point(0, 0)
Me.DrawingBoard1.Width = ClientSize.Width - VScrollBar1.Width
Me.DrawingBoard1.Height = ClientSize.Height - HScrollBar1.Height
Public Sub New()
End If
End Set
End Property
' This call is required by the Windows Form Designer.
InitializeComponent()
Public ReadOnly Property DBoard() As DrawingBoard
Get
Return DrawingBoard1
End Get
End Property
' Add any initialization after the InitializeComponent() call.
End Sub
Public Property PanMode() As Boolean
Get
Return DrawingBoard1.PanMode
End Get
Set(ByVal value As Boolean)
DrawingBoard1.PanMode = value
End Set
End Property
#Region "Public Properties"
Public ReadOnly Property DBoard() As DrawingBoard
Get
Return DrawingBoard1
End Get
End Property
Public Property PanButton() As System.Windows.Forms.MouseButtons
Get
Return DrawingBoard1.PanButton
End Get
Set(ByVal value As System.Windows.Forms.MouseButtons)
DrawingBoard1.PanButton = value
End Set
End Property
Public Property PanMode() As Boolean
Get
Return DrawingBoard1.PanMode
End Get
Set(ByVal value As Boolean)
DrawingBoard1.PanMode = value
End Set
End Property
Public Property ZoomOnMouseWheel() As Boolean
Get
Return DrawingBoard1.ZoomOnMouseWheel
End Get
Set(ByVal value As Boolean)
DrawingBoard1.ZoomOnMouseWheel = value
End Set
End Property
Public Property PanButton() As System.Windows.Forms.MouseButtons
Get
Return DrawingBoard1.PanButton
End Get
Set(ByVal value As System.Windows.Forms.MouseButtons)
DrawingBoard1.PanButton = value
End Set
End Property
Public Property ZoomFactor() As Double
Get
Return DrawingBoard1.ZoomFactor
End Get
Set(ByVal value As Double)
DrawingBoard1.ZoomFactor = value
End Set
End Property
Public Property ZoomOnMouseWheel() As Boolean
Get
Return DrawingBoard1.ZoomOnMouseWheel
End Get
Set(ByVal value As Boolean)
DrawingBoard1.ZoomOnMouseWheel = value
End Set
End Property
Public Property Origin() As System.Drawing.Point
Get
Return DrawingBoard1.Origin
End Get
Set(ByVal value As System.Drawing.Point)
DrawingBoard1.Origin = value
End Set
End Property
Public Property ZoomFactor() As Double
Get
Return DrawingBoard1.ZoomFactor
End Get
Set(ByVal value As Double)
DrawingBoard1.ZoomFactor = value
End Set
End Property
Public Property StretchImageToFit() As Boolean
Get
Return Me.DrawingBoard1.StretchImageToFit
End Get
Set(ByVal value As Boolean)
Me.DrawingBoard1.StretchImageToFit = value
End Set
End Property
Public Property Origin() As System.Drawing.Point
Get
Return DrawingBoard1.Origin
End Get
Set(ByVal value As System.Drawing.Point)
DrawingBoard1.Origin = value
End Set
End Property
Public Property MouseEnabled() As Boolean
Get
Return Me.DrawingBoard1.MouseEnaBled
End Get
Set(ByVal value As Boolean)
Me.DrawingBoard1.MouseEnaBled = value
End Set
End Property
Public Property StretchImageToFit() As Boolean
Get
Return Me.DrawingBoard1.StretchImageToFit
End Get
Set(ByVal value As Boolean)
Me.DrawingBoard1.StretchImageToFit = value
End Set
End Property
Public Property MouseEnabled() As Boolean
Get
Return Me.DrawingBoard1.MouseEnaBled
End Get
Set(ByVal value As Boolean)
Me.DrawingBoard1.MouseEnaBled = value
End Set
End Property
Public ReadOnly Property ApparentImageSize() As System.Drawing.Size
Get
Return DrawingBoard1.ApparentImageSize
End Get
End Property
Public ReadOnly Property ApparentImageSize() As System.Drawing.Size
Get
Return DrawingBoard1.ApparentImageSize
End Get
End Property
Public Shadows Property Image() As System.Drawing.Image
Get
Return DrawingBoard1.Image
End Get
Set(ByVal Value As System.Drawing.Image)
DrawingBoard1.Image = Value
If Value Is Nothing Then
HScrollBar1.Enabled = False
VScrollBar1.Enabled = False
Exit Property
End If
End Set
End Property
Public Sub fittoscreen()
Me.DrawingBoard1.fittoscreen()
End Sub
Public Shadows Property initialimage() As System.Drawing.Image
Get
Return DrawingBoard1.initialimage
End Get
Set(ByVal value As System.Drawing.Image)
DrawingBoard1.initialimage = value
If value Is Nothing Then
HScrollBar1.Enabled = False
VScrollBar1.Enabled = False
Exit Property
End If
End Set
End Property
Public Sub InvertColors()
Me.DrawingBoard1.InvertColors()
End Sub
Public Shadows Property BackgroundImage() As System.Drawing.Image
Get
Return DrawingBoard1.BackgroundImage
End Get
Set(ByVal Value As System.Drawing.Image)
DrawingBoard1.BackgroundImage = Value
If Value Is Nothing Then
HScrollBar1.Enabled = False
VScrollBar1.Enabled = False
Exit Property
End If
End Set
End Property
Public Sub ZoomIn()
Me.DrawingBoard1.ZoomIn()
End Sub
#End Region ' Fields & Properties
Public Sub ZoomOut()
Me.DrawingBoard1.ZoomOut()
End Sub
#Region "CONSTRUCTOR"
Public Property ScrollbarsVisible() As Boolean
Get
Return m_ScrollVisible
End Get
Set(ByVal value As Boolean)
m_ScrollVisible = value
Me.HScrollBar1.Visible = value
Me.VScrollBar1.Visible = value
If value = False Then
Me.DrawingBoard1.Dock = DockStyle.Fill
Else
Me.DrawingBoard1.Dock = DockStyle.None
Me.DrawingBoard1.Location = New Point(0, 0)
Me.DrawingBoard1.Width = ClientSize.Width - VScrollBar1.Width
Me.DrawingBoard1.Height = ClientSize.Height - HScrollBar1.Height
Public Sub New()
End If
End Set
End Property
' This call is required by the Windows Form Designer.
InitializeComponent()
#End Region
#Region "Public/Private Shadows"
Public Shadows Property Image() As System.Drawing.Image
Get
Return DrawingBoard1.Image
End Get
Set(ByVal Value As System.Drawing.Image)
DrawingBoard1.Image = Value
If Value Is Nothing Then
HScrollBar1.Enabled = False
VScrollBar1.Enabled = False
Exit Property
End If
End Set
End Property
Public Shadows Property initialimage() As System.Drawing.Image
Get
Return DrawingBoard1.initialimage
End Get
Set(ByVal value As System.Drawing.Image)
DrawingBoard1.initialimage = value
If value Is Nothing Then
HScrollBar1.Enabled = False
VScrollBar1.Enabled = False
Exit Property
End If
End Set
End Property
Public Shadows Property BackgroundImage() As System.Drawing.Image
Get
Return DrawingBoard1.BackgroundImage
End Get
Set(ByVal Value As System.Drawing.Image)
DrawingBoard1.BackgroundImage = Value
If Value Is Nothing Then
HScrollBar1.Enabled = False
VScrollBar1.Enabled = False
Exit Property
End If
End Set
End Property
#End Region
Public Sub RotateFlip(ByVal RotateFlipType As System.Drawing.RotateFlipType)
DrawingBoard1.RotateFlip(RotateFlipType)
' Add any initialization after the InitializeComponent() call.
End Sub
#End Region ' Constructor
#Region "METHODS"
Public Sub fittoscreen()
Me.DrawingBoard1.fittoscreen()
End Sub
Public Sub InvertColors()
Me.DrawingBoard1.InvertColors()
End Sub
Public Sub ZoomIn()
Me.DrawingBoard1.ZoomIn()
End Sub
Public Sub ZoomOut()
Me.DrawingBoard1.ZoomOut()
End Sub
Public Sub RotateFlip(ByVal RotateFlipType As System.Drawing.RotateFlipType)
DrawingBoard1.RotateFlip(RotateFlipType)
End Sub
#End Region ' Methods
#Region "EVENTS"
Private Sub DrawingBoard1_NewMousePosImage(pm As System.Drawing.PointF) Handles DrawingBoard1.NewMousePosImage
RaiseEvent NewMousePosImage(pm)
End Sub
@@ -185,51 +193,50 @@ Public Class ImageControl
RaiseEvent PointSelected(n)
End Sub
Private Sub DrawingBoard1_SetScrollPositions() Handles DrawingBoard1.SetScrollPositions
Private Sub DrawingBoard1_SetScrollPositions() Handles DrawingBoard1.SetScrollPositions
Dim DrawingWidth As Integer = DrawingBoard1.Image.Width
Dim DrawingHeight As Integer = DrawingBoard1.Image.Height
Dim OriginX As Integer = DrawingBoard1.Origin.X
Dim OriginY As Integer = DrawingBoard1.Origin.Y
Dim FactoredCtrlWidth As Integer = DrawingBoard1.Width / DrawingBoard1.ZoomFactor
Dim FactoredCtrlHeight As Integer = DrawingBoard1.Height / DrawingBoard1.ZoomFactor
Dim DrawingWidth As Integer = DrawingBoard1.Image.Width
Dim DrawingHeight As Integer = DrawingBoard1.Image.Height
Dim OriginX As Integer = DrawingBoard1.Origin.X
Dim OriginY As Integer = DrawingBoard1.Origin.Y
Dim FactoredCtrlWidth As Integer = DrawingBoard1.Width / DrawingBoard1.ZoomFactor
Dim FactoredCtrlHeight As Integer = DrawingBoard1.Height / DrawingBoard1.ZoomFactor
HScrollBar1.Maximum = Me.DrawingBoard1.Image.Width
VScrollBar1.Maximum = Me.DrawingBoard1.Image.Height
If FactoredCtrlWidth >= DrawingBoard1.Image.Width Or StretchImageToFit Then
HScrollBar1.Enabled = False
HScrollBar1.Value = 0
Else
HScrollBar1.LargeChange = FactoredCtrlWidth
HScrollBar1.Enabled = True
HScrollBar1.Value = OriginX
End If
If FactoredCtrlHeight >= DrawingBoard1.Image.Height Or StretchImageToFit Then
VScrollBar1.Enabled = False
VScrollBar1.Value = 0
Else
VScrollBar1.Enabled = True
VScrollBar1.LargeChange = FactoredCtrlHeight
VScrollBar1.Value = OriginY
End If
HScrollBar1.Maximum = Me.DrawingBoard1.Image.Width
VScrollBar1.Maximum = Me.DrawingBoard1.Image.Height
If FactoredCtrlWidth >= DrawingBoard1.Image.Width Or StretchImageToFit Then
HScrollBar1.Enabled = False
HScrollBar1.Value = 0
Else
HScrollBar1.LargeChange = FactoredCtrlWidth
HScrollBar1.Enabled = True
HScrollBar1.Value = OriginX
End If
If FactoredCtrlHeight >= DrawingBoard1.Image.Height Or StretchImageToFit Then
VScrollBar1.Enabled = False
VScrollBar1.Value = 0
Else
VScrollBar1.Enabled = True
VScrollBar1.LargeChange = FactoredCtrlHeight
VScrollBar1.Value = OriginY
End If
End Sub
Private Sub ScrollBar_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles HScrollBar1.ValueChanged, VScrollBar1.ValueChanged
Me.DrawingBoard1.Origin = New Point(HScrollBar1.Value, VScrollBar1.Value)
End Sub
Private Sub ScrollBar_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles HScrollBar1.ValueChanged, VScrollBar1.ValueChanged
Me.DrawingBoard1.Origin = New Point(HScrollBar1.Value, VScrollBar1.Value)
End Sub
Private Sub DrawingBoard1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DrawingBoard1.Load
Private Sub DrawingBoard1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DrawingBoard1.Load
End Sub
End Sub
Private Sub VScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll
End Sub
Private Sub VScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll
End Sub
Private Sub DrawingBoard1_PointUnselected() Handles DrawingBoard1.PointUnselected
RaiseEvent PointUnselected()
End Sub
#End Region ' Events
End Class
+9 -4
View File
@@ -1,10 +1,9 @@
Imports system.io
Imports system.io.path
Imports system.Drawing
Imports System.Windows.Forms
Imports IPadLibrary.FormsInterfaces
Public Module MainModule
#Region "FIELDS & PROPERTIES"
Public Enum statoGenEnum
StatoOk = 0
ErroreCfg = 1
@@ -46,6 +45,10 @@ Public Module MainModule
Public IndexProc As String = String.Empty
#End Region ' Fields & Properties
#Region "METHODS"
Public Function CancelDir(ByVal inPath As String) As Boolean
Try
Kill(inPath & "\*.*")
@@ -54,4 +57,6 @@ Public Module MainModule
Return True
End Function
#End Region ' Methods
End Module
+60 -71
View File
@@ -20,100 +20,89 @@
'******************************************************************************/
Option Explicit On
Imports System
Imports System.Runtime.InteropServices
Public Interface Observer
Sub update(ByVal from As Observable, ByVal msg As Integer, ByVal data As Integer)
Sub update(ByVal from As Observable, ByVal msg As Integer, ByVal data As Integer)
End Interface
Public Class Observable
Private m_numof_ob As Integer
Private m_observers() As Observer
#Region "FIELDS & PROPERTIES"
Private m_numof_ob As Integer
Private m_observers() As Observer
Public Sub New()
m_numof_ob = -1 ' ArraySize = 0
End Sub
#End Region ' Fields & Properties
Protected Overrides Sub Finalize()
deleteObservers()
End Sub
#Region "CONSTRUCTOR"
'// Add an observer.
Public Sub addObserver(ByVal ob As Object)
Public Sub New()
m_numof_ob = -1 ' ArraySize = 0
End Sub
m_numof_ob = m_numof_ob + 1
ReDim Preserve m_observers(m_numof_ob)
m_observers(m_numof_ob) = ob
#End Region ' Constructor
End Sub
#Region "METHODS"
'// Delete an observer .
Public Sub deleteObserver(ByVal ob As Observer)
Protected Overrides Sub Finalize()
deleteObservers()
End Sub
Dim iCnt As Integer
'// Add an observer.
Public Sub addObserver(ByVal ob As Object)
m_numof_ob = m_numof_ob + 1
ReDim Preserve m_observers(m_numof_ob)
m_observers(m_numof_ob) = ob
End Sub
If m_numof_ob <= 0 Then
'// Delete an observer .
Public Sub deleteObserver(ByVal ob As Observer)
Dim iCnt As Integer
ReDim m_observers(-1)
m_numof_ob = -1
If m_numof_ob <= 0 Then
ReDim m_observers(-1)
m_numof_ob = -1
Else
For iCnt = 0 To m_numof_ob
If m_observers(iCnt) Is ob Then
Do
m_observers(iCnt) = m_observers(iCnt + 1)
iCnt = iCnt + 1
Loop Until iCnt = m_numof_ob
End If
Next
m_observers(m_numof_ob) = Nothing
m_numof_ob = m_numof_ob - 1
ReDim Preserve m_observers(m_numof_ob)
End If
End Sub
Else
For iCnt = 0 To m_numof_ob
If m_observers(iCnt) Is ob Then
Do
m_observers(iCnt) = m_observers(iCnt + 1)
iCnt = iCnt + 1
Loop Until iCnt = m_numof_ob
End If
Next
m_observers(m_numof_ob) = Nothing
m_numof_ob = m_numof_ob - 1
ReDim Preserve m_observers(m_numof_ob)
End If
End Sub
'// Notify to observers.
Public Sub notifyObservers(ByVal msg As Integer, Optional ByVal data As Integer = 0)
'// Notify to observers.
Public Sub notifyObservers(ByVal msg As Integer, Optional ByVal data As Integer = 0)
Exit Sub
Dim iCnt As Integer
Dim iCnt As Integer
For iCnt = m_numof_ob To 0 Step -1
For iCnt = m_numof_ob To 0 Step -1
m_observers(iCnt).update(Me, msg, data)
iCnt = iCnt - 1
Next
End Sub
m_observers(iCnt).update(Me, msg, data)
iCnt = iCnt - 1
Public Sub deleteObservers()
Dim icnt As Integer
Next
For icnt = 0 To m_numof_ob
m_observers(icnt) = Nothing
Next
End Sub
' Set the number of observer as 0.
m_numof_ob = 0
End Sub
Public Function countObservers() As Integer
Return m_numof_ob
End Function
Public Sub deleteObservers()
Dim icnt As Integer
For icnt = 0 To m_numof_ob
m_observers(icnt) = Nothing
Next
' Set the number of observer as 0.
m_numof_ob = 0
End Sub
Public Function countObservers() As Integer
Return m_numof_ob
End Function
#End Region ' Methods
End Class
+171 -301
View File
@@ -1,78 +1,18 @@
Imports System.Runtime.InteropServices
Imports System.Windows.Forms
Imports System.Collections
Imports System.IO
Imports System.IO.Path
Imports System.Drawing.Imaging
Imports System.Drawing.Bitmap
Public Class clsCamera
Implements Observer
#Region "FIELDS & PROPERTIES"
Private m_PhotoFileName As String
Private m_ImgCtrl As ImageControl
Private m_Image As System.Drawing.Bitmap
Private m_bDownloaded As Boolean
Private m_LbImageStatus As Label
Private m_DownloadDir As String = "C:\CameraMng\"
Private m_isSDKLoaded As Boolean = False
Private _lastError As Integer = EDS_ERR_OK
Private _bodyID As String = ""
Private m_idList As List(Of String) = Nothing
Private m_ConnectedCameras As Integer = 0
ReadOnly Property PhotoFileName() As String
Get
Return m_PhotoFileName
End Get
End Property
ReadOnly Property CameraImage As Bitmap
Get
Return m_Image
End Get
End Property
WriteOnly Property DownloadDir As String
Set(ByVal value As String)
m_DownloadDir = value
End Set
End Property
ReadOnly Property Downloaded() As Boolean
Get
Return m_bDownloaded
End Get
End Property
ReadOnly Property LastError() As Integer
Get
Return _lastError
End Get
End Property
ReadOnly Property CameraID As String
Get
Return _bodyID
End Get
End Property
WriteOnly Property LbImageStatus() As Label
Set(ByVal LbToSet As Label)
m_LbImageStatus = LbToSet
End Set
End Property
Public Sub New()
End Sub
Public Sub Dispose(ByVal disposing As Boolean)
End Sub
Private _connected As Boolean = False
Private m_bDownloaded As Boolean
Private _lastError As Integer = EDS_ERR_OK
Event DownloadedCompleted()
Event StatusChanged()
Public nCount As Integer = 0
#Region "User defined attributes"
@@ -81,44 +21,184 @@ Public Class clsCamera
Public inObjectEventHandler As New EdsObjectEventHandler(AddressOf handleObjectEvent)
Public inStateEventHandler As New EdsStateEventHandler(AddressOf handleStateEvent)
Public inProgressCallback As New EdsProgressCallback(AddressOf ProgressFunc)
'
Public Shared controller As CameraController
Public Shared model As CameraModel
Public Shared m_cmbTbl As Hashtable = New Hashtable
#End Region ' User defined attributes
Private m_PhotoFileName As String
ReadOnly Property PhotoFileName() As String
Get
Return m_PhotoFileName
End Get
End Property
#End Region
Private m_Image As System.Drawing.Bitmap
ReadOnly Property CameraImage As Bitmap
Get
Return m_Image
End Get
End Property
Private m_DownloadDir As String = "C:\CameraMng\"
WriteOnly Property DownloadDir As String
Set(ByVal value As String)
m_DownloadDir = value
End Set
End Property
Delegate Sub UpdateDelegate(
ByVal from As Observable,
ByVal msg As Integer,
ByVal data As Integer)
Private _bodyID As String = ""
ReadOnly Property CameraID As String
Get
Return _bodyID
End Get
End Property
Private m_ConnectedCameras As Integer = 0
ReadOnly Property ConnectedCameras As String
Get
Return m_ConnectedCameras
End Get
End Property
Public Function cameraModelFactory(ByVal camera As IntPtr, ByVal deviceInfo As EdsDeviceInfo) As CameraModel
Private m_LbImageStatus As Label
WriteOnly Property LbImageStatus() As Label
Set(ByVal LbToSet As Label)
m_LbImageStatus = LbToSet
End Set
End Property
' if Legacy protocol.
If deviceInfo.DeviceSubType = 0 Then
Return New CameraModelLegacy(camera)
End If
' PTP protocol.
Return New CameraModel(camera)
End Function
Private _connected As Boolean = False
ReadOnly Property Connected As Boolean
Get
Return _connected
End Get
End Property
#End Region ' Fields & Properties
#Region "CONSTRUCTOR"
Public Sub New()
End Sub
#End Region ' Constructor
#Region "EVENTS"
Private Function handleObjectEvent(ByVal inEvent As Integer, ByVal inRef As IntPtr, ByVal inContext As IntPtr) As Long
Dim rtn As Long
Dim err As Integer = EDS_ERR_OK
Dim stream As IntPtr = Nothing
Dim directoryItem As IntPtr
'// Get informations of the downloadling directory item.
Dim dirItemInfo As EdsDirectoryItemInfo = Nothing
Select Case inEvent
Case kEdsObjectEvent_DirItemRequestTransfer
err = EdsGetDirectoryItemInfo(inRef, dirItemInfo)
If err = EDS_ERR_OK Then
err = EdsCreateFileStream(m_DownloadDir & dirItemInfo.szFileName, EdsFileCreateDisposition.kEdsFileCreateDisposition_CreateAlways, EdsAccess.kEdsAccess_ReadWrite, stream)
End If
err = EdsDownload(inRef, dirItemInfo.size, stream)
Console.WriteLine("INIZIO DONWLOAD: " & MainModule.IndexProc)
If err = EDS_ERR_OK Then
err = EdsDownloadComplete(inRef)
End If
If IsNothing(inRef) = False Then
err = EdsRelease(inRef)
directoryItem = Nothing
End If
If IsNothing(stream) = False Then
err = EdsRelease(stream)
stream = Nothing
m_PhotoFileName = m_DownloadDir & dirItemInfo.szFileName
If (LCase$(GetExtension(m_PhotoFileName)) = ".jpg") Then
m_Image = Nothing
GC.Collect()
m_Image = New System.Drawing.Bitmap(PhotoFileName)
'm_ImgCtrl.Image = m_Image
m_bDownloaded = True
RaiseEvent DownloadedCompleted()
End If
End If
Console.WriteLine("FINE DONWLOAD: " & MainModule.IndexProc)
Case Else
'//Release unnecessary objects.
If IsNothing(inRef) = False Then
EdsRelease(inRef)
End If
End Select
rtn = CLng(EDS_ERR_OK)
Return rtn
End Function
Private Function handlePropertyEvent(ByVal inEvent As Integer, ByVal inPropertyID As Integer, ByVal inParam As Integer, ByVal inContext As IntPtr) As Long
Dim rtn As Long
Debug.Print("propId =H" & Hex(inPropertyID))
nCount = nCount + 1
If nCount = 1 Then
Console.WriteLine("BINGO")
nCount = 0
End If
Select Case inEvent
Case kEdsPropertyEvent_PropertyChanged
controller.actionPerformed("get", inPropertyID)
Case kEdsPropertyEvent_PropertyDescChanged
controller.actionPerformed("getlist", inPropertyID)
End Select
If inPropertyID = kEdsPropID_OwnerName Then
Debug.Print("bingo")
End If
If inPropertyID = kEdsPropID_ISOSpeed Then
Debug.Print("iso")
End If
rtn = CLng(EDS_ERR_OK)
Return rtn
End Function
Private Function handleStateEvent(ByVal inEvent As Integer, ByVal inParam As Integer, ByVal inContext As IntPtr) As Long
Dim rtn As Long
Select Case inEvent
Case kEdsStateEvent_Shutdown
_connected = False
RaiseEvent StatusChanged()
End Select
rtn = CLng(EDS_ERR_OK)
Return rtn
End Function
#End Region ' Events
#Region "METHODS"
Public Function cameraModelFactory(ByVal camera As IntPtr, ByVal deviceInfo As EdsDeviceInfo) As CameraModel
' if Legacy protocol.
If deviceInfo.DeviceSubType = 0 Then
Return New CameraModelLegacy(camera)
End If
' PTP protocol.
Return New CameraModel(camera)
End Function
Public Sub TakeFoto()
Dim err As Integer = EDS_ERR_OK
'// Take a picture.
@@ -127,7 +207,6 @@ Public Class clsCamera
'// Notify Error.
If err <> EDS_ERR_OK Then
End If
controller.actionPerformed("takepicture")
@@ -137,7 +216,6 @@ Public Class clsCamera
' Creo la connessione con la camera
Public Sub Connect(Optional bodyID As String = "")
If bodyID = "" Then
Connect(0)
Return
@@ -150,32 +228,8 @@ Public Class clsCamera
End If
If _connected Then Disconnect()
Next
End Sub
Public Sub CameraList()
Disconnect()
If m_idList IsNot Nothing Then
m_idList.Clear()
Else
m_idList = New List(Of String)
End If
For i As Integer = 0 To 2
Connect(i)
If Not _connected Then Exit For
m_idList.Add(CameraID)
Disconnect()
Next
End Sub
' Da rivedere !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' Setta il valore di CameraID
Private Sub Connect(ncam As Integer)
@@ -184,6 +238,7 @@ Public Class clsCamera
Dim cameraList As IntPtr = Nothing
Dim camera As IntPtr = Nothing
Dim propObj As New CameraProperty
Dim deviceInfo As EdsDeviceInfo = Nothing
m_ConnectedCameras = 0
_connected = False
@@ -200,10 +255,8 @@ Public Class clsCamera
m_isSDKLoaded = True
_lastError = EdsGetCameraList(cameraList)
If _lastError <> EDS_ERR_OK Then Return
_lastError = EdsGetChildCount(cameraList, m_ConnectedCameras)
If _lastError <> EDS_ERR_OK Then Return
@@ -212,18 +265,14 @@ Public Class clsCamera
Return
End If
Dim deviceInfo As EdsDeviceInfo = Nothing
If ncam > m_ConnectedCameras - 1 Then Return
'// Get the camera.
_lastError = EdsGetChildAtIndex(cameraList, ncam, camera)
If _lastError <> EDS_ERR_OK Then Return
deviceInfo = Nothing
_lastError = EdsGetDeviceInfo(camera, deviceInfo)
If _lastError <> EDS_ERR_OK Then Return
If IsNothing(camera) = True Then
@@ -231,49 +280,26 @@ Public Class clsCamera
Return
End If
' Lebbo il nome della Fotocamera
'Dim dt As EdsDataType
'Dim outSize As Integer
'EdsGetPropertySize(camera, kEdsPropID_ProductName, 0, dt, outSize)
'Dim outData As IntPtr = Marshal.AllocHGlobal(20)
'Dim data As String
'EdsGetPropertyData(camera, kEdsPropID_OwnerName, 0, 100, outData)
'data = Marshal.PtrToStringAnsi(outData)
' la lista delle fotocamere non mi serve più
If IsNothing(cameraList) = False Then
EdsRelease(cameraList)
End If
'// Create the camera model
If _lastError = EDS_ERR_OK Then
model = cameraModelFactory(camera, deviceInfo)
If IsNothing(model) = True Then
_lastError = EDS_ERR_DEVICE_NOT_FOUND
End If
End If
If _lastError <> EDS_ERR_OK Then Return
'// Create a controller
controller = New CameraController
'// Set the model to this controller.
controller.setCameraModel(model)
'// Make notify the model updating to the view.
'model.addObserver(Me)
' ------------------------------------------------------------------------
' ------------------------------------------------------------------------
' You should create class instance of delegates of event handlers
@@ -307,35 +333,25 @@ Public Class clsCamera
_lastError = EdsSetCameraStateEventHandler(camera, kEdsStateEvent_All, inStateEventHandler, IntPtr.Zero)
If _lastError <> EDS_ERR_OK Then
If Not IsNothing(camera) Then
EdsRelease(camera)
camera = Nothing
End If
If (m_isSDKLoaded) Then
EdsTerminateSDK()
End If
If Not IsNothing(model) Then
model = Nothing
End If
If Not IsNothing(controller) Then
controller = Nothing
End If
Return
End If
' -- Execute the controller.
controller.run()
'controller.actionPerformed("set", kEdsPropID_ISOSpeed, &H58)
'Dim prova As Integer
'Dim provaID As Integer
'controller.actionPerformed("get", kEdsPropID_OwnerName, prova)
'controller.actionPerformed("get", kEdsPropID_BodyIDEx, provaID)
controller.actionPerformed("get", kEdsPropID_Unknown)
_bodyID = ""
@@ -349,12 +365,9 @@ Public Class clsCamera
_connected = True
RaiseEvent StatusChanged()
End Sub
Public Sub Disconnect()
controller.actionPerformed("close")
_bodyID = ""
@@ -367,177 +380,38 @@ Public Class clsCamera
EdsTerminateSDK()
m_isSDKLoaded = False
_connected = False
End Sub
Private Function handleObjectEvent(
ByVal inEvent As Integer,
ByVal inRef As IntPtr,
ByVal inContext As IntPtr) As Long
Dim rtn As Long
Dim err As Integer = EDS_ERR_OK
Dim stream As IntPtr = Nothing
Dim directoryItem As IntPtr
'// Get informations of the downloadling directory item.
Dim dirItemInfo As EdsDirectoryItemInfo = Nothing
Select Case inEvent
Case kEdsObjectEvent_DirItemRequestTransfer
'VBSample.controller.actionPerformed("download", inRef)
err = EdsGetDirectoryItemInfo(inRef, dirItemInfo)
If err = EDS_ERR_OK Then
err = EdsCreateFileStream(m_DownloadDir & dirItemInfo.szFileName, EdsFileCreateDisposition.kEdsFileCreateDisposition_CreateAlways, EdsAccess.kEdsAccess_ReadWrite, stream)
End If
err = EdsDownload(inRef, dirItemInfo.size, stream)
Console.WriteLine("INIZIO DONWLOAD: " & MainModule.IndexProc)
If err = EDS_ERR_OK Then
err = EdsDownloadComplete(inRef)
End If
If IsNothing(inRef) = False Then
err = EdsRelease(inRef)
directoryItem = Nothing
End If
If IsNothing(stream) = False Then
err = EdsRelease(stream)
stream = Nothing
m_PhotoFileName = m_DownloadDir & dirItemInfo.szFileName
If (LCase$(GetExtension(m_PhotoFileName)) = ".jpg") Then
m_Image = Nothing
GC.Collect()
m_Image = New System.Drawing.Bitmap(PhotoFileName)
'm_ImgCtrl.Image = m_Image
m_bDownloaded = True
RaiseEvent DownloadedCompleted()
End If
End If
Console.WriteLine("FINE DONWLOAD: " & MainModule.IndexProc)
Case Else
'//Release unnecessary objects.
If IsNothing(inRef) = False Then
EdsRelease(inRef)
End If
End Select
rtn = CLng(EDS_ERR_OK)
Return rtn
End Function
Public nCount As Integer = 0
' Public Shared Function handlePropertyEvent( _
Private Function handlePropertyEvent(
ByVal inEvent As Integer,
ByVal inPropertyID As Integer,
ByVal inParam As Integer,
ByVal inContext As IntPtr) As Long
Dim rtn As Long
Debug.Print("propId =H" & Hex(inPropertyID))
nCount = nCount + 1
If nCount = 1 Then
Console.WriteLine("BINGO")
nCount = 0
End If
Select Case inEvent
Case kEdsPropertyEvent_PropertyChanged
controller.actionPerformed("get", inPropertyID)
Case kEdsPropertyEvent_PropertyDescChanged
controller.actionPerformed("getlist", inPropertyID)
End Select
If inPropertyID = kEdsPropID_OwnerName Then
Debug.Print("bingo")
End If
If inPropertyID = kEdsPropID_ISOSpeed Then
Debug.Print("iso")
End If
rtn = CLng(EDS_ERR_OK)
Return rtn
End Function
Private Function handleStateEvent(
ByVal inEvent As Integer,
ByVal inParam As Integer,
ByVal inContext As IntPtr) As Long
Dim rtn As Long
Select Case inEvent
Case kEdsStateEvent_Shutdown
_connected = False
'VBSample.controller.actionPerformed("close")
RaiseEvent StatusChanged()
End Select
rtn = CLng(EDS_ERR_OK)
Return rtn
End Function
Private Function ProgressFunc(ByVal inPercent As Integer,
ByVal inContext As IntPtr, ByRef outCancel As Boolean) As Long
Private Function ProgressFunc(ByVal inPercent As Integer, ByVal inContext As IntPtr, ByRef outCancel As Boolean) As Long
Dim rtn As Long = CLng(EDS_ERR_OK)
'VBSample.model.notifyObservers(prog, inPercent)
Return rtn
End Function
Sub UpdateProperty(ByVal from As Observable, ByVal msg As Integer, ByVal data As Integer) _
Implements Observer.update
Sub UpdateProperty(ByVal from As Observable, ByVal msg As Integer, ByVal data As Integer) Implements Observer.update
Debug.Print("msg=" & msg & "data=H" & Hex(data))
Select Case msg
Case prog '//Progress of image downloading .
'ProgressBar.Value = data
Case strt '// Start downloading.
'//_progress.SetPos(0);
Case cplt '// Complete downloading.
'ProgressBar.Value = 0
Case updt '// Update properties.
Dim propertyID As Integer = data
Dim propData As Integer = model.getPropertyUInt32(propertyID)
UpdateProperty(propertyID, propData)
Case upls '// Update an available property list.
Dim propertyID As Integer = data
Dim desc As EdsPropertyDesc = model.getPropertyDesc(propertyID)
UpdatePropertyDesc(propertyID, desc)
Case warn '// Warning
'InfoTextBox.Text = "Device Busy"
Case errr '// Error
'// Nothing to do because the first getting property from model 30D is sure to fail.
Dim ss As String
ss = String.Format("%x", data)
'InfoTextBox.Text = ss
Case clse '// Close
'TakeBtn.Enabled = False
'ProgressBar.Enabled = False
@@ -546,21 +420,17 @@ Public Class clsCamera
'TvCmb.Enabled = False
'AvCmb.Enabled = False
'ISOSpeedCmb.Enabled = False
End Select
If msg <> errr And msg <> warn Then
'InfoTextBox.Text = ""
End If
End Sub
Sub UpdateProperty(ByVal propertyID As Integer, ByVal data As Integer)
Dim propList As Hashtable = CameraProperty.g_PropList.Item(propertyID)
Dim valoreprop As String
Select Case propertyID
Case kEdsPropID_AEModeSelect
valoreprop = propList.Item(data)
@@ -577,11 +447,8 @@ Public Class clsCamera
Case kEdsPropID_ImageQuality
valoreprop = propList.Item(data)
End Select
End Sub
Sub UpdatePropertyDesc(ByVal propertyID As Integer, ByVal desc As EdsPropertyDesc)
Dim err As Integer
Dim iCnt As Integer
@@ -598,6 +465,7 @@ Public Class clsCamera
cmb.BeginUpdate()
cmb.Items.Clear()
For iCnt = 0 To desc.numElements - 1
propStr = propList(desc.propDesc(iCnt))
If propStr <> Nothing Then
@@ -607,14 +475,16 @@ Public Class clsCamera
Next
cmb.Tag = propValueList ' Set the property value list
cmb.EndUpdate()
If cmb.Items.Count = 0 Then
cmb.Enabled = False '// No available item.
Else
cmb.Enabled = True
End If
End Sub
#End Region ' Methods
End Class
+79 -61
View File
@@ -1,86 +1,38 @@
Imports System.Runtime.InteropServices
Imports System.Drawing.Imaging
Imports System.Drawing
Imports System.Drawing.Bitmap
Public Class BitmapBytesRGB24
' Provide public access to the picture's byte data.
Public ImageBytes() As Byte
Public RowSizeBytes As Integer
Public Const PixelDataSize As Integer = 24
' A reference to the Bitmap.
Private m_Bitmap As Drawing.Bitmap
' Bitmap data.
Private m_BitmapData As BitmapData
' Save a reference to the bitmap.
Public Sub New(ByVal bm As Drawing.Bitmap)
m_Bitmap = bm
End Sub
' Lock the bitmap's data.
Public Sub LockBitmap()
' Lock the bitmap data.
Dim bounds As Drawing.Rectangle = New Rectangle( _
0, 0, m_Bitmap.Width, m_Bitmap.Height)
m_BitmapData = m_Bitmap.LockBits(bounds, _
Imaging.ImageLockMode.ReadWrite, _
Imaging.PixelFormat.Format24bppRgb)
RowSizeBytes = m_BitmapData.Stride
#Region "FIELDS & PROPERTIES"
' Allocate room for the data.
Dim total_size As Integer = m_BitmapData.Stride * m_BitmapData.Height
ReDim ImageBytes(total_size)
' Copy the data into the ImageBytes array.
Marshal.Copy(m_BitmapData.Scan0, ImageBytes, _
0, total_size)
End Sub
' Copy the data back into the Bitmap
' and release resources.
Public Sub UnlockBitmap()
' Copy the data back into the bitmap.
Dim total_size As Integer = m_BitmapData.Stride * m_BitmapData.Height
Marshal.Copy(ImageBytes, 0, _
m_BitmapData.Scan0, total_size)
' Unlock the bitmap.
m_Bitmap.UnlockBits(m_BitmapData)
' Release resources.
'ImageBytes = Nothing
'm_BitmapData = Nothing
End Sub
Public Sub ReleaseBitmap()
' Release resources.
ImageBytes = Nothing
m_BitmapData = Nothing
GC.Collect()
End Sub
End Class
Public Class BitmapBytes8
' Provide public access to the picture's byte data.
Public ImageBytes() As Byte
Public RowSizeBytes As Integer
Public Const PixelDataSize As Integer = 8
Public Const PixelDataSize As Integer = 24
' A reference to the Bitmap.
Private m_Bitmap As Drawing.Bitmap
' Bitmap data.
Private m_BitmapData As BitmapData
#End Region ' Fields & Properties
#Region "CONSTRUCTOR"
' Save a reference to the bitmap.
Public Sub New(ByVal bm As Drawing.Bitmap)
m_Bitmap = bm
End Sub
#End Region ' Constructor
#Region "METHODS"
' Lock the bitmap's data.
Public Sub LockBitmap()
' Lock the bitmap data.
Dim bounds As Drawing.Rectangle = New Rectangle(0, 0, m_Bitmap.Width, m_Bitmap.Height)
m_BitmapData = m_Bitmap.LockBits(bounds, Imaging.ImageLockMode.ReadWrite, _
m_Bitmap.PixelFormat)
m_BitmapData = m_Bitmap.LockBits(bounds, Imaging.ImageLockMode.ReadWrite, Imaging.PixelFormat.Format24bppRgb)
RowSizeBytes = m_BitmapData.Stride
' Allocate room for the data.
@@ -89,7 +41,70 @@ Public Class BitmapBytes8
' Copy the data into the ImageBytes array.
Marshal.Copy(m_BitmapData.Scan0, ImageBytes, 0, total_size)
End Sub
' Copy the data back into the Bitmap
' and release resources.
Public Sub UnlockBitmap()
' Copy the data back into the bitmap.
Dim total_size As Integer = m_BitmapData.Stride * m_BitmapData.Height
Marshal.Copy(ImageBytes, 0, m_BitmapData.Scan0, total_size)
' Unlock the bitmap.
m_Bitmap.UnlockBits(m_BitmapData)
End Sub
Public Sub ReleaseBitmap()
' Release resources.
ImageBytes = Nothing
m_BitmapData = Nothing
GC.Collect()
End Sub
#End Region ' Methods
End Class
Public Class BitmapBytes8
#Region "FIELDS & PROPERTIES"
' Provide public access to the picture's byte data.
Public ImageBytes() As Byte
Public RowSizeBytes As Integer
Public Const PixelDataSize As Integer = 8
' A reference to the Bitmap.
Private m_Bitmap As Drawing.Bitmap
' Bitmap data.
Private m_BitmapData As BitmapData
#End Region ' Fields & Properties
#Region "CONSTRUCTOR"
' Save a reference to the bitmap.
Public Sub New(ByVal bm As Drawing.Bitmap)
m_Bitmap = bm
End Sub
#End Region ' Constructor
#Region "METHODS"
' Lock the bitmap's data.
Public Sub LockBitmap()
' Lock the bitmap data.
Dim bounds As Drawing.Rectangle = New Rectangle(0, 0, m_Bitmap.Width, m_Bitmap.Height)
m_BitmapData = m_Bitmap.LockBits(bounds, Imaging.ImageLockMode.ReadWrite, m_Bitmap.PixelFormat)
RowSizeBytes = m_BitmapData.Stride
' Allocate room for the data.
Dim total_size As Integer = m_BitmapData.Stride * m_BitmapData.Height
ReDim ImageBytes(total_size)
' Copy the data into the ImageBytes array.
Marshal.Copy(m_BitmapData.Scan0, ImageBytes, 0, total_size)
End Sub
' Copy the data back into the Bitmap
@@ -100,6 +115,7 @@ Public Class BitmapBytes8
Marshal.Copy(ImageBytes, 0, m_BitmapData.Scan0, total_size)
UnlockBitmap()
End Sub
' Release resources.
Public Sub UnlockBitmap()
m_Bitmap.UnlockBits(m_BitmapData)
@@ -111,4 +127,6 @@ Public Class BitmapBytes8
GC.Collect()
End Sub
#End Region ' Methods
End Class
+21 -16
View File
@@ -1,41 +1,46 @@
Imports Emgu
Imports Emgu.CV
Imports Emgu.CV.Util
Imports Emgu.CV.Structure
Public Class FrmImgShow
Public Class FrmImgShow
Private Sub ImageBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImageBox1.Click
End Sub
Private Sub FrmImgShow_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
ImageBox1.FunctionalMode = Emgu.CV.UI.ImageBox.FunctionalModeOption.Everything
End Sub
#Region "CONSTRUCTOR"
Public Sub New(ByVal img As Emgu.CV.IImage)
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
ImageBox1.Image = img
End Sub
Public Sub New()
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
#End Region ' Constructor
#Region "EVENTS"
Private Sub FrmImgShow_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
ImageBox1.FunctionalMode = Emgu.CV.UI.ImageBox.FunctionalModeOption.Everything
End Sub
Private Sub ImageBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImageBox1.Click
End Sub
Private Sub BtnZoomAll_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnZoomAll.Click
Dim zallScale As Double = Math.Min(ImageBox1.Width / ImageBox1.Image.Bitmap.Width, ImageBox1.Height / ImageBox1.Image.Bitmap.Height)
ImageBox1.SetZoomScale(zallScale, New Point(0, 0))
End Sub
#End Region ' Events
#Region "METHODS"
Public Sub DisposeForm()
ImageBox1.Image = Nothing
End Sub
#End Region ' Methods
End Class
+111 -239
View File
@@ -1,6 +1,3 @@
Imports System.Runtime
Imports Emgu.CV.CvEnum
Imports Emgu.CV.Structure
Imports System.Math
@@ -8,28 +5,23 @@ Imports System.IO
Imports System.Globalization
Imports Emgu.CV
Imports System.Threading
Imports Emgu.CV.Util
Imports System.Drawing.Imaging
Public Class clsImageMng
#Region "membri privati"
#Region "FIELDS & PROPERTIES"
Private m_dimx As Short = 1 '3888
Private m_dimy As Short = 1 ' 2592
Private m_Pos_x_mm, m_Pos_y_mm As Double
' Posizione in mm del punto_3 (ibl=3) rispetto all'origine (punto_0)
Private m_Pos_x_z0_mm, m_Pos_y_z0_mm As Double
Private m_bCorrected As Boolean = False
Private m_pmm_bs As New clPuntomm
Private m_pmm_bs_lev0 As New clPuntomm
Private m_scale_center As New clPuntomm
Private m_fscalaxmm As Double
Private m_scale_centerZ As Double
Private m_punto0 As New clCoppiaPunto
Private m_puntoH(4) As clCoppiaPunto
Private m_bCorrAltezzaEnabled As Boolean
' posizione in px dei punti dell'immagine originale rispetto al punto punto_0 (itl=0)
Private m_pdst(3) As System.Drawing.PointF ' punti nuova foto
' indice per distinguere i punti salvati nei vettori 'm_pworld', 'm_psrc', 'm_pdst'
@@ -42,13 +34,13 @@ Public Class clsImageMng
Private m_dim_YProsp As Short = 1
' mm to px all'altezza zero del tavolo
Private m_mm2PixelProspZ0 As Double
Private m_mm2PixelProspFinal As Double
' Estension in Pixel dell'immagine
Private m_ExtXL_pix As Integer, m_ExtXR_pix As Integer ' sinistra e destra
Private m_ExtYT_pix As Integer, m_ExtYB_pix As Integer ' sopra e sotto
' Estension in mm dell'immagine
Private m_ExtXL_mm As Single, m_ExtXR_mm As Single ' sinistra e destra
Private m_ExtYT_mm As Single, m_ExtYB_mm As Single ' sopra e sotto
#If WinXP Then
Private m_MatDir As Matrix(Of Double) 'HomographyMatrix ' Per creare l'immagine correttta, data la coord. XY, mi dà il pixel da prendere
Private m_MatInv As Matrix(Of Double) 'HomographyMatrix ' Per ottenere la coord. in mm da un valore in pixel dell'imm. originale
@@ -64,91 +56,36 @@ Public Class clsImageMng
Private m_SpessLastra As Double = 0
Private m_SpessCorr As Double = 0
Private _thprocess As Thread = Nothing
Private m_UndistImage As Drawing.Bitmap = Nothing
Private m_FinalImage As Drawing.Bitmap = Nothing
Private m_InputImage As Drawing.Bitmap = Nothing
Private m_dim_XProspExt As Integer
Private m_dim_YProspExt As Integer
Private m_bMatProspOk As Boolean = False
Private m_FileCalibLens As String = Nothing
Private m_FileCalibProsp As String = Nothing
Private m_widthImagePixMax As Integer = 6000
Private MatConvP(m_dimx, m_dimy) As clPuntoPix
Private m_CalimageWidth As Integer = 0
' [ fx 0.0 cx
' 0.0 fy cy
' 0.0 0.0 1.0 ]
Private _cameraMatrix As Matrix(Of Double) = Nothing
' [ k1, k2, p1, p2, p3 ]
Private _distCoeffs As Matrix(Of Double) = Nothing
Private m_fileCaliLensRead As Boolean = False
Private m_fileCaliProspRead As Boolean = False
Private Shared ReadOnly m_sync As New Object
' vettore di correzione prospettica: convertita in matrice (m_MatDir)
Private _perspMatDir As Emgu.CV.Mat
Private _ocvMapx As Emgu.CV.Matrix(Of Single)
Private _ocvMapy As Emgu.CV.Matrix(Of Single)
Private m_jpgQuality As Long = 80
#End Region
#Region "membri pubblici"
' --- variabili per la correzione prospettica
Public m_AltRif As Double
Public m_ZCali As Double
' punti world in mm riferiti rispetto all'origine punto_0 (itl=0)
Public m_pworld(3) As System.Drawing.PointF
' punti foto riferiti rispetto all'origine immagine
Public m_psrc(3) As System.Drawing.PointF
#End Region
#Region "eventi"
Public Event FineCorrezioneLente()
Public Event FineCorrezioneProspettiva()
Public Event AvanzamentoCorrezioneLente(value As Double)
Public Event AvanzamentoCorrezioneProspettiva(value As Double)
Public Event ProcessAborted(err As Integer)
#End Region
#Region "Classi Private"
Private Class clPuntoPix
Public X As Single
Public Y As Single
End Class
Private Class clPuntomm
Public x As Double
Public y As Double
End Class
Private Class clCoppiaPunto
Public XTrg As Double
Public YTrg As Double
Public XSrc As Double
Public YSrc As Double
End Class
#End Region
#Region "Costruttori"
Public Sub New()
Dim i As Integer
For i = 0 To 3
If IsNothing(m_puntoH(i)) Then m_puntoH(i) = New clCoppiaPunto
Next
m_ProspCalibrated = False
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
#End Region
#Region "Proprietà"
Private m_UndistImage As Drawing.Bitmap = Nothing
Public ReadOnly Property UndistorcedImage As Bitmap
Get
SyncLock m_sync
@@ -156,6 +93,8 @@ Public Class clsImageMng
End SyncLock
End Get
End Property
Private m_FinalImage As Drawing.Bitmap = Nothing
Public ReadOnly Property FinalImage As Bitmap
Get
SyncLock m_sync
@@ -163,6 +102,8 @@ Public Class clsImageMng
End SyncLock
End Get
End Property
Private m_InputImage As Drawing.Bitmap = Nothing
Public Property InputImage As Bitmap
Get
Return m_InputImage
@@ -172,6 +113,7 @@ Public Class clsImageMng
End Set
End Property
Private m_widthImagePixMax As Integer = 6000
Public Property MaxPxWidthOutImage As Integer
Set(value As Integer)
m_widthImagePixMax = value
@@ -181,30 +123,93 @@ Public Class clsImageMng
End Get
End Property
Private m_mm2PixelProspFinal As Double
Public ReadOnly Property mm2pixelAtZ As Double
Get
Return m_mm2PixelProspFinal
End Get
End Property
#End Region
Private m_bCorrected As Boolean = False
Property Corrected() As Boolean
Get
Return m_bCorrected
End Get
Set(ByVal value As Boolean)
m_bCorrected = value
End Set
End Property
#Region "Metodi Pubblici"
Private m_bCorrAltezzaEnabled As Boolean
ReadOnly Property CorrAltEnabled() As Boolean
Get
Return m_bCorrAltezzaEnabled
End Get
End Property
Public m_ZCali As Double
ReadOnly Property ZCali() As Double
Get
Return m_ZCali
End Get
End Property
Private m_puntoH(4) As clCoppiaPunto
Property XHpix(ByVal i As Integer) As Short
Get
Return (m_puntoH(i).XSrc)
End Get
Set(ByVal value As Short)
m_puntoH(i).XSrc = value
End Set
End Property
Property YHpix(ByVal i As Integer) As Short
Get
Return (m_puntoH(i).YSrc)
End Get
Set(ByVal value As Short)
m_puntoH(i).YSrc = value
End Set
End Property
Public Event FineCorrezioneLente()
Public Event FineCorrezioneProspettiva()
Public Event AvanzamentoCorrezioneLente(value As Double)
Public Event AvanzamentoCorrezioneProspettiva(value As Double)
Public Event ProcessAborted(err As Integer)
#End Region ' Fields & Properties
#Region "CONSTRUCTOR"
Public Sub New()
Dim i As Integer
For i = 0 To 3
If IsNothing(m_puntoH(i)) Then m_puntoH(i) = New clCoppiaPunto
Next
m_ProspCalibrated = False
End Sub
#End Region ' Constructor
#Region "METHODS"
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
Public Function SetFileCalibrazione(NomeFileCaliLens As String, NomeFileCaliProsp As String) As Boolean
m_FileCalibLens = NomeFileCaliLens
m_FileCalibProsp = NomeFileCaliProsp
Return True
End Function
Public Sub Correggi()
Public Sub Correggi()
' corregge solo la lente e carica il file di calibrazione prospettiva per dare la possibilità di calibrare dall'interfaccia
Try
If Not m_fileCaliLensRead Then
m_fileCaliLensRead = LeggiFileCalibrazioneLenteOCV(m_FileCalibLens)
End If
@@ -214,39 +219,31 @@ Public Class clsImageMng
End If
If Not m_UndistImage Is Nothing Then
'm_UndistImage.Dispose()
m_UndistImage = Nothing
End If
Dim outFrame As New Image(Of Emgu.CV.Structure.Rgb, Byte)(m_InputImage.Width, m_InputImage.Height)
Dim newIntrinsecMatrix As IInputArray
Dim newIntrinsecMatrix As IInputArray = Nothing
CvInvoke.Undistort(New Image(Of Emgu.CV.Structure.Rgb, Byte)(m_InputImage), outFrame, _cameraMatrix, _distCoeffs, newIntrinsecMatrix)
m_UndistImage = outFrame.Bitmap
GC.Collect()
m_UndistImage.Save(DirTmp & "corrected.bmp", System.Drawing.Imaging.ImageFormat.Bmp)
m_bCorrected = True
RaiseEvent AvanzamentoCorrezioneProspettiva(100)
Catch ex As Exception
If Not m_UndistImage Is Nothing Then
'm_UndistImage.Dispose()
m_UndistImage = Nothing
End If
Throw New Exception(ex.Message)
End Try
End Sub
Public Sub DownloadCompletato()
m_bCorrected = False
End Sub
'* c00*xi + c01*yi + c02
'* ui = ---------------------
'* c20*xi + c21*yi + c22
@@ -254,9 +251,7 @@ Public Class clsImageMng
'* c10*xi + c11*yi + c12
'* vi = ---------------------
'* c20*xi + c21*yi + c22
Public Sub CorreggiProspettiva(ByVal SpessLastra As Double)
If Not m_bMatProspOk Then
CalcolaMatriceCorrezioneProspettiva()
CalcolaMatriceOCV()
@@ -265,8 +260,8 @@ Public Class clsImageMng
If m_bMatProspOk Then
CorreggiProspettivaDaMatriceOCV(SpessLastra)
End If
End Sub
Public Sub CalcolaDatiCorrezione()
' forzo il ricalcolo
m_ProspCalibrated = False
@@ -282,7 +277,6 @@ Public Class clsImageMng
Dim i As Integer
Dim nfi As New CultureInfo("en-US", False)
writer = New StreamWriter(m_NomeFileCorrezProsp)
writer.WriteLine("ProspPnt")
For i = 0 To 3
@@ -301,7 +295,6 @@ Public Class clsImageMng
writer.WriteLine("ImageWidth= {0}", m_CalimageWidth.ToString("0"))
writer.Close()
CalcolaMatriceCorrezioneProspettiva()
End Sub
Public Sub ProcessStop()
@@ -311,11 +304,9 @@ Public Class clsImageMng
_thprocess.Abort()
_thprocess = Nothing
End If
End Sub
Public Sub CorrezioneCompletaAsync()
Public Sub CorrezioneCompletaAsync()
ProcessStop()
_thprocess = New Thread(Sub()
@@ -323,12 +314,9 @@ Public Class clsImageMng
End Sub)
_thprocess.Start()
End Sub
Public Sub SaveBitmap(bitm As Bitmap, fileName As String)
' Encoder parameter for image quality
Dim qualityParam As New EncoderParameter(Encoder.Quality, m_jpgQuality)
' Jpeg image codec
@@ -338,29 +326,19 @@ Public Class clsImageMng
encoderParams.Param(0) = qualityParam
bitm.Save(fileName, jpegCodec, encoderParams)
End Sub
#End Region
#Region "Metodi Privati"
Private Function TrovaPuntoInmm4p(ByVal p As clCoppiaPunto) As Boolean
p.XTrg = (m_MatInv(0, 0) * p.XSrc + m_MatInv(0, 1) * p.YSrc + m_MatInv(0, 2)) / (m_MatInv(2, 0) * p.XSrc + m_MatInv(2, 1) * p.YSrc + m_MatInv(2, 2))
p.YTrg = (m_MatInv(1, 0) * p.XSrc + m_MatInv(1, 1) * p.YSrc + m_MatInv(1, 2)) / (m_MatInv(2, 0) * p.XSrc + m_MatInv(2, 1) * p.YSrc + m_MatInv(2, 2))
TrovaPuntoInmm4p = True
End Function
Private Function TrovaDatiScalatura() As Boolean
' trova il centro di scala e il fattore di scala in altezza, per mm
Dim a1, b1, c1, a2, b2, c2 As Double
Dim denominatore As Double
Dim distl, disth As Double
TrovaDatiScalatura = False
@@ -391,9 +369,6 @@ Public Class clsImageMng
Exit Function
End If
Dim distl, disth As Double
distl = (m_scale_center.x - m_puntoH(0).XTrg) * (m_scale_center.x - m_puntoH(0).XTrg) + (m_scale_center.y - m_puntoH(0).YTrg) * (m_scale_center.y - m_puntoH(0).YTrg)
distl = Math.Sqrt(distl)
@@ -406,16 +381,14 @@ Public Class clsImageMng
m_scale_centerZ = m_ZCali + m_AltRif / (1 - distl / disth)
TrovaDatiScalatura = True
End Function
Private Function TrovaOffsetPosizione() As Boolean
Dim pt As New clPuntomm
Dim pTmp As New clCoppiaPunto
Dim offset As New clPuntomm ' calcolato
Try
Try
' trovo come si trasforma in mm (senza offset) il punto di origine in pixel
pTmp.XSrc = m_punto0.XSrc
pTmp.YSrc = m_punto0.YSrc
@@ -429,17 +402,13 @@ Public Class clsImageMng
' Trovo dove si trova il punto in pixel in basso a sin
m_pmm_bs_lev0.x = m_pmm_bs.x + offset.x
m_pmm_bs_lev0.y = m_pmm_bs.y + offset.y
Catch ex As Exception
Return False
End Try
Return True
End Function
#Region "Lettura configurazioni"
''' <summary>
''' Legge il file che contiene i parametri di correzione della lente
''' </summary>
@@ -452,12 +421,10 @@ Public Class clsImageMng
Dim Linea As String
Dim split() As String
Dim reader As StreamReader
Dim i, j As Integer
Dim nfi As NumberFormatInfo = New CultureInfo("en-US", False).NumberFormat
Dim CalibType As Integer = 0
Dim FileVersion As Integer = 0
If _cameraMatrix Is Nothing Then
_cameraMatrix = New Matrix(Of Double)(3, 3)
End If
@@ -465,20 +432,6 @@ Public Class clsImageMng
_distCoeffs = New Matrix(Of Double)(1, 4)
End If
'CalibType = 1
'FileVersion = 1
'rms = 2.912043
'fx = 4775.944905
'fy = 4775.944905
'cx = 3103.561924
'cy = 2033.648165
'k1 = -0.153547
'k2 = 0.127935
'p1 = -0.00626
'p2 = -0.000005
'hfov = 66Deg
'vfov = 46.1Deg
'[fx 0 cx; 0 fy cy; 0 0 1]
' setto i coefficenti fissi:
_cameraMatrix.Data(0, 1) = 0
@@ -490,19 +443,16 @@ Public Class clsImageMng
Try
nfi.NumberDecimalSeparator = "."
reader = New StreamReader(NomeFile)
While (Not reader.EndOfStream)
Linea = reader.ReadLine()
split = Linea.Split(" =", 5, StringSplitOptions.RemoveEmptyEntries)
If split.Length > 0 Then
If split(0).Equals("CalibType", StringComparison.InvariantCultureIgnoreCase) Then
CalibType = CInt(split(1))
ElseIf split(0).Equals("FileVersion", StringComparison.InvariantCultureIgnoreCase) Then
FileVersion = CInt(split(1))
ElseIf (Linea.StartsWith("rms")) Then
' non carico dato
' CAMERA MATRIX
ElseIf (Linea.StartsWith("fx")) Then
_cameraMatrix.Data(0, 0) = Convert.ToDouble(split(1), nfi)
@@ -521,7 +471,6 @@ Public Class clsImageMng
_distCoeffs.Data(0, 2) = Convert.ToDouble(split(1), nfi)
ElseIf (Linea.StartsWith("p2")) Then
_distCoeffs.Data(0, 3) = Convert.ToDouble(split(1), nfi)
ElseIf (Linea.StartsWith("hfov")) Then
' non carico dato
ElseIf (Linea.StartsWith("vfov")) Then
@@ -532,7 +481,6 @@ Public Class clsImageMng
' non carico dato
End If
End If
End While
reader.Close()
@@ -546,23 +494,12 @@ Public Class clsImageMng
If FileVersion <> 1 Then
MsgBox("FileVersion error in file: " & NomeFile)
End If
' alla prima acquisizione immagine si controllerà
' controllare se le dimensioni dell'immagine usata per la calibrazione coincidono con quelle attuali
' ScalaCalibrazione()
' If creaMatrice Then
' CreaMatriceCalibrazione()
' End If
Catch ex As Exception
MsgBox("Calibration error : " & NomeFile)
Return False
End Try
Return True
End Function
''' <summary>
@@ -590,7 +527,6 @@ Public Class clsImageMng
' m_nPixOut = 0
While (Not reader.EndOfStream)
Linea = reader.ReadLine()
If (Linea.StartsWith("ProspPnt")) Then
For i = 0 To 3
Linea = reader.ReadLine()
@@ -600,41 +536,36 @@ Public Class clsImageMng
m_psrc(i).X = Convert.ToSingle(split(2), nfi)
m_psrc(i).Y = Convert.ToSingle(split(3), nfi)
Next
ElseIf (Linea.StartsWith("Extend=")) Then
split = Linea.Split(delimiter, 8, StringSplitOptions.RemoveEmptyEntries)
m_ExtXL_mm = Convert.ToSingle(split(1), nfi)
m_ExtXR_mm = Convert.ToSingle(split(2), nfi)
m_ExtYT_mm = Convert.ToSingle(split(3), nfi)
m_ExtYB_mm = Convert.ToSingle(split(4), nfi)
ElseIf (Linea.StartsWith("AltRif=")) Then
split = Linea.Split(delimiter, 5, StringSplitOptions.RemoveEmptyEntries)
m_AltRif = Convert.ToDouble(split(1), nfi)
ElseIf (Linea.StartsWith("p1Rif=")) Then
split = Linea.Split(delimiter, 8, StringSplitOptions.RemoveEmptyEntries)
m_puntoH(0).XSrc = Convert.ToDouble(split(1))
m_puntoH(0).YSrc = Convert.ToDouble(split(2))
m_puntoH(1).XSrc = Convert.ToDouble(split(3))
m_puntoH(1).YSrc = Convert.ToDouble(split(4))
ElseIf (Linea.StartsWith("p2Rif=")) Then
split = Linea.Split(delimiter, 8, StringSplitOptions.RemoveEmptyEntries)
m_puntoH(2).XSrc = Convert.ToDouble(split(1))
m_puntoH(2).YSrc = Convert.ToDouble(split(2))
m_puntoH(3).XSrc = Convert.ToDouble(split(3))
m_puntoH(3).YSrc = Convert.ToDouble(split(4))
ElseIf (Linea.StartsWith("ZCali=")) Then
split = Linea.Split(delimiter, 8, StringSplitOptions.RemoveEmptyEntries)
m_ZCali = Convert.ToDouble(split(1), nfi)
ElseIf (Linea.StartsWith("ImageWidth=")) Then
split = Linea.Split(delimiter, 8, StringSplitOptions.RemoveEmptyEntries)
m_CalimageWidth = Convert.ToDouble(split(1), nfi)
End If
End While
reader.Close()
reader.Dispose()
Catch ex As Exception
@@ -644,57 +575,15 @@ Public Class clsImageMng
CalcolaDatiCorrezione()
Return True
End Function
#End Region ' Lettura configurazioni
Property Corrected() As Boolean
Get
Return m_bCorrected
End Get
Set(ByVal value As Boolean)
m_bCorrected = value
End Set
End Property
ReadOnly Property CorrAltEnabled() As Boolean
Get
Return m_bCorrAltezzaEnabled
End Get
End Property
ReadOnly Property ZCali() As Double
Get
Return m_ZCali
End Get
End Property
Property XHpix(ByVal i As Integer) As Short
Get
Return (m_puntoH(i).XSrc)
End Get
Set(ByVal value As Short)
m_puntoH(i).XSrc = value
End Set
End Property
Property YHpix(ByVal i As Integer) As Short
Get
Return (m_puntoH(i).YSrc)
End Get
Set(ByVal value As Short)
m_puntoH(i).YSrc = value
End Set
End Property
#Region "Caolcolo matrici di correzione prospettica"
#Region "Calcolo matrici di correzione prospettica"
''' <summary>
''' Ottine la matrice 'm_MatDir' di correzione prospettica
''' Viene richiamato il metodo 'CalcolaDatiCorrezioneDiretta'
''' </summary>
Private Sub CalcolaDatiCorrezioneDiretta()
' L'immagine da rettificare non è un rettangolo
CalcolaDatiCorrezioneDirettaNoRett()
' Se ' CalcolaDatiCorrezioneDirettaNoRett' andata a buon fine 'm_ProspCalibrated=true'
@@ -769,15 +658,12 @@ Public Class clsImageMng
m_Pos_x_z0_mm = m_pworld(ibl).X - m_ExtXL_mm
m_Pos_y_z0_mm = m_pworld(ibl).Y - m_ExtYB_mm
m_ProspCalibrated = True
End Sub
''' <summary>
''' Ottiene la matrice 'm_MatDir' per la correzione prospettica nel piano Z=0
''' </summary>
Private Sub CalcolaDatiCorrezioneDirettaNoRett()
Dim distmm As Double, distpix As Double, mm2pix As Double
Dim distXMax As Double, distYMax As Double
@@ -867,15 +753,12 @@ Public Class clsImageMng
m_Pos_x_z0_mm = m_pworld(ibl).X - m_ExtXL_mm
m_Pos_y_z0_mm = m_pworld(ibl).Y - m_ExtYB_mm
m_ProspCalibrated = True
End Sub
''' <summary>
''' Ottiene la matrice 'm_MatInv' per la correzione prospettica nel piano Z=0
''' </summary>
Private Sub CalcolaDatiCorrezioneInversa()
Dim i As Integer
For i = 0 To 3
@@ -897,14 +780,12 @@ Public Class clsImageMng
Next
Next
#End If
End Sub
#End Region ' Calcolo matrici di correzione prospettica
' Crea file FinalImage.txt
Private Sub SaveDataImage(NomeFile As String)
Dim writer As New StreamWriter(NomeFile)
writer.WriteLine("X = {0}", m_Pos_x_mm.ToString("F9", CultureInfo.InvariantCulture))
@@ -920,10 +801,8 @@ Public Class clsImageMng
writer.Close()
End Sub
Public Sub CorrezioneCompleta(Optional rEvents As Boolean = True)
Try
m_UndistImage = Nothing
Console.WriteLine("RICHIESTA CORREZIONE DISTORSIONE: " & MainModule.IndexProc)
@@ -942,13 +821,9 @@ Public Class clsImageMng
Catch ex As Exception
RaiseEvent ProcessAborted(-1)
End Try
End Sub
Private Sub CalcolaMatriceCorrezioneProspettiva()
Dim ix As Integer, iy As Integer
Dim px As Single, py As Single
Dim m00 As Double, m01 As Double, m02 As Double
@@ -957,8 +832,6 @@ Public Class clsImageMng
Dim m01iy As Double, m11iy As Double, m21iy As Double
Try
If m_UndistImage Is Nothing Then Return
m_dimx = m_UndistImage.Width
m_dimy = m_UndistImage.Height
@@ -968,12 +841,10 @@ Public Class clsImageMng
m_SpessLastra = SpessLastra
' correggo calcolando i pixel (con funzione opencv non riesco a estendere)
m00 = m_MatDir(0, 0) : m01 = m_MatDir(0, 1) : m02 = m_MatDir(0, 2)
m10 = m_MatDir(1, 0) : m11 = m_MatDir(1, 1) : m12 = m_MatDir(1, 2)
m20 = m_MatDir(2, 0) : m21 = m_MatDir(2, 1) : m22 = m_MatDir(2, 2)
m_dim_XProspExt = m_dim_XProsp + m_ExtXL_pix + m_ExtXR_pix
m_dim_YProspExt = m_dim_YProsp + m_ExtYT_pix + m_ExtYB_pix
@@ -986,12 +857,10 @@ Public Class clsImageMng
m21iy = m21 * iy2
For ix = 0 To m_dim_XProspExt - 1
Dim ix2 As Short = ix - m_ExtXL_pix
px = (m00 * ix2 + m01iy + m02) / (m20 * ix2 + m21iy + m22)
py = (m10 * ix2 + m11iy + m12) / (m20 * ix2 + m21iy + m22)
MatConvP(ix, iy) = New clPuntoPix
If px >= 0 And px < m_dimx And py >= 0 AndAlso py < m_dimy Then
MatConvP(ix, iy).X = px
MatConvP(ix, iy).Y = py
@@ -999,20 +868,16 @@ Public Class clsImageMng
MatConvP(ix, iy).X = -1
MatConvP(ix, iy).Y = -1
End If
Next
Next
m_bMatProspOk = True
Catch ex As Exception
m_bMatProspOk = False
Throw New Exception(ex.Message)
End Try
End Sub
Private Sub CorreggiProspettivaDaMatriceOCV(spessLastra As Double)
Console.WriteLine("INIZIO CREAZIONE IMMAGINE CON CORREZIONE OCV")
@@ -1044,24 +909,21 @@ Public Class clsImageMng
Return Nothing
End Function
Private Sub CalcolaMatriceOCV()
Private Sub CalcolaMatriceOCV()
Dim ix As Integer, iy As Integer
_ocvMapx = New Matrix(Of Single)(m_dim_YProspExt, m_dim_XProspExt)
_ocvMapy = New Matrix(Of Single)(m_dim_YProspExt, m_dim_XProspExt)
For iy = 0 To m_dim_YProspExt - 1
For ix = 0 To (m_dim_XProspExt - 1)
_ocvMapx(iy, ix) = MatConvP(ix, iy).X
_ocvMapy(iy, ix) = MatConvP(ix, iy).Y
Next
Next
End Sub
Private Sub CalcolaCorrezioniAltezza()
' fattore di scala data la nuova altezza
Dim fattScala As Double
@@ -1076,29 +938,28 @@ Public Class clsImageMng
m_Pos_y_mm = m_Pos_y_mm * fattScala
m_Pos_x_mm = m_Pos_x_mm + m_scale_center.x
m_Pos_y_mm = m_Pos_y_mm + m_scale_center.y
End Sub
Public Sub SaveClickMsg(numerr As Integer)
Dim NomeFile As String
Dim nf As Integer
NomeFile = SaveDir & "click.txt"
nf = FreeFile()
FileOpen(nf, NomeFile, OpenMode.Output)
Print(nf, "Err=" & numerr.ToString)
FileClose(nf)
End Sub
' questa è la correzione inversa a quello che mi serve...
Public Function CorreggiPunto(p As Point) As Point
Dim po As Point
po.X = MatConvP(p.X, p.Y).X
po.Y = MatConvP(p.X, p.Y).Y
Return po
End Function
#End Region
Public Sub FreeImages()
If m_UndistImage IsNot Nothing Then m_UndistImage.Dispose()
m_UndistImage = Nothing
@@ -1115,7 +976,6 @@ Public Class clsImageMng
CalcolaCorrezioniAltezza()
ppx.X = (pmm.X - m_Pos_x_mm) * m_mm2PixelProspFinal
ppx.Y = m_FinalImage.Height - (pmm.Y - m_Pos_y_mm) * m_mm2PixelProspFinal
End Sub
Public Sub Pix2MMOnUndist(ppx As PointF, ByRef pmm As PointF)
@@ -1131,30 +991,42 @@ Public Class clsImageMng
Try
If FinalImage Is Nothing Then Return False
Dim cvimage As New Image(Of Emgu.CV.Structure.Bgr, Byte)(FinalImage)
Dim x1 As Integer = Math.Min(xLeft, xRight)
Dim y1 As Integer = Math.Min(yTop, yBottom)
Dim w As Integer = Math.Abs(xRight - xLeft)
Dim h As Integer = Math.Abs(yBottom - yTop)
Dim rmodel As New Rectangle(x1, y1, w, h)
cvimage.ROI = rmodel
cvimage.Save(FileName)
Return True
Catch ex As Exception
Return False
End Try
End Function
#End Region ' Conversioni da mm a pixel e viceversa su Img già raddrizzata
#End Region
#End Region ' Methods
End Class
Public Class clPuntoPix
Public X As Single
Public Y As Single
End Class
Public Class clPuntomm
Public x As Double
Public y As Double
End Class
Public Class clCoppiaPunto
Public XTrg As Double
Public YTrg As Double
Public XSrc As Double
Public YSrc As Double
End Class
+49 -108
View File
@@ -1,12 +1,11 @@
Imports Emgu
Imports Emgu.CV
Imports Emgu.CV.Util
Imports Emgu.CV.Structure
Imports Emgu.CV
Imports System.IO
Imports System.Globalization
Public Class clsRicerca
#Region "FIELDS & PROPERTIES"
Private Structure stStepSearch
Public ModelFile() As String
Public Name As String ' numero/nome della ventosa
@@ -21,27 +20,46 @@ Public Class clsRicerca
Public foundPosmm As PointF
End Structure
Private _imageMng As clsImageMng = Nothing
Private _image1 As Bitmap = Nothing
Private _searchList As List(Of stStepSearch) = Nothing
Private _searchImage As Image(Of Emgu.CV.Structure.Bgr, Byte)
Public Event LogMessage(msg As String)
Private _numVentoseKO As Integer = 0
Private _writeDate As Boolean = True
Private rosso As New Emgu.CV.Structure.MCvScalar(0, 0, 255)
Private verde As New Emgu.CV.Structure.MCvScalar(0, 255, 0)
Private blu As New Emgu.CV.Structure.MCvScalar(255, 0, 0)
Private nero As New Emgu.CV.Structure.MCvScalar(0, 0, 0)
Private _searchImage As Image(Of Emgu.CV.Structure.Bgr, Byte)
Public ReadOnly Property FinalImage As Bitmap
Get
Return If(_searchImage Is Nothing, Nothing, _searchImage.Bitmap)
End Get
End Property
Private _writeDate As Boolean = True
Public Property WriteDate As Boolean
Set(value As Boolean)
_writeDate = value
End Set
Get
Return _writeDate
End Get
End Property
#End Region ' Fields & Properties
#Region "CONSTRUCTOR"
Public Sub New(imgMng As clsImageMng)
_imageMng = imgMng
End Sub
Public Sub Ricerca()
#End Region ' Constructor
#Region "METHODS"
Public Sub Ricerca()
Dim searchStep As stStepSearch
_numVentoseKO = 0
@@ -59,20 +77,14 @@ Public Class clsRicerca
Next
SaveRisultatiRicerca(0)
End Sub
Private Sub DebugRisultato(sStep As stStepSearch)
Try
' casomai fosse rimasto un ROI
_searchImage.ROI = Nothing
' caso in cui non esiste il modello
' non esiste il file modello
If (sStep.ModelFile Is Nothing OrElse sStep.ModelFile.Length = 0) Then
ScriviTesto(_searchImage, sStep.Name & "?", sStep.reqPospx.X, sStep.reqPospx.Y, blu, 5, 3)
@@ -85,12 +97,11 @@ Public Class clsRicerca
Dim x0, y0 As Integer
Dim modelImage As Emgu.CV.Image(Of Emgu.CV.Structure.Bgr, Byte) = Nothing
Dim TolPix As Integer = CInt(sStep.Toldist * _imageMng.mm2pixelAtZ)
Dim nmodel As Integer = Math.Max(0, sStep.ifound)
' prendo il primo modello per disegnare il rettangolo
modelImage = New Emgu.CV.Image(Of Emgu.CV.Structure.Bgr, Byte)(New Bitmap(sStep.ModelFile(nmodel)))
' disegno la regione di ricerca del primo modello specificato
Dim regWidth As Integer = modelImage.Width
Dim regHeight As Integer = modelImage.Height
@@ -105,22 +116,18 @@ Public Class clsRicerca
y0 = Math.Max(0, y0)
regWidth = Math.Min(regWidth, _searchImage.Width - x0)
regHeight = Math.Min(regHeight, _searchImage.Height - y0)
regioneRicerca = New System.Drawing.Rectangle(x0, y0, regWidth, regHeight)
If sStep.req Then
If sStep.ifound < 0 Then
'non trovato
DisegnaRettangoloX(_searchImage, regioneRicerca, rosso, 5)
ScriviTesto(_searchImage, sStep.Name, regioneRicerca.Location.X + regioneRicerca.Width / 2,
regioneRicerca.Location.Y + regioneRicerca.Height / 2, rosso, 5, 3)
ScriviTesto(_searchImage, sStep.Name, regioneRicerca.Location.X + regioneRicerca.Width / 2, regioneRicerca.Location.Y + regioneRicerca.Height / 2, rosso, 5, 3)
_numVentoseKO += 1
Else
DisegnaRettangolo(_searchImage, regioneRicerca, blu, 5)
' la regione modello la posiziono nel punto dove l'ha trovata
' la regione modello la posiziono nel punto dove l'ha trovata
regWidth = modelImage.Width
regHeight = modelImage.Height
@@ -134,30 +141,21 @@ Public Class clsRicerca
regioneVentosa = New System.Drawing.Rectangle(x0, y0, regWidth, regHeight)
DisegnaRettangolo(_searchImage, regioneVentosa, verde, 3)
ScriviTesto(_searchImage, sStep.Name, regioneVentosa.Location.X + regioneVentosa.Width / 2,
regioneVentosa.Location.Y + regioneVentosa.Height / 2, verde, 5, 3)
ScriviTesto(_searchImage, sStep.Name, regioneVentosa.Location.X + regioneVentosa.Width / 2, regioneVentosa.Location.Y + regioneVentosa.Height / 2, verde, 5, 3)
End If
' caso in cui non deve esserci nulla
Else
If sStep.ifound < 0 Then
'non trovato e va bene
DisegnaRettangolo(_searchImage, regioneRicerca, verde, 5)
ScriviTesto(_searchImage, sStep.Name, regioneRicerca.Location.X + regioneRicerca.Width / 2,
regioneRicerca.Location.Y + regioneRicerca.Height / 2, verde, 5, 3)
ScriviTesto(_searchImage, sStep.Name, regioneRicerca.Location.X + regioneRicerca.Width / 2, regioneRicerca.Location.Y + regioneRicerca.Height / 2, verde, 5, 3)
Else
' ho trovato e non va bene
_numVentoseKO += 1
DisegnaRettangolo(_searchImage, regioneRicerca, rosso, 5)
' la regione modello la posiziono nel punto dove l'ha trovata
' la regione modello la posiziono nel punto dove l'ha trovata
regWidth = modelImage.Width
regHeight = modelImage.Height
@@ -171,40 +169,25 @@ Public Class clsRicerca
regioneVentosa = New System.Drawing.Rectangle(x0, y0, regWidth, regHeight)
DisegnaRettangolo(_searchImage, regioneVentosa, rosso, 3)
ScriviTesto(_searchImage, sStep.Name, regioneVentosa.Location.X + regioneVentosa.Width / 2,
regioneVentosa.Location.Y + regioneVentosa.Height / 2, rosso, 5, 3)
ScriviTesto(_searchImage, sStep.Name, regioneVentosa.Location.X + regioneVentosa.Width / 2, regioneVentosa.Location.Y + regioneVentosa.Height / 2, rosso, 5, 3)
End If
End If
Catch ex As Exception
_numVentoseKO += 1
End Try
End Sub
Private Sub RicercaStep(ByRef sStep As stStepSearch)
Try
Dim resultImage As Emgu.CV.Image(Of Emgu.CV.Structure.Gray, Single)
Dim regioneRicerca As System.Drawing.Rectangle = Nothing
Dim regioneVentosa As System.Drawing.Rectangle = Nothing
Dim x0, y0 As Integer
Dim TolPix As Integer = CInt(sStep.Toldist * _imageMng.mm2pixelAtZ)
Dim modelImage As Emgu.CV.Image(Of Emgu.CV.Structure.Bgr, Byte) = Nothing
sStep.ifound = -1
Dim modelImage As Emgu.CV.Image(Of Emgu.CV.Structure.Bgr, Byte) = Nothing
' se non c'è il modello esco
If (sStep.ModelFile Is Nothing OrElse sStep.ModelFile.Length = 0) Then
Return
@@ -213,9 +196,7 @@ Public Class clsRicerca
ReDim sStep.score(sStep.ModelFile.Length)
For n As Integer = 0 To sStep.ModelFile.Length - 1
Try
' leggo il modello
modelImage = New Emgu.CV.Image(Of Emgu.CV.Structure.Bgr, Byte)(New Bitmap(sStep.ModelFile(n)))
@@ -228,7 +209,6 @@ Public Class clsRicerca
x0 = Math.Max(0, x0)
y0 = Math.Max(0, y0)
regioneVentosa = New System.Drawing.Rectangle(x0, y0, regWidth, regHeight)
' fisso la regione Ricerca
@@ -262,21 +242,14 @@ Public Class clsRicerca
sStep.ifound = n
Return
End If
Catch ex As Exception
_searchImage.ROI = Nothing
End Try
Next
Catch ex As Exception
End Try
End Sub
Public Sub GeneraIstruzioniRicerca(NomeFilePos As String, minscore As Double, toldist As Double)
Dim reader As StreamReader = Nothing
Dim nfi As NumberFormatInfo = New CultureInfo("en-US", False).NumberFormat
@@ -307,8 +280,8 @@ Public Class clsRicerca
y = Double.Parse(strLine.Split(",", 3, StringSplitOptions.RemoveEmptyEntries)(1), nfi)
vt = CInt(strLine.Split(",", 3, StringSplitOptions.RemoveEmptyEntries)(2))
Dim vs As stStepSearch
Dim p As PointF
Dim vs As stStepSearch = Nothing
Dim p As PointF = Nothing
_imageMng.MM2PixOnUndist(New PointF(x, y), p)
vs.reqPospx = New Point(p.X, p.Y)
@@ -358,39 +331,20 @@ Public Class clsRicerca
End Sub
Public ReadOnly Property FinalImage As Bitmap
Get
Return If(_searchImage Is Nothing, Nothing, _searchImage.Bitmap)
End Get
End Property
Public Property WriteDate As Boolean
Set(value As Boolean)
_writeDate = value
End Set
Get
Return _writeDate
End Get
End Property
Private Sub SaveRisultatiRicerca(numerr As Integer)
Dim NomeFile As String
Dim nf As Integer
' per ora faccio questo
_imageMng.SaveClickMsg(numerr)
Dim NomeFile As String
Dim nf As Integer
NomeFile = VacFileEnd
nf = FreeFile()
FileOpen(nf, NomeFile, OpenMode.Output)
PrintLine(nf, "Err=" & _numVentoseKO)
FileClose(nf)
End Sub
#If WinXp Then
Private Sub DisegnaRettangolo(img As Image(Of Emgu.CV.Structure.Bgr, Byte), r As Rectangle,
colore As Emgu.CV.Structure.MCvScalar, spessore As Integer)
@@ -427,35 +381,22 @@ Public Class clsRicerca
#Else
Private Sub DisegnaRettangolo(img As Image(Of Emgu.CV.Structure.Bgr, Byte), r As Rectangle,
colore As Emgu.CV.Structure.MCvScalar, spessore As Integer)
Private Sub DisegnaRettangolo(img As Image(Of Emgu.CV.Structure.Bgr, Byte), r As Rectangle, colore As Emgu.CV.Structure.MCvScalar, spessore As Integer)
Emgu.CV.CvInvoke.Rectangle(_searchImage, r, colore, spessore)
End Sub
Private Sub DisegnaRettangoloX(img As Image(Of Emgu.CV.Structure.Bgr, Byte), r As Rectangle,
colore As Emgu.CV.Structure.MCvScalar, spessore As Integer)
Emgu.CV.CvInvoke.Rectangle(_searchImage, r, colore, spessore)
Emgu.CV.CvInvoke.Line(_searchImage, r.Location, New Point(r.Location.X + r.Width, r.Location.Y + r.Height),
colore, spessore, Emgu.CV.CvEnum.LineType.FourConnected, 0)
Emgu.CV.CvInvoke.Line(_searchImage, New Point(r.Location.X, r.Location.Y + r.Height),
New Point(r.Location.X + r.Width, r.Location.Y),
colore, spessore, Emgu.CV.CvEnum.LineType.FourConnected, 0)
End Sub
Public Sub ScriviTesto(img As Image(Of Emgu.CV.Structure.Bgr, Byte), testo As String, x As Integer, y As Integer,
colore As Emgu.CV.Structure.MCvScalar, scala As Double, spessore As Integer)
Emgu.CV.CvInvoke.PutText(img, testo, New Point(x, y + 30), CvEnum.FontFace.HersheyPlain,
scala, colore, spessore, CvEnum.LineType.AntiAlias)
Private Sub DisegnaRettangoloX(img As Image(Of Emgu.CV.Structure.Bgr, Byte), r As Rectangle, colore As Emgu.CV.Structure.MCvScalar, spessore As Integer)
Emgu.CV.CvInvoke.Rectangle(_searchImage, r, colore, spessore)
Emgu.CV.CvInvoke.Line(_searchImage, r.Location, New Point(r.Location.X + r.Width, r.Location.Y + r.Height), colore, spessore, Emgu.CV.CvEnum.LineType.FourConnected, 0)
Emgu.CV.CvInvoke.Line(_searchImage, New Point(r.Location.X, r.Location.Y + r.Height), New Point(r.Location.X + r.Width, r.Location.Y), colore, spessore, Emgu.CV.CvEnum.LineType.FourConnected, 0)
End Sub
Public Sub ScriviTesto(img As Image(Of Emgu.CV.Structure.Bgr, Byte), testo As String, x As Integer, y As Integer, colore As Emgu.CV.Structure.MCvScalar, scala As Double, spessore As Integer)
Emgu.CV.CvInvoke.PutText(img, testo, New Point(x, y + 30), CvEnum.FontFace.HersheyPlain, scala, colore, spessore, CvEnum.LineType.AntiAlias)
End Sub
#End If
#End Region ' Methods
End Class
File diff suppressed because it is too large Load Diff
+330 -342
View File
@@ -19,366 +19,354 @@
'* *
'******************************************************************************/
Imports System
Imports System.Collections
Imports System.Runtime.InteropServices
Public Structure TPropStrVal
Dim val As Integer
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Dim str As String
Dim val As Integer
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Dim str As String
End Structure
Public Class CameraProperty
' Uniting camera properties and express strings table
' Uniting camera properties and express strings table
Public Shared g_AEMode As Hashtable = New Hashtable
Public Shared g_ISOSpeed As Hashtable = New Hashtable
Public Shared g_Av As Hashtable = New Hashtable
Public Shared g_Tv As Hashtable = New Hashtable
Public Shared g_MeteringMode As Hashtable = New Hashtable
Public Shared g_ExposureComp As Hashtable = New Hashtable
Public Shared g_ImageQuality As Hashtable = New Hashtable
#Region "FIELDS & PROPERTIES"
Public Shared g_AEMode As Hashtable = New Hashtable
Public Shared g_ISOSpeed As Hashtable = New Hashtable
Public Shared g_Av As Hashtable = New Hashtable
Public Shared g_Tv As Hashtable = New Hashtable
Public Shared g_MeteringMode As Hashtable = New Hashtable
Public Shared g_ExposureComp As Hashtable = New Hashtable
Public Shared g_ImageQuality As Hashtable = New Hashtable
Public Shared g_PropList As Hashtable = New Hashtable
Private Shared init_ok As Boolean = False
#End Region ' Fields & Properties
Public Sub New()
#Region "CONSTRUCTOR"
Public Sub New()
If Not init_ok Then tableInit()
init_ok = True
End Sub
End Sub
#End Region ' Constructor
#Region "METHODS"
Private Sub tableInit()
g_MeteringMode.Add(1, "Spot Metering")
g_MeteringMode.Add(3, "Evaluative Metering")
g_MeteringMode.Add(4, "Partial Metering")
g_MeteringMode.Add(5, "Center-Weighted Average Metering")
g_MeteringMode.Add(&HFFFFFFFF, "unkown")
g_ExposureComp.Add(&H18, "+3")
g_ExposureComp.Add(&H15, "+2 2/3")
g_ExposureComp.Add(&H14, "+2 1/2")
g_ExposureComp.Add(&H13, "+2 1/3")
g_ExposureComp.Add(&H10, "+2")
g_ExposureComp.Add(&HD, "+1 2/3")
g_ExposureComp.Add(&HC, "+1 1/2")
g_ExposureComp.Add(&HB, "+1 1/3")
g_ExposureComp.Add(&H8, "+1")
g_ExposureComp.Add(&H5, "+2/3")
g_ExposureComp.Add(&H4, "+1/2")
g_ExposureComp.Add(&H3, "+1/3")
g_ExposureComp.Add(&H0, "0")
g_ExposureComp.Add(&HFD, "-1/3")
g_ExposureComp.Add(&HFC, "-1/2")
g_ExposureComp.Add(&HFB, "-2/3")
g_ExposureComp.Add(&HF8, "-1")
g_ExposureComp.Add(&HF5, "-1 1/3")
g_ExposureComp.Add(&HF4, "-1 1/2")
g_ExposureComp.Add(&HF3, "-1 2/3")
g_ExposureComp.Add(&HF0, "-2")
g_ExposureComp.Add(&HED, "-2 1/3")
g_ExposureComp.Add(&HEC, "-2 1/2")
g_ExposureComp.Add(&HEB, "-2 2/3")
g_ExposureComp.Add(&HE8, "-3")
g_ExposureComp.Add(&HFFFFFFFF, "unkown")
g_AEMode.Add(0, "P")
g_AEMode.Add(1, "Tv")
g_AEMode.Add(2, "Av")
g_AEMode.Add(3, "M")
g_AEMode.Add(4, "Bulb")
g_AEMode.Add(5, "A-DEP")
g_AEMode.Add(6, "Depth-of-Field AE")
g_AEMode.Add(7, "Manual")
g_AEMode.Add(8, "Lock")
g_AEMode.Add(9, "GreenMode")
g_AEMode.Add(10, "Night Scene Portrait")
g_AEMode.Add(11, "Sports")
g_AEMode.Add(12, "Portrait")
g_AEMode.Add(13, "Landscape")
g_AEMode.Add(14, "Close Up")
g_AEMode.Add(15, "Flash Off")
g_AEMode.Add(19, "CreativeAuto")
g_AEMode.Add(20, "Movie")
g_AEMode.Add(21, "PhotoInMovie")
g_AEMode.Add(22, "SceneIntelligentAuto")
g_AEMode.Add(25, "SCN")
g_AEMode.Add(&HFFFFFFFF, "unknown")
g_ISOSpeed.Add(&H0, "Auto")
g_ISOSpeed.Add(&H28, "6")
g_ISOSpeed.Add(&H30, "12")
g_ISOSpeed.Add(&H38, "25")
g_ISOSpeed.Add(&H40, "50")
g_ISOSpeed.Add(&H48, "100")
g_ISOSpeed.Add(&H4B, "125")
g_ISOSpeed.Add(&H4D, "160")
g_ISOSpeed.Add(&H50, "200")
g_ISOSpeed.Add(&H53, "250")
g_ISOSpeed.Add(&H55, "320")
g_ISOSpeed.Add(&H58, "400")
g_ISOSpeed.Add(&H5B, "500")
g_ISOSpeed.Add(&H5D, "640")
g_ISOSpeed.Add(&H60, "800")
g_ISOSpeed.Add(&H63, "1000")
g_ISOSpeed.Add(&H65, "1250")
g_ISOSpeed.Add(&H68, "1600")
g_ISOSpeed.Add(&H6B, "2000")
g_ISOSpeed.Add(&H6D, "2500")
g_ISOSpeed.Add(&H70, "3200")
g_ISOSpeed.Add(&H73, "4000")
g_ISOSpeed.Add(&H75, "5000")
g_ISOSpeed.Add(&H78, "6400")
g_ISOSpeed.Add(&H7B, "8000")
g_ISOSpeed.Add(&H7D, "10000")
g_ISOSpeed.Add(&H80, "12800")
g_ISOSpeed.Add(&H83, "16000")
g_ISOSpeed.Add(&H85, "20000")
g_ISOSpeed.Add(&H88, "25600")
g_ISOSpeed.Add(&H8B, "32000")
g_ISOSpeed.Add(&H8D, "40000")
g_ISOSpeed.Add(&H90, "51200")
g_ISOSpeed.Add(&H98, "102400")
g_ISOSpeed.Add(&HFFFFFFFF, "unknown")
g_Av.Add(&H8, "1")
g_Av.Add(&HB, "1.1")
g_Av.Add(&HC, "1.2")
g_Av.Add(&HD, "1.2")
g_Av.Add(&H10, "1.4")
g_Av.Add(&H13, "1.6")
g_Av.Add(&H14, "1.8")
g_Av.Add(&H15, "1.8")
g_Av.Add(&H18, "2")
g_Av.Add(&H1B, "2.2")
g_Av.Add(&H1C, "2.5")
g_Av.Add(&H1D, "2.5")
g_Av.Add(&H20, "2.8")
g_Av.Add(&H23, "3.2")
g_Av.Add(&H24, "3.5")
g_Av.Add(&H25, "3.5")
g_Av.Add(&H28, "4")
g_Av.Add(&H2B, "4")
g_Av.Add(&H2C, "4.5")
g_Av.Add(&H2D, "5.6")
g_Av.Add(&H30, "5.6")
g_Av.Add(&H33, "6.3")
g_Av.Add(&H34, "6.7")
g_Av.Add(&H35, "7.1")
g_Av.Add(&H38, "8")
g_Av.Add(&H3B, "9")
g_Av.Add(&H3C, "9.5")
g_Av.Add(&H3D, "10")
g_Av.Add(&H40, "11")
g_Av.Add(&H43, "13")
g_Av.Add(&H44, "13")
g_Av.Add(&H45, "14")
g_Av.Add(&H48, "16")
g_Av.Add(&H4B, "18")
g_Av.Add(&H4C, "19")
g_Av.Add(&H4D, "20")
g_Av.Add(&H50, "22")
g_Av.Add(&H53, "25")
g_Av.Add(&H54, "27")
g_Av.Add(&H55, "29")
g_Av.Add(&H58, "32")
g_Av.Add(&H5B, "36")
g_Av.Add(&H5C, "38")
g_Av.Add(&H5D, "40")
g_Av.Add(&H60, "45")
g_Av.Add(&H63, "51")
g_Av.Add(&H64, "54")
g_Av.Add(&H65, "57")
g_Av.Add(&H68, "64")
g_Av.Add(&H6B, "72")
g_Av.Add(&H6C, "76")
g_Av.Add(&H6D, "80")
g_Av.Add(&H70, "91")
g_Av.Add(&HFFFFFFFF, "unknown")
g_Tv.Add(&H10, "30""")
g_Tv.Add(&H13, "25""")
g_Tv.Add(&H14, "20""")
g_Tv.Add(&H15, "20""")
g_Tv.Add(&H18, "15""")
g_Tv.Add(&H1B, "13""")
g_Tv.Add(&H1C, "10""")
g_Tv.Add(&H1D, "10""")
g_Tv.Add(&H20, "8""")
g_Tv.Add(&H23, "6""")
g_Tv.Add(&H24, "6""")
g_Tv.Add(&H25, "5""")
g_Tv.Add(&H28, "4""")
g_Tv.Add(&H2B, "3""" + "2")
g_Tv.Add(&H2C, "3""")
g_Tv.Add(&H2D, "2""" + "5")
g_Tv.Add(&H30, "2""")
g_Tv.Add(&H33, "1""" + "6")
g_Tv.Add(&H34, "1""" + "5")
g_Tv.Add(&H35, "1""" + "3")
g_Tv.Add(&H38, "1""")
g_Tv.Add(&H3B, "0""" + "8")
g_Tv.Add(&H3C, "0""" + "7")
g_Tv.Add(&H3D, "0""" + "6")
g_Tv.Add(&H40, "0""" + "5")
g_Tv.Add(&H43, "0""" + "4")
g_Tv.Add(&H44, "0""" + "3")
g_Tv.Add(&H45, "0""" + "3")
g_Tv.Add(&H48, "4")
g_Tv.Add(&H4B, "5")
g_Tv.Add(&H4C, "6")
g_Tv.Add(&H4D, "6")
g_Tv.Add(&H50, "8")
g_Tv.Add(&H53, "10")
g_Tv.Add(&H54, "10")
g_Tv.Add(&H55, "13")
g_Tv.Add(&H58, "15")
g_Tv.Add(&H5B, "20")
g_Tv.Add(&H5C, "20")
g_Tv.Add(&H5D, "25")
g_Tv.Add(&H60, "30")
g_Tv.Add(&H63, "40")
g_Tv.Add(&H64, "45")
g_Tv.Add(&H65, "50")
g_Tv.Add(&H68, "60")
g_Tv.Add(&H6B, "80")
g_Tv.Add(&H6C, "90")
g_Tv.Add(&H6D, "100")
g_Tv.Add(&H70, "125")
g_Tv.Add(&H73, "160")
g_Tv.Add(&H74, "180")
g_Tv.Add(&H75, "200")
g_Tv.Add(&H78, "250")
g_Tv.Add(&H7B, "320")
g_Tv.Add(&H7C, "350")
g_Tv.Add(&H7D, "400")
g_Tv.Add(&H80, "500")
g_Tv.Add(&H83, "640")
g_Tv.Add(&H84, "750")
g_Tv.Add(&H85, "800")
g_Tv.Add(&H88, "1000")
g_Tv.Add(&H8B, "1250")
g_Tv.Add(&H8C, "1500")
g_Tv.Add(&H8D, "1600")
g_Tv.Add(&H90, "2000")
g_Tv.Add(&H93, "2500")
g_Tv.Add(&H94, "3000")
g_Tv.Add(&H95, "3200")
g_Tv.Add(&H98, "4000")
g_Tv.Add(&H9B, "5000")
g_Tv.Add(&H9C, "6000")
g_Tv.Add(&H9D, "6400")
g_Tv.Add(&HA0, "8000")
g_Tv.Add(&HFFFFFFFF, "unknown")
' PTP Camera
g_ImageQuality.Add(&H64FF0F, "RAW")
g_ImageQuality.Add(&H640013, "RAW + Large Fine Jpeg")
g_ImageQuality.Add(&H640113, "RAW + Middle Fine Jpeg")
g_ImageQuality.Add(&H640213, "RAW + Small Fine Jpeg")
g_ImageQuality.Add(&H640012, "RAW + Large Normal Jpeg")
g_ImageQuality.Add(&H640112, "RAW + Middle Normal Jpeg")
g_ImageQuality.Add(&H640212, "RAW + Small Normal Jpeg")
g_ImageQuality.Add(&H640E13, "RAW + Small1 Fine Jpeg")
g_ImageQuality.Add(&H640E12, "RAW + Small1 Normal Jpeg")
g_ImageQuality.Add(&H640F13, "RAW + Small2 Jpeg")
g_ImageQuality.Add(&H641013, "RAW + Small3 Jpeg")
g_ImageQuality.Add(&H640010, "RAW + Large Jpeg")
g_ImageQuality.Add(&H640510, "RAW + Middle1 Jpeg")
g_ImageQuality.Add(&H640610, "RAW + Middle2 Jpeg")
g_ImageQuality.Add(&H640210, "RAW + Small Jpeg")
g_ImageQuality.Add(&H164FF0F, "MRAW")
g_ImageQuality.Add(&H1640013, "MRAW + Large Fine Jpeg")
g_ImageQuality.Add(&H1640012, "MRAW + Large Normal Jpeg")
g_ImageQuality.Add(&H1640113, "MRAW + Middle Fine Jpeg")
g_ImageQuality.Add(&H1640112, "MRAW + Middle Normal Jpeg")
g_ImageQuality.Add(&H1640213, "MRAW + Small Fine Jpeg")
g_ImageQuality.Add(&H1640212, "MRAW + Small Normal Jpeg")
g_ImageQuality.Add(&H1640E13, "MRAW + Small1 Fine Jpeg")
g_ImageQuality.Add(&H1640E12, "MRAW + Small1 Normal Jpeg")
g_ImageQuality.Add(&H1640F13, "MRAW + Small2 Jpeg")
g_ImageQuality.Add(&H1641013, "MRAW + Small3 Jpeg")
g_ImageQuality.Add(&H264FF0F, "SRAW")
g_ImageQuality.Add(&H2640010, "SRAW + Large Jpegg")
g_ImageQuality.Add(&H2640510, "SRAW + Middle1 Jpeg")
g_ImageQuality.Add(&H2640610, "SRAW + Middle2 Jpeg")
g_ImageQuality.Add(&H2640210, "SRAW + Small Jpeg")
g_ImageQuality.Add(&H2640013, "SRAW + Large Fine Jpeg")
g_ImageQuality.Add(&H2640012, "SRAW + Large Normal Jpeg")
g_ImageQuality.Add(&H2640113, "SRAW + Middle Fine Jpeg")
g_ImageQuality.Add(&H2640112, "SRAW + Middle Normal Jpeg")
g_ImageQuality.Add(&H2640213, "SRAW + Small Fine Jpeg")
g_ImageQuality.Add(&H2640212, "SRAW + Small Normal Jpeg")
g_ImageQuality.Add(&H2640E13, "SRAW + Small1 Fine Jpeg")
g_ImageQuality.Add(&H2640E12, "SRAW + Small1 Normal Jpeg")
g_ImageQuality.Add(&H2640F13, "SRAW + Small2 Jpeg")
g_ImageQuality.Add(&H2641013, "SRAW + Small3 Jpeg")
g_ImageQuality.Add(&H13FF0F, "Large Fine Jpeg")
g_ImageQuality.Add(&H12FF0F, "Large Normal Jpeg")
g_ImageQuality.Add(&H113FF0F, "Middle Fine Jpeg")
g_ImageQuality.Add(&H112FF0F, "Middle Normal Jpeg")
g_ImageQuality.Add(&H213FF0F, "Small Fine Jpeg")
g_ImageQuality.Add(&H212FF0F, "Small Normal Jpeg")
g_ImageQuality.Add(&HE13FF0F, "Small1 Fine Jpeg")
g_ImageQuality.Add(&HE12FF0F, "Small1 Normal Jpeg")
g_ImageQuality.Add(&HF13FF0F, "Small2 Jpeg")
g_ImageQuality.Add(&H1013FF0F, "Small3 Jpeg")
g_ImageQuality.Add(&H10FF0F, "Large Jpeg")
g_ImageQuality.Add(&H510FF0F, "Middle1 Jpeg")
g_ImageQuality.Add(&H610FF0F, "Middle2 Jpeg")
g_ImageQuality.Add(&H210FF0F, "Small Jpeg")
Private Sub tableInit()
' Legacy Camera
g_ImageQuality.Add(&H240000, "RAW")
g_ImageQuality.Add(&H240013, "RAW + Large Fine Jpeg")
g_ImageQuality.Add(&H240113, "RAW + Middle Fine Jpeg")
g_ImageQuality.Add(&H240213, "RAW + Small Fine Jpeg")
g_ImageQuality.Add(&H240012, "RAW + Large Normal Jpeg")
g_ImageQuality.Add(&H240112, "RAW + Middle Normal Jpeg")
g_ImageQuality.Add(&H240212, "RAW + Small Normal Jpeg")
g_ImageQuality.Add(&H130000, "Large Fine Jpeg")
g_ImageQuality.Add(&H1130000, "Middle Fine Jpeg")
g_ImageQuality.Add(&H2130000, "Small Fine Jpeg")
g_ImageQuality.Add(&H120000, "Large Normal Jpeg")
g_ImageQuality.Add(&H1120000, "Middle Normal Jpeg")
g_ImageQuality.Add(&H2120000, "Small Normal Jpeg")
g_ImageQuality.Add(&H2F000F, "RAW")
g_ImageQuality.Add(&H2F001F, "RAW + Large Jpeg")
g_ImageQuality.Add(&H2F051F, "RAW + Middle1 Jpeg")
g_ImageQuality.Add(&H2F061F, "RAW + Middle2 Jpeg")
g_ImageQuality.Add(&H2F021F, "RAW + Small Jpeg")
g_ImageQuality.Add(&H1F000F, "Large Jpeg")
g_ImageQuality.Add(&H51F000F, "Middle1 Jpeg")
g_ImageQuality.Add(&H61F000F, "Middle2 Jpeg")
g_ImageQuality.Add(&H21F000F, "Small Jpeg")
g_MeteringMode.Add(1, "Spot Metering")
g_MeteringMode.Add(3, "Evaluative Metering")
g_MeteringMode.Add(4, "Partial Metering")
g_MeteringMode.Add(5, "Center-Weighted Average Metering")
g_MeteringMode.Add(&HFFFFFFFF, "unkown")
g_ExposureComp.Add(&H18, "+3")
g_ExposureComp.Add(&H15, "+2 2/3")
g_ExposureComp.Add(&H14, "+2 1/2")
g_ExposureComp.Add(&H13, "+2 1/3")
g_ExposureComp.Add(&H10, "+2")
g_ExposureComp.Add(&HD, "+1 2/3")
g_ExposureComp.Add(&HC, "+1 1/2")
g_ExposureComp.Add(&HB, "+1 1/3")
g_ExposureComp.Add(&H8, "+1")
g_ExposureComp.Add(&H5, "+2/3")
g_ExposureComp.Add(&H4, "+1/2")
g_ExposureComp.Add(&H3, "+1/3")
g_ExposureComp.Add(&H0, "0")
g_ExposureComp.Add(&HFD, "-1/3")
g_ExposureComp.Add(&HFC, "-1/2")
g_ExposureComp.Add(&HFB, "-2/3")
g_ExposureComp.Add(&HF8, "-1")
g_ExposureComp.Add(&HF5, "-1 1/3")
g_ExposureComp.Add(&HF4, "-1 1/2")
g_ExposureComp.Add(&HF3, "-1 2/3")
g_ExposureComp.Add(&HF0, "-2")
g_ExposureComp.Add(&HED, "-2 1/3")
g_ExposureComp.Add(&HEC, "-2 1/2")
g_ExposureComp.Add(&HEB, "-2 2/3")
g_ExposureComp.Add(&HE8, "-3")
g_ExposureComp.Add(&HFFFFFFFF, "unkown")
g_AEMode.Add(0, "P")
g_AEMode.Add(1, "Tv")
g_AEMode.Add(2, "Av")
g_AEMode.Add(3, "M")
g_AEMode.Add(4, "Bulb")
g_AEMode.Add(5, "A-DEP")
g_AEMode.Add(6, "Depth-of-Field AE")
g_AEMode.Add(7, "Manual")
g_AEMode.Add(8, "Lock")
g_AEMode.Add(9, "GreenMode")
g_AEMode.Add(10, "Night Scene Portrait")
g_AEMode.Add(11, "Sports")
g_AEMode.Add(12, "Portrait")
g_AEMode.Add(13, "Landscape")
g_AEMode.Add(14, "Close Up")
g_AEMode.Add(15, "Flash Off")
g_AEMode.Add(19, "CreativeAuto")
g_AEMode.Add(20, "Movie")
g_AEMode.Add(21, "PhotoInMovie")
g_AEMode.Add(22, "SceneIntelligentAuto")
g_AEMode.Add(25, "SCN")
g_AEMode.Add(&HFFFFFFFF, "unknown")
g_ISOSpeed.add(&H0, "Auto")
g_ISOSpeed.add(&H28, "6")
g_ISOSpeed.add(&H30, "12")
g_ISOSpeed.add(&H38, "25")
g_ISOSpeed.add(&H40, "50")
g_ISOSpeed.add(&H48, "100")
g_ISOSpeed.add(&H4B, "125")
g_ISOSpeed.add(&H4D, "160")
g_ISOSpeed.add(&H50, "200")
g_ISOSpeed.add(&H53, "250")
g_ISOSpeed.add(&H55, "320")
g_ISOSpeed.add(&H58, "400")
g_ISOSpeed.Add(&H5B, "500")
g_ISOSpeed.Add(&H5D, "640")
g_ISOSpeed.Add(&H60, "800")
g_ISOSpeed.Add(&H63, "1000")
g_ISOSpeed.Add(&H65, "1250")
g_ISOSpeed.Add(&H68, "1600")
g_ISOSpeed.Add(&H6B, "2000")
g_ISOSpeed.Add(&H6D, "2500")
g_ISOSpeed.Add(&H70, "3200")
g_ISOSpeed.Add(&H73, "4000")
g_ISOSpeed.Add(&H75, "5000")
g_ISOSpeed.Add(&H78, "6400")
g_ISOSpeed.Add(&H7B, "8000")
g_ISOSpeed.Add(&H7D, "10000")
g_ISOSpeed.Add(&H80, "12800")
g_ISOSpeed.Add(&H83, "16000")
g_ISOSpeed.Add(&H85, "20000")
g_ISOSpeed.Add(&H88, "25600")
g_ISOSpeed.Add(&H8B, "32000")
g_ISOSpeed.Add(&H8D, "40000")
g_ISOSpeed.Add(&H90, "51200")
g_ISOSpeed.Add(&H98, "102400")
g_ISOSpeed.Add(&HFFFFFFFF, "unknown")
g_Av.Add(&H8, "1")
g_Av.Add(&HB, "1.1")
g_Av.Add(&HC, "1.2")
g_Av.Add(&HD, "1.2")
g_Av.Add(&H10, "1.4")
g_Av.Add(&H13, "1.6")
g_Av.Add(&H14, "1.8")
g_Av.Add(&H15, "1.8")
g_Av.Add(&H18, "2")
g_Av.Add(&H1B, "2.2")
g_Av.Add(&H1C, "2.5")
g_Av.Add(&H1D, "2.5")
g_Av.Add(&H20, "2.8")
g_Av.Add(&H23, "3.2")
g_Av.Add(&H24, "3.5")
g_Av.Add(&H25, "3.5")
g_Av.Add(&H28, "4")
g_Av.Add(&H2B, "4")
g_Av.Add(&H2C, "4.5")
g_Av.Add(&H2D, "5.6")
g_Av.Add(&H30, "5.6")
g_Av.Add(&H33, "6.3")
g_Av.Add(&H34, "6.7")
g_Av.Add(&H35, "7.1")
g_Av.Add(&H38, "8")
g_Av.Add(&H3B, "9")
g_Av.Add(&H3C, "9.5")
g_Av.Add(&H3D, "10")
g_Av.Add(&H40, "11")
g_Av.Add(&H43, "13")
g_Av.Add(&H44, "13")
g_Av.Add(&H45, "14")
g_Av.Add(&H48, "16")
g_Av.Add(&H4B, "18")
g_Av.Add(&H4C, "19")
g_Av.Add(&H4D, "20")
g_Av.Add(&H50, "22")
g_Av.Add(&H53, "25")
g_Av.Add(&H54, "27")
g_Av.Add(&H55, "29")
g_Av.Add(&H58, "32")
g_Av.Add(&H5B, "36")
g_Av.Add(&H5C, "38")
g_Av.Add(&H5D, "40")
g_Av.Add(&H60, "45")
g_Av.Add(&H63, "51")
g_Av.Add(&H64, "54")
g_Av.Add(&H65, "57")
g_Av.Add(&H68, "64")
g_Av.Add(&H6B, "72")
g_Av.Add(&H6C, "76")
g_Av.Add(&H6D, "80")
g_Av.Add(&H70, "91")
g_Av.Add(&HFFFFFFFF, "unknown")
g_Tv.Add(&H10, "30""")
g_Tv.Add(&H13, "25""")
g_Tv.Add(&H14, "20""")
g_Tv.Add(&H15, "20""")
g_Tv.Add(&H18, "15""")
g_Tv.Add(&H1B, "13""")
g_Tv.Add(&H1C, "10""")
g_Tv.Add(&H1D, "10""")
g_Tv.Add(&H20, "8""")
g_Tv.Add(&H23, "6""")
g_Tv.Add(&H24, "6""")
g_Tv.Add(&H25, "5""")
g_Tv.Add(&H28, "4""")
g_Tv.Add(&H2B, "3""" + "2")
g_Tv.Add(&H2C, "3""")
g_Tv.Add(&H2D, "2""" + "5")
g_Tv.Add(&H30, "2""")
g_Tv.Add(&H33, "1""" + "6")
g_Tv.Add(&H34, "1""" + "5")
g_Tv.Add(&H35, "1""" + "3")
g_Tv.Add(&H38, "1""")
g_Tv.Add(&H3B, "0""" + "8")
g_Tv.Add(&H3C, "0""" + "7")
g_Tv.Add(&H3D, "0""" + "6")
g_Tv.Add(&H40, "0""" + "5")
g_Tv.Add(&H43, "0""" + "4")
g_Tv.Add(&H44, "0""" + "3")
g_Tv.Add(&H45, "0""" + "3")
g_Tv.Add(&H48, "4")
g_Tv.Add(&H4B, "5")
g_Tv.Add(&H4C, "6")
g_Tv.Add(&H4D, "6")
g_Tv.Add(&H50, "8")
g_Tv.Add(&H53, "10")
g_Tv.Add(&H54, "10")
g_Tv.Add(&H55, "13")
g_Tv.Add(&H58, "15")
g_Tv.Add(&H5B, "20")
g_Tv.Add(&H5C, "20")
g_Tv.Add(&H5D, "25")
g_Tv.Add(&H60, "30")
g_Tv.Add(&H63, "40")
g_Tv.Add(&H64, "45")
g_Tv.Add(&H65, "50")
g_Tv.Add(&H68, "60")
g_Tv.Add(&H6B, "80")
g_Tv.Add(&H6C, "90")
g_Tv.Add(&H6D, "100")
g_Tv.Add(&H70, "125")
g_Tv.Add(&H73, "160")
g_Tv.Add(&H74, "180")
g_Tv.Add(&H75, "200")
g_Tv.Add(&H78, "250")
g_Tv.Add(&H7B, "320")
g_Tv.Add(&H7C, "350")
g_Tv.Add(&H7D, "400")
g_Tv.Add(&H80, "500")
g_Tv.Add(&H83, "640")
g_Tv.Add(&H84, "750")
g_Tv.Add(&H85, "800")
g_Tv.Add(&H88, "1000")
g_Tv.Add(&H8B, "1250")
g_Tv.Add(&H8C, "1500")
g_Tv.Add(&H8D, "1600")
g_Tv.Add(&H90, "2000")
g_Tv.Add(&H93, "2500")
g_Tv.Add(&H94, "3000")
g_Tv.Add(&H95, "3200")
g_Tv.Add(&H98, "4000")
g_Tv.Add(&H9B, "5000")
g_Tv.Add(&H9C, "6000")
g_Tv.Add(&H9D, "6400")
g_Tv.Add(&HA0, "8000")
g_Tv.Add(&HFFFFFFFF, "unknown")
' PTP Camera
g_ImageQuality.Add(&H64FF0F, "RAW")
g_ImageQuality.Add(&H640013, "RAW + Large Fine Jpeg")
g_ImageQuality.Add(&H640113, "RAW + Middle Fine Jpeg")
g_ImageQuality.Add(&H640213, "RAW + Small Fine Jpeg")
g_ImageQuality.Add(&H640012, "RAW + Large Normal Jpeg")
g_ImageQuality.Add(&H640112, "RAW + Middle Normal Jpeg")
g_ImageQuality.Add(&H640212, "RAW + Small Normal Jpeg")
g_ImageQuality.Add(&H640E13, "RAW + Small1 Fine Jpeg")
g_ImageQuality.Add(&H640E12, "RAW + Small1 Normal Jpeg")
g_ImageQuality.Add(&H640F13, "RAW + Small2 Jpeg")
g_ImageQuality.Add(&H641013, "RAW + Small3 Jpeg")
g_ImageQuality.Add(&H640010, "RAW + Large Jpeg")
g_ImageQuality.Add(&H640510, "RAW + Middle1 Jpeg")
g_ImageQuality.Add(&H640610, "RAW + Middle2 Jpeg")
g_ImageQuality.Add(&H640210, "RAW + Small Jpeg")
g_ImageQuality.Add(&H164FF0F, "MRAW")
g_ImageQuality.Add(&H1640013, "MRAW + Large Fine Jpeg")
g_ImageQuality.Add(&H1640012, "MRAW + Large Normal Jpeg")
g_ImageQuality.Add(&H1640113, "MRAW + Middle Fine Jpeg")
g_ImageQuality.Add(&H1640112, "MRAW + Middle Normal Jpeg")
g_ImageQuality.Add(&H1640213, "MRAW + Small Fine Jpeg")
g_ImageQuality.Add(&H1640212, "MRAW + Small Normal Jpeg")
g_ImageQuality.Add(&H1640E13, "MRAW + Small1 Fine Jpeg")
g_ImageQuality.Add(&H1640E12, "MRAW + Small1 Normal Jpeg")
g_ImageQuality.Add(&H1640F13, "MRAW + Small2 Jpeg")
g_ImageQuality.Add(&H1641013, "MRAW + Small3 Jpeg")
g_ImageQuality.Add(&H264FF0F, "SRAW")
g_ImageQuality.Add(&H2640010, "SRAW + Large Jpegg")
g_ImageQuality.Add(&H2640510, "SRAW + Middle1 Jpeg")
g_ImageQuality.Add(&H2640610, "SRAW + Middle2 Jpeg")
g_ImageQuality.Add(&H2640210, "SRAW + Small Jpeg")
g_ImageQuality.Add(&H2640013, "SRAW + Large Fine Jpeg")
g_ImageQuality.Add(&H2640012, "SRAW + Large Normal Jpeg")
g_ImageQuality.Add(&H2640113, "SRAW + Middle Fine Jpeg")
g_ImageQuality.Add(&H2640112, "SRAW + Middle Normal Jpeg")
g_ImageQuality.Add(&H2640213, "SRAW + Small Fine Jpeg")
g_ImageQuality.Add(&H2640212, "SRAW + Small Normal Jpeg")
g_ImageQuality.Add(&H2640E13, "SRAW + Small1 Fine Jpeg")
g_ImageQuality.Add(&H2640E12, "SRAW + Small1 Normal Jpeg")
g_ImageQuality.Add(&H2640F13, "SRAW + Small2 Jpeg")
g_ImageQuality.Add(&H2641013, "SRAW + Small3 Jpeg")
g_ImageQuality.Add(&H13FF0F, "Large Fine Jpeg")
g_ImageQuality.Add(&H12FF0F, "Large Normal Jpeg")
g_ImageQuality.Add(&H113FF0F, "Middle Fine Jpeg")
g_ImageQuality.Add(&H112FF0F, "Middle Normal Jpeg")
g_ImageQuality.Add(&H213FF0F, "Small Fine Jpeg")
g_ImageQuality.Add(&H212FF0F, "Small Normal Jpeg")
g_ImageQuality.Add(&HE13FF0F, "Small1 Fine Jpeg")
g_ImageQuality.Add(&HE12FF0F, "Small1 Normal Jpeg")
g_ImageQuality.Add(&HF13FF0F, "Small2 Jpeg")
g_ImageQuality.Add(&H1013FF0F, "Small3 Jpeg")
g_ImageQuality.Add(&H10FF0F, "Large Jpeg")
g_ImageQuality.Add(&H510FF0F, "Middle1 Jpeg")
g_ImageQuality.Add(&H610FF0F, "Middle2 Jpeg")
g_ImageQuality.Add(&H210FF0F, "Small Jpeg")
' Legacy Camera
g_ImageQuality.Add(&H240000, "RAW")
g_ImageQuality.Add(&H240013, "RAW + Large Fine Jpeg")
g_ImageQuality.Add(&H240113, "RAW + Middle Fine Jpeg")
g_ImageQuality.Add(&H240213, "RAW + Small Fine Jpeg")
g_ImageQuality.Add(&H240012, "RAW + Large Normal Jpeg")
g_ImageQuality.Add(&H240112, "RAW + Middle Normal Jpeg")
g_ImageQuality.Add(&H240212, "RAW + Small Normal Jpeg")
g_ImageQuality.Add(&H130000, "Large Fine Jpeg")
g_ImageQuality.Add(&H1130000, "Middle Fine Jpeg")
g_ImageQuality.Add(&H2130000, "Small Fine Jpeg")
g_ImageQuality.Add(&H120000, "Large Normal Jpeg")
g_ImageQuality.Add(&H1120000, "Middle Normal Jpeg")
g_ImageQuality.Add(&H2120000, "Small Normal Jpeg")
g_ImageQuality.Add(&H2F000F, "RAW")
g_ImageQuality.Add(&H2F001F, "RAW + Large Jpeg")
g_ImageQuality.Add(&H2F051F, "RAW + Middle1 Jpeg")
g_ImageQuality.Add(&H2F061F, "RAW + Middle2 Jpeg")
g_ImageQuality.Add(&H2F021F, "RAW + Small Jpeg")
g_ImageQuality.Add(&H1F000F, "Large Jpeg")
g_ImageQuality.Add(&H51F000F, "Middle1 Jpeg")
g_ImageQuality.Add(&H61F000F, "Middle2 Jpeg")
g_ImageQuality.Add(&H21F000F, "Small Jpeg")
g_PropList.Add(kEdsPropID_AEModeSelect, g_AEMode)
g_PropList.Add(kEdsPropID_ISOSpeed, g_ISOSpeed)
g_PropList.Add(kEdsPropID_Av, g_Av)
g_PropList.Add(kEdsPropID_Tv, g_Tv)
g_PropList.Add(kEdsPropID_MeteringMode, g_MeteringMode)
g_PropList.Add(kEdsPropID_ExposureCompensation, g_ExposureComp)
g_PropList.Add(kEdsPropID_ImageQuality, g_ImageQuality)
End Sub
g_PropList.Add(kEdsPropID_AEModeSelect, g_AEMode)
g_PropList.Add(kEdsPropID_ISOSpeed, g_ISOSpeed)
g_PropList.Add(kEdsPropID_Av, g_Av)
g_PropList.Add(kEdsPropID_Tv, g_Tv)
g_PropList.Add(kEdsPropID_MeteringMode, g_MeteringMode)
g_PropList.Add(kEdsPropID_ExposureCompensation, g_ExposureComp)
g_PropList.Add(kEdsPropID_ImageQuality, g_ImageQuality)
End Sub
#End Region ' Methods
End Class