|
-
Jan 30th, 2001, 08:08 PM
#1
Thread Starter
Member
I have drawn an image using SetPixelV, unfortunately, it does not do anything to update the .image property, so vb's built in SaveImage method only saves a black picture. Any help? Thanks!
-
Jan 30th, 2001, 11:29 PM
#2
Fanatic Member
Make sure you have set the Picture Box's Autoredraw property to True and also make sure you call the Picture Box's Refresh method before using SavePicture, i.e. ....
Code:
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()
Picture1.AutoRedraw = True
Picture1.ScaleMode = vbPixels
End Sub
Private Sub Picture1_Click()
For I = 1 To 1000
Randomize
SetPixelV Picture1.hdc, Rnd * Picture1.ScaleWidth, Rnd * Picture1.ScaleHeight, RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Next I
Picture1.Refresh
SavePicture Picture1.Image, "C:\Pixels.BMP"
End Sub
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Feb 2nd, 2001, 07:09 PM
#3
Thread Starter
Member
Hmm
Unfortunately, this does not work. SetPixel's results are erased by refresh and AutoRedraw. I need some way to edit the image property itself, or some other solution.
-
Feb 2nd, 2001, 09:32 PM
#4
Fanatic Member
The code I posted works just fine for me.
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Feb 3rd, 2001, 03:23 PM
#5
Addicted Member
You must set the AutoRedraw before you draw anything and Refresh after the job is coplete.
Correct me if I'm wrong, but it sounds to me that you've set AutoRedraw and Refresh both after?
-
Feb 3rd, 2001, 10:36 PM
#6
Good Ol' Platypus
Works fine for me too.
Make sure these are your steps:
1. Set AutoRedraw to True
2. Set pixels with SetPixelV
3. Refresh the picture with .refresh
4. Save image using built-in code.
Cheers,
Sastraxi
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
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
|