49 #include <QuickTime/QuickTimeStreaming.h> 112 Handle grabberName = NewHandle(0);
113 Handle info = NewHandle(0);
114 ComponentDescription desc;
116 desc.componentType = SeqGrabComponentType;
117 desc.componentSubType = 0;
118 desc.componentManufacturer = 0;
119 desc.componentFlags = 0;
120 desc.componentFlagsMask = 0;
124 while (comp = FindNextComponent(comp, &desc))
126 if (GetComponentInfo(comp, &desc, grabberName, info, 0) != noErr)
128 printf(
"error: could not get info on component id = %i\n", comp);
132 printf(
"grabber: '%s'\n", *grabberName + 1);
143 printf(
"error: could not find a sequence grabber named '%s'\n",
m_sComponentName.c_str());
152 printf(
"error: could not open sequence grabber\n");
156 if (SGInitialize(
grabber) != noErr)
158 printf(
"errror: could not initialize the sequence grabber\n");
162 if (SGSetDataRef(
grabber, 0, 0, seqGrabDontMakeMovie) != noErr)
164 printf(
"error: could not set data reference on sequence grabber\n");
168 if (QTNewGWorld(&
gWorld, k24RGBPixelFormat, &
srcRect, 0, 0, 0) != noErr)
170 printf(
"error: could not create new gworld\n");
174 if (!LockPixels(GetPortPixMap(
gWorld)))
176 printf(
"error: could not lock pixels in new gworld\n");
182 printf(
"error: could not set gworld\n");
189 printf(
"error: could not open video channel\n");
193 if (SGSetChannelUsage(
videoChannel, seqGrabRecord) != noErr)
195 printf(
"error: could not set channel usage to 'record'\n");
201 printf(
"error: could not set channel bounds to %ix%i\n",
width,
height);
207 printf(
"error: could not set data proc\n");
252 ImageSequence image_sequence;
254 if (DecompressSequenceBegin(&image_sequence,
imgDesc,
gWorld, 0, &
srcRect, 0, srcCopy, 0, 0, codecNormalQuality, bestSpeedCodec) != noErr)
256 printf(
"error: could not begin decompression\n");
264 const int nBytes = 3 * pImage->
width * pImage->
height;
265 const unsigned char *
input = (
unsigned char *) GetPixBaseAddr(GetGWorldPixMap(
gWorld));
266 unsigned char *output = pImage->
pixels;
267 for (
int i = 0,
offset = 0; i < nBytes; i += 3,
offset += 4)
269 output[i] = input[
offset + 1];
270 output[i + 1] = input[
offset + 2];
271 output[i + 2] = input[
offset + 3];
274 CDSequenceEnd(image_sequence);
290 imgDesc = (ImageDescriptionHandle) NewHandle(0);
int width
The width of the image in pixels.
CQuicktimeCapture(VideoMode mode, const char *pComponentName=0)
Data structure for the representation of 8-bit grayscale images and 24-bit RGB (or HSV) color images ...
unsigned char * pixels
The pointer to the the pixels.
static pascal OSErr sDataProc(SGChannel c, Ptr p, long len, long *offset, long chRefCon, TimeValue time, short writeType, long refcon)
std::string m_sComponentName
ImageDescriptionHandle imgDesc
int height
The height of the image in pixels.
OSErr dataProc(SGChannel c, Ptr p, long length)
GLenum GLsizei GLsizei height
GLenum GLenum GLenum input
ImageType type
The type of the image.
bool CaptureImage(CByteImage **ppImages)
GLuint GLsizei GLsizei * length