请帮我把vb.NET 转 c#.NET代码,万分感谢!! 50
<scriptlanguage="VB"runat="server">SubPage_Load(senderAsObject,eAsEventArgs)Dimimage,...
<script language="VB" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim image,aNewImage As System.Drawing.Image
dim width,height,newwidth,newheight as integer
Dim callb As System.Drawing.Image.GetThumbnailImageAbort
'生成缩略图
image=System.Drawing.Image.FromFile(Server.MapPath("a.jpg"))
width=image.Width
height=image.height
if width>height then
newwidth=110
newheight=image.height/image.Width*newwidth
else
newheight=110
newwidth=image.Width/image.height*newheight
end if
aNewImage=image.GetThumbnailImage(newwidth,newheight,callb,new System.IntPtr())
aNewImage.Save(Server.MapPath("a_s.jpg"))
image.Dispose()
End Sub
</script>
上面的代码是VB的,请高手帮忙转为C#的,现在是直接生成式的,请好人做到底,帮下忙改成能调用式的。
比如GetThumbnailImage("abc.jpg")就能生成对应缩略图,谢谢。
希望测试一下,把Sub 替换成VOID怎么可能通得过? 展开
Sub Page_Load(sender As Object, e As EventArgs)
Dim image,aNewImage As System.Drawing.Image
dim width,height,newwidth,newheight as integer
Dim callb As System.Drawing.Image.GetThumbnailImageAbort
'生成缩略图
image=System.Drawing.Image.FromFile(Server.MapPath("a.jpg"))
width=image.Width
height=image.height
if width>height then
newwidth=110
newheight=image.height/image.Width*newwidth
else
newheight=110
newwidth=image.Width/image.height*newheight
end if
aNewImage=image.GetThumbnailImage(newwidth,newheight,callb,new System.IntPtr())
aNewImage.Save(Server.MapPath("a_s.jpg"))
image.Dispose()
End Sub
</script>
上面的代码是VB的,请高手帮忙转为C#的,现在是直接生成式的,请好人做到底,帮下忙改成能调用式的。
比如GetThumbnailImage("abc.jpg")就能生成对应缩略图,谢谢。
希望测试一下,把Sub 替换成VOID怎么可能通得过? 展开
4个回答
展开全部
【楼主要的代码如下】
</script
[script()]
[language()]
[=()]
[VB()]
[runat()]
[=()]
[server()]
void Page_Load(object sender, EventArgs e) {
System.Drawing.Image image;
System.Drawing.Image aNewImage;
int width;
int height;
int newwidth;
int newheight;
System.Drawing.Image.GetThumbnailImageAbort callb;
// )e�
image = System.Drawing.Image.FromFile(Server.MapPath("a.jpg"));
width = image.Width;
height = image.height;
if ((width > height)) {
newwidth = 110;
newheight = (image.height
/ (image.Width * newwidth));
}
else {
newheight = 110;
newwidth = (image.Width
/ (image.height * newheight));
}
aNewImage = image.GetThumbnailImage(newwidth, newheight, callb, new System.IntPtr());
aNewImage.Save(Server.MapPath("a_s.jpg"));
image.Dispose();
}
希望采纳。
</script
[script()]
[language()]
[=()]
[VB()]
[runat()]
[=()]
[server()]
void Page_Load(object sender, EventArgs e) {
System.Drawing.Image image;
System.Drawing.Image aNewImage;
int width;
int height;
int newwidth;
int newheight;
System.Drawing.Image.GetThumbnailImageAbort callb;
// )e�
image = System.Drawing.Image.FromFile(Server.MapPath("a.jpg"));
width = image.Width;
height = image.height;
if ((width > height)) {
newwidth = 110;
newheight = (image.height
/ (image.Width * newwidth));
}
else {
newheight = 110;
newwidth = (image.Width
/ (image.height * newheight));
}
aNewImage = image.GetThumbnailImage(newwidth, newheight, callb, new System.IntPtr());
aNewImage.Save(Server.MapPath("a_s.jpg"));
image.Dispose();
}
希望采纳。
展开全部
</script
[script()]
[language()]
[=()]
[VB()]
[runat()]
[=()]
[server()]
void Page_Load(object sender, EventArgs e) {
System.Drawing.Image image;
System.Drawing.Image aNewImage;
int width;
int height;
int newwidth;
int newheight;
System.Drawing.Image.GetThumbnailImageAbort callb;
// )e�
image = System.Drawing.Image.FromFile(Server.MapPath("a.jpg"));
width = image.Width;
height = image.height;
if ((width > height)) {
newwidth = 110;
newheight = (image.height
/ (image.Width * newwidth));
}
else {
newheight = 110;
newwidth = (image.Width
/ (image.height * newheight));
}
aNewImage = image.GetThumbnailImage(newwidth, newheight, callb, new System.IntPtr());
aNewImage.Save(Server.MapPath("a_s.jpg"));
image.Dispose();
}
[script()]
[language()]
[=()]
[VB()]
[runat()]
[=()]
[server()]
void Page_Load(object sender, EventArgs e) {
System.Drawing.Image image;
System.Drawing.Image aNewImage;
int width;
int height;
int newwidth;
int newheight;
System.Drawing.Image.GetThumbnailImageAbort callb;
// )e�
image = System.Drawing.Image.FromFile(Server.MapPath("a.jpg"));
width = image.Width;
height = image.height;
if ((width > height)) {
newwidth = 110;
newheight = (image.height
/ (image.Width * newwidth));
}
else {
newheight = 110;
newwidth = (image.Width
/ (image.height * newheight));
}
aNewImage = image.GetThumbnailImage(newwidth, newheight, callb, new System.IntPtr());
aNewImage.Save(Server.MapPath("a_s.jpg"));
image.Dispose();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
楼主你不知道有动软代码生成器吗? 可以实现VB和C#互转。
说不定楼上的都是用它来转的。。
你去下载一个动软代码生成器吧。。
说不定楼上的都是用它来转的。。
你去下载一个动软代码生成器吧。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
不帮
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询