Results 1 to 2 of 2

Thread: WIA 2.0 Vector.Add() method slow

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    WIA 2.0 Vector.Add() method slow

    For some reason Vector.Add() became ridiculously slow starting in Windows Vista.

    What is documented is that most support for non-still images (i.e. video) had been crippled because too many people were using it to bypass DRM. But along with this a new performance problem arose.

    Consider this code:

    Code:
    Option Explicit
    
    Private Sub Main()
        Const W As Long = 256
        Const H As Long = 256
        Const wiaFormatPNG As String = "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}"
        Dim Vector As Object
        Dim ImageProcess As Object
        Dim X As Long
        Dim Y As Long
        Dim Alpha As Long
    
        On Error Resume Next
        GetAttr App.Path & "\bin\wiaaut.dll"
        If Err Then
            On Error GoTo 0
            Set Vector = CreateObject("WIA.Vector")
            Set ImageProcess = CreateObject("WIA.ImageProcess")
        Else
            On Error GoTo 0
            'We found it, assume that it is the redist version and use it:
            With CreateObject("Microsoft.Windows.ActCtx")
                .Manifest = App.Path & "\bin\wiaaut.manifest"
                Set Vector = .CreateObject("WIA.Vector")
                Set ImageProcess = .CreateObject("WIA.ImageProcess")
            End With
        End If
    
        With Vector
            For Y = 0 To H - 1
                If Y And &H80& Then
                    Alpha = (Y And &H7F) * &H1000000 Or &H80000000
                Else
                    Alpha = Y * &H1000000
                End If
                For X = 0 To W - 1
                    .Add Alpha Or &H80D000 Or X
                Next
            Next
        End With
        With ImageProcess
            .Filters.Add .FilterInfos("ARGB").FilterID
            .Filters(1).Properties("ARGBData").Value = Vector
            .Filters.Add .FilterInfos("Convert").FilterID
            .Filters(2).Properties("FormatID").Value = wiaFormatPNG
            On Error Resume Next
            Kill "saved.png"
            On Error GoTo 0
            .Apply(Vector.ImageFile(W, H)).SaveFile "saved.png"
        End With
    
        MsgBox "Complete"
    End Sub
    By default, it will make use of the system copy of wiaaut.dll (assumption: running on Windows Vista or later). This will run, but take an absurd amount of elapsed time.


    If you have the WIA 2.0 SDK you can place a copy of the redistributable wiaaut.dll into the "bin" folder, and then the program runs in just a fraction of the time.

    Microsoft may not host that anymore, but currently the page at http://vbnet.mvps.org/index.html?cod...i/mswaidll.htm has a link to an archived copy. It appears to be legit and safe but if you download it be sure to run your own scan before using it.


    I have attached the demo, ready to be opened in VB6.exe and run. In order to test it with the redist WIA 2.0 you'll have to put your own copy of the redist DLL into the "bin" folder. The copy I have is version 5.1.2600.1106 but I think that was the only version that ever shipped in the SDK.


    Questions:

    Does anyone know why the now "stock" version is so slow? Is there another safe workaround besides packaging the redist wiaaut.dll and an appropriate SxS manifest?
    Attached Files Attached Files
    Last edited by dilettante; Nov 28th, 2020 at 10:17 PM. Reason: reposted with minor cleanup

  2. #2
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,121

    Re: WIA 2.0 Vector.Add() method slow

    Here are some benchmarks on several VMs tested

    Code:
    XP:     Complete in 0.171
    Vista:  Complete in 0.469
    Win7:   Complete in 0.601
    Win8.1: Complete in 0.816
    Win10:  Complete in 2.701 (not VM)
    Shows the evolution of this performance regression quite well. Probably they do not test this use-case at all.

    cheers,
    </wqw>

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