upload image as 24bit pixel format

115 views Asked by At

I use an asp file uploader to upload a bitmap image. The original image is saved in hard disk in 24 bit format but the uploader converted it to 32 bit and subsequently gives wrong result in my web application

How can I upload image as its original 24 bit?

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

There are 0 answers