George Xanthos
asked on
Problem runnig VB5 in Win 10. The program used to run perfectly in Win 98 environment
Hi,
Although the program used to run smoothly on win98 and VB5 now cannot read the pixel info of an image (ie. jpg or gif) and therefore cannot proceed
to calculate the Lab pixel values from RGB? In particular I have test pics of 100x100 pixel and program now reads 585x1890 !! Any ideas?
Following is the part of the program
Cheers
Although the program used to run smoothly on win98 and VB5 now cannot read the pixel info of an image (ie. jpg or gif) and therefore cannot proceed
to calculate the Lab pixel values from RGB? In particular I have test pics of 100x100 pixel and program now reads 585x1890 !! Any ideas?
Following is the part of the program
Cheers
Public Sub Command1_Click()
Dim OFName As OPENFILENAME
OFName.lStructSize = Len(OFName)
'Set the parent window
OFName.hwndOwner = Me.hwnd
'Set the application's instance
OFName.hInstance = App.hInstance
'Select a filter
OFName.lpstrFilter = "Image Files (*.bmp;*.jpg;*.png)" + Chr$(0) + "*.bmp;*.jpg;*.png" + Chr$(0) + "All Files (*.*)" + Chr$(0) + "*.*" + Chr$(0)
'create a buffer for the file
OFName.lpstrFile = Space$(254)
'set the maximum length of a returned file
OFName.nMaxFile = 255
'Create a buffer for the file title
OFName.lpstrFileTitle = Space$(254)
'Set the maximum length of a returned file title
OFName.nMaxFileTitle = 255
'Set the initial directory
OFName.lpstrInitialDir = "C:\"
'Set the title
OFName.lpstrTitle = "Open File"
'No flags
OFName.flags = 0
'Show the 'Open File'-dialog
If GetOpenFileName(OFName) Then
Label2 = Trim$(OFName.lpstrFile)
End If
End Sub
Private Sub Command2_Click()
Dim PicInfo As BITMAP
Dim pic As Picture
Dim X, Y As Long
Dim height, width As Long
Dim R As Long
Dim imagesource As String
Dim hFile As Long, FileInfo As BY_HANDLE_FILE_INFORMATION
Dim Red, Green, Blue As Variant
Dim Xcie, Ycie, Zcie As Double
Dim CIEL, CIEa, CIEb As Variant
Dim RATIOXcie, RATIOYcie, RATIOZcie As Double
Dim miL, mia, mib, maL, maa, mab As Double
imagesource = Label2.Caption
Set pic = LoadPicture(imagesource)
'Graphics formats recognized by VB include (bmp, icon, rle, wmf, emf, GIF _
jpg) files
' Load icon into a picturebox
Picture1.Picture = LoadPicture(imagesource)
Form1.WindowState = vbMaximized
'Get information (such as height and width) about the picturebox
GetObject pic.Handle, Len(PicInfo), PicInfo
Text1.Text = PicInfo.bmHeight
Text2.Text = PicInfo.bmWidth
'-----------------------------------------------------
hFile = Picture1.hDC
MsgBox "Window Handle: " + CStr(hFile), vbInformation
'-----------------------------------------------------
Open "C:\RGB Image Analyser\RGBVALUES.txt" For Output As 1#
Print #1, " Height Width RED GREEN BLUE"
Print #1, "(Pixel) (Pixel) L* a* b* "
Print #1, "------- ------- ---------------------------------"
height = PicInfo.bmHeight
width = PicInfo.bmWidth
maL = Text3.Text
maa = Text4.Text
mab = Text5.Text
miL = Text6.Text
mia = Text7.Text
mib = Text8.Text
For X = 0 To width - 1 Step 1
For Y = 0 To height - 1 Step 1
R = GetPixel(hFile, X, Y)
'Print #1, Y, X, ColorToHTML(R) ' HEXADECIMAL
'------------------------------------------
'TRANSLATES THE HEXADECIMAL TO RGB VALUES
Red = R And &HFF
Green = ((R And &HFF00&) / &H100&) And &HFF
Blue = ((R And &HFF0000) / &H10000) And &HFF
ASKER
Dear Scott.
Thank you for your promptly answer, although VMware + Win 98 do not work in a sufficient way together since Win 98 do not support folders sharing and therefore I could send the program from the host to the guest machine. Re-writing was always my first option but I asked for an idea in order to save time from writing again a program that was working properly In a previous edition of windows. Having the last days reviewing different programming boards I saw that the same problem was expressed by different programmers so I'm not the only complaining person. Anyway, thanks again.
George.
Thank you for your promptly answer, although VMware + Win 98 do not work in a sufficient way together since Win 98 do not support folders sharing and therefore I could send the program from the host to the guest machine. Re-writing was always my first option but I asked for an idea in order to save time from writing again a program that was working properly In a previous edition of windows. Having the last days reviewing different programming boards I saw that the same problem was expressed by different programmers so I'm not the only complaining person. Anyway, thanks again.
George.
Seeing that you have the code, why not "upgrade" it to VB6
And hope that the "upgraded" program compiled in VB6 will work in Win10.
VB5 came out 21 years ago. With all of the changes in the OS in 2 decades I'm not surprised that it won't run in Win10, and just because you are not the only one having the problem doesn't mean that there will be an easy solution.
VB5 came out 21 years ago. With all of the changes in the OS in 2 decades I'm not surprised that it won't run in Win10, and just because you are not the only one having the problem doesn't mean that there will be an easy solution.
Look at the VB6 support document
https://docs.microsoft.com/en-us/visualstudio/vb6/vb6-support
https://docs.microsoft.com/en-us/visualstudio/vb6/vb6-support
Even as a quick an dirty option, can this be replicated with VBA in an Office product? This works in Microsoft Office VBA to retrieve the pixel dimensions of an image file:
Private Sub GetGraphicDimensions()
strFilePath = "C:\Temp\Picture.JPG"
strFilename = Right(strFilePath, InStrRev(strFilePath, "\") + 1)
varFoldername = Left(strFilePath, Len(strFilePath) - Len(strFilename))
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(varFoldername)
Set objFile = objFolder.ParseName(strFilename)
strImageDimensionsRaw = objFile.ExtendedProperty("Dimensions")
For intChr = 1 To Len(strImageDimensionsRaw)
strChr = Mid(strImageDimensionsRaw, intChr, 1)
If Asc(strChr) >= 48 And Asc(strChr) <= 57 Or Asc(strChr) = 120 Then
strImageDimensions = strImageDimensions & strChr
End If
Next
lngImageWidth = CLng(Split(strImageDimensions, "x")(0))
lngImageHeight = CLng(Split(strImageDimensions, "x")(1))
MsgBox "width = " & lngImageWidth & ", height = " & lngImageHeight
End Sub
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Then do a re-write of the program to work properly in a current and supported OS.