Loading...

How to optimize my code ?

Support for GdViewer OCX and GdViewer Pro ActiveX/SDK.

How to optimize my code ?

Postby kylex » Mon Sep 10, 2007 11:48 pm

Hi,
I have three questions for you :):

1) I have a problem regarding memory deallocation. Executing the following code many times repetitively in Access 2003 - VBA causes Windows to go out of memory:

Code: Select all
    If GdPicture.TwainOpenDefaultSource = True Then
        GdPicture.TwainSetErrorMessage True
        GdPicture.TwainSetHideUI True
        GdPicture.TwainSetCurrentPixelType TWPT_GRAY
        GdPicture.TwainSetCurrentResolution 200
        GdPicture.TwainSetCurrentBitDepth 8
       
        nImageID = GdPicture.CreateImageFromTwain(Me.hwnd)

        GdPicture.TwainCloseSourceManager (Me.hwnd)

        If nImageID <> 0 Then
            GdPicture.SaveAsByteArray [...]
            gdViewer.ClosePicture 'Previous picture
            gdViewer.DisplayFromImageRef nImageID
            gdViewer.SetZoomWidth
            gdViewer.SetVScrollBarPosition 0
        end if
        [...]



I create an image from scanner, close the previously opened picture in the viewer, then assign the newly created picture to gdViewer. With this code, each time, I close a picture created with gdPicture in gdViewer, but the picture remains loaded in memory. If I close the picture from gdPicture control, after it is loaded in gdViewer, I get an automation error if I work with the viewer.

2) The viewer works correctly if ViewerQuality = QualityLow. For other kind of qualities there are problems. For example, setting ViewerQuality = QualityBilinear causes scrolling to be slower than ViewerQuality = QualityBicubicHQ.

3) Are there any ways to do the following:
Code: Select all
            gdViewer.SetZoomWidth
            gdViewer.SetVScrollBarPosition 0

and avoid the flikering produced by the second instruction?

Thanks very much for your support.
Kylex
kylex
 
Posts: 7
Joined: Sat Jul 28, 2007 11:39 pm

Postby Loïc » Tue Sep 11, 2007 9:56 pm

3) Are there any ways to do the following:
Code:

gdViewer.SetZoomWidth
gdViewer.SetVScrollBarPosition 0


and avoid the flikering produced by the second instruction?


Yes:

Code: Select all
gdViewer.LockScreen = True
gdViewer.SetZoomWidth
gdViewer.SetVScrollBarPosition 0
gdViewer.LockScreen = False
gdViewer.Redraw()
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4442
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Postby Loïc » Tue Sep 11, 2007 10:15 pm

2) The viewer works correctly if ViewerQuality = QualityLow. For other kind of qualities there are problems. For example, setting ViewerQuality = QualityBilinear causes scrolling to be slower than ViewerQuality = QualityBicubicHQ.


There is no problem kylex.

It is just that the QualityBicubicHQ algorithm can be faster than the QualityBilinear algorithm in some cases. These algorithms com from the microsoft gdiplus.dll library. If you want an explication about these speed diferences I suggest you to ask the question into a msdn newsgroup.

Best regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4442
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Postby Loïc » Tue Sep 11, 2007 10:16 pm

Else, for your first question I need the complete code.


Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4442
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Postby kylex » Sun Sep 16, 2007 9:24 pm

Hi, I checked the latest release and both memory management and viewing wrong behaviors are fixed. Thanks.

Kylex
kylex
 
Posts: 7
Joined: Sat Jul 28, 2007 11:39 pm


Return to GdViewer [Pro] ActiveX

Who is online

Users browsing this forum: Exabot [Bot] and 1 guest