Image alpha transperency problem
in
Programming Questions
•
2 years ago
Hello.. I have come across a problem when I can't make an image transperant. My program loads images into a database, making black transperent (which works fine). Some of the images have to be half-transperent. I have modified the function which filters black (by putting absolutly transperrent pixels in place of black ones), so it would put half-transperent pixels instead of all. But it just does nothing. The only result I was able to get - is to either make the whole image transperent (unseen) or opaque. Here is the routine:
- PImage alphaLevel(PImage img, int level){
- PApplet p = GlobalRef.getPApplet();
- PImage alphed = p.createImage(img.width, img.height, Prototype.ARGB)
- int pos = 0;
- for(int i = 0; i < img.width; i++){
- for(int j = 0; j < img.height; j++){
- pos = i + j * img.width;
- alphed.pixels[pos] = img.pixels[pos] | 0xCC000000;//level;
- }
- }
- return alphed;
- }
So, in my opinion, the red line should make alpha of value "CC". Which it does not. What is the trick? How can I make the image transperent? Using tint() is not an option, since the images are pre-loaded.
1