Results 1 to 8 of 8

Thread: converting to greyscale

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Location
    england
    Posts
    87

    converting to greyscale

    can someone please teach me the codes that copies a picture from one picturebox and puts it in another but now in greyscale ?

    and also the most efficient way cause i need the picture to appear fast.

    pleaseee pleaseee give me a hand here......

  2. #2
    Addicted Member Janus's Avatar
    Join Date
    Aug 2001
    Location
    California
    Posts
    221
    Here's a program I wrote for planet-source-code a long time ago, that does what you want, and more...

    http://www.planet-source-code.com/vb...29762&lngWId=1

    Let me know if it meets your needs.
    "1 4m 4 1337 #4xz0r!'
    Janus

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Location
    england
    Posts
    87
    ive looked at the program in the link. i looked through it but cant get mine to work.

    can somebody come up with simpler codes to copy a picture from a picturebox and put it into another picturebox after converting it to greyscale ?

  4. #4
    Member
    Join Date
    May 2001
    Location
    India
    Posts
    35
    One method could be this.

    Define an array of size (x,y) where x is the width of the picture1 and y is the height.

    Read pixel by pixel from Picture1 into the array using the Pixel function. Separate it into RGB values. Average the RGB values to get the Grayscale value.

    Rewrite the averaged value for each pixel into second picture box using the PSet method.

    if u want email to [email protected] and I'll send u the sample code for the same.
    I believe... in myself

  5. #5
    Addicted Member Janus's Avatar
    Join Date
    Aug 2001
    Location
    California
    Posts
    221
    What problem did you have getting that PSC entry to work for yours? It will be far faster than using GetPixel and SetPixel, trust me on this.

    Email me at [email protected] and I can try and walk you through using get/stretchdibits.
    "1 4m 4 1337 #4xz0r!'
    Janus

  6. #6
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Actually no, averaging doesn't give you the actual greyscale value, you'll find greens turn out very dull when they shouldn't.

    You'll have to multiply red by 0.17, green by 0.62, and blue by 0.11 to get the actual grey. (it's something like that, I cannot remember perfectly)
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  7. #7
    Addicted Member Janus's Avatar
    Join Date
    Aug 2001
    Location
    California
    Posts
    221
    The greyscale formula should be in that PSC submission, if it's not, I have it somewhere
    "1 4m 4 1337 #4xz0r!'
    Janus

  8. #8
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    It was at this german VB site (VBEMPIRE) but it's down at the moment...
    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
  •  



Click Here to Expand Forum to Full Width