Converting a PicHandle to format for use with imageData

Thierry Arbellot thierry.arbellot at wanadoo.fr
Mon Dec 29 16:29:07 CST 2003


I have written an external to drive a video grabber, and copy the  
bitmap into the imageData of an image object.

the GWorld must be 32 bit pixel depth and with the same resolution as  
the image in Rev

*(GetPortPixMap(GWorld)) return a pointer to the PixMap
in the PixMap structure, baseAddr is a pointer to the bitmap, that can  
be copied into the imageData of the image object in Rev.

Before manipulating the bitmap, even just for copy, it's needed to lock  
it with
LockPixels(GetPortPixMap(GWorld))

and to unlock it after use
UnlockPixels(GetPortPixMap(GWorld))


So, the code should look like this:

int				retvalue;
MCstring	rdata;

GWorld	theGWorld;
Rect		trackFrame;
PixMap	*thePixMap;

trackFrame.top = 0;
trackFrame.left = 0;
trackFrame.right = 320;	// if image is 320*240
trackFrame.bottom = 240;
NewGWorld(&theGWorld,32,&trackFrame,nil,nil,(GWorldFlags)0);

// here put your code to get the image from the movie and put it into  
theGWorld

LockPixels(GetPortPixMap(theGWorld));
thePixMap = *(GetPortPixMap(theGWorld));

rdata.sptr = thePixMap->baseAddr;
rdata.length = 320*240*4;
SetVariableEx(args[0],"",&rdata,&retvalue);

UnlockPixels(GetPortPixMap(theGWorld));


in Rev

local theImageData

callTheExternalFunction "theImageData"

set the imageData of image "theImage" to theImageData


I have not tested this code, I hope there is no mistake.
Good luck.

Thierry.

On Monday, Dec 29, 2003, at 20:30 Europe/Paris, Trevor DeVore wrote:

> On Dec 29, 2003, at 11:59 AM, Thierry Arbellot wrote:
>
>> Hi Trevor,
>>
>> Apple gives a sample code on how to get a video frame from a QT movie  
>> and draw it into a GWorld.
>> Then you can copy the PixMap of this GWorld directly into the  
>> imageData of an image object.
>>
>> http://developer.apple.com/samplecode/Sample_Code/QuickTime/Basics/ 
>> VideoFrameToGWorld.htm
>
> Thanks for the info.  This is fairly new territory for me so I'm not  
> quite sure how you would copy the PixMap of the GWorld to the  
> imageData of the image object.  Would I assign the bitmap returned  
> from GetPortBitMapForCopyBits(gSrcGWorld) to the imageData of the  
> image object?
>
> Thanks,
>
> -- 
> Trevor DeVore
> Blue Mango Multimedia
> trevor at mangomultimedia.com
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>


More information about the use-livecode mailing list