Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: removing image background color using java??

  1. #1
    Member
    Join Date
    Mar 2013
    Posts
    67
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default removing image background color using java??

    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

    public class main extends japplet
    {
     ...
     
     
     public void paint(Graphics g)
      {
          g.drawImage(image, x, y, x+width, y+height, 
    	               0, 0, 40, 40 ,sprite_sheet.m1);
      }
    }

    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?


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: removing image background color using java??

    In my opinion, photoshop is probably your best option since you can remove the background without removing the player's color that is similar to the background.

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: removing image background color using java??

    If the image of the player has a continuous boundary and the color of all the pixels outside the boundary is the same,
    you should be able to write code to change those pixels.
    Are there any folds in the boundary?
    If not do it row by row,
    start at left edge and work to the right towards boundary changing pixels
    then do the same starting at the right edge and work left to boundary.

    With folds, it will be harder unless there aren't any color matches in the player.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. background image in java form
    By Pearly in forum AWT / Java Swing
    Replies: 2
    Last Post: January 20th, 2013, 09:11 AM
  2. background image in java form
    By Pearly in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 20th, 2013, 09:11 AM
  3. Replies: 1
    Last Post: August 4th, 2012, 10:02 AM
  4. mode.addRow with background color
    By nsyncpilu in forum AWT / Java Swing
    Replies: 3
    Last Post: December 15th, 2011, 09:50 AM
  5. set Background Excel cell color using POI API
    By ngamal in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 26th, 2011, 11:20 AM