[java] Java and transparent images
I just draw a bmp in paint, load it up in photoshop, make what I need transparent, and then save it as a Compuserve gif. Works like a charm.
Quote:Original post by DRPhil
I just draw a bmp in paint, load it up in photoshop, make what I need transparent, and then save it as a Compuserve gif. Works like a charm.
Why not draw it in photoshop in the first place? ;)
I tried a second paint program called Pixia. I checked the pink color and it was a value of RGB(100,0,100). MS Paint was a horrible way to tell what the value was. Somehow I got 255,0,255. With that being done, I compiled and ran the program. The pink background is still there. I tried the black rectangle behind the PC - nothing happened. With a thought of this just being my code causing the problem, I'll post it here for you to view.
Edit: Also, like in C#, can Java determine what the pixel color is at each image positioned at (0,0)?
Edit: Also, like in C#, can Java determine what the pixel color is at each image positioned at (0,0)?
import java.awt.*;import java.applet.*; import java.awt.event.*;public class Applet_Practice extends Applet implements KeyListener { Image imgPC; int x, y; int size = 50; Color transColor = new Color(100, 0, 100); public void init() { addKeyListener(this); imgPC = getImage(getDocumentBase(), "PC.png"); } public void start() { } public void stop() { } public void destroy() { } public void paint(Graphics g) { g.drawImage(imgPC, x, y, size, size, transColor, this); } public void keyReleased(KeyEvent ke) { } public void keyPressed(KeyEvent ke) { int key = ke.getKeyCode(); switch (key) { case KeyEvent.VK_W: y -= 50; break; case KeyEvent.VK_S: y += 50; break; case KeyEvent.VK_D: x += 50; break; case KeyEvent.VK_A: x -= 50; break; } repaint(); } public void keyTyped(KeyEvent ke) { } }
I think we're misunderstanding that background color parameter. I think the function will paint all transparent pixels of your image with that background color, and not the other way around. I see no purpose in this, though.
Go to Photoshop or Gimp and replace that pink background from your image with transparent pixels. Then use the other drawImage() function without the background color parameter. It will work for sure.
Then, just for the kick of it, use the previous drawImage() function as you had just to see if the pink background magically reappears.
Go to Photoshop or Gimp and replace that pink background from your image with transparent pixels. Then use the other drawImage() function without the background color parameter. It will work for sure.
Then, just for the kick of it, use the previous drawImage() function as you had just to see if the pink background magically reappears.
I went to the site and had some problems as to what link to click on.
My first click downloaded GTK runtime environment. While executing, it wanted to know what language to use, and all users' language. My second click downloaded the source code (I believe). I just want the exe! Can you please tell me which link to use for WinXP?
Edit: Nevermind, I found it.
Because I don't feel like spending all day to figure Gimp out, can someone tell me what to do to make the image transparent? I tried Layer -> Transparency -> Set it to RGB(100,0,100), and the background disapears. However, the character has a tint of green. Why is that?
[Edited by - dxFoo on August 30, 2005 8:08:59 PM]
My first click downloaded GTK runtime environment. While executing, it wanted to know what language to use, and all users' language. My second click downloaded the source code (I believe). I just want the exe! Can you please tell me which link to use for WinXP?
Edit: Nevermind, I found it.
Because I don't feel like spending all day to figure Gimp out, can someone tell me what to do to make the image transparent? I tried Layer -> Transparency -> Set it to RGB(100,0,100), and the background disapears. However, the character has a tint of green. Why is that?
[Edited by - dxFoo on August 30, 2005 8:08:59 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement