' ImageData class Public Class ImageData Private cExtension As String = "" Private nHeight As Integer = 0 Private nWidth As Integer = 0 Friend Property Extension() As String Get Return cExtension End Get Private Set(tcValue As String) cExtension = tcValue End Set End Property Friend Property Height() As Integer Get Return nHeight End Get Private Set(tnValue As Integer) nHeight = tnValue End Set End Property Friend Property Width() As Integer Get Return nWidth End Get Private Set(tnValue As Integer) nWidth = tnValue End Set End Property Friend Sub New(tnWidth As Integer, tnHeight As Integer, tcExtension As String) Width = tnWidth Height = tnHeight Extension = tcExtension End Sub End ClassThis is the initialization of the images in memory:
Dim loImageData As New Dictionary(Of String, ImageData) ' If this is the Web site If oApp.nApplicationMode = 3 Then ' If we have some images in memory If oApp.oAdmin.oRow("Image").length > 0 Then ' Load the application into the string builder loStringBuilderFile.LoadString(oApp.oAdmin.oRow("Image")) ' For each image For lnCounter = 1 To loStringBuilderFile.nLine ' Get the line If Not loStringBuilderFile.MLine(lnCounter) Then Return False End If lcImage = loStringBuilderFile.cLine ' If the file exists If oApp.FileExist(oApp.cGraphicFat + lcImage) Then ' Get the image details making it OK to reender the HTML without flickering loImage = New System.Drawing.Bitmap(oApp.cGraphicFat + lcImage) lnWidth = loImage.Width lnHeight = loImage.Height ' Initializaiton lcName = Trim(lcImage) lnLocation = oApp.At(".", lcName) lcExtension = "" ' If we have found it If lnLocation > 0 Then ' If this is not the last character If lnLocation < lcName.Length Then lcExtension = Mid(lcName, lnLocation + 1) End If End If loImageData.Add(lcImage, New ImageData(lnWidth, lnHeight, lcExtension)) Else AddError(oApp.cGraphicFat + lcImage + " does not exist.") End If Next End If End IfThe tricky part is to access later on in the application, whereas needed, the method to return some info from it. So far, I have something like this:
' Return True or False if an image is loaded in memory ' expC1 Name Public Function IsImageInMemory(ByVal tcName As String) As Boolean Dim lcName As String = "" Dim llFound As Boolean = False Dim loImageData As New Dictionary(Of String, ImageData) Dim loImageData2 As ImageData = Nothing ' Initialization lcName = UCase(Trim(tcName)) ' If the image is found in the dictionary If loImageData.TryGetValue(lcName, loImageData2) Then llFound = True ' Initialization nWidth = loImageData2.Width nHeight = loImageData2.Height End If Return llFound End FunctionBut, this of course wouldn't work. The goal is to instantiate a reference to the ImageData class, which is already initialized, and query it to get the data. The remaining changes are in here and they are probably small to do.