Wia API - Error on changing transfer file format

1

I tried to control my Wifi scanner using the Windows Wia API.

I followed the tutorial on:
https://docs.microsoft.com/en-us/windows/win32/wia/-wia-wia-tutorial

And I looked at the Examples:
https://github.com/pauldotknopf/WindowsSDK7-Samples/tree/master/multimedia/wia

I basically copied the code from the datatransfer project:
https://github.com/pauldotknopf/WindowsSDK7-Samples/tree/master/multimedia/wia/datatransfer

And everthing works fine. I can communicate with my scanner and scan a document to a ".BMP" file.

Now I'd like to play around with some settings.I startet with trying to change the file format.

in DataTransfer.cpp:
https://github.com/pauldotknopf/WindowsSDK7-Samples/blob/master/multimedia/wia/datatransfer/DataTransfer.cpp

The scan happens in HRESULT DownloadItem(IWiaItem2* pWiaItem2 , BOOL bTransferFlag).
I thought the file format is specified there:


HRESULT DownloadItem(IWiaItem2* pWiaItem2 , BOOL bTransferFlag
{
    ...

                    GUID itemCategory = GUID_NULL;
                    ReadPropertyGuid(pWiaItem2,WIA_IPA_ITEM_CATEGORY,&itemCategory );

                    if( (!IsEqualIID(itemCategory,WIA_CATEGORY_FINISHED_FILE)) || (!IsEqualIID(itemCategory,WIA_CATEGORY_FOLDER)) )
                    {                     
                        /* WiaImgFmt_BMP sets the format to ".BMP" */
                        hr = WritePropertyGuid(pWiaPropertyStorage,WIA_IPA_FORMAT,WiaImgFmt_BMP);
                    }

                    if(FAILED(hr))
                    {
                        ReportError(TEXT("WritePropertyGuid() failed in DownloadItem().Format couldn't be set to BMP"),hr);
                    }

    ...

}

So i tried to change WiaImgFmt_BMP to other formats like WiaImgFmt_JPEG or WiaImgFmt_PNG but they return the Error: HRESLUT: 0x80070057.

How can I make this work ?

I thought that maybe the scanner doesn't support the other formats, but I don't know how to check that. When I researched this, I only found reference to the Wia Mini Driver. But I don't quite understand the difference between the API and the driver. If somebody could explain this to me I'd appreciate it.

Windows fax and scan does provide the PNG, JPEG format and I think they also use Wia, so I'd be surprised if the formats aren't supported.

c++
windows
format
wia
asked on Stack Overflow May 18, 2020 by Ambadrant • edited May 18, 2020 by Farbod Ahmadian

1 Answer

1

I think it only support BMP and JPEG, you can use IWiaTransfer::EnumWIA_FORMAT_INFO method to know the format it support.

answered on Stack Overflow Jan 26, 2021 by HappyMax0

User contributions licensed under CC BY-SA 3.0