高分送:如何对图片进行缩放(数据库存的是路径)web c#

jackiecheng001 2006-12-18 09:45:17
(1)我现在在datalist里面做放了一个图片 图片的框架是固定大小,可是图片大小是不固定的,怎样让其显示为缩小后的 没有失真的图片
(2)AspNetPager这个控件谁用过 指点下,我连接培植都可以了,可是工具条就是不出现,为什么???
具体见:http://cpd.gm-apparel.com/Men_tee.aspx?type=1
...全文
390 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
jackiecheng001 2006-12-26
  • 打赏
  • 举报
回复
没有高人关注下吗
http://cpd.gm-apparel.com
具体就是这个上面的演示
如何把变形的图片给处理的好点
jackiecheng001 2006-12-20
  • 打赏
  • 举报
回复
private void reSizeProcess()
{
string pathStrSelText;
int n = 0;
foreach (ListViewItem SelItems in this.listView1.Items)
{
pathStrSelText = SelItems.Text;
Bitmap zc = new Bitmap(SelItems.Text);

我对应的这个地方是 bitmap zc = new bitmap("1.jpg") 而且1.jpg就在当前目录下
为什么提示说参数无效

K1933 2006-12-19
  • 打赏
  • 举报
回复
哦,不好意思,没有用过AspNetPager.
jackiecheng001 2006-12-19
  • 打赏
  • 举报
回复
private void reSizeProcess()
{
string pathStrSelText;
int n = 0;
foreach (ListViewItem SelItems in this.listView1.Items)
{
pathStrSelText = SelItems.Text;
Bitmap zc = new Bitmap(SelItems.Text);

我对应的这个地方是 bitmap zc = new bitmap("1.jpg") 而且1.jpg就在当前目录下
为什么提示说参数无效
jackiecheng001 2006-12-18
  • 打赏
  • 举报
回复
都吃饭了还怎么没有人啊
jackiecheng001 2006-12-18
  • 打赏
  • 举报
回复
但是我的图片格式不一定都相同 在固定后宽度后
这样就会造成一部分图片高 或者一部分低
zhaochong12 2006-12-18
  • 打赏
  • 举报
回复
ResizeBitmap会返回一个Bitmap, 把这个bitmap就是缩放过的图像.
zhaochong12 2006-12-18
  • 打赏
  • 举报
回复
--#... 我居然看到我写的代码了... 深感荣幸 :) 随便用, 随便用, 哈哈哈哈哈哈~
a208756 2006-12-18
  • 打赏
  • 举报
回复
<img src="sex.jpg" height="123px">

or
<img src="sex.jpg" width ="123px">
图片会自动按比列缩小的
jackiecheng001 2006-12-18
  • 打赏
  • 举报
回复
怎么没有人啊 奇怪 来人了啊
tcxx2008 2006-12-18
  • 打赏
  • 举报
回复
c#里image对象有个缩放图片的函数的。用智能感应就能找到,可以把图片固定大小
jackiecheng001 2006-12-18
  • 打赏
  • 举报
回复
楼上 老兄 能不能说个大概意思
好理解点
3q
kokubo_wing 2006-12-18
  • 打赏
  • 举报
回复
/// <summary>
/// 图像尺寸调节
/// </summary>
/// <param name="b">原始图像</param>
/// <param name="dstWidth">目标宽度</param>
/// <param name="dstHeight">目标高度</param>
/// <returns></returns>
public Bitmap ResizeBitmap(Bitmap b, int dstWidth, int dstHeight)
{
Bitmap dstImage = new Bitmap(dstWidth, dstHeight);
System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(dstImage);

// 设置插值模式
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Bilinear;

// 设置平滑模式
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

g.DrawImage(b,
new System.Drawing.Rectangle(0, 0, dstImage.Width, dstImage.Height),
new System.Drawing.Rectangle(0, 0, b.Width, b.Height),
System.Drawing.GraphicsUnit.Pixel);
g.Save();
g.Dispose();

return dstImage;
} // end of Resize


private void reSizeProcess()
{
string pathStrSelText;
int n = 0;
this.label1.Text="";
//string pathStrResize="";
//MessageBox.Show(NewWidth.ToString());
foreach (ListViewItem SelItems in this.listView1.Items)
{
pathStrSelText = SelItems.Text;
Bitmap zc = new Bitmap(SelItems.Text);

zc = ResizeBitmap(zc, NewHeight, NewWidth);
EncoderParameters ep = new EncoderParameters();
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();

//find the encoder with the image/jpeg mime-type
ImageCodecInfo ici = null;
foreach (ImageCodecInfo codec in codecs)
{
if (codec.MimeType == "image/jpeg")
ici = codec;
}

//We'll save images with 25%, 50%, 75% and 100% quality as compared with the original
//for (int x = 25; x < 101; x += 25)
//{
//Create an encoder parameter for quality with an appropriate level setting
ep.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, (long)50);
//}
// zc.Save(@"d:\1.jpg");
Directory.CreateDirectory(Path.GetDirectoryName(pathStrSelText) + @"\" + "bakPhoto" + @"\" + "reSize");
zc.Save((Path.GetDirectoryName(pathStrSelText) + @"\" + "bakPhoto" + @"\" + "reSize" + @"\" + Path.GetFileNameWithoutExtension(pathStrSelText) + Path.GetExtension(pathStrSelText)), ici, ep);
//Directory.CreateDirectory(Application.StartupPath + @"\bakPhoto");
//zc.Save(Application.StartupPath + @"\bakPhoto\" + Path.GetFileName(pathStrSelText), ici, ep);

if (n < 20)
{
this.label1.Text += "\n";
this.label1.Text += Path.GetFileName(SelItems.Text);
n++;
}
else
{
n = 0;
this.label1.Text = "";
}


}
this.label1.Text += "\n";
this.label1.Text += "工作完成.. 累死我了...";
}
九章落地 2006-12-18
  • 打赏
  • 举报
回复
關於問題1,好像不能直接設置得到樓主想要的效果,圖片顯示的大小就是圖片框的大小。
樓主可以這樣:不要設置<img>的高和寬,讓<img>自動取得圖片的高和寬,但把存放<img>的單元格固定大小。
jackiecheng001 2006-12-18
  • 打赏
  • 举报
回复
2以解决

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧