ShowImage – Output an image as a binary stream to the Response object

' Output an image as a binary stream to the Response objectSub ShowImage(ByVal bmp As Bitmap)    ' Clear current content and set returned content type    HttpContext.Current.Response.Clear()    HttpContext.Current.Response.ContentType = "image/jpeg"    ' Save to the Response.OutputStream object    bmp.Save(HttpContext.Current.Response.OutputStream, _        Imaging.ImageFormat.Jpeg)    bmp.Dispose()    HttpContext.Current.Response.End()End Sub' Example:Private Sub Page_Load(ByVal sender As System.Object, _    ByVal e As System.EventArgs) Handles MyBase.Load    ' Create a bitmap with given width, height, and color depth.    Dim bmp As New Bitmap(400, 200, _        Drawing.Imaging.PixelFormat.Format16bppRgb565)    ' Get the underlying Graphics object.    Dim gr As Graphics = Graphics.FromImage(bmp)    ' Clear its background.    gr.Clear(Color.Red)    ' create a font    Dim fnt As New Font("Arial", 16, FontStyle.Regular, GraphicsUnit.Point)    Dim angle As Single    For angle = 0 To 360 Step 30        ' Reset coordinate transforms.        gr.ResetTransform()        ' Translate and rotate the coordinate system.        gr.TranslateTransform(200, 100)        gr.RotateTransform(angle)        ' Draw the (rotated) string.        gr.DrawString("   hello", fnt, Brushes.Yellow, 0, 0)    Next    ' Release resources.    fnt.Dispose()    gr.Dispose()    ShowImage(bmp)End Sub' Note: This code is taken from Francesco Balena's' "Programming Microsoft Visual Basic .NET" - MS Press 2002, ISBN 0735613753' You can read a free chapter of the book at '

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


The Latest

iOS app development

The Future of iOS App Development: Trends to Watch

When it launched in 2008, the Apple App Store only had 500 apps available. By the first quarter of 2022, the store had about 2.18 million iOS-exclusive apps. Average monthly app releases for the platform reached 34,000 in the first half of 2022, indicating rapid growth in iOS app development.

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a