此代码来自Facebook聊天表情符号栏脂猴UserScript
ImagesURL = HttpsOn?'https://s-static.ak.fbcdn.net/images/':'http://static.ak.fbcdn.net/images/';
emotsInfo = [':)', ':(', ':p', ':D', ':o', ';)', '8)', '8|', '>:(', ':/', ':\'(', '3:)', 'O:)', ':*', '<3', '^_^', '-_-', 'o.O', '>:O', ':v', ':3'];
for(i=0;i<emotsInfo.length;i+=1) {
var fEmotsDom = document.createElement('img');
fEmotsDom.setAttribute('alt',emotsInfo[i]);
fEmotsDom.setAttribute('style','cursor: pointer; background-position: -'+ 16*i +'px 0px;');
fEmotsDom.setAttribute('src',ImagesURL + 'blank.gif');
fEmotsDom.setAttribute('class','emote_img');
fEmotsListDom.appendChild(fEmotsDom);
}这段代码从Facebook服务器带来Facebook的情感
我正在编写一个WPF,我理解所有的代码过程,除了从blank.gif获得情感
C#码
const string EmotionsResources = "http://static.ak.fbcdn.net/images/";
private Image Emoticons ( string E )
{
return ( new Image ( ) { Source = new BitmapImage ( new Uri ( EmotionsResources + E ) ) } );
}如果你想找到任何Facebook聊天情绪的来源。您将得到[ http://static.ak.fbcdn.net/images/blank.gif ]这段代码如何从这个链接中检索情感?
发布于 2011-05-19 00:46:02
我在这里猜测,但我认为类会触发一种检查alt文本的样式。(这是唯一有效的答案,一旦你交叉所有不可能的答案。每次迭代中唯一改变的是alt文本,所以这一定是触发它的原因。而css类选择器可以处理属性值)
换句话说-你被困住了。
编辑
所以我被吸引住了,所以我开始更深入地挖掘:
图像上的css样式包含以下css规则:
element.style {
background-position: 0px 0px;
}
.emote_img {
background: url(http://static.ak.fbcdn.net/rsrc.php/v1/zC/r/eKCEtE1PXyK.png) no-repeat;
overflow: hidden;
}第一个由脚本设置,第二个来自CSS文件。
所以。实际的图像可以在png文件中找到,即:
http://static.ak.fbcdn.net/rsrc.php/v1/zC/r/eKCEtE1PXyK.png:

(知道你可以在fb中使用这么多的表情符号,这很酷!:-)
您将在一张图像中看到所有的图像(这是为了保持带宽),因为图像大小为16*16,一次只显示一幅图像。背景位置细化负责移动图像,这样每次都会显示与大图像不同的图标。
因此,要在C#中获取图像,您将执行以下操作:
您可以对其进行裁剪,或者使用完全相同的技巧(更好的海事组织),如下所示:
<Canvas ClipToBounds="true" Width="16" Height="16">
<Image Source="http://static.ak.fbcdn.net/rsrc.php/v1/zC/r/eKCEtE1PXyK.png"
Canvas.Left="0" /> <!-- or -16, -32, -48 etc.. -->
</Canvas>https://stackoverflow.com/questions/6052477
复制相似问题