Image Extender 提供三個 API 來查詢表格直欄中已編目的影像。 這些 API 僅在需要查詢字串或將查詢物件當作輸入時不同:
API | 輸入 |
---|---|
QbQueryStringSearch | 查詢字串 |
QbQuerySearch | 查詢物件 handle |
QbQueryNameSearch | 查詢物件名稱 |
在這三個 API 中,您也要:
您也要指示輸出結構陣列包含搜尋結果。因此,Image Extender 會將特性值與查詢特性值最相似的目標影像之 handle 傳回這些結構中。 也會傳回每一個影像的分數,其指示影像的特性值與查詢的相似性。 此結構定義在 QBIC 併入 (標頭) 檔 dmbqbapi.h 中,如下所示:
typedef struct{ char imageHandle[MMDB_BASE_HANDLE_LEN+1]; SQLDOUBLE SCORE } QbResult;
您必須配置足夠保留所指定最大結果數目的陣列, 並在 API 中指示陣列。 您也要指示計數器;Image Extender 將計數器值設成傳回的結果數。
在下列範例中,QbQueryStringSearch API 用來按內容查詢表格直欄中已編目的影像。 請注意:查詢的指標是設成零值。
QbResult returns[MaxQueryReturns]; SQLINTEGER maxResults=qbiMaxQueryReturns; SQLINTEGER count; QbQueryHandle qHandle; QbResult results[qbiMaxQueryReturns]; rc=QbQueryStringSearch( "QbColorFeatureClass color=<255, 0, 0>" /*query string */ "employee", /* user table */ "picture", /* image column */ maxResults, /* maximum number of results */ 0, /* query scope pointer * / qbiArray, /* store results in an array */ &count, /* count of returned images */ results); /* array of returned results */
此處為使用 QbQuerySearch API 的要求。 請注意:查詢物件 handle 被指定為輸入。
QbResult returns[MaxQueryReturns]; SQLINTEGER maxResults=qbiMaxQueryReturns; SQLINTEGER count; QbQueryHandle qHandle; QbResult results[qbiMaxQueryReturns]; rc=QbQuerySearch( qHandle, / query object handle */ "employee", /* user table */ "picture", /* image column */ maxResults, /* maximum number of results */ 0, /* query scope pointer * / qbiArray, /* store results in an array */ &count, /* count of returned images */ results); /* array of returned results */