Loading...
Logo
Processing Forum
I've read some tutorials here and there explaining that loading a PNG with alpha channel/transparency should work out of the box, however it doesn't with my current experiment. The image currently works like a GIF does, with transparency being only on or off, no alpha channel. What should I look into? I may be running out of keywords to find a proper answer. Thanks in advance!


I'm currently using Processing 2. Below is my code:

Copy code
  1. color BG_COLOR = color(255, 0, 0);


  2. PImage img;


  3. void setup()
  4. {
  5. size(640, 360, P2D);
  6. background(BG_COLOR);

  7. img = loadImage("circle.png");
  8. imageMode(CENTER);
  9. }

  10. void draw()
  11. {
  12. image(img, width * 0.5, height * 0.5);
  13. }


Replies(3)

It works perfectly on Processing 2.0 with MACOSX 10.8.4.

Be careful, you must erase your previous image before displaying another one.

Try with this one


Your image doesn't work either, it's either on or off with the transparency. I'm using Mac OS X v 10.7.5. Anything else I should check?


-mat.
Ah! I finally understood what you meant by " erase your previous image": the draw() function draws an additional image at every loop! So I simply drew the image only once in the setup and the alpha shows properly!

-mat.