<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>抠丁...CODING... &#187; JS</title>
	<atom:link href="http://ice.krystic.com/tag/js/feed/" rel="self" type="application/rss+xml" />
	<link>http://ice.krystic.com</link>
	<description>工作就是一千行代码，再接一千行代码</description>
	<lastBuildDate>Sat, 25 Jun 2011 01:56:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>用户照片的尺寸自适应</title>
		<link>http://ice.krystic.com/2009/05/photo_autosize/</link>
		<comments>http://ice.krystic.com/2009/05/photo_autosize/#comments</comments>
		<pubDate>Mon, 04 May 2009 01:13:17 +0000</pubDate>
		<dc:creator>krystic</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JS]]></category>
		<category><![CDATA[图片缩放]]></category>

		<guid isPermaLink="false">http://ice.krystic.com/?p=3</guid>
		<description><![CDATA[一直在给公司官网做 Flash 的照片编辑器, 上线后发现缩略图的问题解决了, 但大图片的尺寸问题又来了, 系统部没有时间修改大图浏览的模板 (5分钟的时间都没有), 只好用 JS 的方不来解决了  
尺寸并不是难点, 关键问题是平滑的缩放, IE 7 有一个新增加的独有样式 -ms-interpolation-mode 缩放效果比 Firefox 还要好, 详细说明可以看 MSDN 上的例子. IE 6 只能用率镜了, 没有其他办法. 代码如下:
样式表:
#photo img.autosize {
	width:350px;
	height:300px;
	border:none;
	background:#EDF9E5 url('../public/images/loading3d.gif') 10px 10px no-repeat;-ms-interpolation-mode:bicubic;padding:0px;
}
JS (jQuery):
function resize(width,height,src){
	width=parseInt(width);height=parseInt(height);
	if(width&#62;600){
		height=parseInt(600/width*height)+'px';
		width=600+'px';
	}
	if(jQuery.browser.msie&#38;&#38;jQuery.browser.version=='6.0'){
		$('#photo img.autosize').css({width:width,height:height,
		filter:'progid:DXImageTransform.Microsoft.AlphaImageLoader
		(enabled=true,sizingMethod=scale,src='+src+')'});
	}else{
		$('#photo img.autosize').css({width:width,height:height}).attr('src',src);
	}
	$('#photo .border').css('width',width);
}

$(function(){
	var photo=new Image();
	photo.onload=function(){resize(this.width,this.height,this.src);};
	photo.src='/cb/response/upload/images/playershow/1240545495096.jpg';
});

效果: http://event1.wanmei.com/html/playershow/zhuxian/view/player-267597.htm
]]></description>
			<content:encoded><![CDATA[<p>一直在给公司官网做 Flash 的照片编辑器, 上线后发现缩略图的问题解决了, 但大图片的尺寸问题又来了, 系统部没有时间修改大图浏览的模板 (5分钟的时间都没有), 只好用 JS 的方不来解决了 <img src='http://ice.krystic.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>尺寸并不是难点, 关键问题是平滑的缩放, IE 7 有一个新增加的独有样式 -ms-interpolation-mode 缩放效果比 Firefox 还要好, 详细说明可以看 <a href="http://samples.msdn.microsoft.com/workshop/samples/author/css/msInterpolation.htm">MSDN 上的例子</a>. IE 6 只能用率镜了, 没有其他办法. 代码如下:</p>
<p>样式表:</p>
<pre class="brush: css;">#photo img.autosize {
	width:350px;
	height:300px;
	border:none;
	background:#EDF9E5 url('../public/images/loading3d.gif') 10px 10px no-repeat;-ms-interpolation-mode:bicubic;padding:0px;
}</pre>
<p>JS (jQuery):</p>
<pre class="brush: jscript;">function resize(width,height,src){
	width=parseInt(width);height=parseInt(height);
	if(width&gt;600){
		height=parseInt(600/width*height)+'px';
		width=600+'px';
	}
	if(jQuery.browser.msie&amp;&amp;jQuery.browser.version=='6.0'){
		$('#photo img.autosize').css({width:width,height:height,
		filter:'progid:DXImageTransform.Microsoft.AlphaImageLoader
		(enabled=true,sizingMethod=scale,src='+src+')'});
	}else{
		$('#photo img.autosize').css({width:width,height:height}).attr('src',src);
	}
	$('#photo .border').css('width',width);
}

$(function(){
	var photo=new Image();
	photo.onload=function(){resize(this.width,this.height,this.src);};
	photo.src='/cb/response/upload/images/playershow/1240545495096.jpg';
});
</pre>
<p>效果: <a href="http://event1.wanmei.com/html/playershow/zhuxian/view/player-267597.htm" target="_blank">http://event1.wanmei.com/html/playershow/zhuxian/view/player-267597.htm</a></p>
]]></content:encoded>
			<wfw:commentRss>http://ice.krystic.com/2009/05/photo_autosize/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

