summaryrefslogtreecommitdiff
path: root/wia/ProdScan/WiaUtil.h
blob: d395c86ca81bb9f18b08284a4d94bfe0d9457096 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**************************************************************************
*
*  Copyright � Microsoft Corporation
*
*  File Title:  WiaUtil.h
*
*  Project:     Production Scanning Driver Sample
*
*  Description: This file contains various helper functions for the driver.
*
***************************************************************************/

#pragma once

HRESULT
MakeFullItemName(
    _In_ IWiaDrvItem* pParent,
    _In_ BSTR bstrItemName,
    _Out_ BSTR* pbstrFullItemName);

HRESULT
CreateWIAChildItem(
    _In_ LPOLESTR pszItemName,
    _In_ IWiaMiniDrv *pIWiaMiniDrv,
    _In_ IWiaDrvItem *pParent,
    LONG lItemFlags,
    GUID guidItemCategory,
    _Inout_opt_ IWiaDrvItem **ppChild = NULL);

HRESULT
wiasGetDriverItemPrivateContext(
    _In_ BYTE* pWiasContext,
    _Out_ BYTE** ppWiaDriverItemContext);

HRESULT AllocateTransferBuffer(
    _Outptr_result_bytebuffer_(*pulBufferSize) BYTE** ppBuffer,
    _Out_ ULONG* pulBufferSize);

void
FreeTransferBuffer(
    _In_opt_ BYTE* pBuffer);

void
QueueWIAEvent(
    _In_ BYTE* pWiasContext,
    const GUID& guidWIAEvent);

inline LONG
BytesPerLine(
    LONG lImageWidth,
    LONG lBitDepth)
{
    //
    // The number of bytes per line include the padding necessary to make each uncompressed
    // line (DIB or Raw) DWORD aligned. When the image data is compressed the number of bytes
    // per line calculated here describes the original uncompressed image:
    //
    return (((lImageWidth * lBitDepth) + 31) / 32) * 4;
};