Bitmap 的应用问题

sisiz 2008-04-22 11:39:35
public partial class Public_WebUserControl_NewPicNoun : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int thumbnailWidth = 10, thumbnailHeight = 10;

BMNounInsert TJCiTiao = new BMNounInsert();

Bitmap fullPicture = null;
ArrayList PicName = new ArrayList();

ArrayList picList = TJCiTiao.NewPicNounInfo();

if (picList.Count != 0)
{
for (int k = 0; k < picList.Count; k++)
{
string[] Pic = (string[])picList[k];

PictureInfo picNouns = new PictureInfo();

//picNouns.GID = new Guid (szClass[0]);
picNouns.PName = Pic[1].ToString();

fullPicture = new Bitmap(picNouns.PName);

PicName.Add(picNouns);

}
}
string PathToSave = "Public\\UploadWiKiPic\\";//图片的保存的地方
Bitmap thumbnail = ResizeImage(fullPicture, thumbnailWidth, thumbnailHeight, ResizeOption.FixedWidthHeight);
//thumbnail.Save(PathToSave + ThumbnailFilename, ImageFormat.Jpeg);

Data_picList.DataSource = ??????????????怎么付给数据源
Data_picList.DataBind();


}

}
public enum ResizeOption
{

NoResize,

FixedWidthHeight,

MaintainAspectWidth,

MaintainAspectHeight
}
private Bitmap ResizeImage(Bitmap original, int newWidth, int newHeight, ResizeOption option)
{
if (original.Width == 0 || original.Height == 0 || newWidth == 0 || newHeight == 0) return null;
if (original.Width < newWidth) newWidth = original.Width;
if (original.Height < newHeight) newHeight = original.Height;

switch (option)
{
case ResizeOption.NoResize:
newWidth = original.Width;
newHeight = original.Height;
break;
case ResizeOption.FixedWidthHeight:
break;
case ResizeOption.MaintainAspectWidth:
newHeight = (newWidth * original.Height / original.Width);
break;
case ResizeOption.MaintainAspectHeight:
newWidth = (newHeight * original.Width / original.Height);
break;
}
Bitmap newBitmap = new Bitmap(newWidth, newHeight);
Graphics g = Graphics.FromImage(newBitmap);
g.DrawImage(original, 0, 0, newWidth, newHeight);
return newBitmap;
}


}
...全文
56 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wenbin 2008-04-23
  • 打赏
  • 举报
回复
把图片转换流的形式?
卧_槽 2008-04-23
  • 打赏
  • 举报
回复
Data_picList 是个什么东西?

110,534

社区成员

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

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

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