Support Forums
Image transparency lulz - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: Java Programming (https://www.supportforums.net/forumdisplay.php?fid=22)
+---- Thread: Image transparency lulz (/showthread.php?tid=5177)



Image transparency lulz - Project Evolution - 03-06-2010

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.


RE: Image transparency lulz - Foresight - 03-06-2010

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.


RE: Image transparency lulz - Project Evolution - 03-06-2010

All you do is invoke it. Of course, its meant for pictures and such.