• Post Reply Bookmark Topic Watch Topic
  • New Topic

removing image background color using java?  RSS feed

 
sudde gameeef
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a sprite sheet(image) and i want to draw on screen.


image = sprite sheet image
x = player x postion
y = player y postion
width = player width
height = player heigh



so on spreet sheet i have a image of player, and its background color is blue. when i drawImage it create image background blue. now i cloud remove the color by using photoshop but i really dont want to do this. bc it will remove part of my player.

is there way to del the background color using java code?? may be there is a funtion
 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know how to remove the color from the image.

However, you should NOT be overriding the paint() method of your JApplet. Custom painting should be done by overriding the paintComponent() method of a JPanel. Then you add the panel to the applet.
 
sudde gameeef
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i c. this seem to be working now but if i paint in different class than it doesnt work. for ex. below player_class paint doesnt work. any idea?

error on: player_class.paintComponent(g);





player.java



error:
The method paint(Graphics, main) in the type main_menu is not applicable for the arguments (Graphics, main.Display)
 
m Korbel
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
crossposted
 
Rob Camick
Ranch Hand
Posts: 2801
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Name your classes correctly. Class names start with an upper case character. "player" should be "Player". Your contructor for the Player is wrong, you have "player1". Also you should be creating the Player object in the Display class not the applet class. The applet is just a shell for the panel you add to the content pane.
 
sudde gameeef
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also in main i have Player p lower case.
and two line were

player_class.paint(g, this);
and

public void paint(Graphics g, main m)
 
sudde gameeef
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sudde gameeef wrote:i remove the 1 also in main i have Player p lower case.
and two line were

player_class.paint(g, this);
and

public void paint(Graphics g, main m)
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!