本文整理汇总了C++中SetGWorld函数的典型用法代码示例。如果您正苦于以下问题:C++ SetGWorld函数的具体用法?C++ SetGWorld怎么用?C++ SetGWorld使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetGWorld函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MCRegionCalculateMask
bool MCRegionCalculateMask(MCRegionRef self, int32_t w, int32_t h, MCBitmap*& r_mask)
{
// Create a pixmap
Pixmap t_image;
t_image = MCscreen -> createpixmap(w, h, 1, False);
// Draw into the pixmap's port
CGrafPtr t_old_port;
GDHandle t_old_device;
GetGWorld(&t_old_port, &t_old_device);
SetGWorld((CGrafPtr)t_image -> handle . pixmap, NULL);
BackColor(whiteColor);
ForeColor(blackColor);
Rect t_rect;
SetRect(&t_rect, 0, 0, w, h);
EraseRect(&t_rect);
PaintRgn((RgnHandle)self);
SetGWorld(t_old_port, t_old_device);
// Fetch the pixmap as a bitmap
MCBitmap *t_bitmap;
t_bitmap = MCscreen -> getimage(t_image, 0, 0, w, h, False);
// Discard the pixmap
MCscreen -> freepixmap(t_image);
r_mask = t_bitmap;
return true;
}
示例2: RGB2IndexGW
// Same as above except that it quickly uses a gworld to allow the systems excellent routines to do
// the business instead.
short RGB2IndexGW(CTabHandle theTable,RGBColor *theCol)
{
Boolean openWorld=false;
short index=-1;
if (gBL_TintWorld==0L)
{
openWorld=true;
OpenTintWorld(theTable);
}
if (gBL_TintWorld)
{
CGrafPtr origPort;
GDHandle origGD;
GetGWorld(&origPort,&origGD);
SetGWorld(gBL_TintWorld,0L);
SetCPixel(0,0,theCol);
index=GPixelColour(GetGWorldPixMap(gBL_TintWorld),0,0);
SetGWorld(origPort,origGD);
}
else
return -1;
if (openWorld)
CloseTintWorld();
return index;
}
示例3: QTNewGWorldFromPtr
// Create the offscreen GWorld (using Image as target memory)
void QuicktimeLiveImageStream::createGWorld()
{
Rect destinationBounds;
OSStatus err;
GDHandle origDevice;
CGrafPtr origPort;
destinationBounds.left = 0;
destinationBounds.top = 0;
destinationBounds.right = m_videoRectWidth;
destinationBounds.bottom = m_videoRectHeight;
err = QTNewGWorldFromPtr(&m_gw, k32ARGBPixelFormat, &destinationBounds,
NULL, NULL, 0, (Ptr)data(), 4*m_videoRectWidth);
if (err !=0 )
{
OSG_DEBUG << "Could not create gWorld" << std::endl;
}
else
{
// Query
GetGWorld (&origPort, &origDevice);
SetGWorld (m_gw, NULL); // set current graphics port to offscreen
m_pixmap = GetGWorldPixMap(m_gw);
if (m_pixmap)
{
if (!LockPixels (m_pixmap)) // lock offscreen pixel map
{
OSG_FATAL << "Could not lock PixMap" << std::endl;
}
}
// Set back
SetGWorld(origPort, origDevice);
}
}
示例4: XFillRectangles
void
XFillRectangles(
Display* display, /* Display. */
Drawable d, /* Draw on this. */
GC gc, /* Use this GC. */
XRectangle *rectangles, /* Rectangle array. */
int n_rectangels) /* Number of rectangles. */
{
MacDrawable *macWin = (MacDrawable *) d;
CGrafPtr saveWorld;
GDHandle saveDevice;
GWorldPtr destPort;
Rect theRect;
int i;
destPort = TkMacGetDrawablePort(d);
display->request++;
GetGWorld(&saveWorld, &saveDevice);
SetGWorld(destPort, NULL);
TkMacSetUpClippingRgn(d);
TkMacSetUpGraphicsPort(gc);
for (i=0; i<n_rectangels; i++) {
theRect.left = (short) (macWin->xOff + rectangles[i].x);
theRect.top = (short) (macWin->yOff + rectangles[i].y);
theRect.right = (short) (theRect.left + rectangles[i].width);
theRect.bottom = (short) (theRect.top + rectangles[i].height);
FillCRect(&theRect, gPenPat);
}
SetGWorld(saveWorld, saveDevice);
}
示例5: createOffscreen
void createOffscreen(int pictItem)
{
PicHandle pict;
Rect rect;
CGrafPtr currentPort;
GDHandle currentDevice;
if (gGWorld != nil)
DisposeGWorld( gGWorld );
pict = (PicHandle)GetResource( 'PICT', pictItem + 127 );
rect = (**pict).picFrame;
GetGWorld( ¤tPort, ¤tDevice );
NewGWorld( &gGWorld, 32, &rect, nil, nil, 0 );
LockPixels( GetPortPixMap(gGWorld));
SetGWorld( gGWorld, nil );
DrawPicture( pict, &rect );
SetGWorld( currentPort, currentDevice );
ReleaseResource( (Handle)pict );
}
示例6: GetGWorld
void MCScreenDC::querymouse(int2 &x, int2 &y)
{
CGrafPtr oldport;
GDHandle olddevice;
GetGWorld(&oldport, &olddevice);
MoveWindow(invisibleWin, 0, 0, False); // OS X moves this.
SetGWorld(GetWindowPort(invisibleWin), GetMainDevice());
Point mloc;
GetMouse(&mloc); //get local mouse position
SetGWorld(oldport, olddevice);
x = mloc.h;
y = mloc.v;
}
示例7: GetGWorld
// Create the Sequence Grabber Audio Channel
void QuicktimeLiveImageStream::createSequenceGrabberAudioChannel()
{
// Check capability and setting of Sequence Grabber
GDHandle origDevice;
CGrafPtr origPort;
// Create GWorld
GetGWorld (&origPort, &origDevice);
SetGWorld (m_gw, NULL); // set current graphics port to offscreen
// Setup
// Get a video channel
ComponentResult result = SGNewChannel (m_gSeqGrabber, SoundMediaType, &m_gSoundChannel);
if ((m_gSoundChannel != nil) && (result == noErr))
{
result = SGInitChannel(m_gSoundChannel, m_gSeqGrabber);
// result = SGSetChannelUsage (m_gSoundChannel, seqGrabPreview );
// Usage
if (g_s_use_sg_record)
result = SGSetChannelUsage (m_gSoundChannel, seqGrabRecord | seqGrabLowLatencyCapture);
else
{
result = SGSetChannelUsage (m_gSoundChannel, seqGrabPreview | seqGrabRecord | seqGrabLowLatencyCapture);
}
// Get
Str255 deviceName;
Str255 inputName;
short inputNumber;
result = SGGetChannelDeviceAndInputNames(m_gSoundChannel, deviceName, inputName, &inputNumber);
// Set
// OSG_DEBUG << "Setting up audio component from input prefs" << std::endl;
result = SGSetChannelDevice (m_gSoundChannel, m_soundDeviceIDStr);
result = SGSetChannelDeviceInput(m_gSoundChannel, m_soundDeviceInputID);
// Set the volume low to prevent feedback when we start the preview,
// in case the mic is anywhere near the speaker.
short volume = 0;
result = SGGetChannelVolume (m_gSoundChannel, &volume);
// result = SGSetChannelVolume (m_gSoundChannel, 255);
// Inform
result = SGChangedSource (m_gSeqGrabber, m_gSoundChannel);
}
else
{
OSG_FATAL << "Could not create SGNewChannel for Sound Channel" << std::endl;
}
// Set GWorld back
SetGWorld(origPort, origDevice);
}
示例8: XFillPolygon
void
XFillPolygon(
Display* display, /* Display. */
Drawable d, /* Draw on this. */
GC gc, /* Use this GC. */
XPoint* points, /* Array of points. */
int npoints, /* Number of points. */
int shape, /* Shape to draw. */
int mode) /* Drawing mode. */
{
MacDrawable *macWin = (MacDrawable *) d;
PolyHandle polygon;
CGrafPtr saveWorld;
GDHandle saveDevice;
GWorldPtr destPort;
int i;
destPort = TkMacGetDrawablePort(d);
display->request++;
GetGWorld(&saveWorld, &saveDevice);
SetGWorld(destPort, NULL);
TkMacSetUpClippingRgn(d);
TkMacSetUpGraphicsPort(gc);
PenNormal();
polygon = OpenPoly();
MoveTo((short) (macWin->xOff + points[0].x),
(short) (macWin->yOff + points[0].y));
for (i = 1; i < npoints; i++) {
if (mode == CoordModePrevious) {
Line((short) (macWin->xOff + points[i].x),
(short) (macWin->yOff + points[i].y));
} else {
LineTo((short) (macWin->xOff + points[i].x),
(short) (macWin->yOff + points[i].y));
}
}
ClosePoly();
FillCPoly(polygon, gPenPat);
KillPoly(polygon);
SetGWorld(saveWorld, saveDevice);
}
示例9: defined
void ofVideoPlayer::createImgMemAndGWorld(){
Rect movieRect;
movieRect.top = 0;
movieRect.left = 0;
movieRect.bottom = height;
movieRect.right = width;
offscreenGWorldPixels = new unsigned char[4 * width * height + 32];
pixels = new unsigned char[width*height*3];
#if defined(TARGET_OSX) && defined(__BIG_ENDIAN__)
QTNewGWorldFromPtr (&(offscreenGWorld), k32ARGBPixelFormat, &(movieRect), NULL, NULL, 0, (offscreenGWorldPixels), 4 * width);
#else
QTNewGWorldFromPtr (&(offscreenGWorld), k24RGBPixelFormat, &(movieRect), NULL, NULL, 0, (pixels), 3 * width);
#endif
LockPixels(GetGWorldPixMap(offscreenGWorld));
SetGWorld (offscreenGWorld, NULL);
SetMovieGWorld (moviePtr, offscreenGWorld, nil);
//------------------------------------ texture stuff:
if (bUseTexture){
// create the texture, set the pixels to black and
// upload them to the texture (so at least we see nothing black the callback)
tex.allocate(width,height,GL_RGB);
memset(pixels, 0, width*height*3);
tex.loadData(pixels, width, height, GL_RGB);
allocated = true;
}
}
示例10: UnlockPixels
void _HYPlatformGraphicPane::_EndDraw (void)
{
UnlockPixels (GetGWorldPixMap(thePane));
SetGWorld (savedPort,savedDevice);
RGBForeColor (&saveFG);
RGBBackColor (&saveBG);
}
示例11: defined
void ofQuickTimePlayer::createImgMemAndGWorld() {
Rect movieRect;
movieRect.top = 0;
movieRect.left = 0;
movieRect.bottom = height;
movieRect.right = width;
offscreenGWorldPixels = new unsigned char[4 * width * height + 32];
pixels.allocate(width,height,OF_IMAGE_COLOR);
#if defined(TARGET_OSX) && defined(__BIG_ENDIAN__)
QTNewGWorldFromPtr (&(offscreenGWorld), k32ARGBPixelFormat, &(movieRect), NULL, NULL, 0, (offscreenGWorldPixels), 4 * width);
#else
QTNewGWorldFromPtr (&(offscreenGWorld), k24RGBPixelFormat, &(movieRect), NULL, NULL, 0, (pixels.getPixels()), 3 * width);
#endif
LockPixels(GetGWorldPixMap(offscreenGWorld));
// from : https://github.com/openframeworks/openFrameworks/issues/244
// SetGWorld do not seems to be necessary for offscreen rendering of the movie
// only SetMovieGWorld should be called
// if both are called, the app will crash after a few ofVideoPlayer object have been deleted
#ifndef TARGET_WIN32
SetGWorld (offscreenGWorld, NULL);
#endif
SetMovieGWorld (moviePtr, offscreenGWorld, nil);
}
示例12: defined
void ofxAlphaVideoPlayer::createImgMemAndGWorld(){
Rect movieRect;
movieRect.top = 0;
movieRect.left = 0;
movieRect.bottom = height;
movieRect.right = width;
offscreenGWorldPixels = new unsigned char[4 * width * height + 32];
pixels = new unsigned char[width*height*4]; // 4 =>rgba
#if defined(TARGET_OSX) && defined(__BIG_ENDIAN__)
//cout << "with Big Endian"<<endl;
QTNewGWorldFromPtr (&(offscreenGWorld), k32ARGBPixelFormat, &(movieRect), NULL, NULL, 0, (offscreenGWorldPixels), 4 * width);
#else
//cout << "no Big Endian"<<endl;
QTNewGWorldFromPtr (&(offscreenGWorld), k32RGBAPixelFormat, &(movieRect), NULL, NULL, 0, (pixels), 4 * width);
#endif
/** POSSIBLE PIXEL FORMATS
k32BGRAPixelFormat = 'BGRA', // 32 bit bgra (Matrox)
k32ABGRPixelFormat = 'ABGR', // 32 bit abgr
k32RGBAPixelFormat = 'RGBA', // 32 bit rgba
***********/
LockPixels(GetGWorldPixMap(offscreenGWorld));
SetGWorld (offscreenGWorld, NULL);
SetMovieGWorld (moviePtr, offscreenGWorld, nil);
//------------------------------------ texture stuff:
if (bUseTexture){
// create the texture, set the pixels to black and
// upload them to the texture (so at least we see nothing black the callback)
tex.allocate(width,height,GL_RGBA);
memset(pixels, 0, width*height*4);
tex.loadData(pixels, width, height, GL_RGBA);
allocated = true;
}
}
示例13: defined
void ofQuickTimePlayer::createImgMemAndGWorld(){
Rect movieRect;
movieRect.top = 0;
movieRect.left = 0;
movieRect.bottom = height;
movieRect.right = width;
if (pixelFormat == OF_PIXELS_RGBA) {
pixels.allocate(width, height, OF_IMAGE_COLOR_ALPHA);
}
else {
pixels.allocate(width, height, OF_IMAGE_COLOR);
}
#if defined(TARGET_OSX) && defined(__BIG_ENDIAN__)
offscreenGWorldPixels = new unsigned char[4 * width * height + 32];
QTNewGWorldFromPtr (&(offscreenGWorld), k32ARGBPixelFormat, &(movieRect), NULL, NULL, 0, (offscreenGWorldPixels), 4 * width);
#else
if (pixelFormat == OF_PIXELS_RGBA) {
QTNewGWorldFromPtr (&(offscreenGWorld), k32RGBAPixelFormat, &(movieRect), NULL, NULL, 0, (pixels.getPixels()), 4 * width);
}
else {
QTNewGWorldFromPtr (&(offscreenGWorld), k24RGBPixelFormat, &(movieRect), NULL, NULL, 0, (pixels.getPixels()), 3 * width);
}
#endif
LockPixels(GetGWorldPixMap(offscreenGWorld));
SetGWorld (offscreenGWorld, NULL);
SetMovieGWorld (moviePtr, offscreenGWorld, nil);
}
示例14: MCRedrawLockScreen
void MCStack::setgeom()
{
//set stack(window) size or position from script
if (MCnoui || !opened)
return;
// MW-2009-09-25: Ensure things are the right size when doing
// remote dialog/menu windows.
if (window == DNULL)
{
// MW-2011-08-18: [[ Redraw ]] Update to use redraw.
MCRedrawLockScreen();
state &= ~CS_NEED_RESIZE;
resize(rect . width, rect . height);
MCRedrawUnlockScreen();
mode_setgeom();
return;
}
// MW-2011-09-12: [[ MacScroll ]] Make sure we apply the current scroll setting.
applyscroll();
Rect windRect;
GetPortBounds(GetWindowPort((WindowPtr)window->handle.window), &windRect);
SetGWorld(GetWindowPort((WindowPtr)window->handle.window), GetMainDevice());
Point p;
p.h = windRect.left;
p.v = windRect.top;
LocalToGlobal(&p);
int2 curWidth = windRect.right - windRect.left;
int2 curHeight = windRect.bottom - windRect.top;
if (IsWindowVisible((WindowPtr)window->handle.window))
{
if (mode != WM_SHEET && mode != WM_DRAWER
&& (rect.x != p.h || rect.y != p.v))
{
MoveWindow((WindowPtr)window->handle.window, rect.x, rect.y, False);
state |= CS_BEEN_MOVED;
}
if (rect.width != curWidth || rect.height != curHeight)
{
SizeWindow((WindowPtr)window->handle.window, rect.width, rect.height, True);
resize(curWidth, curHeight + getscroll());
}
state &= ~CS_NEED_RESIZE;
}
else
{
if (mode != WM_SHEET && mode != WM_DRAWER)
MoveWindow((WindowPtr)window->handle.window, rect.x, rect.y, False);
if (rect.width != curWidth || rect.height != curHeight)
{
SizeWindow((WindowPtr)window->handle.window, rect.width, rect.height, True);
resize(curWidth, curHeight + getscroll());
}
state &= ~(CS_BEEN_MOVED | CS_NEED_RESIZE);
}
}
示例15: CountComponents
// 1.
// Create the Sequence Grabber (using GWorld as target memory)
void QuicktimeLiveImageStream::createSequenceGrabber()
{
ComponentDescription sg_component_description;
sg_component_description.componentType = SeqGrabComponentType; /* A unique 4-byte code indentifying the command set */
sg_component_description.componentSubType = 0L; /* Particular flavor of this instance */
sg_component_description.componentManufacturer = 'appl'; /* Vendor indentification */
sg_component_description.componentFlags = 0L; /* 8 each for Component,Type,SubType,Manuf/revision */
sg_component_description.componentFlagsMask = 0L; /* Mask for specifying which flags to consider in search, zero during registration */
long num_sg_components = CountComponents (&sg_component_description);
if (num_sg_components)
{
Component aComponent = 0;
ComponentDescription full_sg_component_description = sg_component_description;
aComponent = FindNextComponent(aComponent, &full_sg_component_description);
if (aComponent)
{
m_gSeqGrabber = OpenComponent(aComponent);
// If we got a sequence grabber, set it up
if (m_gSeqGrabber != 0L)
{
// Check capability and setting of Sequence Grabber
GDHandle origDevice;
CGrafPtr origPort;
// Create GWorld
GetGWorld (&origPort, &origDevice);
SetGWorld (m_gw, NULL); // set current graphics port to offscreen
// Initialize the sequence grabber
ComponentResult result = noErr;
result = SGInitialize (m_gSeqGrabber);
if (result == noErr)
{
// Set GWorld
result = SGSetGWorld(m_gSeqGrabber, (CGrafPtr)m_gw, 0);
if (result != noErr)
{
OSG_FATAL << "Could not set GWorld on SG" << std::endl;
}
}
// Set GWorld back
SetGWorld(origPort, origDevice);
}
}
}
}