Change color of image in javascript

前端 未结 4 1402
滥情空心
滥情空心 2020-12-18 01:47

I want to change the color of a map image dynamically (say from blue to red). And I can\'t use canvas as I have to support IE.Any idea how i can manipulate an image on clien

4条回答
  •  盖世英雄少女心
    2020-12-18 02:35

    If the color transitions are very polarized (ie, not a lot of subtle gradient changes), you can make a transparent "hole" for the colored part of you image (use the 8-bit png or gif format to support IE6), and set the background-color to the real color:

    
    
    
    
    

    This does not address your quest to "manipulate an image on client side". Manipulating images in arbitrary ways is only possible with things like canvas, and some parts of IE-only vml. But if it's a simple color change, this trick might suffice.

提交回复
热议问题