再100分讨论.net下缩放图片后质量有关问题

再100分讨论.net下缩放图片后质量问题
http://community.csdn.net/Expert/topic/5400/5400258.xml?temp=.1330683
前段时间,我发帖请教了.net下缩放图片后质量不好的问题。

非常感谢net_lover(【孟子E章】)   给我一个解决方法是使用Image.GetThumbnailImage方法来实现,的确这样的图像的确很高,几乎可以和ps缩放后生成的最高质量jpg相比。

但是这个方法有一个问题,如果原图中带有一个缩略图信息的话(比如这张图:http://adow.thmz.com/pk/images/k.jpg),GetThumbnailImage就会直接从图像中取得这个缩略图返回,而不是根据整张图片来生成。问题在于,我希望缩放后的图片大小是我定义的,如果一张原图中包括了缩略图被返回的话,就会从一个很小的尺寸(一般图像信息中包括的所录图只有128*96这样级别的)被放大到我指定的尺寸,那样的图片惨不忍睹。对这样的图片,大家看有什么方法解决。

------解决方案--------------------
up
------解决方案--------------------
up
------解决方案--------------------
不是太明白。
------解决方案--------------------
不会
------解决方案--------------------
原图中带有一个缩略图信息??
------解决方案--------------------
http://www.microsoft.com/china/MSDN/library/archives/library/DNAspp/html/colorquant.asp
------解决方案--------------------
楼主看看我写的代码,如果原图小于缩放以后的图的话,是不会执行的
/// <summary>
/// 按比例缩放图片,并非按原来大小裁剪
/// 水平长度优先.
/// </summary>
public static string ResizeImage(string _srcImage, int _DstX, string _dstPath)
{
System.Drawing.Image img = System.Drawing.Image.FromFile(_srcImage);
int newHight = img.Height;
int newWidth = img.Width;
while (newWidth > _DstX)//按比例缩小图片
{
newHight = Convert.ToInt32(newHight / 1.01);
newWidth = Convert.ToInt32(newWidth / 1.01);
}
System.Drawing.Image newimg = img.GetThumbnailImage(newWidth, newHight, new System.Drawing.Image.GetThumbnailImageAbort(ThumbCallBack), IntPtr.Zero);
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(newimg);
string tempName=GenRandomNumber(22) + ".jpg ";
bmp.Save(_dstPath + tempName , System.Drawing.Imaging.ImageFormat.Jpeg);
return tempName;
}

/// <summary>
/// 按比例缩放图片,并非按原来大小裁剪
/// 垂直长度优先
/// </summary>
public static string ResizeImage(int _DstY, string _srcImage, string _dstPath)
{
System.Drawing.Image img = System.Drawing.Image.FromFile(_srcImage);
int newHight = img.Height;
int newWidth = img.Width;
while (newWidth > _DstY)//按比例缩小图片
{
newHight = Convert.ToInt32(newHight / 1.01);
newWidth = Convert.ToInt32(newWidth / 1.01);
}
System.Drawing.Image newimg = img.GetThumbnailImage(newWidth, newHight, new System.Drawing.Image.GetThumbnailImageAbort(ThumbCallBack), IntPtr.Zero);
System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(newimg);
string tempName = GenRandomNumber(22) + ".jpg ";
bmp.Save(_dstPath + tempName, System.Drawing.Imaging.ImageFormat.Jpeg);
return tempName;
}
public static bool ThumbCallBack()
{
return true;
}
public static string GenRandomNumber(int _seed)
{
Random rdm = new Random(_seed);
return System.DateTime.Now.Millisecond.ToString() + rdm.Next(1, 65536).ToString();
}
------解决方案--------------------