Friday, December 07, 2012

TCanvas

剛剛在 C++ Builder 的 Developer's Guide 看到一段話, 解了一個很久以來的疑問!

"Canvases are available only at runtime, so you do all your work with canvases by writing code"

這也解釋了為什麼這個 Image 物件中的小物件沒有出現在 Object Inspector 的 Properties 之中, 而 Picture 卻有出現在 Image 中的 Properties 之中。


Thursday, May 03, 2012

BITMAPINFOHEADER structure

BITMAPINFOHEADER structure 結構資料型態主要是用來描述 DIB (Device Independent Bitmap) 物件的相關屬性。
The BITMAPINFOHEADER structure contains information about the dimensions and color format of a DIB.

Windows 95, Windows NT 4.0: Applications can use the BITMAPV4HEADER structure for added functionality.

Windows 98/Me, Windows 2000/XP: Applications can use the BITMAPV5HEADER structure for added functionality. However, these are used only in the CreateDIBitmap function.

typedef struct tagBITMAPINFOHEADER{
DWORD biSize;
LONG biWidth;
LONG biHeight;
WORD biPlanes;
WORD biBitCount;
DWORD biCompression;
DWORD biSizeImage;
LONG biXPelsPerMeter;
LONG biYPelsPerMeter;
DWORD biClrUsed;
DWORD biClrImportant;
} BITMAPINFOHEADER, *PBITMAPINFOHEADER;

Members

biSize

Specifies the number of bytes required by the structure.

biWidth

Specifies the width of the bitmap, in pixels.

Windows 98/Me, Windows 2000/XP: If biCompression is BI_JPEG or BI_PNG, the biWidth member specifies the width of the decompressed JPEG or PNG image file, respectively.

biHeight

Specifies the height of the bitmap, in pixels. If biHeight is positive, the bitmap is a bottom-up DIB and its origin is the lower-left corner. If biHeight is negative, the bitmap is a top-down DIB and its origin is the upper-left corner.

If biHeight is negative, indicating a top-down DIB, biCompression must be either BI_RGB or BI_BITFIELDS. Top-down DIBs cannot be compressed.

Windows 98/Me, Windows 2000/XP: If biCompression is BI_JPEG or BI_PNG, the biHeight member specifies the height of the decompressed JPEG or PNG image file, respectively.

biPlanes

Specifies the number of planes for the target device. This value must be set to 1.

biBitCount

Specifies the number of bits-per-pixel. The biBitCount member of the BITMAPINFOHEADER structure determines the number of bits that define each pixel and the maximum number of colors in the bitmap. This member must be one of the following values.

0 Windows 98/Me, Windows 2000/XP: The number of bits-per-pixel is specified or is implied by the JPEG or PNG format.

1 The bitmap is monochrome, and the bmiColors member of BITMAPINFO contains two entries. Each bit in the bitmap array represents a pixel. If the bit is clear, the pixel is displayed with the color of the first entry in the bmiColors table; if the bit is set, the pixel has the color of the second entry in the table.

4 The bitmap has a maximum of 16 colors, and the bmiColors member of BITMAPINFO contains up to 16 entries. Each pixel in the bitmap is represented by a 4-bit index into the color table. For example, if the first byte in the bitmap is 0x1F, the byte represents two pixels. The first pixel contains the color in the second table entry, and the second pixel contains the color in the sixteenth table entry.

8 The bitmap has a maximum of 256 colors, and the bmiColors member of BITMAPINFO contains up to 256 entries. In this case, each byte in the array represents a single pixel.

16 The bitmap has a maximum of 2^16 colors. If the biCompression member of the BITMAPINFOHEADER is BI_RGB, the bmiColors member of BITMAPINFO is NULL. Each WORD in the bitmap array represents a single pixel. The relative intensities of red, green, and blue are represented with five bits for each color component. The value for blue is in the least significant five bits, followed by five bits each for green and red. The most significant bit is not used. The bmiColors color table is used for optimizing colors used on palette-based devices, and must contain the number of entries specified by the biClrUsed member of the BITMAPINFOHEADER.
If the biCompression member of the BITMAPINFOHEADER is BI_BITFIELDS, the bmiColors member contains three DWORD color masks that specify the red, green, and blue components, respectively, of each pixel. Each WORD in the bitmap array represents a single pixel.

Windows NT/Windows 2000/XP: When the biCompression member is BI_BITFIELDS, bits set in each DWORD mask must be contiguous and should not overlap the bits of another mask. All the bits in the pixel do not have to be used.

Windows 95/98/Me: When the biCompression member is BI_BITFIELDS, the system supports only the following 16bpp color masks: A 5-5-5 16-bit image, where the blue mask is 0x001F, the green mask is 0x03E0, and the red mask is 0x7C00; and a 5-6-5 16-bit image, where the blue mask is 0x001F, the green mask is 0x07E0, and the red mask is 0xF800.

24 The bitmap has a maximum of 2^24 colors, and the bmiColors member of BITMAPINFO is NULL. Each 3-byte triplet in the bitmap array represents the relative intensities of blue, green, and red, respectively, for a pixel. The bmiColors color table is used for optimizing colors used on palette-based devices, and must contain the number of entries specified by the biClrUsed member of the BITMAPINFOHEADER.

32 The bitmap has a maximum of 2^32 colors. If the biCompression member of the BITMAPINFOHEADER is BI_RGB, the bmiColors member of BITMAPINFO is NULL. Each DWORD in the bitmap array represents the relative intensities of blue, green, and red, respectively, for a pixel. The high byte in each DWORD is not used. The bmiColors color table is used for optimizing colors used on palette-based devices, and must contain the number of entries specified by the biClrUsed member of the BITMAPINFOHEADER.
If the biCompression member of the BITMAPINFOHEADER is BI_BITFIELDS, the bmiColors member contains three DWORD color masks that specify the red, green, and blue components, respectively, of each pixel. Each DWORD in the bitmap array represents a single pixel.

Windows NT/ 2000: When the biCompression member is BI_BITFIELDS, bits set in each DWORD mask must be contiguous and should not overlap the bits of another mask. All the bits in the pixel do not need to be used.

Windows 95/98/Me: When the biCompression member is BI_BITFIELDS, the system supports only the following 32-bpp color mask: The blue mask is 0x000000FF, the green mask is 0x0000FF00, and the red mask is 0x00FF0000.

biCompression
Specifies the type of compression for a compressed bottom-up bitmap (top-down DIBs cannot be compressed). This member can be one of the following values.

BI_RGB An uncompressed format.
BI_RLE8 A run-length encoded (RLE) format for bitmaps with 8 bpp. The compression format is a 2-byte format consisting of a count byte followed by a byte containing a color index. For more information, see Bitmap Compression.
BI_RLE4 An RLE format for bitmaps with 4 bpp. The compression format is a 2-byte format consisting of a count byte followed by two word-length color indexes. For more information, see Bitmap Compression.
BI_BITFIELDS Specifies that the bitmap is not compressed and that the color table consists of three DWORD color masks that specify the red, green, and blue components, respectively, of each pixel. This is valid when used with 16- and 32-bpp bitmaps.
BI_JPEG Windows 98/Me, Windows 2000/XP: Indicates that the image is a JPEG image.
BI_PNG Windows 98/Me, Windows 2000/XP: Indicates that the image is a PNG image.

biSizeImage

Specifies the size, in bytes, of the image. This may be set to zero for BI_RGB bitmaps.
Windows 98/Me, Windows 2000/XP: If biCompression is BI_JPEG or BI_PNG, biSizeImage indicates the size of the JPEG or PNG image buffer, respectively.

biXPelsPerMeter

Specifies the horizontal resolution, in pixels-per-meter, of the target device for the bitmap. An application can use this value to select a bitmap from a resource group that best matches the characteristics of the current device.

biYPelsPerMeter

Specifies the vertical resolution, in pixels-per-meter, of the target device for the bitmap.

biClrUsed

Specifies the number of color indexes in the color table that are actually used by the bitmap. If this value is zero, the bitmap uses the maximum number of colors corresponding to the value of the biBitCount member for the compression mode specified by biCompression.

If biClrUsed is nonzero and the biBitCount member is less than 16, the biClrUsed member specifies the actual number of colors the graphics engine or device driver accesses. If biBitCount is 16 or greater, the biClrUsed member specifies the size of the color table used to optimize performance of the system color palettes. If biBitCount equals 16 or 32, the optimal color palette starts immediately following the three DWORD masks.

When the bitmap array immediately follows the BITMAPINFO structure, it is a packed bitmap. Packed bitmaps are referenced by a single pointer. Packed bitmaps require that the biClrUsed member must be either zero or the actual size of the color table.

biClrImportant

Specifies the number of color indexes that are required for displaying the bitmap. If this value is zero, all colors are required.
Remarks
The BITMAPINFO structure combines the BITMAPINFOHEADER structure and a color table to provide a complete definition of the dimensions and colors of a DIB. For more information about DIBs, see Device-Independent Bitmaps and BITMAPINFO.

An application should use the information stored in the biSize member to locate the color table in a BITMAPINFO structure, as follows:

pColor = ((LPSTR)pBitmapInfo + (WORD)(pBitmapInfo->bmiHeader.biSize));

Windows 98/Me, Windows 2000/XP: The BITMAPINFOHEADER structure is extended to allow a JPEG or PNG image to be passed as the source image to StretchDIBits.

Wednesday, May 02, 2012

BITMAPINFO structure

結構型資料型態中含有結構型資料型態的組成成員(member)是高階程式設計中非常常見的。BITMAPINFO structure 的組成成員只有 2 個, 其中 bmiHeader 就是同樣屬於結構型資料型態 BITMAPINFOHEADER structure 的成員, 主要是用來描述 DIB (Device Independent Bitmap) 物件的相關屬性。
The BITMAPINFO structure defines the dimensions and color information for a DIB.

typedef struct tagBITMAPINFO {
BITMAPINFOHEADER bmiHeader;
RGBQUAD bmiColors[1];
} BITMAPINFO, *PBITMAPINFO;

Members

bmiHeader

Specifies a BITMAPINFOHEADER structure that contains information about the dimensions of color format.

bmiColors

The bmiColors member contains one of the following:
(1) An array of RGBQUAD. The elements of the array that make up the color table.
(2) An array of 16-bit unsigned integers that specifies indexes into the currently realized logical palette. This use of bmiColors is allowed for functions that use DIBs. When bmiColors elements contain indexes to a realized logical palette, they must also call the following bitmap functions:

CreateDIBitmap

CreateDIBPatternBrush

CreateDIBSection

The iUsage parameter of CreateDIBSection must be set to DIB_PAL_COLORS.

The number of entries in the array depends on the values of the biBitCount and biClrUsed members of the BITMAPINFOHEADER structure.

The colors in the bmiColors table appear in order of importance. For more information, see the Remarks section.

Remarks

A DIB consists of two distinct parts: a BITMAPINFO structure describing the dimensions and colors of the bitmap, and an array of bytes defining the pixels of the bitmap. The bits in the array are packed together, but each scan line must be padded with zeroes to end on a LONG data-type boundary. If the height of the bitmap is positive, the bitmap is a bottom-up DIB and its origin is the lower-left corner. If the height is negative, the bitmap is a top-down DIB and its origin is the upper left corner.

A bitmap is packed when the bitmap array immediately follows the BITMAPINFO header. Packed bitmaps are referenced by a single pointer. For packed bitmaps, the biClrUsed member must be set to an even number when using the DIB_PAL_COLORS mode so that the DIB bitmap array starts on a DWORD boundary.

Note The bmiColors member should not contain palette indexes if the bitmap is to be stored in a file or transferred to another application.

Unless the application has exclusive use and control of the bitmap, the bitmap color table should contain explicit RGB values.

capGetVideoFormat macro

透過 VFW 所提供的 capGetVideoFormat 函式, 可以取得視訊畫面資料的寬、高、一個像素(pixel)由幾個位元組成及視訊畫面資料是否經過壓縮... 等等。如果想要修改視訊擷取視窗中的畫面內容, 這些資料就變成相當重要。
The capGetVideoFormat macro retrieves a copy of the video format in use. You can use this macro or explicitly call the WM_CAP_GET_VIDEOFORMAT message.

DWORD capGetVideoFormat(
hwnd,
psVideoFormat,
wSize
);

Parameters

hwnd

Handle to a capture window.

psVideoFormat

Pointer to a BITMAPINFO structure. You can also specify NULL to retrieve the number of bytes needed by BITMAPINFO.

wSize

Size, in bytes, of the structure referenced by s.

Return Values

Returns the size, in bytes, of the video format or zero if the capture window is not connected to a capture driver. For video formats that require a palette, the current palette is also returned.

Remarks

Because compressed video formats vary in size requirements applications must first retrieve the size, then allocate memory, and finally request the video format data.

Tuesday, April 24, 2012

capCaptureStop macro

結束連續視訊串流擷取。
The capCaptureStop macro stops the capture operation. You can use this macro or explicitly send the WM_CAP_STOP message.

In step frame capture, the image data that was collected before this message was sent is retained in the capture file. An equivalent duration of audio data is also retained in the capture file if audio capture was enabled.

BOOL capCaptureStop(
hwnd
);
Parameters

hwnd

Handle to a capture window.

Return Values

Returns TRUE if successful or FALSE otherwise.

Remarks

The capture operation must yield to use this message. Use the capCaptureAbort macro to abandon the current capture operation.

capCaptureAbort macro

中止錄影動作。
The capCaptureAbort macro stops the capture operation. You can use this macro or explictly send the WM_CAP_ABORT message.

BOOL capCaptureAbort(
hwnd
);

Parameters

hwnd

Handle to a capture window.

Return Values

Returns TRUE if successful or FALSE otherwise.

Remarks

The capture operation must yield to use this macro.

In the case of step capture, the image data collected up to the point of the capCaptureAbort macro will be retained in the capture file, but audio will not be captured.

Use the capCaptureStop macro to halt step capture at the current position, and then capture audio.

Monday, April 23, 2012

capFileAlloc macro

預先從硬碟配置固定大小的空間存放錄影檔案。
The capFileAlloc macro creates (preallocates) a capture file of a specified size. You can use this macro or explicitly send the WM_CAP_FILE_ALLOCATE message.

BOOL capFileAlloc(
hwnd,
dwSize
);

Parameters

hwnd

Handle to a capture window.

dwSize

Size, in bytes, to create the capture file.

Return Values

Returns TRUE if successful or FALSE otherwise.

If an error occurs and an error callback function is set using the capSetCallbackOnError macro, the error callback function is called.

Remarks

You can improve streaming capture performance significantly by preallocating a capture file large enough to store an entire video clip and by defragmenting the capture file before capturing the clip.

capFileSetCaptureFile macro

若要將視訊擷取視窗的視訊、音訊內容儲存成檔案, 可以先使用 capFileSetCaptureFile macro 設定所要儲存的檔案名稱。若沒有預先設定, 檔案名稱則內定為 C:\CAPTURE.AVI。
The capFileSetCaptureFile macro names the file used for video capture. You can use this macro or explicitly call the WM_CAP_FILE_SET_CAPTURE_FILE message.

BOOL capFileSetCaptureFile(
hwnd,
szName
);

Parameters

hwnd

Handle to a capture window.

szName

Pointer to the null-terminated string that contains the name of the capture file to use.

Return Values

Returns TRUE if successful or FALSE if the filename is invalid or if streaming or single-frame capture is in progress.

Remarks

This message stores the filename in an internal structure. It does not create, allocate, or open the specified file. The default capture filename is C:\CAPTURE.AVI.

capFileGetCaptureFile macro

透過 capFileGetCaptureFile macro, 可以得知所錄影的視訊內容, 將會被儲存的檔案名稱。如果使用者沒有透過 capFileSetCaptureFile macro 重新設定過, 內定的名稱為 C:\CAPTURE.AVI。
The capFileGetCaptureFile macro returns the name of the current capture file. You can use this macro or explicitly call the WM_CAP_FILE_GET_CAPTURE_FILE message.

BOOL capFileGetCaptureFile(
hwnd,
szName,
wSize
);

Parameters

hwnd

Handle to a capture window.

szName

Pointer to an application-defined buffer used to return the name of the capture file as a null-terminated string.

wSize

Size, in bytes, of the application-defined buffer referenced by szName.

Return Values

Returns TRUE if successful or FALSE otherwise.

Remarks

The default capture filename is C:\CAPTURE.AVI.

Tuesday, April 17, 2012

capCaptureSequence macro

使用 capCaptureSequence macro 可以將視訊擷取視窗中的視訊與音訊內容儲存成一個 AVI 檔案, 檔案名稱則可以是透過 capFileSetCaptureFile macro 事先設定, 若沒有設定檔案名稱, 則內定為 C:\CAPTURE.AVI。
The capCaptureSequence macro initiates streaming video and audio capture to a file. You can use this macro or explicitly send the WM_CAP_SEQUENCE message.

BOOL capCaptureSequence(
hwnd
);


Parameters

hwnd

Handle of a capture window.

Return Values

Returns TRUE if successful or FALSE otherwise.
If an error occurs and an error callback function is set using the capSetCallbackOnError macro, the error callback function is called.

Remarks

If you want to alter the parameters controlling streaming capture, use the capCaptureSetSetup macro prior to starting the capture.
By default, the capture window does not allow other applications to continue running during capture. To override this, either set the fYield member of the CAPTUREPARMS structure to TRUE, or install a yield callback function.
During streaming capture, the capture window can optionally issue notifications to your application of specific types of conditions. To install callback procedures for these notifications, use the following macros:

capSetCallbackOnError
capSetCallbackOnStatus
capSetCallbackOnVideoStream
capSetCallbackOnWaveStream
capSetCallbackOnYield

Wednesday, April 04, 2012

openGL 的範例程式

C++ Builder 提供了一個關於如何使用 openGL 的範例程式, 在媒體櫃文件目錄中的

RAD Studio\9.0\Sample\CPP\VCL\OpenGL\Drawing\

內有 glskeleton.cppproj 及其相關檔案。

至於 openGL 的標頭檔則是放置於

Embarcadero\RAD Studio\9.0\include\windows\sdk\gl\

內有 gl.h, glaux.h, glu.h 等三個檔案。

Tuesday, March 27, 2012

CAPTUREPARMS structure

這是從 C++ Builder 的 Help 所複製出來的文章, 內容是說明在 vfw.h 中所定義的結構資料型態 CAPTUREPARMS structure 每個成員(member) 所代表的意義。
The CAPTUREPARMS structure contains parameters that control the streaming video capture process. This structure is used to get and set parameters that affect the capture rate, the number of buffers to use while capturing, and how capture is terminated.

typedef struct {
DWORD dwRequestMicroSecPerFrame;
BOOL fMakeUserHitOKToCapture;
UINT wPercentDropForError;
BOOL fYield;
DWORD dwIndexSize;
UINT wChunkGranularity;
BOOL fUsingDOSMemory;
UINT wNumVideoRequested;
BOOL fCaptureAudio;
UINT wNumAudioRequested;
UINT vKeyAbort;
BOOL fAbortLeftMouse;
BOOL fAbortRightMouse;
BOOL fLimitEnabled;
UINT wTimeLimit;
BOOL fMCIControl;
BOOL fStepMCIDevice;
DWORD dwMCIStartTime;
DWORD dwMCIStopTime;
BOOL fStepCaptureAt2x;
UINT wStepCaptureAverageFrames;
DWORD dwAudioBufferSize;
BOOL fDisableWriteCache;
UINT AVStreamMaster;
} CAPTUREPARMS;

Members

dwRequestMicroSecPerFrame

Requested frame rate, in microseconds. The default value is 66667, which corresponds to 15 frames per second.

fMakeUserHitOKToCapture

User-initiated capture flag. If this member is TRUE, AVICap displays a dialog box prompting the user to initiate capture. The default value is FALSE.

wPercentDropForError

Maximum allowable percentage of dropped frames during capture. Values range from 0 to 100. The default value is 10.

fYield

Yield flag. If this member is TRUE, the capture window spawns a separate background thread to perform step and streaming capture. The default value is FALSE.

Applications that set this flag must handle potential reentry issues because the controls in the application are not disabled while capture is in progress.

dwIndexSize

Maximum number of index entries in an AVI file. Values range from 1800 to 324,000. If set to 0, a default value of 34,952 (32K frames plus a proportional number of audio buffers) is used.

Each video frame or buffer of waveform-audio data uses one index entry. The value of this entry establishes a limit for the number of frames or audio buffers that can be captured.

wChunkGranularity

Logical block size, in bytes, of an AVI file. The value 0 indicates the current sector size is used as the granularity.

fUsingDOSMemory

Not used in Win32 applications.

wNumVideoRequested

Maximum number of video buffers to allocate. The memory area to place the buffers is specified with fUsingDOSMemory. The actual number of buffers allocated might be lower if memory is unavailable.

fCaptureAudio

Capture audio flag. If this member is TRUE, audio is captured during streaming capture. This is the default value if audio hardware is installed.

wNumAudioRequested

Maximum number of audio buffers to allocate. The maximum number of buffers is 10.

vKeyAbort

Virtual keycode used to terminate streaming capture. The default value is VK_ESCAPE. You must call the RegisterHotKey function before specifying a keystroke that can abort a capture session.

You can combine keycodes that include CTRL and SHIFT keystrokes by using the logical OR operator with the keycodes for CTRL (0x8000) and SHIFT (0x4000).

fAbortLeftMouse

Abort flag for left mouse button. If this member is TRUE, streaming capture stops if the left mouse button is pressed. The default value is TRUE.

fAbortRightMouse

Abort flag for right mouse button. If this member is TRUE, streaming capture stops if the right mouse button is pressed. The default value is TRUE.

fLimitEnabled

Time limit enabled flag. If this member is TRUE, streaming capture stops after the number of seconds in wTimeLimit has elapsed. The default value is FALSE.

wTimeLimit

Time limit for capture, in seconds. This parameter is used only if fLimitEnabled is TRUE.

fMCIControl

MCI device capture flag. If this member is TRUE, AVICap controls an
MCI-compatible video source during streaming capture. MCI-compatible video sources include VCRs and laserdiscs.

fStepMCIDevice

MCI device step capture flag. If this member is TRUE, step capture using an MCI device as a video source is enabled. If it is FALSE, real-time capture using an MCI device is enabled. (If fMCIControl is FALSE, this member is ignored.)

dwMCIStartTime

Starting position, in milliseconds, of the MCI device for the capture sequence. (If fMCIControl is FALSE, this member is ignored.)

dwMCIStopTime

Stopping position, in milliseconds, of the MCI device for the capture sequence. When this position in the content is reached, capture ends and the MCI device stops. (If fMCIControl is FALSE, this member is ignored.)

fStepCaptureAt2x

Double-resolution step capture flag. If this member is TRUE, the capture hardware captures at twice the specified resolution. (The resolution for the height and width is doubled.)

Enable this option if the hardware does not support hardware-based decimation and you are capturing in the RGB format.

wStepCaptureAverageFrames

Number of times a frame is sampled when creating a frame based on the average sample. A typical value for the number of averages is 5.

dwAudioBufferSize

Audio buffer size. If the default value of zero is used, the size of each buffer will be the maximum of 0.5 seconds of audio or 10K bytes.

fDisableWriteCache

Not used in Win32 applications.

AVStreamMaster

Indicates whether the audio stream controls the clock when writing an AVI file. If this member is set to AVSTREAMMASTER_AUDIO, the audio stream is considered the master stream and the video stream duration is forced to match the audio duration. If this member is set to AVSTREAMMASTER_NONE, the durations of audio and video streams can differ.

Remarks

The WM_CAP_GET_SEQUENCE_SETUP message or capCaptureGetSetup macro is used to retrieve the current capture parameters. The WM_CAP_SET_SEQUENCE_SETUP message or capCaptureSetSetup macro is used to set the capture parameters.
延伸閱讀: 取得與設定錄影參數

Monday, March 19, 2012

TCapStatus structure

CAPSTATUS
The CAPSTATUS structure defines the current state of the capture window.

typedef struct {
UINT uiImageWidth;
UINT uiImageHeight;
BOOL fLiveWindow;
BOOL fOverlayWindow;
BOOL fScale;
POINT ptScroll;
BOOL fUsingDefaultPalette;
BOOL fAudioHardware;
BOOL fCapFileExists;
DWORD dwCurrentVideoFrame;
DWORD dwCurrentVideoFramesDropped;
DWORD dwCurrentWaveSamples;
DWORD dwCurrentTimeElapsedMS;
HPALETTE hPalCurrent;
BOOL fCapturingNow;
DWORD dwReturn;
UINT wNumVideoAllocated;
UINT wNumAudioAllocated;
} CAPSTATUS;

Members

 uiImageWidth

Image width, in pixels.

 uiImageHeight 

Image height, in pixels

 fLiveWindow 

Live window flag. The value of this member is TRUE if the window is displaying video using the preview method.

 fOverlayWindow 

Overlay window flag. The value of this member is TRUE if the window is displaying video using hardware overlay.

 fScale

Input scaling flag. The value of this member is TRUE if the window is scaling the input video to the client area when displaying video using preview. This parameter has no effect when displaying video using overlay.

 ptScroll

The x- and y-offset of the pixel displayed in the upper left corner of the client area of the window.

 fUsingDefaultPalette

Default palette flag. The value of this member is TRUE if the capture driver is using its default palette.

 fAudioHardware

Audio hardware flag. The value of this member is TRUE if the system has waveform-audio hardware installed.

 fCapFileExists

Capture file flag. The value of this member is TRUE if a valid capture file has been generated.

 dwCurrentVideoFrame

Number of frames processed during the current (or most recent) streaming capture. This count includes dropped frames.

 dwCurrentVideoFramesDropped

Number of frames dropped during the current (or most recent) streaming capture. Dropped frames occur when the capture rate exceeds the rate at which frames can be saved to file. In this case, the capture driver has no buffers available for storing data. Dropping frames does not affect synchronization because the previous frame is displayed in place of the dropped frame.

 dwCurrentWaveSamples

Number of waveform-audio samples processed during the current (or most recent) streaming capture.

 dwCurrentTimeElapsedMS

Time, in milliseconds, since the start of the current (or most recent) streaming capture.

 hPalCurrent

Handle to current palette.

 fCapturingNow

Capturing flag. The value of this member is TRUE when capturing is in progress.

 dwReturn

Error return values. Use this member if your application does not support an error callback function.

 wNumVideoAllocated

Number of video buffers allocated. This value might be less than the number specified in the wNumVideoRequested member of the CAPTUREPARMS structure.

 wNumAudioAllocated

Number of audio buffers allocated. This value might be less than the number specified in the wNumAudioRequested member of the CAPTUREPARMS structure.

Remarks

Because the state of a capture window changes in response to various messages, an application should update the information in this structure whenever it needs to enable menu items, determine the actual state of the capture window, or call the video format dialog box. If the application yields during streaming capture, this structure returns the progress of the capture in the dwCurrentVideoFrame, dwCurrentVideoFramesDropped, dwCurrentWaveSamples, and dwCurrentTimeElapsedMS members. Use the WM_CAP_GET_STATUS message or capGetStatus macro to update the contents of this structure.

VFW: 視訊擷取視窗狀態

capGetStatus
The capGetStatus macro retrieves the status of the capture window. You can use this macro or explicitly call the WM_CAP_GET_STATUS message.

BOOL capGetStatus(
hwnd,
s,
wSize
);

Parameters

hwnd Handle to a capture window.

s Pointer to a CAPSTATUS structure.

wSize Size, in bytes, of the structure referenced by s.

Return Values

Returns TRUE if successful or FALSE if the capture window is not connected to a capture driver.

Remarks

The CAPSTATUS structure contains the current state of the capture window. Since this state is dynamic and changes in response to various messages, the application should initialize this structure after sending the capDlgVideoFormat macro and whenever it needs to enable menu items or determine the actual state of the window.

Wednesday, February 29, 2012

VFW: 視訊參數對話盒 Video Dialog Box

一般來說, 硬體製造廠商會提供驅動程式(driver)供使用者將硬體裝置安裝到電腦。視訊裝置也是一樣, 所安裝的驅動程式還會提供一些預先寫好的視訊參數對話盒, 供程式設計師直接呼叫, 以修改視訊裝置的相關參數。不同的廠商所提供的視訊參數對話盒不一定相同, 甚至有些廠商並不一定有提供視訊參數對話盒, 因此, 程式設計師在呼叫視訊參數對話盒之前, 可以先透過 capDriverGetCaps 函式, 先取得視訊裝置驅動程式的效能, 確認之後再進行呼叫。

視訊參數對話盒一共有四種, 分別是:
 1. 視訊來源對話盒 (Video Source Dialog)
 2. 視訊格式對話盒 (Video Format Dialog)
 3. 視訊顯示對話盒 (Video Display Dialog)
 4. 視訊壓縮對話盒 (Video Compression Dialog)

接下來我們將分別介紹各種視訊參數對話盒的呼叫函式。

 1. 視訊來源對話盒 (Video Source Dialog Box)

 capDlgVideoSource

The capDlgVideoSource macro displays a dialog box in which the user can control the video source. The Video Source dialog box might contain controls that select input sources; alter the hue, contrast, brightness of the image; and modify the video quality before digitizing the images into the frame buffer. You can use this macro or explicitly send the WM_CAP_DLG_VIDEOSOURCE message.

BOOL capDlgVideoSource(
hwnd
);

Parameters

 hwnd

  Handle to a capture window.

Return Values

 Returns TRUE if successful or FALSE otherwise.

Remarks

The Video Source dialog box is unique for each capture driver. Some capture drivers might not support a Video Source dialog box. Applications can determine if the capture driver supports this message by checking the fHasDlgVideoSource member of the CAPDRIVERCAPS structure.

Saturday, February 25, 2012

wchar_t type

wchar_t 的用法:

wchar_t wchA = L'A';
wchar_t *wstrA = L"ABCD";

Saturday, February 18, 2012

XE2: the Hello World Example!

首先, 我們建立一個 VCL Form 的應用程式, 然後從工具盤 Tool Palette 中, 從 standard 的群組中, 找出 TButton, 將其拉進 Form1 中, 並用滑鼠在 button1 元件上點選一下, 選擇起來。接著, 就可以透過 Object Inspector 修改 button1 的相關屬性, 例如:

a. 將 Name 改成 btnHelloWorld
b. 將 Caption 改成 Hello World

就可以看到如下圖的樣子。



接著, 我們可以連按(double click) TButton btnHelloWorld 兩下, 進入可以撰寫程式(事件處理程序)的畫面, 即 unit1.cpp 程式之中, 輸入下列指令:

ShowMessage("Hello World!");

如下圖:



就可以開始執行(Run, F9) 我們的第一個 C++ Builder 的應用程式了。



按下 TButton btnHelloWorld 就可以看到跳出如下的訊息視窗:



按 OK button 訊息視窗就會自動消失!

Wednesday, February 15, 2012

XE2: 儲存 Project

除了 Form/Unit 必須儲存之外, 每一個應用程式的專案也要儲存起來, 從功能表中選取 File | Save Project As.. 就可以將專案的內容儲存起來。



在你儲存的目錄中, 你一共可以看到關於專案的 3 個不同的副檔名。

1. Project1.cbproj

  副檔名是 cbproj, 指的是 C++ Builder 的 Project File, 儲存的內容是關於整個專案內容的描述。

2. Project1.cbproj.local

  在副檔名是 cbproj 的後面加加上 .local, 用記事本打開看, 可以看到專案儲存在這台電腦(local)的相關目錄。

3. Project1.cpp

  副檔名是 cpp, 因此是整個專案能夠在視窗環境下執行的 C++ 語言指令的相關部分。

如下圖的三個檔案。

XE2: 儲存 Form/Unit

當我們完成一個 Form 的設計與其對應的 Unit 的程式撰寫後, 或是想要休息一下, 下次再繼續寫程式, 就要先將 Form/Unit 先儲存起來, 可以從功能表中選取 File | Save 或 Save as... 來進行第一次的儲存, 如果已經儲存過了, 那就可以直接選 File | Save 進行儲存。



如果沒有對 Unit1 進行重新命名, 就會看到 Unit1 一共被儲存成下列三個檔案:

 1. Unit1.cpp

   副檔名為 cpp, 類型為 C++ Source File, 內容就是你在撰寫程式時, 所看到的程式內容。

 2. Unit1.dfm

   副檔名為 dfm, 內容其實就是對你所設計的 Form 之描述, 如果你用記事本開啟 Unit1.dfm, 你就可以看到 C++ Builder 是如何描述一個 Form 的。



  由於上圖中的 Form1 並沒有任何元件, 所以描述內容僅有對 object Form1 的描述。

 3. Unit1.h
 
   副檔名為 h, 表示為一個 C 語言的標頭檔(header file), 每一個 Unit 都會搭配一個標頭檔, 在 Unit1.cpp 中, 你也可以找到一行 #include "Unit1.h" 的指令。

 在你儲存的目錄中, 你一共可以看到如下圖的三個檔案。

XE2: Object Inspector

在 C++ Builder 中, 可以用 Object Inspector 來觀看與設定所有元件的 Properties, 也可以從 Events 中設定 Object 的所有事件處理程序。

XE2: 開啟一個 VCL Form 應用

進入 C++ Builder XE2 的整合開發環境後, 如果你要開始寫一個全新的應用程式, 你可以從功能列中選擇 File | New | VCL Forms Application (如下圖),
 

 
C++ Builder 就會幫你產生一個 Form, 讓你開始規劃你的 Form 上要放哪些元件。


要修改 Form1 物件 Properties 的內容, 可以直接在位於左下角的 Object Inspector 中直接更改。

Tuesday, February 14, 2012

XE2: 工具盤 Tool Palette

C++ Builder XE2 的工具盤(Tool Palette) 其實就是 BCB6 中的元件盤(Component Palette), 可以從這邊找到想要的元件, 直接拉到 Form 上就可以了。