📄 okapi32.h
字号:
#define BUFFER (TARGET)1 //Buffer(physical) allocated from host memory
#define VIDEO (TARGET)0 //Video source input to the board
#define SCREEN (TARGET)-1 //Screen supported by VGA
#define FRAME (TARGET)-2 //Frame buffer on the board
#define MONITOR (TARGET)-3 //Monitor supported by (D/A) TV standard
#define SEQFILE 0x5153 //SQ
#define BMPFILE 0x4d42 //BM
#define BLKHEADER 0x4b42 //BK
#define BUFHEADER 0x4642 //BF
//-----defines messages for user
#define WM_CLOSEREPLAY WM_USER+100
//send this message when close replay dlg
#define WM_BEGINSEQPROC WM_USER+101
//begin seq proc, wParam=hBaord
#define WM_SEQPROGRESS WM_USER+102
//seq in progress, wParam=hBaord, lParam=No. to
#define WM_ENDSEQPROC WM_USER+103
//end seq proc, wParam=hBaord
//-----------struct defines---------------
//--app user used struct
typedef struct _boardtype {
short iBoardTypeCode; //ok board type code
char szBoardName[22]; //board name (eg."OK_M20H")
} BOARDTYPE, *LPBOARDTYPE; //24 bytes
//image file block size
typedef struct _blocksize {
short iWidth; //width
short iHeight; //height
short iBitCount; //pixel bytes iBitCount
short iFormType; //rgb format type, need to fill when RGB565 or RGB 555
long lBlockStep; //block stride (step to next image header)
//need to fill when treat multi block else set 0
}BLOCKSIZE;
//image block info
typedef struct _blockinfo {
short iType; //=BK or SQ, BM
//struct _blocksize;
short iWidth; //width
short iHeight; //height
short iBitCount; //pixel bytes iBitCount
short iFormType; //rgb format type, need to fill when RGB565 or RGB 555
short lBlockStep; //block stride (step to next image header)
short iHiStep;// HIWORD of block stride
short lTotal; //frame num
short iHiTotal;// HIWORD of total
short iInterval; //frame interval
LPBYTE lpBits;// image data pointer / file path name
LPBYTE lpExtra;// extra data (like as palette, mask) pointer
} BLOCKINFO, *LPBLOCKINFO;
//sequence file info
typedef struct { //file info for seq
short iType; //=SQ or BM
//struct _blocksize;
short iWidth; //width
short iHeight; //height
short iBitCount; //pixel bytes iBitCount
short iFormType; //rgb format type, need to fill when RGB565 or RGB 555
short lBlockStep; //block stride (step to next image header)
short iHiStep;// HIWORD of block stride
short lTotal; //frame num
short iHiTotal;// HIWORD of total
short iInterval; //frame interval
} SEQINFO;
//for replay
typedef struct { //file info for seq
LPBITMAPINFOHEADER lpbi; //bitmap info
BYTE *lpdib; //dib data
HWND hwndPlayBox; //1 replaying, 0 quit
short iCurrFrame; //current frame in buffer
short iReserved; //
} DIBINFO, *LPDIBINFO;
//------ okapi32 functions list -----------
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
//--1. basic routines--------------
//prolog and epilog
HANDLE WINAPI okOpenBoard(long *iIndex); //okLockBoard
//open a Ok series board in specified index(0 based), return 0 if not found any
//if success, return a handle to control specified board
//if set index=-1, mean takes default index no. (default is 0
//if user not specified by 'Ok Device Manager' in Control Pannel)
//this index can be also a specified board type code
//this function will change iIndex to the true used index,
//if index input is -1 or type code
BOOL WINAPI okCloseBoard(HANDLE hBoard); //okCloseBoard
//Unlock and close Ok board specified handle
long WINAPI okGetLastError();
//Get last error msg
long WINAPI okGetBufferSize(HANDLE hBoard, void **lpLinear, DWORD *dwSize);
//get base address and size of pre-allocated buffer,
//if success return the max. frame num in which can be store according to current set
//else return false;
LPVOID WINAPI okGetBufferAddr(HANDLE hBoard, long lNoFrame);
//get base address of specified frame No. in BUFFER
//if success return the linear base address
//else return false;
LPVOID WINAPI okGetTargetInfo(HANDLE hBoard, TARGET tgt, long lNoFrame, short * wid, short * ht, long *stride);
//get target info include base address, width, height and stride specified frame No.
//if success return the linear base address and other infos, else return false;
short WINAPI okGetTypeCode(HANDLE hBoard, LPSTR lpBoardName);
//return type code and name of specified handle
//set rect and capture
long WINAPI okSetTargetRect(HANDLE hBoard, TARGET target, LPRECT lpTgtRect);
//set target (VIDEO, SCREEN, BUFFER, FRAME)capture to or from
//if Rect.right or .bottom) are -1 , they will be filled current value
//special note for target=BUFFER:
//if never set CAPTURE_BUFBLOCKSIZE, the block size(W,H) of buffer will be changed
//according to size of right x bottom of lpRect, else the size will not changed
//if success return max frames this target can support, else return <=0
BOOL WINAPI okSetToWndRect(HANDLE hBoard, HWND hWnd);
//set client rect of hwnd as screen rect
BOOL WINAPI okCaptureSingle(HANDLE hBoard, TARGET Dest, LONG lStart);
//capture video source to target which can be BUFFER, SCREEN, FRAME, MONITOR
//wParam=start(o based).if success return 1, if failed return 0, if not support target -1
//when this function sent command to grabber, then return immediately not wait to finish.
//this function same as okCaptureTo(hBoard, Dest, wParam, 1);
BOOL WINAPI okCaptureActive(HANDLE hBoard, TARGET Dest, LONG lStart);
//capture continuous active video to same position in target which can be BUFFER, SCREEN, FRAME, MONITOR
//wParam=start(o based).if success return 1, if failed return 0, if not support target -1
//when this function sent continuous command to grabber, then return immediately
//but note that some card like RGB30. when target is SCREEN, this function is a thread.
//this function same as okCaptureTo(hBoard, Dest, wParam, 0);
BOOL WINAPI okCaptureThread(HANDLE hBoard, TARGET Dest, LONG lStart, LPARAM lNoFrame);
//capture sequencely video to target which can be BUFFER, SCREEN, FRAME, MONITOR
//wParam=start(o based). lParam>0: number of frame to capture to,
//if lParam > total frames in BUFER, it will loop in rewind mode(i%total)
//if lParam=-N mean it loop in buffer of N frame infinitely until call okStopCapture,
//when -1 mean loop in all buffer.
//return max num frame can be stored in the target if success,
// return 0 if failed(eg. format not matched). -1 not support target
//this call will create a thread to manage to capture sequencely then
//return immediately not wait to finish. This thread will callback if need
//this function same as okCaptureTo(hBoard, Dest, wParam, n);
//but it is not same, when n=1 this function is also a thread and still support callback
BOOL WINAPI okCaptureToScreen(HANDLE hBoard);
//Start to capture to screen (video real-time display on screen) and return immediately
//this is just a special routine of okCaptureTo(hBoard,SCREEN,0,0)
BOOL WINAPI okCaptureTo(HANDLE hBoard, TARGET Dest, WORD wParam, LPARAM lParam);
//capture video source to target which can be BUFFER, SCREEN, FRAME, MONITOR
//wParam=start(o based), lParam>0: number of frame to capture to, =0: cont. mode,
//if lParam > total frames in BUFER, it will loop in rewind mode(i%total)
//if lParam=-1 mean it loop infinitely until call okStopCapture
//return max num frame can be stored in the target if success,
// return 0 if failed(eg. format not matched). -1 not support target
//this call will return immediately not wait to finish.
//This function is not recomended to use for new user
BOOL WINAPI okPlaybackFrom(HANDLE hBoard, TARGET src, WORD wParam, LPARAM lParam);
//playback on monitor from target which can be BUFFER, FRAME
//wParam=start(o based), lParam>0: number of frame to capture to, =0: cont. mode
//if lParam > total frames in BUFER, it will loop in rewind mode (i%total)
//if lParam=-1 mean it loop infinitely until call okStopCapture
//return max num frame be stored in the target if success,
//return 0 if wrong. -1 not support target
//this call will return immediately not wait to finish.
//
//get status and stop capture
long WINAPI okGetCaptureStatus(HANDLE hBoard, BOOL bWait);
//query capturing status, if bWait then wait to finish capturing, else return immediately.
//return 0 if finished, if cont. mode capturing return target capture to
//(which include SCREEN -1, FRAME -2, MONITOR -3)
//if capturing to/from BUFFER or file, return the frame No.(1 based) being capturing
BOOL WINAPI okStopCapture(HANDLE hBoard);
//Stop capturing to or playback from SCREEN, BUFFER or other targets
//return target just captured to or from.
//if capturing to/from BUFFER or file, return the frame No.(1 based) being capturing
//capture by to /from
BOOL WINAPI okCaptureByBuffer(HANDLE hBoard, TARGET dest, short start, long num);
//capture sequence images to dest by way of two frame buffers (in BUFFER),
//the frame size and format is taken as same as current config of BUFFER
//if dest is file name which can be .seq or .bmp (will generate multi bmp files)
//dest can be also a user memory pointer or a BLOCKINFO pointer (with user memory pointer)
//retrun true immediately if success. num should be great than 0
BOOL WINAPI okCaptureByBufferEx(HANDLE hBoard, long fileset, TARGET dest, long start, long num);
// all are same as okCaptureByBuffer except for fileset which is quality when to jpg file
BOOL WINAPI okPlaybackByBuffer(HANDLE hBoard, TARGET src, short start, long num);
//playback sequence images on monitor from src by way of two frame buffers (in BUFFER)
//the size and format of BUFFER will be changed to same as src
//src can be a file name which may be .seq or .bmp (first orderd bmp files)
////src can be also a BLOCKINFO pointer (with infos of user memory pointer,size and format)
//if src is just user memory pointer, this function will think its block size and format
//are same as current config of BUFFER (in this case can not support loop function).
//retrun true immediately if success
//if num is great than the true frame number in src, it will loop back
//if num=-1 mean it will loop infinitely until call okStopCapture
//set and get params
long WINAPI okSetVideoParam(HANDLE hBoard, WORD wParam, long lParam);
//----set video param sub-function defines
//set video param and return previous param;
//if input lParam=-1, just return previous param
//if not support return -1, if error return -2
long WINAPI okSetCaptureParam(HANDLE hBoard, WORD wParam, long lParam);
//set capture param and return previous param;
//if input lParam=-1, just return previous param
//if not support return -1, if error return -2
//transfer and convert rect
long WINAPI okSetConvertParam(HANDLE hBoard, WORD wParam, long lParam);
//set convert param for for function okConvertRect
//if not support return -1, if error return -2
long WINAPI okReadRect(HANDLE hBoard, TARGET src, short start, LPBYTE lpBuf);
//read data into lpBuf from rect(set previous) in frame start of dst (SCREEN, BUFFER, FRAME)
//the data in lpBuf stored in way row by row
//if src not supported return -1, if failed return 0,
//return -1 if not support, return 0 failed,
//if success return data length read in byte
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -