将图像上传为24位像素格式

时间:2015-06-07 21:51:56

标签: asp.net image 24-bit

我使用asp文件上传器上传位图图像。原始图像以24位格式保存在硬盘中,但上传器将其转换为32位,随后在我的Web应用程序中显示错误结果

如何将图片上传为原始的24位?

Dim face As search_eng.face 
face = New face() ' initialize object (face)
If (Not System.IO.Directory.Exists(getpath() + "\pics\")) Then 
    System.IO.Directory.CreateDirectory(getpath() + "\pics\") 
End If

Dim i = 0
While System.IO.File.Exists(getpath() + "\pics\" + i.ToString + ".jpg") 
    i += 1
End While

FileUpload1.SaveAs(getpath() + "\pics\" + i.ToString + ".jpg")
Image1.ImageUrl = "\pics\" + i.ToString + ".jpg"
Dim fs As System.IO.FileStream   ' define a file stream
fs = New IO.FileStream(getpath() + "\pics\" + i.ToString + ".jpg",  IO.FileMode.Open, IO.FileAccess.Read)  ' open for read

Dim img As System.Drawing.Image
img = System.Drawing.Image.FromStream(fs)
fs.Dispose()

Dim btimg As System.Drawing.Bitmap   
Dim Original_img As System.Drawing.Bitmap
btimg = New Drawing.Bitmap(img, img.Width, img.Height)
Original_img = New Drawing.Bitmap(img, img.Width, img.Height)

img = btimg
Original_img = btimg
Original_img.Save("d:\after_open_Web.bmp")

0 个答案:

没有答案