SilabGarza - RS Private Server  
Home Forum Play Register Store Market Highscores Mark Forums Read
Go Back   SilabGarza - RS Private Server > SilGar Media > Computers > Programming
Reload this Page Image transparency


Image transparency
Old
  (#1 (permalink))
Evolution is Offline
Also known as Anthony`
image
 
Evolution's Avatar
 
Posts: 43
Cookies Given: 0
Cookies Received: 0
Time Online: 2 h 50 m
   
Lightbulb Image transparency - 06-27-2010, 12:42 PM

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);
    }
Makes images translucent or completely transparent.
  
Old
  (#2 (permalink))
I R Maggot is Offline
Member
image
 
I R Maggot's Avatar
 
Posts: 64
Cookies Given: 0
Cookies Received: 0
Time Online: 3 h 28 m
   
Default 07-15-2010, 04:10 PM

setAlpha?

Why did you name it that?


Yes, I am better than you.
  
Old
  (#3 (permalink))
Rodrigues is Offline
Senior Member
image
 
Rodrigues's Avatar
 
Posts: 1,556
Cookies Given: 37
Cookies Received: 12
Time Online: 27 d 5 h 20 m
Clan: None.
   
Default 07-15-2010, 04:30 PM

Quote:
Originally Posted by I R Maggot View Post
setAlpha?

Why did you name it that?
I would of just called it setTransparency. Use convenstions, Evolution.

Code:
public void setTransparency(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);
}
Also, why did you use this? Wastes space, to be honest. Just use the instance normally. Instead of this.blah.blahMore();, just say blah.blahMore();. Good job, though.




^ Thanks, Nigma.


^ Thanks, Devon.


^ Thanks, Xanadu.


^ Thanks, Martin.

In-game/Forums Name - Rodrigues
RS Name - dom platano2
  
adsense code2.3
Closed Thread

Bookmarks

Image transparency

Programming




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
adsense2.6
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 11:59 PM.





Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.