Thread: pil and alpha

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    11
    Rep Power
    0

    pil and alpha


    hi, ive got a string in "L" i convert to RGB, how do i add an alpha channel with an alpha based on the L value
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    28
    Rep Power
    0
    Trivial:
    PHP Code:
    im1=im.convert("RGBA")
    im1.putalpha(msk
    What's the problem?
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    11
    Rep Power
    0
    thanks, how do i display it now? im still getting the same alpha over the whole image. should i be using glBlendFunc(GL_SRC_ALPHA,GL_DST_ALPHA)
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    11
    Rep Power
    0
    also, should the alpha mask be from 0-255 ot 0.0-1.0?
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    28
    Rep Power
    0
    how do i display it now? im still getting the same alpha over the whole image
    I haven't got your point. Are you asking about PIL or about OpenGL?
    should the alpha mask be from 0-255 ot 0.0-1.0?
    Any of them - either mode "L" or "1", in PIL jargon. Alpha mask is full-blown PIL image, just single-banded one
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    11
    Rep Power
    0
    sorry about the confusion, im having troubles varying the alpha in OpenGL. I can change the overall Alpha value using glColor4f but I see no varying alpha on the texture.

    im assuming the alpha channel is int's 0-255 since the RGB channels are. the putalpha method comes up with no errors but i cant get getpixel(xy) to work. ive tried
    im.getpixel([x,y])
    im.getpixel(x,y)

    temp=x*y
    im.getpixel(temp)
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    28
    Rep Power
    0
    you've almost caught it
    Code:
    im.getpixel((x, y))
    will return 4-tuple (if your image is really RGBA) of integers in 1..255 , like
    Code:
    (106, 106, 106, 196)
    .
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2003
    Posts
    11
    Rep Power
    0
    thanks man

IMN logo majestic logo threadwatch logo seochat tools logo