cuốn sách gpt4 ai đã làm

jquery - Cách vẽ đường viền hình ảnh png (viền) với độ trong suốt

In lại Tác giả: Walker 123 更新时间:2023-11-28 13:18:33 27 4
mua khóa gpt4 Nike

如何绘制具有透明度的png图像轮廓(边框)。

就像我们有这张图片:nhập mô tả hình ảnh ở đây

我们想要这个:nhập mô tả hình ảnh ở đây

我正在通过 HTML5 创建图像阴影,但无法获得我想要的。我想使用 HTML5 或 jquery 或两者来绘制它,如果有人有其他想法,请告诉我。


Canvas:



Your browser does not support the HTML5 canvas tag.


var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
var img=document.getElementById("scream");

ctx.shadowColor="#000000";
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 0;
ctx.shadowBlur = 15;
ctx.drawImage( img, 25, 25 );

câu trả lời hay nhất

我认为cái này问题很有用也许这段代码




解决此问题的另一种方法是使用这个简单的 jQuery 插件,因为我无法更改结构。我会给出出处,但老实说,我不记得我是在哪里找到它的。

/* IE PNG fix multiple filters */
(function ($) {
if (!$) return;
$.fn.extend({
fixPNG: function(sizingMethod, forceBG) {
if (!($.browser.msie)) return this;
var emptyimg = "empty.gif"; //Path to empty 1x1px GIF goes here
sizingMethod = sizingMethod || "scale"; //sizingMethod, defaults to scale (matches image dimensions)
this.each(function() {
var isImg = (forceBG) ? false : jQuery.nodeName(this, "img"),
imgname = (isImg) ? this.src : this.currentStyle.backgroundImage,
src = (isImg) ? imgname : imgname.substring(5,imgname.length-2);
this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + sizingMethod + "')";
if (isImg) this.src = emptyimg;
else this.style.backgroundImage = "url(" + emptyimg + ")";
});
trả lại cái này;
}
});
})(jQuery);

关于jquery - 如何绘制具有透明度的png图像轮廓(边框),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14833544/

27 4 0
Chứng chỉ ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com
Xem sitemap của VNExpress