Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Image transparency lulz
#1
Code:
public void setAlpha(int alpha, int width, int height) {
        if (alpha < 0)
                alpha = 0;
        else if (alpha > 100)
                alpha = 100;

        alpha *= 2.55;

        int w = width;
        int h = height;

        int[] pixels = new int[w * h];

        pixels = this.image.getRGB(0, 0, w, h, pixels, 0, w);

        for(int i = 0; i < pixels.length; i++)
                pixels[i] = ((pixels[i] == 0) ? 0 << 24 : alpha << 24) | (pixels[i] & 0xffffff);

        this.image.setRGB(0, 0, w, h, pixels, 0, w);
    }

Enjoy, rofl.
My SMF Modifications:
http://anthony.vibrantvps.com/smf
Reply
#2
I'm kind of new to this, so do I have to insert anything else? Because when I used the w3school's Java Tryit Editor, it didn't show anything transparent, in fact a lot of the code is all that displayed.
[Image: b7yj2x.png]
Reply
#3
All you do is invoke it. Of course, its meant for pictures and such.
My SMF Modifications:
http://anthony.vibrantvps.com/smf
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)