in

Data Techniques Online Forums

How is memory freed when using hImageData?

Last post 03-22-2007 4:59 AM by fritzl. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 03-20-2007 10:09 AM

    • fritzl
    • Not Ranked
    • Joined on 03-20-2007
    • Posts 2

    How is memory freed when using hImageData?

    I am populating an ImageMan control in a VB6 application via a webservice call that returns a byte array.  I have the conversion of a byte array to a global memory block, via GlobalAlloc and CopyMemory, working just fine.  My question is, do I have to explicitly free the allocated memory if I change images in the ImageMan control or does the control free the resource once it has been assigned?

     

    Thanks for any information,

    Fritz

     

  • 03-21-2007 3:30 PM In reply to

    Re: How is memory freed when using hImageData?

    Hi,

     
    Once the image data is in the control it will free the memory. Can you show me exactly how you are getting the data in just so we can be sure you are leaking anything ?

     

    Sean
    Data Techniques Online Support
  • 03-22-2007 4:59 AM In reply to

    • fritzl
    • Not Ranked
    • Joined on 03-20-2007
    • Posts 2

    Re: How is memory freed when using hImageData?

    The parameters to GetImage are normally encrypted state data for the user and numeric references, they are unimportant to the client side of the process:

     

        Dim svcSOAP As MSSOAPLib.SoapClient
        Set svcSOAP = New MSSOAPLib.SoapClient
            
        Dim url As String
        url = "http:\\devfritzl\TestService\ImageService.asmx?wsdl"
        svcSOAP.mssoapinit url
        
        Dim imgArray() As Byte
        imgArray = svcSOAP.GetImage("", -1, -1)  ' returns TIFF as byte array from server
        
        Dim isize As Long
        isize = UBound(imgArray) + 1
        Dim hMem As Long
        Dim lpMem As Long
        hMem = GlobalAlloc(GPTR, isize)
        lpMem = GlobalLock(hMem)
        CopyMemory ByVal lpMem, imgArray(0), isize
        GlobalUnlock (hMem)
        
        ImageMan1.AutoScale = Stretch
        ImageMan1.ImageDataSize = isize
        ImageMan1.hImageData = lpMem
        ImageMan1.Refresh

Page 1 of 1 (3 items)
Copyright 2007 Data Techniques, Inc. All Rights Reserved.