|
-
Sep 7th, 2001, 07:45 AM
#1
Thread Starter
Addicted Member
Picture Box
Is there a way to retrieve each pixel color (RGB) in a picture box?
Cause I want to select some pixels (with the mouse) from a picture loaded in a picture box and then retrieve each selected pixel colors to modify it and affect theses pixels to another picture box. Any Idea how to do?
-
Sep 7th, 2001, 08:21 AM
#2
Lively Member
Private Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Declare Function SetPixel Lib "gdi32" Alias "SetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
Make sure your Pic's ScaleMode is set to Pixel, then...
For x = 0 to pic.ScaleWidth - 1
For y = 0 to pic.ScaleHeight - 1
lColor = GetPixel(pic.hdc,x,y)
Setcolor(pic.hdc,x,y,lColor)
Next y
Next x
This code would just set the pixels to the same color they already were, so it's useless, but you get the idea.
-
Sep 7th, 2001, 01:08 PM
#3
Thread Starter
Addicted Member
!!!!
Thanks a lot! It Should do quite well the job!
-
Sep 8th, 2001, 02:19 PM
#4
Frenzied Member
Hey Megistral, if you're interested in a faster method, I can post it here 
Btw, SetPixelV is faster than SetPixel...
-
Sep 9th, 2001, 10:17 AM
#5
Thread Starter
Addicted Member
Thks...
Thanks Jotaf98 but I've found a new way to Stretch my picture and to set pixel
To stretch I've used PaintPicture that comes with with the Picture Box (cause I don't need to stretch very often so it's ok) and for setting pixels, I will use BitBlt.
Is the speed the only difference Between Setpixel and SetpixelV ?
-
Sep 9th, 2001, 10:28 AM
#6
Good Ol' Platypus
The reason it is speedier is because SetPixelV doesn't return anything.
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
|