我一张GIF的无背景图片,生成缩略图后,结果背景变成黑色了,
代码如下
oriImg = System.Drawing.Image.FromStream(picpath.PostedFile.InputStream);
newImg = oriImg.GetThumbnailImage(intFeThumbWidth, intFeThumbWidth * oriImg.Height/oriImg.Width,null,new System.IntPtr(0));
请问有什么办法生成的缩略图还是的原图一样,没有背景色呀.
代码如下
oriImg = System.Drawing.Image.FromStream(picpath.PostedFile.InputStream);
newImg = oriImg.GetThumbnailImage(intFeThumbWidth, intFeThumbWidth * oriImg.Height/oriImg.Width,null,new System.IntPtr(0));
请问有什么办法生成的缩略图还是的原图一样,没有背景色呀.
解决方案 »
- 使用相对地址导致伪静态后找不到css和图片
- fck 图片不显示
- 请教一下以下代码为什么找不到cookie文件
- masterpage 的viewstate 能否在usercontrol中使用???
- 请教如何在图片类型的控件上再放上按钮?
- 在WinXP上安装sqlserver2005失败,如何解决?
- 请推荐几本比较好的关于asp.net的书
- 紧急求助:???????net与SQLserver数据源连接不上请各位大侠指点!!!!
- windows xp 有IIS么?能在XP上编写asp.net程序么?
- 在asp.net中如何引用.cs文件呀
- 请大家推荐一款好的新闻程序
- 求重复字符串取出值,类似sql distinct的函数
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("classpic/"+"rs1.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("smallpic/"+"rs1.gif"))
image.Dispose()
End Sub
</script>
Try
If UpFile.ContentLength = 0 Then
Exit Sub
Else
Dim oImg As Image
Dim FileByteArray(UpFile.ContentLength) As Byte '图象文件临时储存Byte数组
Dim StreamObject As Stream = UpFile.InputStream '建立数据流对像
'读取图象文件数据,FileByteArray为数据储存体,0为数据指针位置、FileLnegth为数据长度
StreamObject.Read(FileByteArray, 0, UpFile.ContentLength)
If blnGetFromFile Then
oImg = oImg.FromFile(UpFile.FileName)
Else
oImg = oImg.FromStream(StreamObject)
End If
oImg = oImg.GetThumbnailImage(iWidth, iheight, Nothing, (New IntPtr).Zero)
Dim strFileExt As String = UpFile.FileName.Substring(UpFile.FileName.LastIndexOf("."))
'保存到本地
oImg.Save(IcoPath & strFileExt, GetImageType(UpFile.ContentType))
End If
Catch ex As Exception
Console.WriteLine(ex.Message)
Exit Sub
End Try
End Sub