Results 1 to 16 of 16

Thread: how can i get each pixel's color of my picturebox

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163

    Question how can i get each pixel's color of my picturebox

    Hi guys
    I wanted to see, How can I get Each pixel’s color In a picturebox The main Purpese I’m doing this is that I want to find out which pixels’ of my image file are More darker than the others.
    Can any body help?
    Thank u very much

  2. #2

  3. #3
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Use "Pixel" and "Point" to set and get the pixel on a picturebox.
    Baaaaaaaaah

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163
    but it seems that it gives me the color of each point in a smaller unit than pixel(maybe twips) how can i take the pixels' color?

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163
    hellllllllllooo
    can't anyone answer?

  6. #6
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Set the scalemode of the picturebox to 3, and use the GetPixel API call
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  7. #7
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    Earth
    Posts
    277
    try this code

    Code:
    Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, _
        ByVal y As Long) As Long
    Dim pixelColor As Long
    pixelColor = GetPixel(Picture1.hdc, x, y)

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163
    I guess that if I set scalemode to pixel then no more API call will be needed if the point method would work for pixels after that. don't u think so? or the api call works faster?

  9. #9
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    FYI, pixel is the smallest unit that is displayed on the screen.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163
    no pixel is 12*12 twips

  11. #11
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    "Virtually" perhaps. But physically the smallest definable/displayable unit on the screen is a pixel
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163
    yeah maybe on the monitor screen it's so. but when working with printer u can difine and use twip coz some printers r more accuret than monitors

  13. #13
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    *cough* 2 nil *cough*
    *mutter* pansy goalie *mutter*

    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  14. #14
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744
    mrdj1002 even for the printer, Pixel - is the smallest unit:
    Also, twips are screen independent measurements.

    Check out ScaleMode Property for a reference.

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Aug 2001
    Location
    shiraz
    Posts
    163
    thanks serg. but u should complain the auther of the book i read this thing in it. and hey plendreg i didn't understand what u said. BTW it seems that u hammerd us in dublin but hey watch out your guys in tehran

  16. #16
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Ypur goalkeeper was ... for want of a better word ... a pansy.
    He was useless and kept pretending he was hurt. He should have been given a red card !
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width