• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

removing image background color using java?

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
crossposted
 
Rob Camick
Rancher
Posts: 3324
32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)

 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

m Korbel wrote:crossposted


Thanks m Korbel.

sudde gameeef
Please read https://coderanch.com/how-to/java/BeForthrightWhenCrossPostingToOtherSites
 
To get a wish, you need a genie. To get a genie, you need a lamp. To get a lamp, you need a tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic