我有一个黑色的心PNG图像我想用不同的颜色显示.如何使用javascript/css/jquery更改心脏的颜色?
我正在努力打造一名衬衫设计师.所以背景是衬衫,心脏是印花设计(以及其他形状).
PS我知道这已经是重复但似乎没有任何解决方案有帮助.希望你们能帮助我,如果你已经这样做了.非常感谢!
解决方案更新:
解决方案是使用canvas.发现我的解决方案在这里.这是代码:
<h4>Original Image</h4>
<img id="testImage" src='black-heart.png'/>
<h4>Image copied to canvas</h4>
<canvas id="canvas" width="128" height="128"></canvas>
<h4>Modified Image copied to an image tag</h4>
<img id="imageData"/>
<script>
var canvas = document.getElementById("canvas"),
ctx = canvas.getContext("2d"),
image = document.getElementById("testImage");
ctx.drawImage(image,0,0);
var imgd = ctx.getImageData(0, 0, 128, 128),
pix = imgd.data,
uniqueColor = [0,0,255]; // Blue for an example, can change this value to be anything.
// Loops through all of the pixels and modifies the components.
for …Run Code Online (Sandbox Code Playgroud) 嗨,我刚升级到Mountain Lion.我创建了一个空的单视图应用程序并运行它.它第一次运行正常,但下一次运行将给我"有一个内部API错误"弹出警告TWICE.这和我的其他项目一样.它们运行正常,但在下次运行时会出现此错误.没有任何警告或任何特定警告信息.
不知道怎么解决这个问题?
真的很感谢你的帮助.