void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) { if ( m_selected.Ok() ) { UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) ); } m_selected = bitmap; if (m_selected.Ok()) { if ( m_selected.GetHBITMAP() ) { m_macPort = (GrafPtr) m_selected.GetHBITMAP() ; LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ; wxMask * mask = bitmap.GetMask() ; if ( mask ) { m_macMask = mask->GetMaskBitmap() ; } SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , 0 , 0 , m_selected.GetWidth() , m_selected.GetHeight() ) ; CopyRgn( (RgnHandle) m_macBoundaryClipRgn ,(RgnHandle) m_macCurrentClipRgn ) ; m_ok = TRUE ; } else { m_ok = FALSE; } } else { m_ok = FALSE; } }
//-------------------------------------------------------- void ofQtVideoSaver::setGworldPixel( GWorldPtr gwPtr, int r, int g, int b, short x, short y){ Ptr gwAddress, gwAddressBase; long gwWidth; char red, blue, green; gwAddressBase = GetPixBaseAddr( GetGWorldPixMap( gwPtr ) ); /* Get head address of offscreen */ gwWidth = ( **GetGWorldPixMap( gwPtr ) ).rowBytes & 0x3fff; /* Get with of offscreen */ gwAddress = gwAddressBase + ( x * 3 ) + ( y * gwWidth ); /* Get adress for current pixel */ *gwAddress = (unsigned char)r; /* Put red and move address forward */ *(gwAddress+1) = (unsigned char)g; /* Put green and move address forward */ *(gwAddress+2) = (unsigned char)b; /* Put blue */ }
// 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); } }
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); }
void _HYPlatformGraphicPane::_EndDraw (void) { UnlockPixels (GetGWorldPixMap(thePane)); SetGWorld (savedPort,savedDevice); RGBForeColor (&saveFG); RGBBackColor (&saveBG); }
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; } }
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); }
void pxBuffer::blit(pxSurfaceNative s, int dstLeft, int dstTop, int dstWidth, int dstHeight, int srcLeft, int srcTop) { Rect pr; MacSetRect(&pr, 0, 0, width(), height()); GWorldPtr gworld; NewGWorldFromPtr (&gworld, 32, &pr, NULL, NULL, 0, (char*)base(), 4*width()); Rect dr, sr; MacSetRect(&dr, dstLeft, dstTop, dstLeft + dstWidth, dstTop + dstHeight); MacSetRect(&sr, srcLeft, srcTop, srcLeft + dstWidth, srcTop + dstHeight); CopyBits((BitMapPtr)*GetGWorldPixMap(gworld),(BitMapPtr)*GetGWorldPixMap(s),&sr,&dr,srcCopy,NULL); DisposeGWorld(gworld); }
//============================================================================= // QutTexture_CreateCompressedTextureObjectFromFile : Create a QD3D // compressed texture. //----------------------------------------------------------------------------- TQ3TextureObject QutTexture_CreateCompressedTextureObjectFromFile( const FSSpec * theFSSpec, TQ3PixelType pixelType, TQ3Boolean wantMipMaps) { TQ3TextureObject theTexture = NULL; GWorldPtr theGWorld = NULL; PixMapHandle thePixmap = NULL; // Load the image, then create a texture from it theGWorld = QutTexture_CreateGWorldFromFile(theFSSpec, pixelType); if (theGWorld != NULL) { thePixmap = GetGWorldPixMap(theGWorld); if( thePixmap != NULL) { theTexture = QutTexture_CreateCompressedTextureObjectFromPixmap(thePixmap, pixelType, wantMipMaps); DisposeGWorld(theGWorld); } } return(theTexture); }
PRIVATE PicHandle pict_from_gworld (GWorldPtr gp, int *lenp) { PicHandle retval; if (!gp) retval = NULL; else { Rect pict_frame; PixMapHandle pm; pm = GetGWorldPixMap (gp); pict_frame = PIXMAP_BOUNDS (pm); retval = OpenPicture (&pict_frame); if (retval) { ClipRect (&pict_frame); HLock ((Handle) pm); CopyBits ((BitMap *) STARH (pm), PORT_BITS_FOR_COPY (thePort), &pict_frame, &pict_frame, srcCopy, NULL); HUnlock ((Handle) pm); ClosePicture (); } } return retval; }
void EraseRectAndAlpha(GWorldPtr gWorld, Rect *pRect) { PixMapHandle pixMap = GetGWorldPixMap(gWorld); long rows; Ptr rowBaseAddr; LockPixels(pixMap); rows = pRect->bottom - pRect->top; rowBaseAddr = GetPixBaseAddr(pixMap) + (GetPixRowBytes(pixMap) & 0x3fff) * pRect->top + pRect->left * GetPixDepth(pixMap) / 8; do { long cols; UInt32 *baseAddr; cols = pRect->right - pRect->left; baseAddr = (UInt32*)rowBaseAddr; rowBaseAddr += (**pixMap).rowBytes & 0x3fff; do { *baseAddr++ = 0; } while (--cols); } while (--rows); UnlockPixels(pixMap); } // EraseRectAndAlpha
OSErr CreateDecompSeqForGWorldData(GWorldPtr srcGWorld, Rect *srcBounds, MatrixRecordPtr mr, GWorldPtr imageDestination, ImageSequence *imageSeqID) { OSErr err; ImageDescriptionHandle imageDesc = (ImageDescriptionHandle)NewHandle(sizeof(ImageDescription)); if (imageDesc) { err = MakeImageDescriptionForPixMap (GetGWorldPixMap(srcGWorld), &imageDesc); err = DecompressSequenceBegin( imageSeqID, imageDesc, imageDestination, 0, srcBounds, mr, srcCopy, nil, 0, codecNormalQuality, bestSpeedCodec); DisposeHandle((Handle)imageDesc); } else { err = MemError(); } return err; }
// 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; }
static void ROM_UnsetVideoMode(_THIS, SDL_Surface *current) { /* Free the current window, if any */ if ( SDL_Window != nil ) { GWorldPtr memworld; /* Handle OpenGL support */ Mac_GL_Quit(this); memworld = (GWorldPtr)GetWRefCon(SDL_Window); if ( memworld != nil ) { UnlockPixels(GetGWorldPixMap(memworld)); DisposeGWorld(memworld); } if ( (current->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { #if USE_QUICKTIME EndFullScreen(fullscreen_ctx, nil); SDL_Window = nil; #else ROM_ShowMenuBar(this); #endif } } current->pixels = NULL; current->flags &= ~(SDL_HWSURFACE|SDL_FULLSCREEN); }
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; } }
wxMemoryDC::~wxMemoryDC() { if ( m_selected.Ok() ) { UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) ); } };
//------------------------------------------------------------------------ unsigned pixel_map::width() const { if(m_pmap == nil) return 0; PixMapHandle pm = GetGWorldPixMap (m_pmap); Rect bounds; GetPixBounds (pm, &bounds); return bounds.right - bounds.left; }
//------------------------------------------------------------------------ unsigned pixel_map::height() const { if(m_pmap == nil) return 0; PixMapHandle pm = GetGWorldPixMap (m_pmap); Rect bounds; GetPixBounds (pm, &bounds); return bounds.bottom - bounds.top; }
void gr_palette_step_up( int r, int g, int b ) { int i; ubyte *p; int temp; ColorSpec colors[256]; GDHandle old_device; // PaletteHandle palette; // RGBColor color; // CTabHandle ctab; if (gr_palette_faded_out) return; if ( (r==last_r) && (g==last_g) && (b==last_b) ) return; last_r = r; last_g = g; last_b = b; p=gr_palette; // palette = GetPalette(GameWindow); for (i=0; i<256; i++ ) { colors[i].value = i; // temp = (int)(*p++) + r + gr_palette_gamma; temp = (int)(*p++) + r; if (temp<0) temp=0; else if (temp>63) temp=63; colors[i].rgb.red = gr_mac_gamma[temp]; // temp = (int)(*p++) + g + gr_palette_gamma; temp = (int)(*p++) + g; if (temp<0) temp=0; else if (temp>63) temp=63; colors[i].rgb.green = gr_mac_gamma[temp]; // temp = (int)(*p++) + b + gr_palette_gamma; temp = (int)(*p++) + b; if (temp<0) temp=0; else if (temp>63) temp=63; colors[i].rgb.blue = gr_mac_gamma[temp]; // SetEntryColor(palette, i, &color); } old_device = GetGDevice(); SetGDevice(GameMonitor); SetEntries(0, 255, colors); SetGDevice(old_device); #if 0 ctab = (CTabHandle)NewHandle(sizeof(ColorTable)); Palette2CTab(palette, ctab); AnimatePalette(GameWindow, ctab, 0, 0, 256); ActivatePalette(GameWindow); DisposeHandle((Handle)ctab); if (GameGWorld != NULL) { ctab = (**GetGWorldPixMap(GameGWorld)).pmTable; // get the color table for the gWorld. CTabChanged(ctab); (**ctab).ctSeed = (**(**(*(CGrafPtr)GameWindow).portPixMap).pmTable).ctSeed; } #endif }
// Operations: bool wxTaskBarIcon::SetIcon(const wxIcon& icon, const wxString& tooltip) { wxBitmap bmp( icon ) ; OSStatus err = noErr ; CGImageRef pImage; #if 0 // is always available under OSX now -- crashes on 10.2 in CFRetain() - RN pImage = (CGImageRef) bmp.CGImageCreate() ; #else WXHBITMAP iconport ; WXHBITMAP maskport ; iconport = bmp.GetHBITMAP( &maskport ) ; if (!maskport) { // Make a mask with no transparent pixels wxBitmap mbmp(icon.GetWidth(), icon.GetHeight()); wxMemoryDC dc; dc.SelectObject(mbmp); dc.SetBackground(*wxBLACK_BRUSH); dc.Clear(); dc.SelectObject(wxNullBitmap); bmp.SetMask( new wxMask(mbmp, *wxWHITE) ) ; iconport = bmp.GetHBITMAP( &maskport ) ; } //create the icon from the bitmap and mask bitmap contained within err = CreateCGImageFromPixMaps( GetGWorldPixMap(MAC_WXHBITMAP(iconport)), GetGWorldPixMap(MAC_WXHBITMAP(maskport)), &pImage ); wxASSERT(err == 0); #endif wxASSERT(pImage != NULL ); err = SetApplicationDockTileImage(pImage); wxASSERT(err == 0); if (pImage != NULL) CGImageRelease(pImage); return m_iconAdded = err == noErr; }
static pascal OSErr DrawCompleteProc (Movie theMovie, long refCon) { long int h; long int w; int y, x; GWorldPtr offWorld = (GWorldPtr) refCon; Rect bounds; Ptr baseAddr; long rowBytes; uint8_t* imbuf; mwSize dims[3]; GetPixBounds(GetGWorldPixMap(offWorld), &bounds); baseAddr = GetPixBaseAddr(GetGWorldPixMap(offWorld)); rowBytes = GetPixRowBytes(GetGWorldPixMap(offWorld)); h = rint(bounds.bottom - bounds.top); w = rint(bounds.right - bounds.left); dims[0] = h; dims[1] = w; dims[2] = 3; framedata = mxCreateNumericArray(3, dims, mxUINT8_CLASS, mxREAL); imbuf = (uint8_t*) mxGetData(framedata); // Retrieve the pixel data, unpack the RGB values and copy for (y = 0; y < h; ++y) { long *p; p = (long *) (baseAddr + rowBytes * (long) y); for (x = 0; x < w; ++x) { UInt32 color = *(long *)((long) p + 4 * (long) x);; long B = (color & 0xFF000000) >> 24; long G = (color & 0x00FF0000) >> 16; long R = (color & 0x0000FF00) >> 8; imbuf[y + x * h + 0 * (h * w)] = R; imbuf[y + x * h + 1 * (h * w)] = G; imbuf[y + x * h + 2 * (h * w)] = B; } } return noErr; }
Pixmap Tk_GetPixmap( Display *display, /* Display for new pixmap (can be null). */ Drawable d, /* Drawable where pixmap will be used (ignored). */ int width, /* Dimensions of pixmap. */ int height, int depth) /* Bits per pixel for pixmap. */ { QDErr err; GWorldPtr gWorld; Rect bounds; MacDrawable *macPix; PixMapHandle pixels; if (display != NULL) { display->request++; } macPix = (MacDrawable *) ckalloc(sizeof(MacDrawable)); macPix->winPtr = NULL; macPix->xOff = 0; macPix->yOff = 0; macPix->clipRgn = NULL; macPix->aboveClipRgn = NULL; macPix->referenceCount = 0; macPix->toplevel = NULL; macPix->flags = 0; bounds.top = bounds.left = 0; bounds.right = (short) width; bounds.bottom = (short) height; if (depth != 1) { depth = 0; } /* * Allocate memory for the off screen pixmap. If we fail * try again from system memory. Eventually, we may have * to panic. */ err = NewGWorld(&gWorld, depth, &bounds, NULL, NULL, 0); if (err != noErr) { err = NewGWorld(&gWorld, depth, &bounds, NULL, NULL, useTempMem); } if (err != noErr) { panic("Out of memory: NewGWorld failed in Tk_GetPixmap"); } /* * Lock down the pixels so they don't move out from under us. */ pixels = GetGWorldPixMap(gWorld); LockPixels(pixels); macPix->portPtr = gWorld; return (Pixmap) macPix; }
void _HYPlatformGraphicPane::_CopyToClipboard (void) { _HYGraphicPane* parent = (_HYGraphicPane*)this; #ifdef TARGET_API_MAC_CARBON ClearCurrentScrap(); #else ZeroScrap(); #endif Rect bRect; bRect.left = bRect.top = 0; bRect.right = parent->w; bRect.bottom = parent->h; PicHandle pic = OpenPicture (&bRect); GrafPtr topPort; GetPort (&topPort); LockPixels (GetGWorldPixMap(thePane)); #ifdef OPAQUE_TOOLBOX_STRUCTS CopyBits (GetPortBitMapForCopyBits(thePane),GetPortBitMapForCopyBits(topPort), &bRect,&bRect,srcCopy,(RgnHandle)nil); #else CopyBits ((BitMap*)*GetGWorldPixMap(thePane), (BitMap*)&(topPort->portBits),&bRect,&bRect, srcCopy,(RgnHandle)nil); #endif UnlockPixels (GetGWorldPixMap(thePane)); ClosePicture (); HLock ((Handle)pic); #ifdef TARGET_API_MAC_CARBON ScrapRef theScrapRef; GetCurrentScrap(&theScrapRef); PutScrapFlavor(theScrapRef, 'PICT', kScrapFlavorMaskNone,GetHandleSize((Handle)pic),*pic); #else PutScrap (GetHandleSize((Handle)pic),'PICT',*pic); #endif KillPicture (pic); }
//////////////////////////////////////////////////////////////////////////////// // virtual unsigned char* LLMediaImplQuickTime::getMediaData() { unsigned char* ptr = NULL; if ( mGWorldHandle ) { PixMapHandle pix_map_handle = GetGWorldPixMap( mGWorldHandle ); ptr = ( unsigned char* )GetPixBaseAddr( pix_map_handle ); }; return ptr; }
// decode a frame static mp_image_t* decode(sh_video_t *sh,void* data,int len,int flags){ OSErr result = 1; CodecFlags ignore; if(len<=0) return NULL; // skipped frame #if defined(WIN32_LOADER) && !defined(CONFIG_QUICKTIME) Setup_FS_Segment(); #endif result = DecompressSequenceFrameS(imageSeq, data, len, 0, &ignore, NULL); if(result) { mp_msg(MSGT_DECVIDEO,MSGL_ERR,"DecompressSequenceFrameS result=0x%d\n",result); return NULL; } if((int)sh->context==0x73797639){ // Sorenson 16-bit YUV -> std YVU9 int i; PixMap dstPixMap = **GetGWorldPixMap(OutBufferGWorld); short *src0=(short *)((char*)dstPixMap.baseAddr+0x20); for(i=0;i<mpi->h;i++){ int x; unsigned char* dst=mpi->planes[0]+i*mpi->stride[0]; unsigned short* src=src0+i*((mpi->w+15)&(~15)); for(x=0;x<mpi->w;x++) dst[x]=src[x]; } src0+=((mpi->w+15)&(~15))*((mpi->h+15)&(~15)); for(i=0;i<mpi->h/4;i++){ int x; unsigned char* dst=mpi->planes[1]+i*mpi->stride[1]; unsigned short* src=src0+i*(((mpi->w+63)&(~63))/4); for(x=0;x<mpi->w/4;x++) dst[x]=src[x]; src+=((mpi->w+63)&(~63))/4; } src0+=(((mpi->w+63)&(~63))/4)*(((mpi->h+63)&(~63))/4); for(i=0;i<mpi->h/4;i++){ int x; unsigned char* dst=mpi->planes[2]+i*mpi->stride[2]; unsigned short* src=src0+i*(((mpi->w+63)&(~63))/4); for(x=0;x<mpi->w/4;x++) dst[x]=src[x]; src+=((mpi->w+63)&(~63))/4; } } return mpi; }
void Tk_FreePixmap( Display *display, /* Display. */ Pixmap pixmap) /* Pixmap to destroy */ { MacDrawable *macPix = (MacDrawable *) pixmap; PixMapHandle pixels; display->request++; pixels = GetGWorldPixMap(macPix->portPtr); UnlockPixels(pixels); DisposeGWorld(macPix->portPtr); ckfree((char *) macPix); }
void gr_palette_load( ubyte *pal ) { int i, j; GDHandle old_device; ColorSpec colors[256]; // PaletteHandle palette; // RGBColor color; // CTabHandle ctable; for (i=0; i<768; i++ ) { // gr_current_pal[i] = pal[i] + gr_palette_gamma; gr_current_pal[i] = pal[i]; if (gr_current_pal[i] > 63) gr_current_pal[i] = 63; } for (i = 0, j = 0; j < 256; j++) { colors[j].value = j; colors[j].rgb.red = gr_mac_gamma[gr_current_pal[i++]]; colors[j].rgb.green = gr_mac_gamma[gr_current_pal[i++]]; colors[j].rgb.blue = gr_mac_gamma[gr_current_pal[i++]]; } old_device = GetGDevice(); SetGDevice(GameMonitor); SetEntries(0, 255, colors); SetGDevice(old_device); #if 0 palette = GetPalette(GameWindow); for (i = 0; i < 768; i += 3) { color.red = gr_current_pal[i] << 9; color.green = gr_current_pal[i+1] << 9; color.blue = gr_current_pal[i+2] << 9; SetEntryColor(palette, i / 3, &color); } ctable = (CTabHandle)NewHandle(sizeof(ColorTable)); Palette2CTab(palette, ctable); AnimatePalette(GameWindow, ctable, 0, 0, 256); ActivatePalette(GameWindow); DisposeHandle((Handle)ctable); if (GameGWorld != NULL) { ctable = (**GetGWorldPixMap(GameGWorld)).pmTable; // get the color table for the gWorld. CTabChanged(ctable); (**ctable).ctSeed = (**(**(*(CGrafPtr)GameWindow).portPixMap).pmTable).ctSeed; } #endif gr_palette_faded_out = 0; init_computed_colors(); }
void wxMemoryDC::DoSelect( const wxBitmap& bitmap ) { if ( m_selected.Ok() ) { #if wxMAC_USE_CORE_GRAPHICS m_selected.EndRawAccess() ; delete m_graphicContext ; m_graphicContext = NULL ; #else // TODO: UnlockPixels( GetGWorldPixMap(MAC_WXHBITMAP(m_selected.GetHBITMAP())) ); #endif } m_selected = bitmap; if (m_selected.Ok()) { #if wxMAC_USE_CORE_GRAPHICS if ( m_selected.GetDepth() != 1 ) m_selected.UseAlpha() ; m_selected.BeginRawAccess() ; m_width = bitmap.GetWidth(); m_height = bitmap.GetHeight(); CGColorSpaceRef genericColorSpace = wxMacGetGenericRGBColorSpace(); CGContextRef bmCtx = (CGContextRef) m_selected.GetHBITMAP(); if ( bmCtx ) { CGContextSetFillColorSpace( bmCtx, genericColorSpace ); CGContextSetStrokeColorSpace( bmCtx, genericColorSpace ); SetGraphicsContext( wxGraphicsContext::CreateFromNative( bmCtx ) ); } m_ok = (m_graphicContext != NULL) ; #else m_macPort = m_selected.GetHBITMAP( &m_macMask ) ; m_ok = (m_macPort != NULL) ; if (m_ok) { LockPixels( GetGWorldPixMap( (CGrafPtr) m_macPort ) ) ; SetRectRgn( (RgnHandle) m_macBoundaryClipRgn , 0 , 0 , m_selected.GetWidth() , m_selected.GetHeight() ) ; CopyRgn( (RgnHandle) m_macBoundaryClipRgn , (RgnHandle) m_macCurrentClipRgn ) ; } #endif } else { m_ok = false; } }
void *fontmng_create(int size, UINT type, const TCHAR *fontface) { void *ret; _FNTMNG fnt; int fontalign; int allocsize; ZeroMemory(&fnt, sizeof(fnt)); if (size < 0) { size *= -1; } if (size < 6) { size = 6; } else if (size > 128) { size = 128; } fnt.fontsize = size; fnt.fonttype = type; fnt.fontwidth = size + 1; fnt.fontheight = size + 1; fontalign = sizeof(_FNTDAT) + (fnt.fontwidth * fnt.fontheight); allocsize = sizeof(fnt); allocsize += fontalign; SetRect(&fnt.rect, 0, 0, fnt.fontwidth, fnt.fontheight); if (NewGWorld(&fnt.gw, 32, &fnt.rect, NULL, NULL, useTempMem) != noErr) { return(NULL); } fnt.pm = GetGWorldPixMap(fnt.gw); GetFNum("\pOsaka−等幅", &fnt.fontid); fnt.fg.red = 0xffff; fnt.fg.green = 0xffff; fnt.fg.blue = 0xffff; ret = _MALLOC(allocsize, "font mng"); if (ret) { CopyMemory(ret, &fnt, sizeof(fnt)); } else { DisposeGWorld(fnt.gw); } (void)fontface; return(ret); }
void gr_palette_clear() { int i; ColorSpec colors[256]; GDHandle old_device; // PaletteHandle palette; // RGBColor color; // CTabHandle ctable; for (i = 0; i < 256; i++) { colors[i].value = i; colors[i].rgb.red = 0; colors[i].rgb.green = 0; colors[i].rgb.blue = 0; } old_device = GetGDevice(); SetGDevice(GameMonitor); SetEntries(0, 255, colors); SetGDevice(old_device); #if 0 palette = GetPalette(GameWindow); for (i=0; i<256; i++) { color.red = 0x0; color.green = 0x0; color.blue = 0x0; SetEntryColor(palette, i, &color); } ctable = (CTabHandle)NewHandle(sizeof(ColorTable)); Palette2CTab(palette, ctable); AnimatePalette(GameWindow, ctable, 0, 0, 256); ActivatePalette(GameWindow); DisposeHandle((Handle)ctable); // make the seeds match for the gworld clut and the window palette. I don't know if // this is necessary, but it doesn't hurt. if (GameGWorld != NULL) { ctable = (**GetGWorldPixMap(GameGWorld)).pmTable; CTabChanged(ctable); (**ctable).ctSeed = (**(**(*(CGrafPtr)GameWindow).portPixMap).pmTable).ctSeed; } #endif gr_palette_faded_out = 1; }