Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleUse the LoadImage API function to antialias an image
Keywordsantialias, anti-alias, anti alias, alias, LoadImage, resize
CategoriesGraphics
 

Load the picture using LoadImage. This function returns a handle to a bitmap containing the image at the indicated size. Use SelectObject to select the bitmap into a PictureBox.

 
' Use LoadImage to load the picture.
Private Sub LoadWithLoadImage(ByVal pic As PictureBox, _
    ByVal file_name As String)
Dim hbm As Long
Dim wid As Long
Dim hgt As Long

    ' Load the image using LoadImage.
    wid = pic.ScaleX(pic.ScaleWidth, pic.ScaleMode, _
        vbPixels)
    hgt = pic.ScaleY(pic.ScaleHeight, pic.ScaleMode, _
        vbPixels)
    hbm = LoadImage(ByVal 0&, file_name, _
        IMAGE_BITMAP, wid, hgt, &H10)

    ' Select the image into the PictureBox's device context.
    pic.AutoRedraw = True
    SelectObject pic.hdc, hbm

    ' Delete the bitmap.
    DeleteObject hbm
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated