The difficult part with writing a video widget is to do the "bit blitting" to the actual window. In other words, use a raw in memory RGB (or YUV) data and draw this to screen. Tk uses an abstract data type
Drawable d;
to describe the destination context. Only on X11 is this something real. On Windows it looks like
TkWinDrawable *twdPtr = (TkWinDrawable *) d;
where TkWinDrawable is a struct which also contains a bitmap.handle.
On MacOSX it looks like
CGrafPtr port;
port = TkMacOSXGetDrawablePort(d);
and then it is possible to draw raw image data using something like:
Code from TkPath. I see now that all QuickDraw (CGrafPtr) code need to go away for 8.5 since Daniel has replaced everything with CoreGraphics.
Bottom line: This will need a great deal of platform dependent code. The SDL sources contain tons of examples but the problem is to understand them. I guess we only need to implement this for the special case of RGB32 or YUV formats. That should be easier. It is like drawing a tk image in TkPath.
The difficult part with writing a video widget is to do the "bit blitting" to the actual window. In other words, use a raw in memory RGB (or YUV) data and draw this to screen. Tk uses an abstract data type
Drawable d;
to describe the destination context. Only on X11 is this something real. On Windows it looks like
TkWinDrawable *twdPtr = (TkWinDrawable *) d;
where TkWinDrawable is a struct which also contains a bitmap.handle.
On MacOSX it looks like
CGrafPtr port; ablePort( d);
port = TkMacOSXGetDraw
and then it is possible to draw raw image data using something like:
PathSetUpCG Context( port, &cgContext); reateWithData( NULL, block.pixelPtr, size, NULL); ateDeviceRGB( ); block.width, block.height,
block. pixelSize* 8, /* bitsPerPixel */
block. pitch, /* bytesPerRow */
colorspace , /* colorspace */
alphaInfo, /* alphaInfo */
provider, NULL,
kCGRenderi ngIntentDefault ); awImage( context- >c, CGRectMake(0.0, 0.0, width, height), cgImage);
...
provider = CGDataProviderC
colorspace = CGColorSpaceCre
cgImage = CGImageCreate(
8, /* bitsPerComponent */
1, /* shouldInterpolate */
...
CGContextDr
Code from TkPath. I see now that all QuickDraw (CGrafPtr) code need to go away for 8.5 since Daniel has replaced everything with CoreGraphics.
Bottom line: This will need a great deal of platform dependent code. The SDL sources contain tons of examples but the problem is to understand them. I guess we only need to implement this for the special case of RGB32 or YUV formats. That should be easier. It is like drawing a tk image in TkPath.