IWiaSegmentationFilter::D etectRegions 메서드
각 하위 영역을 별도의 이미지 항목으로 가져올 수 있도록 플랫베드 도금에 배치된 이미지의 하위 영역을 결정합니다.
구문
HRESULT DetectRegions(
[in] LONG lFlags,
[in] IStream *pInputStream,
[in] IWiaItem2 *pWiaItem2
);
매개 변수
-
lFlags [in]
-
형식: LONG
현재 사용되지 않습니다. 0으로 설정해야 합니다.
-
pInputStream [in]
-
형식: IStream*
IStream 미리 보기 이미지에 대한 포인터를 지정합니다.
-
pWiaItem2 [in]
-
형식: IWiaItem2*
pInputStream을 획득한 IWiaItem2 항목에 대한 포인터를 지정합니다. 구분 필터는 이 항목에 대한 자식 항목을 만듭니다.
반환 값
형식: HRESULT
메서드가 성공하면 S_OK를 반환하고, 그러지 않으면 HRESULT 오류 코드를 반환합니다.
설명
이 메서드는 pInputStream으로 표시되는 이미지의 하위 영역을 결정합니다. 검색되는 각 하위 지역에 대해 pWiaItem2 매개 변수에 지정된 IWiaItem2 항목에 대한 자식 항목을 만듭니다. 각 자식 항목에 대해 구분 필터는 다음 스캐너 WIA 항목 속성 상수를 사용하여 검사할 영역의 경계 사각형에 대한 값을 설정해야 합니다.
고급 필터에는 드라이버가 기울이기 해제를 지원하는 경우 WIA_IPS_DESKEW_X 및 WIA_IPS_DESKEW_Y 같은 다른 스캐너 WIA 항목 속성 상수도 필요할 수 있습니다.
애플리케이션이 IWiaSegmentationFilter::D etectRegions 를 두 번 이상 호출하는 경우 애플리케이션은 먼저 IWiaSegmentationFilter::D etectRegions에 대한 마지막 호출로 만든 자식 항목을 삭제해야 합니다.
애플리케이션이 pInputStream으로 이미지를 가져오는 것과 IWiaSegmentationFilter::D etectRegions에 대한 호출 사이에 속성을 pWiaItem2로 변경하는 경우 원래 속성(즉, 스트림을 획득할 때 항목이 가진 속성)을 복원해야 합니다. 이 작업은 GetPropertyStream 및 SetPropertyStream에서 수행할 수 있습니다.
호출이 동일한 스트림을 세분화 필터에 두 번 이상 전달하는 경우 애플리케이션은 IStream 을 다시 설정해야 합니다. 또한 애플리케이션은 초기 다운로드 후와 IWiaSegmentationFilter::D etectRegions를 호출하기 전에 스트림을 다시 설정해야 합니다.
예제
구분은 DetectSubregions에 전달된 스트림(pImageStream
)에서 지역 검색을 수행합니다. 이 예제에 사용된 CreateSegmentationFilter 메서드에 대한 GetExtension 을 참조하세요.
HRESULT
DetectSubregions(
IN IStream *pImageStream,
IN IWiaItem2 *pWiaItem2)
{
HRESULT hr = S_OK;
IWiaSegmentationFilter* pSegmentationFilter = NULL;
if (!pWiaItem2 || !pImageStream)
{
hr = E_INVALIDARG;
}
if (SUCCEEDED(hr))
{
hr = CreateSegmentationFilter(pWiaItem2, &pSegmentationFilter);
}
if (SUCCEEDED(hr))
{
hr = pSegmentationFilter->DetectRegions(0,pImageStream, pWiaItem2);
}
if (pSegmentationFilter)
{
pSegmentationFilter->Release();
pSegmentationFilter = NULL;
}
return hr;
}
DownloadPreviewImage는 미리 보기 구성 요소의 GetNewPreview 메서드를 호출하여 스캐너에서 이미지 데이터를 다운로드합니다. 그런 다음, 애플리케이션 사용자가 감지하는 각 지역에 대해 pWiaItem2 아래에 자식 항목을 만드는 구분 필터를 호출하려는 경우 DetectSubregions를 호출합니다. 이 예제에 사용된 DetectSubregions 메서드는 IWiaSegmentationFilter::D etectRegions 를 참조하세요.
이 예제에서 애플리케이션 사용자는 검사 상자를 클릭하여 설정합니다m_bUseSegmentationFilter
. 애플리케이션이 이를 지원하는 경우 먼저 CheckExtension을 호출하여 드라이버에 구분 필터가 있는지 검사 합니다. 이 작업을 수행하는 방법을 보여 주는 CheckImgFilter 메서드 예제는 GetNewPreview 를 참조하세요.
HRESULT
DownloadPreviewImage(
IN IWiaItem2 *pWiaFlatbedItem2)
{
HRESULT hr = S_OK;
BOOL bHasImgFilter = FALSE;
IWiaTransferCallback *pAppWiaTransferCallback = NULL;
hr = CheckImgFilter(pWiaFlatbedItem2, &bHasImgFilter)
if (SUCCEEDED(hr))
{
if (bHasImgFilter)
{
IWiaPreview *pWiaPreview = NULL;
// In this example, the AppWiaTransferCallback class implements
// the IWiaTransferCallback interface.
// The constructor of AppWiaTransferCallback sets the reference count
// to 1.
pAppWiaTransferCallback = new AppWiaTransferCallback();
hr = pAppWiaTransferCallback ? S_OK : E_OUTOFMEMORY;
if (SUCCEEDED(hr))
{
// Acquire image from scanner
hr = m_pWiaPreview->GetNewPreview(pWiaFlatbedItem2,
0,
pAppWiaTransferCallback);
}
//
// Check the application UI for whether the user wants
// to use the segmentation filter indicated by the value
// of m_bUseSegmentationFilter.
//
// m_FlatbedPreviewStream is the stream that
// AppWiaTransferCallback::GetNextStream returned for the
// flatbed item.
// This stream is where the image data is stored after
// the successful return of GetNewPreview.
// The stream is passed into the segmentation filter
// for region detection.
if (SUCCEEDED(hr) && m_bUseSegmentationFilter)
{
DetectSubregions(m_FlatbedPreviewStream, pWiaFlatbedItem2);
}
if (pAppWiaTransferCallback)
{
// If the call to GetNewPreview was successful, the
// preview component calls AddRef on the callback so
// this call doesn't delete the object.
pAppWiaTransferCallback->Release();
}
}
else
{
// Do not create an instance of preview component if the driver
// does not come with an image-processing filter.
// You can use a segmentation filter, however, if the driver
// comes with one (omitted here).
}
}
return hr;
}
요구 사항
요구 사항 | 값 |
---|---|
지원되는 최소 클라이언트 |
Windows Vista [데스크톱 앱만 해당] |
지원되는 최소 서버 |
Windows Server 2008 [데스크톱 앱만 해당] |
헤더 |
|
IDL |
|