I get an image from SQL server, add a watermark to it and display it on a page as an Bmp format, however, when I change the format to “Jpeg” it won’t show the image! Any idea? ….. 'get the image from SQl server and store it in Img as byte Dim memStream As New
MemoryStream Dim img As Byte() = myDataReader.Item("SavedImage") myConnection.Close() 'Copy raw data to a memory stream Dim ms As New MemoryStream ms.Write(img, 0, img.Length) 'Create a bitmap from the memory stream Dim imgOutput As New Bitmap(ms) ms.Close()
Dim waterMark As Image WaterMark = Image.FromFile(Server.MapPath("Images\watermark.gif")) Dim g As Graphics g = g.FromImage(imgOutput) g.DrawImage(waterMark, New Point(10, 50)) g.Dispose() ‘this won’t work!!! Response.ContentType = "image/jpeg" imgOutput.Save(memStream,
ImageFormat.Jpeg) ‘this works. Response.ContentType = "image/jpeg" imgOutput.Save(memStream, ImageFormat.Bmp) ‘and the memory stream to the output memStream.WriteTo(Response.OutputStream) Response.End() memStream.Close() When image is displayed in Bmp it has
a huge size! That’s why I like to display/compress it to “Jpeg” format. Thanks.
molavi
Member
322 Points
65 Posts
Problem with adding watermark and show the image as Jpeg?
Apr 18, 2004 09:33 PM|LINK