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]
# 1
[url= http://forum.java.sun.com/thread.jspa?threadID=5160096&tstart=0]Multipost.[/url]
CaptainMorgan08a at 2007-7-11 23:27:33 > top of Java-index,Other Topics,Java Game Development...
# 2
Sorry, i thought i edited it. Obviusly i wanted the left picture to appear, not right one. Please help
alexxziusa at 2007-7-11 23:27:34 > top of Java-index,Other Topics,Java Game Development...
# 3
Just make the background of the image transparent in Photoshop or whatever you would like to use.
CaptainMorgan08a at 2007-7-11 23:27:34 > top of Java-index,Other Topics,Java Game Development...
# 4
im using MS Paint and it dont have transparent backgrounds. . . I thought it has to do something with clipping . . .
alexxziusa at 2007-7-11 23:27:34 > top of Java-index,Other Topics,Java Game Development...
# 5
> im using MS Paint and it dont have transparent backgrounds. . . Then use software which does. The GIMP is free to download and use.
YAT_Archivista at 2007-7-11 23:27:34 > top of Java-index,Other Topics,Java Game Development...
# 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 > top of Java-index,Other Topics,Java Game Development...