MapWindow Home
Search MapWindow.org


  • Home
    • Download
    • Why MW
    • FAQ
    • Contact
  • Products
    • MapWindow
    • ActiveX
    • Plug-ins
  • Software Dev
    • Sample Code
    • Scripts
    • Source
    • Bugs
    • Support
    • Languages
  • Site Tools
    • Forums
    • Tutorials
    • Mailing Lists
    • Team
    • Site Stats
    • Links
  • Get Stuff
    • Buy a CD
    • Buy a T-Shirt
    • MW Book
    • ActiveX Book
    • Donate
    • Buy Support
  • Documentation
    • MWGIS App. User Guide
    • GISTools User Guide
    • MW Plug-ins Dev. Guide
    • MWGIS ActiveX Dev. Guide
    • MWGeoProc Dev. Guide

MapWinGIS:Utils hBitmapToPicture

From MapWindow GIS

Jump to: navigation, search

hBitmapToPicture

Converts an hBitmap to an IPictureDisp object..


VB.NET Usage

Function hBitmapToPicture(hBitmap As Integer) As stdole.IPictureDisp

            Parameters

hBitmap

A device context handle to a bitmap.
ReturnValue An IPictureDisp object created from the bitmap.

Sample Code

    'Use the user32 function "LoadImage" from user32.dll
        Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Integer, ByVal lpsz As String, ByVal un1 As Integer, ByVal n1 As Integer, ByVal n2 As Integer, ByVal un2 As Integer) As Integer
        '...
        Private Sub Utils_hBitmap()
        Dim hBitmap As Integer
        Dim iPictDisp As stdole.IPictureDisp
        Dim utils As New MapWinGIS.Utils()
        Dim image As New MapWinGIS.Image()
        'Constants used to get an hBitmap
        Const IMAGE_BITMAP As Integer = 0
        Const LR_LOADFROMFILE As Integer = &H10
        Const LR_CREATEDIBSECTION As Integer = &H2000
        'Load a bitmap from file storing a handle to the bitmap in hBitmap
        hBitmap = LoadImage(0, "C:\test.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE Or LR_CREATEDIBSECTION)
        'Get an IPictureDisp object from the hBitmap
        iPictDisp = utils.hBitmapToPicture(hBitmap)
        'Set the picture for the image to the IPictureDisp object created from the hBitmap
        image.Picture = iPictDisp
        'Add the image to the map
        Map1.AddLayer(image, True)
    End Sub
  

VB 6 Usage
Function hBitmapToPicture(hBitmap As Long) As IPictureDisp
            Parameters

hBitmap

A device context handle to a bitmap.
ReturnValue An IPictureDisp object created from the bitmap.

Sample Code

    'Use the user32 function "LoadImage" from user32.dll
        Private Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As Long, ByVal lpsz As String, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As Long, ByVal un2 As Long) As Long
        '...
    Private Sub Utils_hBitmap()
        Dim hBitmap As Long, hndl As Long
        Dim iPictDisp As IPictureDisp
        Dim utils As New MapWinGIS.utils
        Dim image As New MapWinGIS.image
        'Constants used to get an hBitmap
        Const IMAGE_BITMAP As Long = 0
        Const LR_LOADFROMFILE As Long = &H10
        Const LR_CREATEDIBSECTION As Long = &H2000
        'Load a bitmap from file storing a handle to the bitmap in hBitmap
        hBitmap = LoadImage(0, "C:\test.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE Or LR_CREATEDIBSECTION)
        'Get an IPictureDisp object from the hBitmap
        Set iPictDisp = utils.hBitmapToPicture(hBitmap)
        'Set the picture for the image to the IPictureDisp object created from the hBitmap
        Set image.Picture = iPictDisp
        'Add the image to the map
        hndl = Map1.AddLayer(image, True)
    End Sub

Retrieved from "http://www.mapwindow.org/wiki/index.php/MapWinGIS:Utils_hBitmapToPicture"
Views
  • Page
  • Discussion
  • View source
  • History
Personal tools
  • Log in / create account
  • What links here
  • Related changes
  • Upload file
  • Special pages
  • Printable version
  • Permanent link

Geospatial Software Lab

Copyright © 2008 - MapWindow Open Source Team
( last updated: November 12 2008.)
Home | Donate | Download | MapWindow GIS Desktop | MapWinGIS.ocx | Plug-ins | Contact | Lists | Bugs | Sample Code | Documentation
Code Repository | Open Source License | Discussion Forum | Wiki | Join the Team | Site Statistics | Links