File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes How to change the color of an image? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to change the color of an image?" Watch "How to change the color of an image?" New topic
Author

How to change the color of an image?

chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 800

Hi all, I want to change the color of an image using javascript or any javascript library such as jQuery.

For example if I have a car image(car body) initially white color, then if I choose blue color in options menu the color of the car must change to blue. I don't want to replace images. There will be only one image on my server.

Can anyone please help me?

Thank you all in advance, good day.


Love all, trust a few, do wrong to none.
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 800

For instance you can take al look at this website. There is a car, when you click on the car there appears 3 + symbols. When you click one of the plus symbols you can change the color of the car.

Actually I our project there is already code to do that. And I am sure there is only one copy of the car image. I want to know how to do this. Please don't say me to debug the code, I am not interested in that because there are many javascript files and I dint write the code.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You are going to need more than one image for that.

Eric
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 800

Eric Pascarello wrote:You are going to need more than one image for that.

Eric

But in my project I check all images, there is only one copy of the car body which is grey in color.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I got out of bed to "debug it for you" which you seemed to lazy to do yourself and they use more than one image.




Do you want the rest of them?

How can you see what is going on? Open up your browser and enable the debugger. Switch to the net tab. This will allow you to see the traffic for the page. With the debugger enabled, click on the differennt colors. You will see pings to the server for analysis stuff and you will see the images of the different colored cars.

Can JavaScript be used to change colors of an image? Yes, you could import the image into canvas and try doing some stuff with it, but in this case they use different images. I am going to bed now.

Eric
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 800

@Eric Pascarello: I said that in my application also we have the same feature. I just gave that link to make you people understand about what I meant when about changing the color of an image.

I am sure there are no images with other color in my application. I have done the same which you said to me earlier itself and came to know that it is not fetching new images. So I wondered how this could be possible and asked a question here.
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9315
    
109

chaitanya karthikk wrote: I have done the same which you said to me earlier itself and came to know that it is not fetching new images.

What is not fetching new images?


[My Blog] [JavaRanch Journal]
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 800

I mean it is not making requests to the server to get different images with different colors
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60045
    
  65

If you are going to talk in riddles, you're not going to get much help.

Are you saying that you have a web page that changes colors that haven't shown us?

Please explain what you are asking with more than cryptic one-sentence replies.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
chaitanya karthikk
Ranch Hand

Joined: Sep 15, 2009
Posts: 800

Bear Bibeault wrote:Please explain what you are asking with more than cryptic one-sentence replies.


Hi Bear, I think I explained everything in the beginning of the post itself.

All I need to know is there any way to change the color of an image (hue, saturation, brightness) in javascript? For example in Photoshop we have a tool called as curves, using that tool we can change the color of an image by adjusting the intensities of red, blue and green levels in it.

What I want to know is, is there any way to do the same using javascript or any javascript extended library.

Right now I am working on an application where there is a web page which displays a car and we have options to change the color of the car. When I tried to debug using firebug I came to know that no calls are made to the server to change the car body. he color of the car is being changed at the client side itself. Then I checked in my application whether there are any images of the car body. Interestingly I found only one image of the car body which is in grey color.

Today again I tried to debug and found that we are using jSmart library which is actually changing the color of the car at client side adjusting its red, blue, green levels. jSmart is built on javascript only. Now I want to know which javascript functions are available to change the color intensities?

I hope this could explain in detail.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to change the color of an image?
 
Similar Threads
Changing Color of a selectedtext in TextArea
I want to change colour of image.
How can I change color of Title bar in frame?
Image color changing
Hi, I want to color byte array of image pixels with any color say Color(25,25,50). please help.