|
-
Feb 16th, 2002, 10:34 PM
#1
Thread Starter
Lively Member
imagebox problem
ive used setpixelv to set a picture into a picturebox.
as i want to use the stretch feature of the imagebox i tried :
image1 = picture1
but it seems i could not get the picture to appear on the imagebox.
i've notice that imagebox uses vbtwip and picturebox uses pixels, could this be the problem ?
i did get a few values into the first few pixels of the imagebox after checking it but still cant see a thing.
someone please help !!
-
Feb 16th, 2002, 10:45 PM
#2
You need to make sure the added Pixels are Persistent (stay there as part of the "Picture"), i.e.
VB Code:
Option Explicit
Private Declare Function SetPixelV Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Private Sub Form_Load()
' Make the Image Box Twice the Size of the Picturebox
' And set it to Stretch it's Contents to Fit
With Picture1
Image1.Move .Left + .Width, .Top, .Width * 2, .Height * 2
Image1.Stretch = True
End With
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbLeftButton Then
With Picture1
.AutoRedraw = True ' Make sure the Pixels Persist
Call SetPixelV(.hdc, .ScaleX(x, .ScaleMode, vbPixels), .ScaleY(y, .ScaleMode, vbPixels), vbBlack)
' Transfer the Edited "Image" to the "Picture"
.Picture = .Image
' Now you can assign the Picture to the Image Control
Image1 = .Picture
End With
End If
End Sub
-
Feb 16th, 2002, 10:54 PM
#3
Thread Starter
Lively Member
Ahhhhh....it works
Thanks man !
-
Feb 16th, 2002, 11:19 PM
#4
Thread Starter
Lively Member
does anyone know how to get the value of the pixels in a imagebox ?
used windows api getpixel for picturebox but cant get it to work with imagebox.
any tips ?
-
Feb 17th, 2002, 07:05 AM
#5
Frenzied Member
well get the dc and get it from there. not a to great way to do it, but it works. But I am sure you could somehow find the real dc to it in the properties or through api.
Sanity is a full time job
Puh das war harter Stoff!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|