×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

VB5 getpixel for a picture loaded ina picturebox

VB5 getpixel for a picture loaded ina picturebox

VB5 getpixel for a picture loaded ina picturebox

(OP)
Hi,
Although the program used to run smoothly on win98 and VB5 now cannot read the info about the window pixel and therefore cannot proceed
to calculate the Lab pixel values from RGB? The VB5 run fine for some other programs built with VB5 under Win10 environment.
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)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close