transparent sprites
My applet pisplays the right graphic and i wanit to display the left one.
Im using
g.drawImage(shipImage,shipx-shipw/2,shipy-shiph/2,this);
to draw the sprite.
[URL=http://imageshack.us][IMG]http://img71.imageshack.us/img71/5212/piccx9.png[/IMG][/URL]
Thanx. And no "go there and read so many pages and remain clueless" stuff, please.
[372 byte] By [
alexxziusa] at [2007-11-27 0:54:58]

# 6
static BufferedImage playWithTransparency(BufferedImage input) {
BufferedImage result = changeType(input, BufferedImage.TYPE_INT_ARGB);
for(int x=0; x < result.getWidth(); x++){
for(int y=0; y < result.getHeight(); y++) {
int argb = result.getRGB(x, y);
int r = (argb >> 16) & 0xff;
int g = (argb >> 8) & 0xff;
int b = argb & 0xff;
//if (b > r + g)
if(b > 230 && r > 230 && g > 230)
result.setRGB(x, y, 0);
}}
return result;
}
public static BufferedImage changeType(BufferedImage input, int type) {
int w = input.getWidth();
int h= input.getHeight();
BufferedImage result = new BufferedImage(w, h, type);
Graphics2D g = result.createGraphics();
g.drawRenderedImage(input, null);
g.dispose();
return result;
}
edit the rgb values to the color you want to be made transparent.
Bogada at 2007-7-11 23:27:34 >
