dibdib command

NAME

dib – enables drawing of video frames

SYNOPSIS

dibpathname width height

DESCRIPTION

The dib command creates a new widget of widthxheight pixels (given by the pathName argument). The dib command returns its pathName argument. At the time this command is invoked, there must not exist a window named pathName, but pathName's parent must exist.

A dib widget is able to display and resize video frames. It woks easily with avicap.

WIDGET COMMAND

The dib command creates a new Tcl command whose name is pathName. This command may be used to invoke various operations on the widget. It has the following general form:

pathNameoption ?argarg ...?

option and the args determine the exact behavior of the command. The following commands are possible for dib widgets:

refresh","getsize","setsize"

pathNamebeginbitmapinfo

Initiates drawing of video frames. bitmapinfo is the BITMAPINFO of the video frames to draw, as returned by getbmpinfo command of avicap.

pathNamedestroy

Destroys the dib widget.

pathNamedrawframedata

Draws the framedata in the dib widget. The widget should have been initialized with begin. The framedata can be e.g. the data returned by an avicap capture.

pathNameend

Ends the drawing of video frames. Can be used in order to use another bitmapinfo value for the next video frames thanks to the use of begin.

pathNamegetsize

Returns a tcl list containing the current width and height of the dib widget.

pathNamerefresh

Forces a refresh of the dib since sometimes, when using e.g. DIVX codecs, the video gets dirty.

pathNamesetsizewidth height

Sets the size of the dib widget, and resizes the video frames. Depending on the codec used for the video frames, resizing the window with the mouse works or crashes the application !!! So it is better to call setsize and to disable the manual window resizing.

EXAMPLE

load vfwtcl.dll

avicap .avi

pack .avi

.avi connect 0

.avi preview 50

.avi setcapturesetup -thread 1 -captureaudio 0

if {[.avi compressdlg]!="DIB "} {

set compressed 1

.avi begincompression

} else {

set compressed 0

}

dib .dib 640 480

.dib begin [.avi getbmpinfo $compressed]

pack .dib

proc video_callback {w data datalen videohdr} {

.dib draw $data

}

pack [button .stop -text "Exit" -command stop]

.avi cbkonvideostream video_callback $compressed

.avi capture

proc stop {} {

global compressed

.avi stopcapture

if {$compressed} {

.avi endcompression

}

.dib end

.dib destroy

.avi disconnect

.avi destroy

# Do not forget to destroy at the end

}

SEE ALSO

Avicap, avifile

AUTHOR

Emmanuel Grolleau © 2002, contact: (please put “vfwtcl” in the subject field)