Chapter 3: Xt Video Widgets




Parallax Graphics offers four Xt video widgets (VideoIn, VideoOut, JPEG, and TCWindow) that support a full range of video capabilities: video input with control of input settings (color, image size, etc.), video output to a VCR or other external device, and JPEG compression and decompression of video for videoconferencing and movie capture and playback. These widgets are available to developers on Sun Solaris and HP-UX platforms. This chapter includes:

Overview
Source Code for Applications
Source Code for Example Programs
Include and Library Files
Usage, Makefile, and Imakefile Support
For More Information
VideoIn Widget
VideoOut Widget
JPEG Widget
TC Window Widget


Overview


Four widgets are provided to speed your development of Xt-based video applications for the XVideo, PowerVideo, and MultiVideo video cards from Parallax:

Table 1-1

Xt Widgets use and behavior.
Widget Use Behavior
Video In Displays live or still video in an X window, and adjusts display characteristics (color settings, display size, etc.)
The VideoIn widget creates an X window on the display and fills it with video, applying X resources (display characteristics) that you set for the widget
VideoOut Exports a user-selected region of the display as video to a TV monitor, VCR, or other such video device connected to your XVideo card On video framebuffer cards (Sun XVideo, PowerVideo, MultiVideo) the VideoOutWidget grabs anything drawn to a user-selected reion of the display--such as video, mouse, and window movements--and exports this as video to a connected video output device. On video overlay cards, (Sun XVideo-Xtra, H-P XVC700), only the video and images on the overlay card can be output.
JPEG Stores the contents of an X window in a JPEG-compressed image file; decompresses and displays a JPEG-compressed image; and converts JPEG-compressed images into JFIF images (or vice versa). Designed for general-purpose, hardware assisted JPEG rendering and compression, the JPEG widget can be used with XVideo and PowerVideo cards. This widget will compress live video and still images displayed by Parallax cards, and import JPEG data to and from JFIF files. On the video framebuffer cards(Sun), this widget can also compress the contents of any 24-bit X window.
TCWindow Creates a window suitable for displaying video for JPEG decompression for Xt or Motif applications. The TCWindow widget creates a TrueColor window if possible, or if TrueColor is not available (for example with an 8-bit framebuffer), TCWindow will create a default-depth visual window.

Note: Certain display characteristics have been hard-coded in out Xt Widgets. The video input type, for example, is set to PLX_RGB24, since this is the only type supported by Parallax's XVideo, PowerVideo, and MultiVideo video cards; and the window gravity is ignored (set to ForgetGravity). Also, the JPEG widget allocates shared memory (and deallocates memory of the JPEG widget is "destroyed" by the application before exiting); programmers are not required to keep track of shared memory or to allocate manually.

Source Code for Applications


We provide source-code for our applications, VideoTool and MovieTool, which demonstrate how to program with the Parallax Xt video widgets. The source files for the application programs are located in $PARALLAX_HOME/src in the following sub-directories:

Table 1-2 Application locations within $PARALLAX_HOME/src:

Application Summary Source Location
MovieTool Sun Solaris 2.x and HP-UX: Captures and plays back MovieTool format movies with audio in real-time.
/motif/MovieTool
VideoTool Sun Solaris 2.x and HP-UX: Displays live video (up to two simultaneously for XVideo), captures still images, adjusts color settings and image size, sends video out to external devices for XVideo /motif/VideoTool

Note: These motif applications are not available for SunOS 4.1.x/X11R5.

Source Code for Example Programs


To demonstrate how to use the Parallax Xt video widgets, we provide simple source-code example programs that can be run from the UNIX command line. These example programs are not as carefully built as the application programs, but do provide useful brief examples of how to use the Parallax development tools and hardware capabilities.
To use the sample programs:
1. Look for a program that has some functionality you want to use (see summaries below). See how the program works (Multimedia Users Guide, Appendix C) and try out the program.
2. Look at source code for the sample program. The source files for sample programs are located in $PARALLAX_HOME/src in the following sub-directories:

Table 1-3 Sample program locations within $PARALLAX_HOME/src:
Sample Program Summary Source File Name and Location
jpegContinuousTest Opens a live video display window, captures and JPEG-compresses a series of still images, and decompresses and displays them in another window (without saving them).
/xt/example/jpegContinuousTest.c
jpegFileTest Displays a previously captured JFIF still image /xt/example/jpegFileTest.c
jpegPlaybackTest Opens, decompresses, and displays MovieTool movies, then displays performance statistics /xt/example/jpegPlaybackTest.c
jpegTest Opens a live video display window, captures and compresses a still image, then decompresses and displays it (without saving it). /xt/example/jpegTest.c
jpegTimingTest Displays live video, captures and JPEG-compresses a MovieTool movie file, and saves the movie to disk. /xt/example/jpegTimingTest.c
xvInTest Opens a video window and displays live video from the first available NTSC, PAL, or SECAM video source. /xt/example/xvInTest.c

Note: X11R5 users: If you are using SunOS 4.1.x and X11R5, look in "PARALLAX_HOME/X11R5/src/xt/examples."

Include and Library Files


Programs developed with the Xt widgets should include the <XPlxExt.h> and <XVideoIn.h> if you're using the VideoIn widget, <XVideoOut.h> if you're using the VideoOut widget, <JPEG.h> if using the JPEG widget, and/or <TCWindow.h> if using the TrueColor Window widget--along with standard <stdio.h>, <X11/Xlib.h>, and other include files--and shoudl be compiled with the Parallax Xlib and Xt library files, libXPlx.a libXtPlx.a, and libXv.a. For more details please see Appendix A: Include and Library Files.

Note: If you are using Solaris 2.4 or earlier, you do not need to compile libXv.a

1. Add the appropriate include files to your application sourcefile:

#include <XPlxExt.h>
#include <XVideoIn.h, XVideoOut.h, JPEG.h, or TCWindow.h>


Usage, Makefile, and Imakefile Support



1. If you are using a Makefile, add the applicable compiler command to your application Makefile:

Parallax software for Solaris 2.5 (framebuffers and Xtra), HP 9.3, or later:
cc <sourcefile> -L$(PARALLAX_HOME)/lib -lXtPlx -lXPlx -lXv -lXext -lXt -lX11 -lm

Parallax software for Solaris 2.4 or earlier:
cc <sourcefile> -L$(PARALLAX_HOME)/lib -lXTvid -lXvid -lXext -lXt -lX11 -lm

Parallax software for HP-UX version 9.2 or earlier:
cc <sourcefile> -L$(PARALLAX_HOME)/lib -lXTvid -lXvid -lXv -lXext -lXt -lX11 -lm

Parallax software for Sun Solaris 1.x(4.1.x) and X11R5 version 1.2:
cc <sourcefile> -L$(PARALLAX_HOME)/X11R5/lib

Note: The user must set a site-specific environment variable to successfully compile the makefiles. PARALLAX_HOME should point to the directory where the VDE software is installed.

Example:
setenv PARALLAX_HOME /opt/parallax

Note: Motif users on the Sun platform: If you are developing a Motif application using Parallax libraries and our imakefile support, you must have the Motif distribution installed in "/opt/SUNWmotif" (Motif located here or linked to this location).

Example:
setenv MotifHome /opt/SUNWmotif

2. Parallax software version Solaris 2.5 or HP 9.3 or higher: If you are using an Imakefile, be sure that these lines are included in you application Imakefile:

	INCLUDES	= -I$(INCLUDESRC) -I$(PLXINCLUDESRC)
	DEPLIBS		= $(PlxXtDepLib) $(DEPEXTENSIONLIB)
			  $(DEPXTOOLLIB) $(DEPXLIB)
	LOCAL_LIBRARIES = $(PlxXtLib) $(XTOOLLIB) $(XLIB)
	SYS_LIBRARIES	= $(SystemSpecific)


Note: Sample Imakefiles are provided in the same location as sample application source code. You can copy the Imakefile provided and modify it as needed.

3. ANSI-C: You must use an ANSI-C compiler to compile the source files included with your Video Development Environment.

For More Information


For more details on the include and library files, please see Appendix A: Include and Library Files

For a description of the Parallax variables that can be used with Xt resources to hard-code and/or alter the behavior of video inputs and outputs, please see Appendix b: Parallax Video Variables. (These variables are defined in the plx_* data structures in the XPlxExt.h include file).

The Parallax Xt widgets rely on standard Xt events and messages, which are documented in standard Xt publications from O'Reilly & Associates.

VideoInWidget


Displays live or still video in an X window, and adjusts display characteristics such as color settings.

X Resources



A set of VideoIn resources are provided to control the behavior of the widget's video input window. These resources are a subclass of the Xt Intrinsics Core class and inherit basic X display behavior from the Core class. (The VideoIn widget uses all of the resources available in the Xt Intrinsics Core class of resources.)

The VideoIn resource class pointer is VideoInWidgetClass.

The VideoIn resource class name is VideoIn.

The VideoIn widget's X resource class, type, and default values are outlined in the table on the following page.

Full descriptions of the X Resources are on the following pages (in alphabetical order).

Standard Xt[Va]SetValues and Xt[Va}GetValues routines can be used with the VideoIn resources to set and get resources for the video input window.

Note: If a resource is set from the application, any user-specified value for that resource set by .Xdefaults or xrdb will be overwritten.

The following legend is used throughout the resource descriptions to indicate which description can be written with Xt[Va]SetValues and which resource values can be retrieved with Xt[Va]GetValues:

Set=Writable via Xt[Va]SetValues

Get=Readable via Xt[Va]GetValues

X Resource Summary Type Default Value
XtNautoSearch Tells the widget how to search for a valid video signal.
int True
XtNblankIntervalHeight Represents the height of the blanking interval for the incoming video signal, based on the signal standard currently in use.
Dimension 45 (Signal Dependent)
XtNbrightness Represents the brightness for the video signal.
int 128
XtNchannel Represents the channel being used for the video signal.
int PLX_INPUT_0
XtNcontrast Represents the contrast for the video signal.
int 128
XtNcropped Controls video cropping in the video input window.
Boolean False
XtNdiagnostics If True, the widget will print diagnostic messages.
Boolean False
XtNdisplayRect Points to an XRectangle that describes the window area to display video.
XRectangle* NULL (Internally allocated)
XtNdrawMethod Specifies a function that will be called each time the widget redraws itself.
XtExposeProc NULL
XtNhardwareType Represents the type of Parallax video card.
int PLX_XVIDEO_24
XtNhue Represents the hue for the video signal.
int 128
XtNinstance Selects the wire instance for a video input signal.
int 0
XtNinterlaced Verifies whether the incoming video signal is interlaced.
Boolean True
XtNlive Turns on and off live video digitization in the video input window.
Boolean True
XtNnewFrame Displays a new still image from the video source.
Boolean False
XtNnormalAspectRatio Controls the aspect ratio of the video input window.
Boolean True
XtNresizeParent Defines whether size changes in this widget should propagate to the widget's parent.
Boolean False
XtNrestoreColorSettings Sets the color settings to those previously stored.
int FACTORY
XtNsaturation Represents the saturation for the video signal.
int 128
XtNsaveColorSettings Saves the current color settings.
int FACTORY
XtNshowBlankInterval Controls display of the blanking interval in the video input window.
Boolean False
XtNsignalFormat Represents the video input format (Composite, S-VHS, ...).
int PLX_COMP
XtNsignalHeight Represents the height of the incoming video signal, based on the signal standard currently in use.
Dimension 480 (Signal dependent)
XtNsignalStandard Represents the video input standard (NTSC, PAL, SECAM).
int PLX_NTSC
XtNsignalWidth Represents the width of the incoming video signal, based on the signal standard currently in use.
Dimension 640 (Signal dependent)
XtNsourceRect Points to an XRectangle structure that describes the area of the incoming video signal to be digitized.
XRectangle* NULL (Internally allocated)
XtNsync Verifies whether the current video input channel has valid sync (does this channel have an incoming video signal).
Boolean True
XtNvideoParameterString Video framebuffer cards only: Supports video effects such as black and white video, inverse video (like a film negative).
String "COLOR"


XtNautoSearch: Get, Set


VideoIn widget: Parallax software for Solaris 2.5 or version 9.3 for HP or higher: Tells the widget how to serach for a valid video signal. By default, the widget will search every input on each board until it finds a valid video signal. If no valid signal is found, the XtNsync resource is set to False.
The AutoSearch values available are:
True Search all boards on each input for a valid signal
AutoSearchInput0 Search all wires connected to the first video digitizer for a valid signal.
AutoSearchInput1 Search all wires connected to the second video digitizer for a valid signal.
False Do not perform an auto search.
If an autosearch is performed, the XtNsync resource will be updated to indicate if a valid signal was found.
Example

Widget videoInWidget;
XtVaSetValues(videoInWidget, 
		XtNautoSearch, AutoSearchInput0, NULL);


XtNblankIntervalHeight: Get(Read Only)



VideoIn widget: Represents the height of the blanking interval for the incoming video signal, based on the signal standard currently being used.

Example

Widget videoInWidget;
int blankIntervalHeight;
XtVaGetValues(videoInWidget, 
		XtNblankIntervalHeight, &blankIntervalHeight, NULL);
printf("The unviewable portion of the video signal is %d pixels high\n",blankIntervalHeight);


XtNbrightness: Set, Get



VideoIn widget: Represents the brightness for the video signal. Valid values range from 0 (darkest) to 255 (brightest).

Example
Widget videoInWidget;
int brightnessValue;
XtVaGetValues(videoInWidget, 
		XtNbrightness, &brightnessValue, NULL);


XtNchannel: Set, Get



VideoIn widget: Represents the channel being used for the video signal. Valid values-- which are taken from the include file XPlxExt.h--include: PLX_INPUT_0 (the default), PLX_INPUT_1 (available for all XVideo products), and PLX_IO_OFF (to turn off incoming video).

Example

Widget videoInWidget;
XtVaSetValues(videoInWidget, 
		XtNchannel, PLX_INPUT_0, NULL);
printf("Now showing channel 1a.  About to switch to channel 2.\n");
XtVaSetValues(videoInWidget, 
		XtNchannel, PLX_INPUT_1, NULL);


XtNcontrast: Set, Get


.
VideoIn widget: Represents the contrast for the video signal. Valid values range from 0 (least contrast) to 255 (greatest contrast).

Example

Widget videoInWidget;
int contrastValue;
XtVaSetValues(videoInWidget, 
		XtNbrightness, brightnessValue, NULL);


XtNcropped: Set, Get


.
VideoIn widget: Controls video cropping in the widget's window. When set to True, the video signal is cropped against the widget's window (that is, if the area of the video signal is larger than the area of the window, some of the video signal is obscured). The gravity of the crop is forget gravity, meaning that it is undefined. In other word, a random area of the video signal is shown.

When False, the video signal is squeezed to fit into the widget's window (the video shrinks to fit completely inside the widget's window).

Example

Widget videoInWidget;
XtVaSetValues(videoInWidget, 
		XtNcropped, True, NULL);


XtNdiagnostics: Set, Get


.
VideoIn widget: When set to True, the widget will print diagnostic messages to help debug the behavior of the widget.

Example

input1Widget = XtVaCreateManagedWidget("input1Widget,
			xVideoInWidgetClass, input1Shell,
			XtNdiagnostics, True, 
			NULL);


XtNdisplayRect: Set, Get


.
VideoIn widget: Points to an XRectangle structure that describes the area of the widget's window in which video will display. By default, the area of the XRectangle is the full size of the widget's window. By modifying the area (size) of the XRectangle-- or by supplying your own rectangle--you can inform the VideoIn widget to display its incoming video signal in a portion of the widget's window (the rest of the window would be black). If the cropped resource is set to False, the video signal fits completely in this rectangle. If the cropped resource is set to True, the video signal is cropped against this rectangle.

Example


If you wanted to display a video signal at a quarter of the window's size, centered within the window, you might do the following (for this example, assume that the widget's window is 640x480 pixels in size):
Widget	videoInWidget;
XRectangle	myRect;
myRect.x = (640/2) - (320/2);
myRect.y = (480/2) - (240/2);
myRect.width = 320*zoomFactor;
myRect.height = 240*zoomFactor;
XtVaSetValues(videoInWidget, XtNdisplayRect, &myRect, NULL);


Note: zoomFactor applies only to video overlay cards (XVideo-Xtra on Sun, and all video cards on H-P systems). zoomFactor's default value is 1 for normal-sized display, and 2 for enlarged display (two times width, height, four times area). If you are writing code for video framebuffer cards (XVideo, PowerVideo, and MultiVideo for Sun), just leave out zoomFactor (or set zoomFactor to 1):

	myRect.width = 320;
	myRect.height = 240;


Note: The widget does not copy this XRectangle structure; it only maintains a copy of the pointer to this structure. If you specify your own display rectangle, do not let the structure go out of scope. If the structure does go out of scope, the results are unpredictable.


XtNdrawMethod: Set, Get


.
VideoIn widget: Parallax software for Solaris 2.5 (framebuffer cards only) Specifies a function that will be called each time the widget redraws itself. This is useful for drawing graphics into the widget.

Note: Video overlay cards: This resource is not recommended for use with video overlay cards because it uses graphics over video. It is included in the software releases for the overlay cards XVideo-Xtra (Solaris 2.5) and HP (Parallax version 9.3 or higher) for cross-platform developers.
Example

This draw method will paint a border around the window:
void CustomDrawMethod(Widget w, XEvent* event, Region region)
{
  Dimension width, height;
  .
  .
  .
     XtVaGetValues(w,
		XtNwidth, &width
		XtNheight, &height
		NULL);
     XDrawRectangle(XtDisplay(w),
		XtWindow(w),
		gc,
		0, 0,
		width, height);
}

XtVaCreateManagedWidget("input1Widget",
			xVideoInWidgetClass,
			input1Shell,
			XtNdrawMethod, CustomDrawMethod,
			NULL);


Note: The "XEvent*" and "Region" parameters may be NULL when your drawing function is called. This is the case if a widget instructs itself to redraw, as when displaying a new still image. In this case your application must assume that the whole window is damaged and must be redrawn.


XtNhardwareType: Get(Read Only)


.
VideoIn widget: Represents the type of Parallax hardware product currently installed. The hardware type for XVideo, PowerVideo, and MultiVideo--as taken from the include file XPlxExt.h--is PLX_XVIDEO_24, and is currently the only product for which this widget is supported.

Example

Widget 	videoInWidget;
int	hardwareType;
XtVaGetValues(videoInWidget, 
		XtNhardwareType, &hardwareType,
			NULL);
if (hardwareType != PLX_VIDEO_24)
	printf("You are not working with an XVideo board.\n");


XtNhue: Set, Get


.
VideoIn widget: Represents the hue for the video signal. Valid values range from 0 to 255. (Not valid for PAL or SECAM).

Example

Widget 	videoInWidget;
int	hueValue;
XtVaSetValues(videoInWidget, 
		XtNhue, hueValue,
			NULL);


XtNinstance: Set, Get


.
VideoIn widget: Parallax software for Solaris 2.5 or version 9.3 for HP or higher: Selects the wire instance. This resource is only useful if you are not using auto-search.

Example

Widget 	videoInWidget;
XtVaSetValues(videoInWidget, 
		XtNchannel, PLX_INPUT_0,
		XtNsignalFormat, PLX_COMP,
		XtNinstance, 1,			/* Select the Composite */
						/* 2 wire (2nd instance) */
		XtNsignalStandard, PLX_NTSC,
		NULL);


XtNinterlaced: Get (Read Only)


.
VideoIn widget: Verifies whether the incoming video signal is comprised of interlaced fields. If True, incoming video signal is interlaced. If False, the signal is a non-interlaced signal.

Example

Widget 	videoInWidget;
Boolean 	interlaced;
XtVaSetValues(videoInWidget, 
		XtNinterlaced, &interlaced, 
		NULL);
if (interlaced == True)
	printf("The incoming signal is an interlaced TV signal.\n");

Note: This call should be used only after verifying the existence of a valid video signal (see XtNsync).


XtNlive: Set, Get


.
VideoIn widget: Turns on and off live video digitization in the widget's window. When set to True, video displays live in the widget's window (normal motion video appears). When set to False, the widget freezes the last digitized frame of video and displays the stilled image until either this resource or the XtNnewFrame resource is set to True.

Example

Widget 	videoInWidget;
Boolean 	interlaced;
XtVaSetValues(videoInWidget, 
		XtNlive, True, 
		NULL);




XtNnewFrame: Set (Write Only)


.
VideoIn widget: Displays a new still image from the video source. When set to True, the widget digitizes a new frame of video from the incoming video signal and displays it until either this resource or the live resource is set to True. (This resource only has meaning when the live resouce is set to False[that is, when still video is in effect]). This resource can be used to display a new frame of video from the incoming video signal after digitizing and freezing video in the widget's window.

Example


A common application would be to grab a single frame of video and store it as an image file to disk, or to record a series of still images to disk to create a movie (these images would commonly be obtained form a videodisc player or VCR). Typically, the recording sequence would be performed in a loop as follows:
Widget 	videoInWidget;
Boolean 	interlaced;
XtVaSetValues(videoInWidget, 
		XtNlive, False, 
		NULL);
	/* stops digitizing, shows still video frame */
AdvanceVideoDiscPlayerToNextFrame();
	/* imaginary function, goes to next frame */
XtVaSetValues(videoInWidget, 
		XtNnewFrame, True, 
		NULL);
	/* grabs new frame of video, shows it as a still */



XtNnormalAspectRatio: Set, Get


.
VideoIn widget: Controls the aspect ratio of the widget's window. When set to True, the widget's window maintains a 4-to-3 aspect ratio (that is, if the widget's window is four units wide, the window height is maintaines at three units high.) when the widget's window is resized, the widget does its best to resize itself to maintain a 4-to-3 aspect ratio. This feature is useful when trying to display video in the same proportions as it is digitized, so that resizing the widget doesn't make the video look stretched or squeezed.


When set to False, the widget's window can be resized to any proportion. A possible side effect of this is that, when the cropped resource is set to False, video may look squeezed (if the proportions of the window are not 4-to-3, the video image does not look like the original).

Example

Widget 	videoInWidget;
XtVaSetValues(videoInWidget, 
		XtNnormalAspectRatio, False, 
		NULL);



XtNresizeParent: Set, Get


.
VideoIn widget: Defines whether size changes in this widget should be propagated to the widget's parent. Strictly speaking, it is ill-advised for a widget to resize its parent, (but video might be thought of as a special case which should be allowed to break the rules).

Example


This resource is probably best used when the widget is created. In this example, the programmer creates a VideoIn widget that attempts to force its parent widget to conform to the widget's preferred size. Again, this is probably not necessary, but the example is included here for the sake of completeness. Note that the widget is referred to the first video input when it is created.
input1Widget = XtVaCreateManagedWidget("input1Widget,
			xVideoInWidgetClass, input1Shell,
			XtNchannel, PLX_INPUT_0, 
			XtNresizeParent, True, 
			NULL);



XtNrestoreColorSettings: Set (Write Only)


.
VideoIn widget, framebuffer cards only: Sets the widget's color settings (brightness, contrast, hue, saturation) to those stored in one of the framebuffer cards on-board NVRAM locations. (Color settings can be stored in the NVRAM using the XtNsaveColorSettings resource.) There are two valid NVRAM entries (as defined in the include file XPlxExt.h): USER_0 and USER_1.

Note: Overlay cards: For overlay cards, see Note under XtNsaveColorSettings
Example

Widget 	videoInWidget;
int brightness, saturation, contrast, hue;
XtVaSetValues(videoInWidget, 
		XtNrestorecolorSettings, USER_0, 
		NULL);
XtVaGetValues(videoInWidget, 
		XtNbrightness, &brightness, 
		XtNsaturation, &saturation, 
		XtNcontrast, &contrast, 
		XtNhue, &hue,
		NULL);
printf("Color values:  brightness:%d, saturation:%d, contrast:%d, hue:%d\n",
brightness, saturation, contrast, hue);



XtNsaturation: Set, Get


.
VideoIn widget: Represents the saturation for the video signal. Valid values range from 0 (least saturated) to 255 (most saturated).

Example

Widget 	videoInWidget;
int saturationValue;
XtVaSetValues(videoInWidget, 
		XtNsaturation, saturationValues, 
		NULL);



XtNsaveColorSettings: Set (Write Only)


.
VideoIn widget, framebuffer cards only: Savess the current color settings (brightness, contrast, hue, saturation) to one of the framebuffer card's on-board NVRAM locations. These settings can later be retrieved with the XtNrestoreColorSettings resource.) There are two valid NVRAM entries (as defined in the include file XPlxExt.h): USER_0 and USER_1.

Note: Overlay cards: For overlay cards, color settings could theoretically be saved to a file. Parallax has not created functions that support this functionality for overlay because of the question of where to put the file (ideal locations would vary from user to user), and the issue of getting read/write permissions.
Example

Widget 	videoInWidget;
XtVaSetValues(videoInWidget, 
		XtNsavecolorSettings, USER_0, 
		NULL);



XtNshowBlankInterval: Set, Get


.
VideoIn widget: Controls the display of the blanking interval in the widget's window. When set to True, the blanking interval is shown as part of the incoming video signal. When set to False, only the viewable portion of the incoming video signal displays.

Example

void ShowBlankInterval()
{
  XtVaSetValues(videoInWidget, XtNshowBlankInterval, False, NULL);
	/* determine the full height of this video signal */
  XtVaGetValues(videoInWidget, XtNsignalHeight, &height, NULL);
  printf("Without the blank interval showing, the signal height is %d pixels.\n",height);
  XtVaSetValues(videoInWidget, XtNshowBlankInterval, True, NULL);
	/* determine the full height of this video signal */
  XtVaGetValues(videoInWidget, XtNsignalHeight, &height, NULL);
  printf("With the blank interval showing, the signal height is %d pixels.\n",height);
}



XtNsignalFormat: Set, Get


.
VideoIn widget: Represents the format of the video input signal. Valid choices--as taken from the include file XPlxExt.h--are PLX_COMP (composite video), PLX_YC (SuperVHS), PLX_YUV (YUV component video), and PLX_RGB (RGB component video).

Note: On the Sun platform, some formats are not available on all incoming video channels. For example, PLX_YUV and PLX_RGB are only available on the second video input provided on the XVideo+RGB option card.
Example

When the programmer sets this resource with Xt[Va]SetValues, the widget looks for an incoming video signal of the format requested. The programmer can determine the format of the signal currently being used by passing this resource to Xt[Va]GetValues.
Widget 	videoInWidget;
XtVaSetValues(videoInWidget, 
		XtNsignalFormat, PLX_COMP, 
		NULL);



XtNsignalHeight: Get (Read Only)


.
VideoIn widget: Represents the height of the incoming video signal, based on the signal standard currently being used. When the XtNshowBlankInterval resource is set to True, this resource represents the height of the viewable portion of the incoming video signal plus the height of the blanking interval. When the XtNshowBlankInterval resource is set to False, this resource represents only the height of the viewable portion of the incoming video signal.

Example

In this example, the programmer makes the widget one-quarter of its normal size.
Dimension	width, height;
	/* Determine the full size of this video signal */
XtVaGetValues(videoInWidget, 
		XtNsignalWidth, &width, 
		XtNsignalHeight, &height, 
		NULL);
	/* Reset the video widget to one-fourth the size of the signal */
	/* This is done as a side effect of resizing the video widgets */
	/* parent shell						       */
XtVaSetValues(videoInWidget, 
		XtNWidth, (width/2), 
		XtNHeight, (height/2), 
		NULL);



XtNsignalStandard: Set, Get


.
VideoIn widget: Represents the video standard of the video input signal. Valid choices--as taken from the include file XPlxExt.h--are PLX_NTSC, PLX_PAL, and PLX_SECAM>

Example

When the programmer sets this resource with Xt[Va]SetValues, the widget looks for an incoming video signal of the type requested. The programmer can determine the type of the signal currently being used by passing this resource to Xt[Va]GetValues.
Widget 	outputWidget;
XtVaSetValues(outputWidget, 
		XtNsignalStandard, PLX_NTSC, 
		NULL);



XtNsignalWidth: Get (Read Only)


.
VideoIn widget: Represents the width of the video input signal, based on the signal standard currently being used.

Example

See the example for XtNsignalHeight


XtNsourceRect: Set, Get


.
VideoIn widget: Points to an XRectangle structure that describes the area of the incoming video signal to be digitized. By default, the entire incoming video signal is digitized.
Example

By modifying the area (size) of the XRectangle--or by supplying your own, uniquely sized rectangle--you can inform the VideoIn widget to digitize only a portion of the incoming video signal. If the incoming video signal were 640x480 pixels in size and you wanted to display only the top, left quarter of the signal, you might do the following:
Widget	videoInWidget;
XRectangle	myRect;
myRect.x = 0;
myRect.y = 0;
myRect.width = 320*zoomFactor;
myRect.height = 240*zoomFactor;
XtVaSetValues(videoInWidget, XtNsourceRect, &myRect, NULL);

Note: zoomFactor applies only to video overlay cards (XVideo-Xtra on Sun, and all video cards on H-P systems). zoomFactor's default value is 1 for normal-sized display, and 2 for enlarged display (two times width, height, four times area). If you are writing code for video framebuffer cards (XVideo, PowerVideo, and MultiVideo for Sun), just leave out zoomFactor (or set zoomFactor to 1):
	myRect.width = 320;
	myRect.height = 240;

Note: The widget does not copy this XRectangle structure; it only maintains a copy of the pointer to this structure. If you specify your own display rectangle, do not let the structure go out of scope. If the structure does go out of scope, the results are unpredictable.


XtNsync: Get (Read Only)


.
VideoIn widget: Verifies whether a valid video-signal sync is detected on the current video input channel. If True, a valid sync signal is detected. If False, there is not valid incoming video signal.

Example


Widget 	videoInWidget;
boolean	sync;
XtVaGetValues(videoInWidget, 
		XtNsync, &sync, 
		NULL);
if (sync == False)
  printf("There is no video signal connected to this channel.  Please check cables.\n");



XtNvideoParameterString: Set,Get


.
VideoIn widget, video framebuffer cards only: Used for limited special effects provided by the board. This resource works only for Parallax video framebuffer cards. Currently the effects available to the programmer are:

INVERTED To display reverse video (which looks like a film negative).
NONINVERTED To restore normal video (turn off INVERTED effect).
BW To display incoming full-color video in black-and-white. This string turns off internal comb filters and eliminates any chroma information prior to storing data in the video buffer.
COLOR To restore the incoming video signal to full color
GENLOCK To lock signal sync of an incoming video signal on the current input channel to the signal sync of a video output signal on the current output channel. (To digitize and record seamless video from a device on the XVideo Input#1 channel to a device on the XVideo output channel, the two devices should be genlocked. If the devices are not genlocked--and since many devices operate at different clock rates--video frames may be skipped and the video output may appear choppy.
FREERUN To turn off the genlock effect

Example

In this example, the programmer shows reverse (inverted) video (like a film negative).

Widget 	videoInWidget;
XtVaSetValues(videoInWidget, 
		XtNvideoParameterString, "INVERTED", 
		NULL);





VideoOut Widget


Exports either a user-selected window or region of the display as video to any device connected to the XVideo output port.

Note: Overlay cards: Only content on the Parallax video overlay card will show up as output (live or still video, JPEG movies and stills, Ximages on the Parallax card). Any images or graphics that are not on the overlay will show up as black in the output. A normal X window cannot be used for video output.

Xt Resources

The VideoOut widget requires the Parallax XVideo board.

A set of VideoOut resources are provided to control the behavior of the widget's video output region. These resources are a subclass of the Xt Intrinsics Core class and inherit basic X display behavior from the Core class. (The VideoOut widget uses all of the resources available in the Xt Intrinsics Core class of resources.)

The VideoOut resource class pointer is VideoOutWidgetClass.

The VideoOut resource class name is VideoOut.

Standard Xt[Va]SetValues and Xt[Va]GetValues routines can be used with the VideoOut resources to set and get resources for the video input window.
Note: If a resource is set from the application, any user-specified value for that resource set by .Xdefaults or xrdb will be overwritten.

The following legend is used throughout the resource descriptions to indicate which description can be written with Xt[Va]SetValues and which resource values can be retrieved with Xt[Va]GetValues:

Set = Writable via Xt[Va]SetValues

Get = Readable via Xt[Va]GetValues

X Resource Summary Type Default Value
XtNchannel Represents the channel being used for the video signal.
int PLX_OUTPUT_0
XtNdestRect Points to an XRectangle specifying the desired area of the video output region to be sent to the video output port.
XRectangle* NULL (Internally allocated)
XtNdiagnostics If True, the widget will print diagnostic messages.
Boolean False
XtNhardwareType Represents the type of Parallax video card.
int PLX_XVIDEO_24
XtNnormalAspectRatio Controls the aspect ratio of the video output region.
Boolean True
XtNsignalFormat Represents the video format (Composite, S-VHS, ...) to be used to produce a video output signal.
int PLX_COMP
XtNsignalHeight Represents the height of the video output signal being produced, based on the signal standard currently in use.
Dimension 480 (Signal dependent)
XtNsignalStandard Represents the video standard (NTSC, PAL) to be used to produce a video output signal.
int PLX_NTSC
XtNsignalWidth Represents the width of the incoming video signal, based on the signal standard currently in use.
Dimension 640 (Signal dependent)
XtNsourceRect Points to an XRectangle structure that specifies the area to be grabbed and exported as a video output signal.
XRectangle* NULL (Internally allocated)
XtNsourceWin Represents the VideoOut widget's output region (X window) on the display whose contents will be grabbed and sent to output
Window Root Window ID


XtNchannel: Set, Get



VideoOut widget: Represents the channel being used to export the video output signal. Valid values for this widget-- which are taken from the include file XPlxExt.h--include: PLX_OUTPUT_0 (the default), and PLX_IO_OFF (to turn off incoming video).

Example

Widget videoOutWidget;
int contrastValue;
XtVaSetValues(videoOutWidget, 
		XtNchannel, PLX_OUTPUT_0, NULL);
printf("Just turned on video output generation.  About to turn it off.\n");
XtVaSetValues(videoOutWidget, 
		XtNchannel, PLX_IO_OFF, NULL);


XtNdestRect: Set, Get


.
VideoOut widget: Points to an XRectangle structure specifying the desired area of the video output region to be sent to the video output port. Generally, the application should set the width and height of the destination rectangle to the signal size multiplied by the zoom factor. For Parallax framebuffer cards, use 1 for the zoom factor; if you are developing only for framebuffer cards, omit zoom factor altogether.
Example

To produce a video output signal in which only the top left quarter contains useful video information (the rest being black), the programmer might do the following:
Widget	videoOutWidget;
XRectangle	myRect;
myRect.x = 0;
myRect.y = 0;
myRect.width = 320*zoomFactor;
myRect.height = 240*zoomFactor;
XtVaSetValues(videoOutWidget, XtNsourceRect, &myRect, NULL);


Note: By combining XtNsourceRect and XtNdestRect, the image area to be output can be expanded or squeezed or bordered. Having a small source area and a full size destination results in an expanded image filling the full output display.

Note: The widget does not copy this XRectangle structure; it only maintains a copy of the pointer to this structure. If you specify your own display rectangle, do not let the structure go out of scope. If the structure does go out of scope, the results are unpredictable.


XtNdiagnostics: Set, Get


.
VideoOut widget: When set to True, the widget will print diagnostic messages to help debug the behavior of the widget.

Example

output1Widget = XtVaCreateManagedWidget("output1Widget,
			xVideoOutWidgetClass, output1Shell,
			XtNdiagnostics, True, 
			NULL);


XtNhardwareType: Get(Read Only)


.
VideoOut widget: Represents the type of video card currently installed: Parallax video cards versus any other video cards. The hardware type for all XVideo, PowerVideo, and MultiVideo cards--as taken from the include file XPlxExt.h--is PLX_XVIDEO_24, and XVideo is currently the only product for which this widget is supported.

Example

Widget 	videoOutWidget;
int	hardwareType;
XtVaGetValues(videoOutWidget, 
		XtNhardwareType, &hardwareType,
			NULL);
if (hardwareType != PLX_VIDEO_24)
	printf("You are not working with an XVideo board.\n");


XtNnormalAspectRatio: Set, Get


.
VideoOut widget: Controls the aspect ratio of the video output region. When set to True, the widget's exports a video output signal from a region with a 4-to-3 aspect ratio (that is, if the widget's output region is four units wide, the region's height is maintained at three units high.) When the widget's XtNsourceRect resource is modified (when the width and height of the widget's output region are changed), the widget does its best to readjust the video output signal to maintain a 4-to-3 aspect ratio. This feature is useful to capture a region of the display kin tt looks good as a video signal, so that the resulting video doesn't look stretched or squeezed.

Example

In this example, the VideoOut widget can capture a rectangle of any proportions. Since the XtNnormalAspectRatio is set to False, a 400x400 pixel region of the display can be captured; if XtNormalAspectRatio were set to True, the VideoOut widget would resize the height of the output region to 300 pixels).
Widget 	videoOutWidget;
int contrastValue;
XtVaSetValues(videoOutWidget, 
		XtNnormalAspectRatio, False, 
		NULL);



XtNsignalStandard: Set, Get


.
VideoOut widget: Represents the video standard to be used to produce a video output signal. Valid choices--as taken from the include file XPlxExt.h--are PLX_NTSC and PLX_PAL.

Example

In this example, a PAL signal is produced from the region of the display being captured.
Widget 	videoOutWidget;
XtVaSetValues(videoOutWidget, 
		XtNsignalStandard, PLX_PAL, 
		NULL);



XtNsignalFormat: Set, Get


.
VideoOut widget: Represents the format of the video signal to be used to produce a video output signal. Valid choices--as taken from the include file XPlxExt.h--are PLX_COMP (composite video), PLX_YC (SuperVHS), PLX_YUV (YUV component video), and PLX_RGB (RGB component video).
Note: YUV and RGB are only available for the Sun XVideo-RGB product
Example

In this example, the programmer wants to produce an S-VHS signal from the region of the display being captured.
Widget 	videoOutWidget;
XtVaSetValues(videoOutWidget, 
		XtNsignalFormat, PLX_YC, 
		NULL);



XtNsignalWidth: Get (Read Only)


.
VideoOut widget: Represents the width of the video output signal being produced, based on the signal standard currently being used.

Example

See the example for the XtNsourceRect resource.


XtNsignalHeight: Get (Read Only)


.
VideoOut widget: Represents the height of the video output signal being produced, based on the signal standard for the output device currently being used..

Example

See the example for the XtNsourceRect resource.


XtNsourceWin: Set, Get


.
VideoOut widget: Represents the widget's output region (an X window on the display whose contents will be grabbed to produce a video output signal). By default, this resource is set to the window ID of the root window. Using the root window as the output region, the XtNsourceRect rectangle can be set to capture any visible area of the display (that is, the XtNsourceRect's coordinates are treated as absolute coordinates). If you set this resource to the window ID of any other visible window, the XtNsourceRect's coordinates are interpreted as relative to the window specified by the XtNsourceWin. Turn off XtNsourceWin by resetting the sourceWindow to the root window.

Note: Overlay cards: Only content on the Parallax video overlay card will show up as output (live or still video, JPEG movies and still, Ximages on the Parallax card.) Any images or graphics that are not on the overlay will show up as black in the output. A normal X window cannot be used for video output.

Note: The XtNsourceWin coordinates are used only as a hint to indicate the area to be grabbed for video output, and any portion of the XtNsourceWin that is not visible on the workstation display will not be visible in the video output signal. Whatever occludes the XtNsourceWin is shown, instead. (Black will appear for areas of the output region that are offscreen; otherwise, any objects or events occurring in the foreground of the output region will appear).

Example

Widget	videoOutWidget;
Window	sourceWindow;
XtVaSetValues(videoOutWidget, XtNsourceWin, sourceWindow, NULL);



XtNsourceRect: Set, Get


.
VideoOut widget: Points to an XRectangle structure that specifies the area to be grabbed and exported as a video output signal. The XtNsourceRect coordinates are relative to those of the window specified by the XtNsourceWin resource (if the XtNsourceWin is the root window, then the XtNsourceRect coordinates are treated as absolute coordinates). Usually (even in zoom 2x mode), the width and height of the sourceRect structure should be the size of the window.

Note: Overlay cards: Only content on the Parallax video overlay card will show up as output (live or still video, JPEG movies and still, Ximages on the Parallax card.) Any images or graphics that are not on the overlay will show up as black in the output. A normal X window cannot be used for video output.
Example

In this example, the maximum allowed region of the display is grabbed and exported as a video output signal.
int		width;
int		height;
XRectangle	myRect;
Widget		videoOutWidget;

XtVaGetValues(videoOutWidget, XtNsignalWidth, &width, 
			XtNsignalheight, &height, NULL);
myRect.x = 0;
myRect.y = 0;
myRect.width = width;
myRect.height = height;
XtVaSetValues(videoOutWidget, XtNsourceRect, &myRect, NULL);

Note: The widget does not copy this XRectangle structure; it only maintains a copy of the pointer to this structure. If you specify your own display rectangle, do not let the structure go out of scope. If the structure does go out of scope, the results are unpredictable.



JPEG Widget


Compresses and decompresses (displays) JPEG image data, and converts JPEG images to JFIF (or vice-versa). To view JPEG images, XVideo or PowerVideo cards' hardware compression and decompression are required.

Xt Widget Resources
A set of JPEG resources are provided to control the behavior of the widget's JPEG source and destination windows. These resources are a subclass of the Xt Intrinsics Core class and inherit basic X display behavior from the Core class. (The JPEG widget uses all of the resources available in the Xt Intrinsics Core class of resources.)

The JPEG resource class pointer is jpegWidgetClass.

The JPEG resource class name is JPEG.

Standard Xt[Va]SetValues and Xt[Va}GetValues routines can be used with the JPEG resources to set and get resources for the JPEG source and destination windows.

Note: If a resource is set from the application, any user-specified value for that resource set by .Xdefaults or xrdb will be overwritten.

The following legend is used throughout the resource descriptions to indicate which description can be written with Xt[Va]SetValues and which resource values can be retrieved with Xt[Va]GetValues:

Set=Writable via Xt[Va]SetValues

Get=Readable via Xt[Va]GetValues

X Resource Summary Type Default Value
XtNcompressDestRect Points to an XRectangle structure that describes the size of the image to be produced for compression
XRectangle* NULL (internally allocated)
XtNcompressSourceRect Points to an XRectangle structure that describes the ares of the source input window to be compressed
XRectangle* NULL (internally allocated)
XtNdestWin Represents the X window into which a JPEG image can be drawn.
Window 0
XtNdiagnostics If True, the widget will print diagnostic messages.
Boolean False
XtNdisplayDestRect Points to an XRectangle that describes the portion of the window into which the JPEG image is to be drawn.
XRectangle* NULL (Internally allocated)
XtNdisplaySourceRect Points to an XRectangle that describes the portion of the window into which the JPEG image is to be displayed.
XRectangle* NULL (Internally allocated)
XtNdrawMethod Specifies a function that will be called each time the widget redraws itself.
XtExposeProc NULL
XtNgetNewImage Informs the JPEG windget to compress a new image form the XtNsourceWin window.
Boolean False
XtNjfifInputFile Informs the widget to read a JFIF file from disk.
String NULL
XtNjfifOutputFile Informs the widget to save its current JPEG data to disk as a JFIF file.
String NULL
XtNjpegData Points to an XPlxCImage structure containing data for a JPEG image.
XPlxCImage* NULL
XtNputNewImage Informs the widget that new JPEG image data is available to display.
Boolean False
XtNqFactor Represents the Q factor to use when compressing (creating) and decompressing (displaying) JPEG images .
int 50
XtNsourceWin Represents the Xwindow from which to grab image data for compression.
Window 0
XtNsqueezeDest Controls the scaling behavior of the widget's destination window.
Boolean False
XtNuseSharedMemory Indicates whether the widget is currently using shared memory to store its JPEG data.
Boolean True

Note: The default Q factor was different (100) for Solaris 2.4, HP version 9.2, and earlier releases, because the Q tables we used then were different. We found out that our Q tables were not standard, so we corrected them for our Solaris 2.5 and HP version 9.3 or higher software releases.


XtNcompressDestRect: Set, Get


.
JPEG widget: Points to an XRectangle structure that describes the size of the image to be produced for compression (only the width and height fields are relevant for this resource). The JPEG widget squeezes the contents of the source video input window to fit this rectangle before doing the compression on the image data (the width and height of the XtNcompressDestRect must be at least as large as the width and height of the XtNcompressSourceRect). By default, the XtNcompressDestRect is 640x480 pixels in size.

Example

You can inform the JPEG widget to compress small portions of the source video input window and produce squeezed JPEG images: modify the area of the XtNcompressSourceRect (to capture only a portion of the display), then modify the area of the XtNcompressDestRect (or supply your own rectangle, making the area of the destination rectangle smaller than the area of the source rectangle).

For example, to create a 320x240 image from a 640x480 source, the programmer might do the following:

Widget		jpegWidget;
XRectangle	compressSourceRect;
XRectangle	compressDestRect;
compressSourceRect.x = 0;
compressSourceRect.y = 0;
compressSourceRect.width = 640;
compressSourceRect.height = 480;
compressDestRect.width = 320;  /* x & y field are irrelevant... */
compressDestRect.height = 240; /* ... for this resource         */

XtVaSetValues(jpegWidget,
		XtNcompressSourceRect, &compressSourceRect,
		XtNcompressDestRect, &compressDestRect, NULL);


Note: The widget does not copy this XRectangle structure; it only maintains a copy of the pointer to this structure. If you specify your own display rectangle, do not let the structure go out of scope. If the structure does go out of scope, the results are unpredictable.


XtNcompressSourceRect: Set, Get


.
JPEG widget: Points to an XRectangle structure that describes the area of the source input window to be compressed. By default, the area to be compressed is the size of the source window.
Example

You can inform the JPEG widget to compress only a portion of the source window by modifying the area of the XtNsourceRect (or by supplying your own rectangle). For example, to compress only the top, left quarter of a source video input window that is 640x480 pixels in size, you might do the following:

Widget		jpegWidget;
XRectangle	myRect;
myRect.x = 0;
myRect.y = 0;
my.width = 320;
myRect.height = 240;

XtVaSetValues(jpegWidget,
		XtNcompressSourceRect, &myRect, NULL);


Note: The widget does not copy this XRectangle structure; it only maintains a copy of the pointer to this structure. If you specify your own display rectangle, do not let the structure go out of scope. If the structure does go out of scope, the results are unpredictable.


XtNdestWin: Set, Get


.
JPEG widget: Represents the X window into which to draw JPEG images. If the default of 0 is not overridden at initialization time (that is, at the time the widget is created with the XtCreate[Managed]Widget() function), the JPEG widget creates its own window for displaying JPEG images. However, if the programmer specifies a valid window ID at any time (at creation, or with Xt[Va}SetValues()), the JPEG widget draws JPEG images into that window.

As a side effect, you can inform the widget not to display images by using Xt[Va]SetValues() to set this resource to 0 after the widget has been created. This is convenient for applications that compress data only. For example, applications that create JPEG data and write it to disk may not have time to display the images after they have been compressed.

Note: For video overlay cards (HP, XVideo-Xtra), the XtNdestWin must be a video window or another JPEG window. "Normal" windows may not be used as XtNdestWin arguments.

Example

In this example, the programmer wants to compress images from the VideoIn widget used in the example for the XtNsourceWin resource. The example compresses an image and writes it to disk, but does not display the compressed image; doing so would require routing the data through the Parallax compression hardware another time for decompression, and so would reduce overall performance. (For the sake of simplicity, this example assumes that the widget is using shared memory).

int		offset = 0;
Widget		jpegWidget;
Boolean		useSharedMemory;
XPlxCImage*	jpegDataPtr;

XtVaGetValues(jpegWidget,				/* Determine if the JPEG widget  */
	      XtNuseSharedMemory,			/* is using shared memory for    */ 
	      &useSharedMemory,  			/* speed purposes.  If so, point */
	      XtNjpegData,				/* to the shared memory segment  */
	      &jpegDataPtr,				/* since it will be recycled     */
	      NULL);
XtVaSetValues(jpegWidget,				/* Tell the JPEG widget not to   */
	      XtNdestWin, 0,				/* bother trying to draw the     */ 
	      NULL);					/* images it just compressed.    */
							/* This will save time and allow */
							/* the program to write data to  */
							/* disk more quickly		 */
/* Tell the JPEG widget to compress another image right now */
XtVaSetValues(jpegWidget, 
	      XtNgetNewImage, True,
	      NULL);
/* Check for garbage data */
if (0xffffffd0 == *(unsigned int*)jpegDataPtr->data)
{
  offset = 4;
  jpegDataPtr->size -= offset;
}
/* Write the image header first */
result = write(outputFile, jpegDataPtr, sizeof(XPlxCImage));
/* Next, write the image data itself */
result = write(outputFile,
	       jpegDataPtr->data + offset,
	       jpegDataPtr->size);


Note: If you are writing your own application supporting HP with shared memory (Parallax software version 9.3 or higher for HP), and if there is a possibility that you may use software decompression of JPEG data, then you should search for and remove a string of garbage data (FFFFFFD0) in each JPEG frame before you write the frame. The example above shows how to do this.


XtNdiagnostics: Set, Get


.
JPEG widget: When set to True, the widget will print diagnostic messages to help debug the behavior of the widget.

Example

jpegWidget = XtVaCreateManagedWidget("jpegWidget,
			jpegWidgetClass, jpegShell,
			XtNdiagnostics, True, 
			NULL);

XtNdisplayDestRect: Set, Get


.
JPEG widget: Points to an XRectangle structure that describes the portion of the window into which the JPEG image is to be drawn. By default, it points to a rectangle exactly the size of the JPEG image. You can also display the image in a smaller window. By supplying your own XRectangle, you can inform the JPEG widget to draw its JPEG image in any part of the XtNdestWin window that you want.
Note: You may not modify the default XtNdisplayDestRect rectangle, since, each time the widget redraws itself, it resets the default rectangle to fit the JPEG image currently stored in the widget. To draw a JPEG image in the part of the XtNdestWin that you want, you must supply your own XRectangle.

Example

In this example, the programmer has a 640x480 JPEG image stored as a JFIF file on disk, but wants to display the image in a 320x240 window (that is, the JPEG image will be scaled down to fill the display window).

Widget 		jpegWidget;
XRectangle	myRect;
String		fileName;			/* assume that this is filled in */
int		zoomFactor;

myRect.x = 0;
myRect.y = 0;
myRect.width = 320 * zoomFactor;
myRect.height = 240 * zoomFactor;

XtVaSetValues(jpegWidget, 
		jfifInputFile, fileName,
		XtNdisplayDestRect, &myRect,
		NULL);


Note: The widget does not copy this XRectangle structure; it only maintains a copy of the pointer to this structure. If you specify your own display rectangle, do not let the structure go out of scope. If the structure does go out of scope, the results are unpredictable.
Note: zoomFactor applies only to video overlay cards (XVideo-Xtra on Sun, and all video cards on H-P systems). zoomFactor's default value is 1 for normal-sized display, and 2 for enlarged display (two times width, height, four times area). If you are writing code for video framebuffer cards (XVideo, PowerVideo, and MultiVideo for Sun), just leave out zoomFactor (or set zoomFactor to 1):
	myRect.width = 320;
	myRect.height = 240; 


XtNdisplaySourceRect: Set, Get


.
JPEG widget: Points to an XRectangle structure that describes the portion of the JPEG image that is to be displayed. By default, it points to a rectangle exactly the size of the JPEG image. By supplying your own XRectangle, you can inform the JPEG widget to display only part of a JPEG image.
Note: You may not modify the default XtNdisplaySourceRect rectangle; each time the widget redraws itself, it resets the default rectangle to fit the JPEG image currently stored in the widget. In order to display a portion of a JPEG image, you must supply your own XRectangle.

Example

In this example, the programmer has a 640x480 JPEG image but wants to display only the center quarter of the image.
Widget 		jpegWidget;
XRectangle	myRect;

myRect.x = (320 / 2) - (160 / 2);
myRect.y = (240 / 2) - (120 / 2);
myRect.width = 320;
myRect.height = 240;

XtVaSetValues(jpegWidget, 
		XtNdisplaySourceRect, &myRect,
		NULL);


Note: The widget does not copy this XRectangle structure; it only maintains a copy of the pointer to this structure. If you specify your own display rectangle, do not let the structure go out of scope. If the structure does go out of scope, the results are unpredictable.

XtNdrawMethod: Set, Get


.
JPEG widget: Parallax software for Solaris 2.5 or version 9.3 for HP or higher: Specifies a function that will be called each time the widget redraws itself. This is useful for drawing graphics into the widget.

Example

This draw method will paint a border around the window:
void CustomerDrawMethod(Widget w, XEvent* event, Region region)
{
  Dimension width, height;
  .
  .
  .
  XtVaGetValues(w, XtNwidth, &width, XtNheight, &height, NULL);
  XDrawRectangle(XtDisplay(w), XtWindow(w), gc, 0, 0, width, height);
}

XtVaCreateManagedWidget("jpeg", jpegWidgetClass, jpegShell,
			XtNdrawMethod, CustomDrawMethod, NULL);

Note: The "XEvent*" and "Region" parameters may be NULL when your drawing function is called. This is the case if a widget instructs itself to redraw, as when displaying a new JPEG image. In this case, your application must assume that the whole window is damaged and must be redrawn.

XtNgetNewImage: Set (Write Only)


.
JPEG widget: Informs the JPEG widget to compress a new image from the XtNsourceWin window. The JPEG widget replaces whatever JPEG image was previously stored with the new JPEG image data created by setting this resource to True, then resets this resource to False so the programmer may use it again immediately.
Note: If you are writing your own application supporting HP with shared memory (Parallax software version 9.3 or higher for HP), and if there is a possibility that you may use software decompression of JPEG data, then you should search for and remove a string of garbage data (FFFFFFD0) in each JPEG frame before you write the frame. In Parallax software version 9.3 or higher from HP, MovieTool and VideoTool remove this garbage data; scomp does not. Following is an example of how to search for and delete the garbage data:
/* 
 * Use the JPEG widget to compress a new image
 */
XtVaSetValues(playbackWidget, XtNgetNewImage, True, NULL);

if (0xffffffd0 == *(unsigned int*)jpegImage->data)
{
/* Some video cards return JPEG data that begins */
/* with a StartFrame marker code.  For software  */
/* decompressor compatibility, do not write these */
/* bytes into the movie file */
  offset = 4;
  jpegImage->size -= offset;
}

Note: If you are saving JFIF images, you may want to check that the image width is divisible by 16 before using XPlxShmPutCImage, and reduce the image size if needed. The reason is to make the image displayable by third party applications such as ImageMagick's "display" that require a JFIF image width that is divisible by 16. See MovieTool (HP version 9.3 or higher) for an example of how to do this automatically.
Example
See the example for the XtNdestWin resource for best application.


XtNjfifInputFile: Set, Get


.
JPEG widget: Informs the JPEG widget to read a JFIF (JPEG File Interchange Format) file from disk. The string associated with this resource is the name of the disk file containing the JFIF data. When this resource is set, the JPEG widget attempts to open the file as a JFIF file, and--- if successful--uses the contents of the JFIF file as JPEG image data. If the widget cannot open the file, the widget retains its current JPEG image.
Example
See the example for the XtNdisplayDestRect resource for best application.


XtNjfifOutputFile: Set, Get


.
JPEG widget: Informs the JPEG widget to save its current JPEG data to disk as a JFIF (JPEG File Interchange Format) file. The string associated with this resource is the name of the disk file that is used to store the JFIF data.

Note: You do not need to worry about the HP/shared memory (Parallax software version 9.3 or higher) JPEG garbage data for XtNjfifOutputFile because this resource searches for and removes the garbage data (FFFFFFD0) automatically.
Example
Assume for this example that the JPEG widget already contains a JPEG image. To save this JPEG image as a JFIF file, specified by the String outputFileName, the programmer might do the following:
Widget		jpegWidget;
String		outputFileName;
   
XtVaSetValues(jpegWidget, XtNjfifOutputFile, outputFileName, NULL);



XtNjfifOutputFile: Set, Get


.
JPEG widget: Points to an XPlxCImage structure containing data for a JPEG image. If the widget is using shared memory, this data should never be freed by the programmer>.
Also, the programmer is allowed to overwrite the contents of the shared memory segment pointed to by the XtNjpegData resource, but may not tell the JPEG widget to point to a different portion of memory. In other words, if the JPEG widget is using shared memory (via the XtNuseSharedMemory resource) to store JPEG data, this resource may not be set with Xt[Va]SetValues().
Example

If JPEG image data for the widget is available to display, the programmer might do the following:

With Shared Memory:

XPlxCImage*	jpegData;
XPlxCImage*	myImageData;
int		sizeOfImageData;

XtVaGetValues(jpegWidget, XtNjpegDAta, &jpegData, NULL);
bcopy(myImageData->data, jpegData->data, sizeOfImageData);
	/* at this point, the JPEG widget has new image data to */
	/* render; use the "putNewImage" resource to inform     */
	/* the JPEG widget of this information.                 */
XtVaSetValues(jpegWidget, XtNputNewImage, True, NULL);


Without Shared Memory

XPlxCImage*	myImageData;
	/* assume that myImageData was read from disk or some   */
	/* other source */
XtVaSetValues(jpegWidget, jpegData, myImageData, NULL);
	/* at this point, the JPEG widget is aware that it has   */
	/* new JPEG image data to display; it is okay to set the */
	/* "putNewImage" resource to inform the JPEG widget of   */
	/* this information, but it is not necessary in this     */
	/* case.                                                 */

To retrieve JPEG data currently stored in the widget, you could do the following:
XPlxCImage*	jpegData;
XtVaGetValues(jpegWidget, XtNjpegData, &jpegData, NULL);

You can then examine the contents of the XPlxCImage* data pointed to by the XtNjpegData variable.


XtNputNewImage: Set (Write Only)


.
JPEG widget: Informs the JPEG widget that new JPEG image data is available to display. When this resource is set, the JPEG widget immediately redraws itself, using whatever JPEG data is stored in the widget. This resource is especially useful when the widget is using shared memory and the application program is writing its own JPEG data into the widget for display (for example, when an application is reading JPEG data from disk).
Example
See the example for the XtNjpegData resource for best application.


XtNqFactor: Set, Get


.
JPEG widget: Represents the Q factor to use when compressing (creating) and decompressing (displaying) JPEG images. The default value is 50; valid values range from 25 (least compression, higher image quality), to 1000 (most compression, lower image quality).
Note: The default Q factor was different (100) for Solaris 2.4, HP version 9.2, and earlier releases, because the Q tables we used then were different. We found out that our Q tables were not standard, so we corrected them for our Solaris 2.5 and HP version 9.3 or higher software releases.
Example
Widget		jpegWidget;
XtVaSetValues(jpegWidget, XtNqFactor, 500, NULL);



XtNsourceWin: Set, Get


.
JPEG widget: Represents the X window from which to grab image data for compression. The contents of the source window are sent to the Parallax JPEg hardware, which compresses the image data and returns a JPEG image to the widget. This JPEG image data is accessible with the XtNjpegData resource.

Note: Overlay cards: On overlay cards, only video or JPEG windows (images on the overlay) may be used as the source window.

Note: Only 24-bit source windows produce viewable JPEG images. While 8-bit images are readily compressed, the resulting JPEG images are not useful for any practical purpose.

Note: The JPEG widget can only compress the contents of a visible (on-screen) window; the contents of off-screen windows are not accessible to the JPEG widget.

Example

JPEG widget: In this example, compressed images are produced from a live video source. This example creates the VideoIn widget, which provides the live video source, and the JPEG widget and then informs the JPEG widget to compress source data being displayed in the VideoIn widget's window.

/* For this example, assume that "videoShell" and "jpegShell" are */
/* Shell widgets that have already been created.		  */
Widget videoshell, jpegShell, videoWidget, jpegWidget;

/* Create a widget for displaying video */
videoWidget = XtVaCreateManagedWidget("videoIn",
					xVideoInWidgetClass,
					videoShell, NULL);
/* Create a widget for compressing JPEG image data */
videoWidget = XtVaCreateManagedWidget("jpeg",
					jpegWidgetClass, jpegShell,
					XtNsourceWin, XtWindow(videoWidget),
					NULL);



XtNsqueezeDest: Set, Get


.
JPEG widget: Controls the scaling behavior of the widget's destination window. When True (the default), the JPEG image is scaled to fit the XtNdisplayDestRect rectangle. When set to False, the image is cropped against the XtNdisplayDestRect rectangle.
Example
Widget		jpegWidget;
XtVaSetValues(jpegWidget, XtNsqueezeDest, False, NULL);



XtNuseSharedMemory: Set, Get


.
JPEG widget: Indicates whether the JPEG widget is currently using shared memory to store its JPEG data. When the JPEG widget is created, it attempts to use shared memory to increase performance. If the widget is able to use shared memory, the widget sets this resource to True; if the widget cannot use shared memory, this resource is set to False.

If this resource is set to True, the programmer is not allowed to set the XtNjpegData> resource (via Xt[Va]SetValues()). In other words, if shared memory is in use by the widget, the widget points to the shared memory segment and will not allow the programmer to force the JPEG widget to point to different JPEG data. The only way for the programmer to point to new JPEG images in this case is to overwrite the data pointed to by the widget's XtNjpegData resource. The programmer can force the JPEG widget not to use shared memory by setting this resource to False at initialization time.

Example

In this example, JPEG images are loaded into the JPEG widget. If the JPEG widget is using shared memory, the programmer will need to know that so as not to try to set the XtNjpegData resource to point to application memory.
Widget		jpegWidget;
Boolean		useSharedMemory;
XPlxCImage*	sharedMemJpegDataPtr;
XPlxCImage*	jpegData;

XtVaGetValues(jpegWidget,		/* Determine if JPEG widget    */ 
	      XtNuseSharedMemory,       /* is using shared memory.     */
	      &useSharedMemory,         /* If so, point to the         */
	      XtNjpegData,              /* shared memory segment,      */
	      &sharedMemJpegDataPtr,    /* since it will be            */
	      NULL);			/* recycled                    */

if (useSharedMemory == True)		/* Is the widget using         */
					/* shared memory?	       */
  {
  result = read(inputFile,              /* If yes, read data           */
                sharedMemJpegDataPtr->data,  /* directly into          */
                jpegImage.size);        /* the shared memory segment   */
  sharedMemJpegDataPtr->size = jpegImage.size;
           				/* Update the size (bytes)     */
					/* of the new JPEG image       */
  XtVaSetValues(jpegWidget, XtNputNewImage, True, NULL);
					/* Tell the widget there's a   */
					/* new image to draw	       */
  }
else
					/* If no, the widget isn't     */
					/* using shared memory         */
  {
  result = read(inputFile,		/* Read data into	       */
                jpegDataPtr->data,      /* application-allocated       */
		jpegImage.size);        /* memory		       */

  XtVaSetValues(jpegWidget,		/* Tell the widget to point    */
	        XtNjpegData,		/* to new JPEG image	       */
		jpegDataPtr, NULL);
  }



TCWindow Widget


Parallax software for Solaris 2.5 or version 9.3 for HP or higher: The "TCWindow" widget (an abbreviation for "TrueColor Window") is a convenience for programmers who wish to create TrueColor windows in their Xt or Motif applications. It provides a window suitable for displaying video or JPEG decompression on all platforms supported by Parallax. TCWindow will create a TrueColor (24-bit) window if possible, or if TrueColor is not available (for example with a video overlay card and an 8-bit framebuffer), TCWindow will create a default depth visual window.
Note: This widget is not available for earlier Parallax software releases (Solaris 2.4 or earlier, or version 9.2 for HP).
Usage
autoSearch <True, False, AutoSearchInput0, AutoSearchInput1>

Definition
<True, False, AutoSearchInput0, AutoSearchInput1> 

Specifies whether the widget should automatically search for the first valid video input signal on all digitizers (True), do not perform autosearch (False), search only on the first digitizer (AutoSearchInput0), or search only on the second digitizer (AutoSearchInput1).

Resources

The TCWindow widget adds a draw method resource and a resource that indicates if the widget really created a TrueColor window. These resources are a subclass of the Xt Intrinsics Core class and inherit basic X display behavior from the Core class. (The TCWindow widget uses all of the resources available in the XtIntrinsics Core class of resources).

The TCWindow resource class pointer is tcWindowWidgetClass

The TCWindow resource class name is TCWindow.

Full descriptions follow (in alphabetical order).

X Resource Summary Type Default Value
XtNdrawMethod Specifies a function that will be called each time the widget redraws itself
XtExposeProc NULL
XtNtrueColor Indicates whetehr or not the TCWindow widget was able to get a TrueColor window
Boolean --

XtNdrawMethod: Set, Get


.
TCWindow widget: Parallax software for Solaris 2.5 or version 9.3 for HP or higher: Specifies a function that will be called each time the widget redraws itself. This is useful for drawing graphics into the widget.

Example

This draw method will paint a border around the window:
void CustomDrawMethod(Widget w, XEvent* event, Region region)
{
  Dimension width, height;
  .
  .
  .
  XtVaGetValues(w, XtNwidth, &width, XtNheight, &height, NULL);
  XDrawRectangle(XtDisplay(w), XtWindow(w), gc, 0, 0, width, height);
}

XtVaCreateManagedWidget("jpeg", tcWindowWidgetClass, shellWidget,
			XtNdrawMethod, CustomDrawMethod, NULL);



XtNtrueColor: Get (Read Only)


.
TCWindow widget: Parallax software for Solaris 2.5 or version 9.3 for HP or higher: Indicates whether or not the TCWindow widget was able to get a TrueColor window. (On Parallax overlay hardware, it is not necessary to get a TrueColor window).

Example

In this example, the resource will be used to print a diagnostic message about the visual class of the window.
Boolean trueColor;

XtVaGetValues(tcWindow, XtNtrueColor, &trueColor, NULL);
if (trueColor)
  printf("True Color window.\n");
else
  printf("Default visual window.\n");