Results 1 to 6 of 6

Thread: [RESOLVED] Scale image (memorystream)

Threaded View

  1. #1

    Thread Starter
    PowerPoster Radjesh Klauke's Avatar
    Join Date
    Dec 2005
    Location
    Sexbierum (Netherlands)
    Posts
    2,244

    Resolved [RESOLVED] Scale image (memorystream)

    Hi,

    I'm loading an image into a memorystream from my server.

    Dim MS As New MemoryStream(wc.DownloadData(result)) ' wc = webclient
    Dim myimage = Image.FromStream(MS)
    mytab.image = myimage

    This works, but I want to scale the image to 16px*16px. How do I do that?

    I tried the following, but the images isn't smaller:

    vb.net Code:
    1. Dim bm As New Bitmap(myimage)
    2. Dim w As Integer = 16 'image width.
    3. Dim h As Integer = 16 'image height
    4. Dim thumb As New Bitmap(w, h)
    5. Dim g As Graphics = Graphics.FromImage(thumb)
    6. g.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
    7. g.DrawImage(bm, New Rectangle(0, 0, w, h), New Rectangle(0, 0, bm.Width, bm.Height), GraphicsUnit.Pixel)
    8. g.Dispose()
    9. mytab.image = bm

    EDIT: The image can be .png (transparent), bmp, jp(e)g, gif

    Thanks in advance.
    Last edited by Radjesh Klauke; Sep 8th, 2012 at 06:43 AM.


    If you found my post helpful, please rate it.

    Codebank Submission: FireFox Browser (Gecko) in VB.NET, Load files, (sub)folders treeview with Windows icons

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width