コード例 #1
0
_HYPlatformGraphicPane::_HYPlatformGraphicPane(int h, int w, int d)
{
	Rect  bRect;
	bRect.left = bRect.top = 0;
	bRect.right = w;
	bRect.bottom = h;
	
	short errCode;
	
	if (d>1)
	{
	  	errCode = NewGWorld (&thePane,d,&bRect,0,GetMainDevice(),noNewDevice);
	
		if (errCode == -108) // no memory
			errCode = NewGWorld (&thePane,d,&bRect,0,GetMainDevice(),noNewDevice|useTempMem);
	}
	else
	{
	  	errCode = NewGWorld (&thePane,d,&bRect,0,nil,0);
	
		if (errCode == -108) // no memory
			errCode = NewGWorld (&thePane,d,&bRect,0,nil,useTempMem);
	}
		
	fillColor = NewPixPat();
	//backColor = NewPixPat();
	if (errCode||(!fillColor))
	{
		_String errMsg ("MacOS Error ");
		errMsg = errMsg & (long)errCode &" while trying to allocate memory for GraphicPane";
		FlagError (errMsg);
	}
	savedPort = nil;
}
コード例 #2
0
void _HYPlatformGraphicPane::_SetPaneSize  (int h,int w, int d)
{
	DisposeGWorld (thePane);
	Rect  bRect;
	bRect.left = bRect.top = 0;
	bRect.right = w;
	bRect.bottom = h;
	short errCode;
	if (d>1)
	{
	  	errCode = NewGWorld (&thePane,d,&bRect,0,GetMainDevice(),noNewDevice);
	
		if (errCode == -108) // no memory
			errCode = NewGWorld (&thePane,d,&bRect,0,GetMainDevice(),noNewDevice|useTempMem);
	}
	else
	{
	  	errCode = NewGWorld (&thePane,d,&bRect,0,nil,0);
	
		if (errCode == -108) // no memory
			errCode = NewGWorld (&thePane,d,&bRect,0,nil,useTempMem);
	}

	if (errCode)
	{
		_String errMsg ("MacOS Error ");
		errMsg = errMsg & (long)errCode &" while trying to allocate memory for GraphicPane";
		FlagError (errMsg);
	}
}
コード例 #3
0
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;
}
コード例 #4
0
ファイル: BLAST Tint.c プロジェクト: MaddTheSane/tntbasic
QDErr OpenTintWorld(CTabHandle theTable)
{
	Rect	rect={0,0,1,1};
	QDErr	theErr=NewGWorld(&gBL_TintWorld,8,&rect,theTable,0L,0);
	
	return theErr;
}
コード例 #5
0
ファイル: main.c プロジェクト: fruitsamples/QuickDraw_FX
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( &currentPort, &currentDevice );
	NewGWorld( &gGWorld, 32, &rect, nil, nil, 0 );
		
	LockPixels( GetPortPixMap(gGWorld));
	SetGWorld( gGWorld, nil );

	DrawPicture( pict, &rect );
	
	SetGWorld( currentPort, currentDevice );
	
	ReleaseResource( (Handle)pict );
}
コード例 #6
0
OSErr myNewGWorld(
	GWorldPtr *gw,
	short depth,
	Rect *bounds,
	CTabHandle clut,
	GDHandle dev,
	unsigned long flags)
{
	return NewGWorld(gw,depth,bounds,clut,dev,flags);
}
コード例 #7
0
void CreateSpriteStuff (Rect *windowBounds, CGrafPtr windowPtr)
{
	OSErr err;
	Rect bounds;

	// calculate the size of the destination
	bounds = *windowBounds;
	OffsetRect (&bounds, -bounds.left, -bounds.top);
	gBounceBox = bounds;
	InsetRect (&gBounceBox, 16, 16);

	// create a sprite layer graphics world with a bit depth of 32
	NewGWorld (&gSpritePlane, 32, &bounds, nil, nil, useTempMem);
	if (gSpritePlane == nil)
	{
		NewGWorld (&gSpritePlane, 32, &bounds, nil, nil, 0);
	}
	
	if (gSpritePlane)
	{
		LockPixels (GetPortPixMap(gSpritePlane));
		
		gBackgroundColor.red = 0x1234;
		gBackgroundColor.green = 0x0001;
		gBackgroundColor.blue = 0x0044;
		

		// create a sprite world
		err = NewSpriteWorld (&gSpriteWorld,		/* on return, a new sprite world */
								windowPtr,			/* destination */
								gSpritePlane,		/* sprite layer graphics world */
								&gBackgroundColor,	/* background color */
								nil);				/* graphics world to be used as the background. */
		
		// create sprites
		CreateSprites();
	}
}
コード例 #8
0
ファイル: fontmng.cpp プロジェクト: FREEWING-JP/np2pi
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);
}
コード例 #9
0
ファイル: scrap.c プロジェクト: LarBob/executor
PRIVATE GWorldPtr
gworld_from_pict (PicHandle ph)
{
  GWorldPtr retval;

  retval = NULL;
  if (ph)
    {
      CGrafPtr save_port;
      GDHandle save_device;
      Rect r;
      OSErr err;

      GetGWorld (&save_port, &save_device);
      save_port = MR (save_port);
      save_device = MR (save_device);
      r = HxX (ph, picFrame);
      err = NewGWorld (&retval, 32, &r, NULL, NULL, keepLocal);
      if (retval)
	{
	  PixMapHandle pm;

	  retval = MR (retval);
	  SetGWorld (retval, NULL);
	  pm = GetGWorldPixMap (retval);
	  LockPixels (pm);
	  DrawPicture (ph, &r);
#if 0
#warning THIS INTERFERES WITH PICT PASTING
	  {
	    char *p;

	    EraseRect (&r);
	    p = GetPixBaseAddr (pm);
	    memset (p, 0x00, 4 * RECT_HEIGHT(&r) * RECT_WIDTH (&r));
	    memset (p, 0xFF, 4 * RECT_HEIGHT(&r) * RECT_WIDTH (&r) / 2);
	  }
#endif
	  UnlockPixels (pm);
	}
      SetGWorld (save_port, save_device);
    }
  return retval;
}
コード例 #10
0
void drawWindowFrame(WindowRef window)
{
    /*------------------------------------------------------
        Draw the frame of our window.
        
        This function needs to draw the title bar, 
        the grow box, the title string and the 
        structural aspects of the window.
    --------------------------------------------------------*/
    static GWorldPtr framePict=NULL;
    static Rect pictureRect;
    GrafPtr thePort;
    Rect frame;

    if(!framePict){//haven't cached our picture
        PicHandle myPicture=GetPicture(kPictureID);
        GrafPtr	origPort;
        GDHandle origDev;
        GetGWorld(&origPort,&origDev);
        pictureRect=(*myPicture)->picFrame;
        NewGWorld(&framePict,0,&pictureRect,NULL,NULL,0);
        SetGWorld(framePict,NULL);
        DrawPicture(myPicture,&pictureRect);
        SetGWorld(origPort,origDev);
        ReleaseResource((Handle)myPicture);
    }

    getCurrentPortBounds(&frame);
    GetPort(&thePort);
    CopyBits(GetPortBitMapForCopyBits(framePict),
             GetPortBitMapForCopyBits(thePort),
             &pictureRect,&frame,srcCopy,NULL);//draw our picture
    myWindowDrawGrowBox(window,0);//draw grow box as part of frame
    
    if(IsWindowHilited(window))
    {
        //do any hilighting
    }
    
}
コード例 #11
0
RgnHandle getWindowStructureRegion(WindowRef window, RgnHandle structureRegion)
{
    /*------------------------------------------------------
        Define the structural region of our window.
    --------------------------------------------------------*/
    static RgnHandle pictureRgn=NULL;
    static Rect pictureRect;
    Rect windowRect;
    
    SetEmptyRgn(structureRegion);
    
    if(!pictureRgn){//haven't Cached our region yet
        PicHandle myPicture=GetPicture(kMaskPictureID);
        GrafPtr	origPort;
        GDHandle origDev;
        GWorldPtr pictMask;
        PixMapHandle maskBitMap;
        GetGWorld(&origPort,&origDev);
        pictureRgn=NewRgn();
        pictureRect=(*myPicture)->picFrame;
        NewGWorld(&pictMask,1,&pictureRect,NULL,NULL,0);
        maskBitMap=GetPortPixMap(pictMask);
        LockPixels(maskBitMap);
        SetGWorld(pictMask,NULL);
        EraseRect(&pictureRect);
        DrawPicture(myPicture,&pictureRect);
        BitMapToRegion(pictureRgn,(BitMap*)*maskBitMap);//use the mask to create a region
        InsetRgn(pictureRgn,1,1);
        SetGWorld(origPort,origDev);
        UnlockPixels(maskBitMap);
        DisposeGWorld(pictMask);
        ReleaseResource((Handle)myPicture);
    }
    getCurrentPortBounds(&windowRect);//how big is the window
    CopyRgn(pictureRgn,structureRegion);//make a copy of our cached region
    MapRgn(structureRegion,&pictureRect,&windowRect);//scale it to our actual window size
    return structureRegion;
}
コード例 #12
0
ファイル: qtexport.cpp プロジェクト: Reinis/wxmacmolplt
void MolDisplayWin::WriteQTMovie(wxString & filepath) {
	//Create a QuickTime movie using the standard animation codecs with normal quality, and 
	//temporal compression. The final file is flattened for cross platform compatability
	
	QTExport * QTOptions = new QTExport(this);
	//setup controls for the current data
	if (MainData->GetNumFrames() > 1) { //default to frame animation
		QTOptions->SetMovieChoice(0);
	} else {
		QTOptions->EnableFrameMovie(false);
	}
	if (MainData->cFrame->GetNumberNormalModes() <= 0) {
		QTOptions->EnableModeMovie(false);
	}
	
	if (QTOptions->ShowModal() != wxID_OK) {
		//user cancelled the operation
		QTOptions->Destroy();
		return;
	}
	//retrieve the value of each option
	int MovieType = QTOptions->GetMovieChoice();
	bool IncludeEPlot = QTOptions->AddEnergyPlot();
	int compressorChoice = QTOptions->GetCompressorChoice();
	int keyFrameRate = QTOptions->GetKeyFrameRate();
	if (keyFrameRate < 0) keyFrameRate = 0;
	
	QTOptions->Destroy();
	
	CodecType mCodec;
	switch (compressorChoice) {
		case 0:
			mCodec = kCinepakCodecType;
			break;
		case 1:
			mCodec = kGraphicsCodecType;
			break;
		case 2:
			mCodec = kAnimationCodecType;
			break;
		case 3:
		default:
			mCodec = kMPEG4VisualCodecType;
	}

	OSStatus s;
	OSErr myErr = myErr;
	FSSpec targetSpec;
	//ugh I need to get an FSSpec to hand to quicktime, but these calls only seem to work if
	//the file already exists...
	const char * t = filepath.mb_str(wxConvUTF8);
	FILE * temp = fopen(t, "wb");
	fclose(temp);

#ifdef __WXOSX_COCOA__
	//This function is not found in the wxCocoa implementation, it is probably possible to work around it
	//Otherwise the code appears to link and run currently. However, it is probably better to redue the
	//code to use the Cocoa qtKit framework rather than the old Carbon QT library.
	
	//This path is not tested as the current Cocoa code does not properly support the extended save dialog.
	//	void wxMacFilename2FSSpec( const wxString& path , FSSpec *spec )
	{
		OSStatus err = noErr;
		FSRef fsRef;
		wxMacPathToFSRef( filepath , &fsRef );
		err = FSGetCatalogInfo(&fsRef, kFSCatInfoNone, NULL, NULL, &targetSpec, NULL);
		verify_noerr( err );
	}
#else
	wxMacFilename2FSSpec(filepath, &targetSpec);
#endif
	
	Movie	theMovie = NULL;
		
	FSSpec tempSpec = targetSpec;
	strcpy((char *) &(tempSpec.name[1]), "MacMolPlt8933tempMovie");
	tempSpec.name[0] = 22;

	BeginOperation();
	ProgressInd->ChangeText("Creating movie...");
		
	myErr = EnterMovies();	//initialize the quicktime manager
	if (myErr != noErr) {
		FinishOperation();
		MessageAlert("Error initializing QuickTime!");
		return;
	}
		//Create the movie file and initialize file data
		//Use Quicktime creator code 'TVOD' instead of simpletext 'ttxt'
	short	resRefNum = 0;
	short	resId = 0;
	myErr = CreateMovieFile(&tempSpec, 'TVOD', smCurrentScript, createMovieFileDeleteCurFile,
							&resRefNum, &theMovie);
	if (myErr != noErr) {
		MessageAlert("Error creating movie file!");
	} else {
		bool KillEPlot = false;
		int width, height, savedEPlotWidth, savedEPlotHeight;
		glCanvas->GetClientSize(&width, &height);
		Rect lDisplayRect={0,0,0,0};
		lDisplayRect.right = width;
		lDisplayRect.bottom = height;
		Rect		gRect = lDisplayRect;

		Rect EPlotRect = lDisplayRect;
		//If we are including an energy plot add space for it here
		if (IncludeEPlot && (MovieType == 0)) {
			EPlotRect.left = EPlotRect.right;
			EPlotRect.right = EPlotRect.left + height;
			if (!energyPlotWindow) {
				energyPlotWindow = new EnergyPlotDialog(this);
				KillEPlot = true;
			} else {
				energyPlotWindow->GetSize(&savedEPlotWidth, &savedEPlotHeight);
			}
			gRect.right += height;
			width += height;
			energyPlotWindow->Show(false);
			energyPlotWindow->SetSize(height, height);
			energyPlotWindow->Update();	//This is needed to initialise the window if we just created it
		}

		LocalToGlobal ((Point *) &(gRect.top));
		LocalToGlobal ((Point *) &(gRect.bottom));
		WindowRef TempWindow;
		s = CreateNewWindow(kDocumentWindowClass, kWindowNoAttributes, &gRect, &TempWindow);
		if (s == noErr) {
													//Create the video track
			Track theTrack = NewMovieTrack (theMovie, FixRatio(width,1),
											FixRatio(height,1), kNoVolume);
			if ((noErr == GetMoviesError())&&theTrack) {
				Media theMedia = NewTrackMedia (theTrack, VideoMediaType,
												60, // Video Time Scale
												NULL, 0);
				if ((noErr == GetMoviesError())&&theMedia) {
					myErr = BeginMediaEdits (theMedia);
					if (myErr == noErr) {
						//create the actual movie frames
						GWorldPtr	lgWorld=NULL;
						
						if (! NewGWorld (&lgWorld, 0, &gRect, (CTabHandle) NULL, (GDHandle) NULL,
										 (GWorldFlags) (pixPurge + useTempMem))) {
							long MaxCompressedSize;
							ImageSequence seqID;
							ImageDescriptionHandle imageDesc = (ImageDescriptionHandle)NewHandle(4);
							PixMapHandle myPixMap = GetPortPixMap(lgWorld);
							LockPixels (myPixMap);
							myErr = CompressSequenceBegin(&seqID, myPixMap, NULL, &gRect, &gRect, 0,
														  mCodec, bestCompressionCodec, codecNormalQuality, codecNormalQuality, keyFrameRate, NULL,
														  codecFlagUpdatePreviousComp, imageDesc);
							GetMaxCompressionSize (myPixMap, &gRect,
												   0, codecNormalQuality, mCodec, (CompressorComponent) anyCodec, &MaxCompressedSize);
							Handle Buffer = TempNewHandle(MaxCompressedSize, &myErr);
							if (!Buffer)
								Buffer = NewHandle(MaxCompressedSize);
							if (Buffer) {
								qtData myqtData = {theMedia, imageDesc, seqID, lDisplayRect, gRect};
								if (MovieType == 0) {
									CreateFrameMovie(lgWorld, Buffer, myqtData, IncludeEPlot);
								} else {
									CreateModeMovie(lgWorld, Buffer, myqtData);
								}
								DisposeHandle(Buffer);
							}
							myErr = CDSequenceEnd(seqID);
							if (lgWorld != NULL) DisposeGWorld (lgWorld);
							if (imageDesc) DisposeHandle((Handle) imageDesc);
						}
						
						myErr = EndMediaEdits (theMedia);
					}
					myErr = InsertMediaIntoTrack (theTrack, 0,/* track start time */
						0,        /* media start time */
						GetMediaDuration (theMedia),
						FixRatio(1,1));
				}
				myErr = AddMovieResource (theMovie, resRefNum, &resId, NULL);
			}
			if (resRefNum) {
						//Create the actual file as a flat data fork so it can be placed on the www
				ProgressInd->ChangeText("Flattening movieÉ");
				FlattenMovie(theMovie, flattenAddMovieToDataFork, &targetSpec, 'TVOD', smCurrentScript, 
							 createMovieFileDeleteCurFile, &resId, NULL);
				CloseMovieFile (resRefNum);
			}
			DisposeWindow(TempWindow);
		}
		DisposeMovie (theMovie);
		DeleteMovieFile (&tempSpec);	//delete the temp file after disposing of the movie

		if (energyPlotWindow) {
			if (KillEPlot) {
				delete energyPlotWindow;
				energyPlotWindow = NULL;
			} else {
				energyPlotWindow->SetSize(savedEPlotWidth, savedEPlotHeight);
				energyPlotWindow->FrameChanged();
				energyPlotWindow->Show(true);
			}
		}
	}
	ExitMovies();	//Close out quicktime as we are done with it for now
	FinishOperation();
}
コード例 #13
0
ファイル: SDL_romvideo.c プロジェクト: 3bu1/crossbridge
static SDL_Surface *ROM_SetVideoMode(_THIS, SDL_Surface *current,
				int width, int height, int bpp, Uint32 flags)
{
	Rect wrect, orect;
#if TARGET_API_MAC_CARBON
	Rect tmprect;
#endif

	/* Free any previous video mode */
	ROM_UnsetVideoMode(this, current);

	/* Create the ROM window and SDL video surface */
	current->flags = 0;		/* Clear flags */
	current->w = width;
	current->h = height;
	SetRect(&wrect, 0, 0, width, height);
	if ( SDL_Window ) {
		/* If we recreate the window, don't move it around */
#if TARGET_API_MAC_CARBON
		orect = *GetWindowPortBounds(SDL_Window, &tmprect);
#else
		orect = SDL_Window->portRect;
#endif
		OffsetRect(&wrect, orect.left, orect.top);
	} else {
		/* Center the window the first time we show it */
		OffsetRect(&wrect,
		(SDL_modelist[0]->w-width)/2, (SDL_modelist[0]->h-height)/2);
	}

#if defined(__MACOSX__) && !USE_QUICKTIME
	/* Hum.. fullscreen mode is broken */
	flags &= ~SDL_FULLSCREEN;
#endif
	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
		/* Create the fullscreen window and use screen bits */
		current->flags |= SDL_HWSURFACE|SDL_FULLSCREEN;
		if ( SDL_Window ) {
			DisposeWindow(SDL_Window);
		}
#if USE_QUICKTIME
		BeginFullScreen(&fullscreen_ctx, nil, 0,0, &SDL_Window, nil, 0);
#else
		SDL_Window = NewCWindow(nil, &wrect, "\p", true, plainDBox,
						(WindowPtr)-1, false, 0);
		ROM_HideMenuBar(this);
#endif
		current->pitch = (**(**SDL_Display).gdPMap).rowBytes & 0x3FFF;
		current->pixels = (**(**SDL_Display).gdPMap).baseAddr;
		this->UpdateRects = ROM_DirectUpdate;
	} else {
		GWorldPtr memworld;
		PixMapHandle pixmap;
		int style;

		style = noGrowDocProc;
		if ( flags & SDL_NOFRAME ) {
			style = plainDBox;
			current->flags |= SDL_NOFRAME;
		} else
		if ( flags & SDL_RESIZABLE ) {
			style = zoomDocProc;
			current->flags |= SDL_RESIZABLE;
		}
		if ( SDL_Window && (style == current_style) ) {
			/* Resize existing window, if necessary */
			if ( ((orect.right-orect.left) != width) ||
			     ((orect.bottom-orect.top) != height) ) {
				SizeWindow(SDL_Window, width, height, false);
			}
		} else {
			/* Recreate the window in the new style */
			if ( SDL_Window ) {
				DisposeWindow(SDL_Window);
			}
			SDL_Window = NewCWindow(nil, &wrect, "\p", true,
			                        style, (WindowPtr)-1, true, 0);

			/* Set the window title, if any */
			{ char *title;
				SDL_WM_GetCaption(&title, NULL);
				if ( title ) {
					Mac_SetCaption(this, title, NULL);
				}
			}
		}
		current_style = style;
		SetPalette(SDL_Window, SDL_CPal, false);
		ActivatePalette(SDL_Window);
		if ( NewGWorld(&memworld, 0,
#if TARGET_API_MAC_CARBON
			       GetWindowPortBounds(SDL_Window, &tmprect),
#else
			       &SDL_Window->portRect,
#endif
			       SDL_CTab, nil, 0) != noErr ) {
			SDL_SetError("NewGWorld() failed");
			return(NULL);
		}
		SetWRefCon(SDL_Window, (long)memworld);
		pixmap = GetGWorldPixMap(memworld);
		LockPixels(pixmap);
		current->pitch = (**pixmap).rowBytes & 0x3FFF;
		current->pixels = GetPixBaseAddr(pixmap);
		this->UpdateRects = ROM_WindowUpdate;
	}
	SetPortWindowPort(SDL_Window);
	SelectWindow(SDL_Window);

	/* Handle OpenGL support */
	if ( flags & SDL_OPENGL ) {
		if ( Mac_GL_Init(this) == 0 ) {
			current->flags |= SDL_OPENGL;
		} else {
			current = NULL;
		}
	}
	
	if ( (flags & SDL_HWPALETTE) && (flags & SDL_FULLSCREEN) )
	   current->flags |= SDL_HWPALETTE;
	   
	/* We're live! */
	return(current);
}
コード例 #14
0
DisplayDialog::DisplayDialog(ProfileDoc *dc,RawData *pD,int wn):InputDialog(dc,pD,1)
{
	short		iType;
	Handle		iHandle;
	Handle		sHandle;
	Rect 		iRect, r,pRect,tRect;	
	UserItemUPP  box3D;
	
	QDErr		error;
	GDHandle	oldGD;
	GWorldPtr	oldGW;
	RGBColor	c,oldbackcolor,oldforecolor;
	WindowPtr	oldP;
	OSErr			err;
	int32 		i,wi,hi;
	double w,h;
	short		dtp_ids[] = DISPPATCH_IDS;
	Str255		theString,name;
	
	for (i=0; i<NumInputIDS; i++) ids[i] = dtp_ids[i];

	WinType = DisplayWindow;
	WinNum = wn;

	setDialog(Input_Dialog);

	
	GetIndString(theString,Display_Title,1);
	
	SetWTitle( dp, theString);
	
	// Added by James, 3D the box
	threeD_box(ids[ThreeDBox]);
	

	//playSound(8193);
	
	
	// initialize the big gworld 
	GetDItem (dp, ids[Strip_Rect], &iType, (Handle*)&iHandle, &iRect);
	tRect = iRect;
	OffsetRect(&tRect,-iRect.left,-iRect.top);
	error = NewGWorld( &BigGW, 32, &tRect, 0, 0, 0 );
	if (error != 0) 
		{
		delete this;
		return;
		} 
	GetGWorld(&oldGW,&oldGD);
	SetGWorld(BigGW,nil);	
	
	
//	GetBackColor(&oldbackcolor);
	GetForeColor(&oldforecolor);
	c.red = 65535;
	c.green = 65535;
	c.blue = 65535;
	RGBBackColor(&c);
	c.red = 0;
	c.green = 0;
	c.blue = 0;
	RGBForeColor(&c);		
//	EraseRect( &tRect );
	
	SetGWorld(oldGW,oldGD);	
//	RGBBackColor(&oldbackcolor);
	RGBForeColor(&oldforecolor);	

//	SetPort(oldP);
		
	GetDItem (dp, ids[Patch_Rect], &iType, (Handle*)&iHandle, &pRect);
	num_display_patch = (iRect.bottom-iRect.top)/(pRect.bottom-pRect.top);
	top_patch = 0;
						
//init the static members
	//current_patch = total_patches-1;
	//current_patch = 0;
	current_patch = 0;
	current_strip = 0;
	current_sheet = 0;
 		
 	_done = 0;
 	_waiting = 0;
	
	SetSheetStripText();
	
	current_top = current_patch - 2*num_display_patch/3;
	current_bottom = current_top + num_display_patch - 1;
	if (current_top < 0) 
		{
		current_top = 0;
		current_bottom = current_top + num_display_patch - 1;
		}
	if (current_bottom >= total_patches-1)
		{
		current_bottom = total_patches - 1;
		current_top = current_bottom - num_display_patch + 1;
		}
	
	current_disp = 2*num_display_patch/3;
	
	init();	
	getpatchRGB();
	
	
	Disable(dp,ids[Redo]);

	
	GetDItem (dp, ids[Slider], &iType, (Handle*)&iHandle, &pRect);
	SetCtlMin((ControlHandle)iHandle,0);
	SetCtlMax((ControlHandle)iHandle,total_patches-1);
	
//	GetDItem ( dp,ids[Message], &iType, (Handle*)&iHandle, &pRect );
//	SetIText(iHandle,"\p");
	
	GetDItem ( dp,PatchLabel, &iType, (Handle*)&iHandle, &pRect );
	GetIndString(theString,Message_List_ID,Patch_Message);
	SetIText(iHandle,theString);
	
	strcpy((char*)name,pD->desc);
	ctopstr((char*)name);
	SetWTitle( dp, name);
	
	DrawWindow();
}	
コード例 #15
0
static void QTDR_DrawFrame (short theTrackWidth, short theTrackHeight, long theNumSample, GWorldPtr theGWorld)
{
	Handle								myHandle = NULL;
	char								myData[kPICTFileHeaderSize];
	static PicHandle					myPicture = NULL;
	static GWorldPtr					myGWorld = NULL;
	static GraphicsImportComponent		myImporter = NULL;
	Rect								myRect;
	RGBColor							myColor;
	ComponentResult						myErr = noErr;

	MacSetRect(&myRect, 0, 0, theTrackWidth, theTrackHeight);

	if (myPicture == NULL) {
		myErr = NewGWorld(&myGWorld, kPixelDepth, &myRect, NULL, NULL, (GWorldFlags)0);
		if (myErr != noErr)
			goto bail;

		// read a picture from our resource file
		myPicture = GetPicture(kPictureID);
		if (myPicture == NULL)
			goto bail;

		// use Munger to prepend a 512-byte header onto the picture data; this converts the PICT
		// resource data into in-memory PICT file data (see Ice Floe 14 for an explanation of this)
		myHandle = (Handle)myPicture;
		Munger(myHandle, 0, NULL, 0, myData, kPICTFileHeaderSize);

		// get a graphics importer for the picture
		myErr = OpenADefaultComponent(GraphicsImporterComponentType, kQTFileTypePicture, &myImporter); 
		if (myErr != noErr)
			goto bail;
				
		// configure the graphics importer
		myErr = GraphicsImportSetGWorld(myImporter, myGWorld, NULL);
		if (myErr != noErr)
			goto bail;
		
		myErr = GraphicsImportSetDataHandle(myImporter, myHandle);
		if (myErr != noErr)
			goto bail;
			
		myErr = GraphicsImportSetBoundsRect(myImporter, &myRect);
		if (myErr != noErr)
			goto bail;
			
		// draw the picture into the source GWorld
		myErr = GraphicsImportDraw(myImporter);
		if (myErr != noErr)
			goto bail;
	}
	
	// set the blend amount (0 = fully transparent; 0xffff = fully opaque)
	myColor.red = (theNumSample - 1) * (0xffff / kNumVideoFrames - 1);
	myColor.green = (theNumSample - 1) * (0xffff / kNumVideoFrames - 1);
	myColor.blue = (theNumSample - 1) * (0xffff / kNumVideoFrames - 1);
	OpColor(&myColor);
	
	// blend the picture (in the source GWorld) into the empty rectangle (in the destination GWorld)
	CopyBits((BitMapPtr)*GetGWorldPixMap(myGWorld),
			 (BitMapPtr)*GetGWorldPixMap(theGWorld),
			 &myRect,
			 &myRect,
			 blend,
			 NULL);

	if (theNumSample == kNumVideoFrames)
		goto bail;
		
	return;
	
bail:
	if (myHandle != NULL)
		DisposeHandle(myHandle);
		
	if (myPicture != NULL)
		ReleaseResource((Handle)myPicture);
		
	if (myImporter != NULL)
		CloseComponent(myImporter);
} 
コード例 #16
0
ファイル: scrap.c プロジェクト: LarBob/executor
PRIVATE GWorldPtr
gworld_from_surface (SDL_Surface *surfp)
{
  GWorldPtr retval;

  retval = NULL;

  if (surfp)
    {
      QDErr err;
      int surf_depth;
      CTabHandle ctab;

      ctab = NULL;

      surf_depth = SDL_Surface_depth (surfp);
      switch (surf_depth)
	{
	case 8:
	  ctab = ctab_from_surface (surfp);
	  break;
	case 32:
	  break;
	default:
	  warning_unexpected ("surf_depth = %d", surf_depth);
	  surf_depth = 0;
	  break;
	}

      if (surf_depth)
	{
	  int n_lines;
	  int pixels_per_line;
	  Rect r;

	  n_lines = SDL_Surface_height (surfp);
	  pixels_per_line = SDL_Surface_width (surfp);

	  r.top = CWC (0);
	  r.left = CWC (0);
	  r.bottom = CW (n_lines);
	  r.right = CW (pixels_per_line);
	  {
	    CGrafPtr save_port;
	    GDHandle save_device;

	    GetGWorld (&save_port, &save_device);
	    save_port = MR (save_port);
	    save_device = MR (save_device);
	    err = NewGWorld (&retval, surf_depth, &r, ctab, NULL, keepLocal);
	    SetGWorld (save_port, save_device);
	  }
	  if (retval)
	    {
	      PixMapHandle pm;

	      retval = MR (retval);
	      pm = GetGWorldPixMap (retval);
	      LockPixels (pm);
	      SDL_LockSurface (surfp);

	      switch (surf_depth)
		{
		case 8:
		  {
		    uint8 *ip, *eip;
		    uint8 *op;
		    int rowbytes;
		    int pitch;

		    pitch = SDL_Surface_pitch (surfp);
		    rowbytes = PIXMAP_ROWBYTES (pm);

		    ip = SDL_Surface_pixels (surfp);
		    op = (typeof (op)) GetPixBaseAddr (pm);
		    eip = ip + n_lines * pitch;
		    for (; ip != eip; ip += pitch, op += rowbytes)
		      memcpy (op, ip, rowbytes);
		    break;
		  }

		case 32:
		  {
		    sdl_pixel24 *ip;
		    mac_pixel32 *op;
		  
		    op = (typeof (op)) GetPixBaseAddr (pm);
		    ip = SDL_Surface_pixels (surfp);

		    memcpy (op, ip, n_lines * pixels_per_line * sizeof *op);
		    
		    break;
		  }
		default:
		  warning_unexpected ("surf_depth = %d", surf_depth);
		  break;
		}
	      SDL_UnlockSurface (surfp);
	      UnlockPixels (pm);
	    }
	}
    }
  return retval;
}
コード例 #17
0
void do_explosion_anim(short sound_num,short special_draw)
// sound_num currently ignored
// special_draw - 0 normal 1 - first half 2 - second half
{
	Rect temp_rect,active_area_rect,to_rect,from_rect;
	Rect base_rect = {0,0,36,28},text_rect;
	char str[60];
	short i,temp_val,temp_val2;
	location screen_ul;
	
	short t,cur_boom_type = 0; 
	Point current_terrain_ul; 
	GWorldPtr temp_gworld;
	GrafPtr old_port;
	short boom_type_sound[3] = {5,10,53};
	
	if ((have_boom == false) || (boom_anim_active == false)) {
		boom_anim_active = false;
		return;
		}
	
	for (i = 0; i < 30; i++)
		if (store_booms[i].boom_type >= 0)
			i = 50;
	if (i == 30)
		return;

	// initialize general data
	if (in_startup_mode) {
		current_terrain_ul.h = 306;
		current_terrain_ul.v = 5;
	} else current_terrain_ul.h = current_terrain_ul.v = 5;
	
	// make terrain_template contain current terrain all nicely
	draw_terrain(1);
	if (special_draw != 2) {
		GetPortBounds(terrain_screen_gworld,&to_rect);
		Rect oldRect = to_rect;
		OffsetRect(&to_rect,current_terrain_ul.h, current_terrain_ul.v);
		rect_draw_some_item(terrain_screen_gworld,oldRect,to_rect,ul);
		}
		
	GetPort(&old_port);	
				
	// create and clip temporary anim template 
	GetPortBounds(terrain_screen_gworld,&temp_rect);
	NewGWorld(&temp_gworld,  0 /*8*/,&temp_rect, NULL, NULL, kNativeEndianPixMap);
	SetPort(temp_gworld);
	TextFont(geneva_font_num);
	TextFace(bold);
	TextSize(10);
	active_area_rect = temp_rect;
	InsetRect(&active_area_rect,13,13);
	ClipRect(&active_area_rect);
	SetPort(GetWindowPort(mainPtr));
	
	// init missile paths
	screen_ul.x = center.x - 4; screen_ul.y = center.y - 4;
	for (i = 0; i < 30; i++) 
		if ((store_booms[i].boom_type >= 0)  && (special_draw < 2)) {
			cur_boom_type = store_booms[i].boom_type;
			explode_place_rect[i] = base_rect;
			OffsetRect(&explode_place_rect[i],13 + 28 * (store_booms[i].dest.x - screen_ul.x) + store_booms[i].x_adj,
				13 + 36 * (store_booms[i].dest.y - screen_ul.y) + store_booms[i].y_adj);
				
			if ((store_booms[i].place_type == 1) && (special_draw < 2)) {
				temp_val = get_ran(1,0,50) - 25;
				temp_val2 = get_ran(1,0,50) - 25;
				OffsetRect(&explode_place_rect[i],temp_val,temp_val2);
				}
			
			// eliminate stuff that's too gone. 
			Rect tempRect2;
			GetPortBounds(terrain_screen_gworld,&tempRect2);
			SectRect(&explode_place_rect[i],&tempRect2,&temp_rect);
			if (EqualRect(&temp_rect,&explode_place_rect[i]) == false) {
				store_booms[i].boom_type = -1;
				}
			
			}
			else if (special_draw < 2)
				explode_place_rect[i].top =explode_place_rect[i].left =explode_place_rect[i].bottom =explode_place_rect[i].right = 0;
	
	//play_sound(-1 * sound_num);
	if (special_draw < 2)
		play_sound(-1 * boom_type_sound[cur_boom_type]);
	
	// Now, at last, do explosion
	for (t = (special_draw == 2) ? 6 : 0; t < ((special_draw == 1) ? 6 : 11); t++) { // t goes up to 10 to make sure screen gets cleaned up
		// First, lay terrain in temporary graphic area;
		for (i = 0; i < 30; i++) 
			if (store_booms[i].boom_type >= 0) 
				rect_draw_some_item(terrain_screen_gworld,explode_place_rect[i],
					temp_gworld,explode_place_rect[i]);

		// Now put in explosions
		for (i = 0; i < 30; i++) 
			if (store_booms[i].boom_type >= 0) {
				if ((t + store_booms[i].offset >= 0) && (t + store_booms[i].offset <= 7)) {
						from_rect = base_rect;
						OffsetRect(&from_rect,28 * (t + store_booms[i].offset),36 * (1 + store_booms[i].boom_type));
						rect_draw_some_item(boom_gworld,from_rect,
							temp_gworld,explode_place_rect[i],transparent);
					
					if (store_booms[i].val_to_place > 0) {
						text_rect = explode_place_rect[i];
						text_rect.top += 4;
						text_rect.left -= 10;
						if (store_booms[i].val_to_place < 10)
							text_rect.left += 8;
						sprintf(str,"%d",store_booms[i].val_to_place);
						SetPort(temp_gworld);
						ForeColor(whiteColor);
						char_port_draw_string(temp_gworld,text_rect,str,1,12);
						ForeColor(blackColor);
						SetPort(GetWindowPort(mainPtr));
						}
					}
				}
		// Now draw all missiles to screen
		for (i = 0; i < 30; i++) 
			if (store_booms[i].boom_type >= 0) {
				to_rect = explode_place_rect[i];
				OffsetRect(&to_rect,current_terrain_ul.h,current_terrain_ul.v);
				rect_draw_some_item(temp_gworld,explode_place_rect[i],to_rect,ul);
				}
		//if (((PSD[SDF_GAME_SPEED] == 1) && (t % 3 == 0)) || ((PSD[SDF_GAME_SPEED] == 2) && (t % 2 == 0)))
			FlushAndPause(2 * (1 + PSD[SDF_GAME_SPEED]));
		}
		
	// Exit gracefully, and clean up screen
	for (i = 0; i < 30; i++) 
		if (special_draw != 1)
			store_booms[i].boom_type = -1;
	DisposeGWorld(temp_gworld);
	SetPort(old_port);

	//to_rect = terrain_screen_gworld->portRect;
	//OffsetRect(&to_rect,current_terrain_ul.h,current_terrain_ul.v);
	//rect_draw_some_item(terrain_screen_gworld,terrain_screen_gworld->portRect,
	//	terrain_screen_gworld,to_rect,0,1);
}
コード例 #18
0
ファイル: osximage.cpp プロジェクト: soapdog/livecode
bool MCImageBitmapToPICT(MCImageBitmap *p_bitmap, MCMacSysPictHandle &r_pict)
{
#ifdef LIBGRAPHICS_BROKEN
	bool t_success = true;
	
	Pixmap drawdata = nil, drawmask = nil;
	MCBitmap *maskimagealpha = nil;
	
	t_success = MCImageSplitPixmaps(p_bitmap, drawdata, drawmask, maskimagealpha);
	
	if (!t_success)
		return false;

	Rect t_rect;
	SetRect(&t_rect, 0, 0, p_bitmap->width, p_bitmap->height);
	
	GWorldPtr t_old_gworld;
	GDHandle t_old_gdevice;
	GetGWorld(&t_old_gworld, &t_old_gdevice);

	PixMapHandle t_draw_pixmap;
	t_draw_pixmap = GetGWorldPixMap((CGrafPtr)drawdata -> handle . pixmap);
	
	GWorldPtr t_img_gworld;
	t_img_gworld = NULL;
	if (t_success)
	{
		QDErr t_err;
		t_err = NewGWorld(&t_img_gworld, 32, &t_rect, NULL, NULL, 0);
		if (t_err != noErr)
			t_success = false;
	}
	
	if (t_success)
	{
		SetGWorld(t_img_gworld, GetGDevice());
		
		PenMode(srcCopy);
		ForeColor(blackColor);
		BackColor(whiteColor);
		
		if (maskimagealpha != NULL)
		{
			GWorldPtr t_alpha_gworld;
			if (NewGWorldFromPtr(&t_alpha_gworld, 8, &t_rect, GetCTable(40), NULL, 0, maskimagealpha -> data, maskimagealpha -> bytes_per_line) == noErr)
			{
				const BitMap *t_dst_bits;
				t_dst_bits = GetPortBitMapForCopyBits(t_img_gworld);
				
				const BitMap *t_src_bits;
				t_src_bits = GetPortBitMapForCopyBits((CGrafPtr)drawdata -> handle . pixmap);
				
				const BitMap *t_mask_bits;
				t_mask_bits = GetPortBitMapForCopyBits(t_alpha_gworld);
				
				EraseRect(&t_rect);
				
				CopyDeepMask(t_src_bits, t_mask_bits, t_dst_bits, &t_rect, &t_rect, &t_rect, srcCopy, NULL);
			}
		}
		else if (drawmask != NULL)
		{
			PixMapHandle t_mask_pixmap;
			t_mask_pixmap = GetGWorldPixMap((CGrafPtr)drawmask -> handle . pixmap);
			
			EraseRect(&t_rect);
			
			const BitMap *t_dst_bits;
			t_dst_bits = GetPortBitMapForCopyBits(t_img_gworld);
			
			const BitMap *t_src_bits;
			LockPixels(t_draw_pixmap);
			t_src_bits = (BitMap *)*t_draw_pixmap;
			
			const BitMap *t_mask_bits;
			LockPixels(t_mask_pixmap);
			t_mask_bits = (BitMap *)*t_mask_pixmap;
			
			CopyMask(t_src_bits, t_mask_bits, t_dst_bits, &t_rect, &t_rect, &t_rect);
			
			UnlockPixels(t_mask_pixmap);
			
			UnlockPixels(t_draw_pixmap);
		}
		else
		{
			const BitMap *t_dst_bits;
			t_dst_bits = GetPortBitMapForCopyBits(t_img_gworld);
			
			const BitMap *t_src_bits;
			LockPixels(t_draw_pixmap);
			t_src_bits = (BitMap *)*t_draw_pixmap;
			CopyBits(t_src_bits, t_dst_bits, &t_rect, &t_rect, srcCopy, NULL);
			UnlockPixels(t_draw_pixmap);
		}
	}
	
	PicHandle t_handle;
	t_handle = NULL;
	if (t_success)
	{
		OpenCPicParams t_params;
		t_params . srcRect = t_rect;
		t_params . hRes = 72 << 16;
		t_params . vRes = 72 << 16;
		t_params . version = -2;
		t_params . reserved1 = 0;
		t_params . reserved2 = 0;
		t_handle = OpenCPicture(&t_params);
		if (t_handle == NULL)
			t_success = false;
	}

	if (t_success)
	{
		GWorldPtr t_pict_gworld;
		GDHandle t_pict_gdevice;
		GetGWorld(&t_pict_gworld, &t_pict_gdevice);
		
		PenMode(srcCopy);
		ForeColor(blackColor);
		BackColor(whiteColor);
		
		const BitMap *t_dst_bits;
		t_dst_bits = GetPortBitMapForCopyBits(t_pict_gworld);

		const BitMap *t_src_bits;
		t_src_bits = GetPortBitMapForCopyBits(t_img_gworld);
		CopyBits(t_src_bits, t_dst_bits, &t_rect, &t_rect, srcCopy, NULL);
		
		ClosePicture();
	}
	
	if (t_img_gworld != NULL)
		DisposeGWorld(t_img_gworld);
	
	SetGWorld(t_old_gworld, t_old_gdevice);

	MCscreen->freepixmap(drawdata);
	MCscreen->freepixmap(drawmask);
	if (maskimagealpha != nil)
		MCscreen->destroyimage(maskimagealpha);
	
	if (t_success)
		r_pict = (MCMacSysPictHandle)t_handle;
	
	return t_success;
#else
	return false;
#endif
}
コード例 #19
0
ファイル: Badge.c プロジェクト: fruitsamples/Tiler
/*******************************************************************************
**	TileBadge
*******************************************************************************/
void TileBadge( Boolean inRestoreTileBeforeBadging )
{
	OSStatus	theErr;
	PicHandle	theBadge;
	PicHandle	theBadgeMask;
	GWorldPtr	theBadgeWorld;
	GWorldPtr	theBadgeMaskWorld;
	Rect		theRect = { 0, 0, 128, 128 };
	CGImageRef	theBadgeImage;
	GDHandle	theSavedDevice;
	GrafPtr		theSavedPort;

	// ***
	//
	// PITFALL!
	//
	// Rebadging the tile will composite over the old one!
	// You might want to restore the tile before badging.
	//
	// ***
	if ( inRestoreTileBeforeBadging )
		RestoreApplicationDockTileImage();

	// Load the pictures
	theBadge = GetPicture( kBadge );
	require( theBadge != NULL, CantLoadBadge );
	theBadgeMask = GetPicture( kBadgeMask );
	require( theBadgeMask != NULL, CantLoadBadgeMask );

	// Make some GWorlds
	theErr = NewGWorld( &theBadgeWorld, 32, &theRect, NULL, NULL, 0 );
	require_noerr( theErr, CantMakeBadgeWorld );
	theErr = NewGWorld( &theBadgeMaskWorld, 32, &theRect, NULL, NULL, 0 );
	require_noerr( theErr, CantMakeBadgeMaskWorld );

	// Draw the pictures into the GWorlds
	GetGWorld( &theSavedPort, &theSavedDevice );
	SetGWorld( theBadgeWorld, NULL );
	DrawPicture( theBadge, &theRect );
	SetGWorld( theBadgeMaskWorld, NULL );
	DrawPicture( theBadgeMask, &theRect );
	SetGWorld( theSavedPort, theSavedDevice );

	// ***
	//
	// Make a CGImage from the GWorlds' pixmaps
	//
	// ***
	theErr = CreateCGImageFromPixMaps( GetGWorldPixMap( theBadgeWorld ),
		GetGWorldPixMap( theBadgeMaskWorld ), &theBadgeImage );
	if ( theErr != noErr )
		SysBeep( 0 );
	require_noerr( theErr, CantMakeBadgeImage );

	// ***
	//
	// Badge the tile
	//
	// ***
	theErr = OverlayApplicationDockTileImage( theBadgeImage );

	if ( theBadgeImage != NULL )
		CGImageRelease( theBadgeImage );

CantMakeBadgeImage:
	DisposeGWorld( theBadgeMaskWorld );

CantMakeBadgeMaskWorld:
	DisposeGWorld( theBadgeWorld );

CantMakeBadgeWorld:
	ReleaseResource( (Handle) theBadgeMask );

CantLoadBadgeMask:
	ReleaseResource( (Handle) theBadge );

CantLoadBadge:
	;
}
コード例 #20
0
ファイル: tooltip.cpp プロジェクト: gitrider/wxsj2
void wxMacToolTip::Draw()
{
    if ( m_label.Length() == 0 )
        return ;
    
    if ( m_window == s_ToolTipWindowRef )
    {
        m_shown = true ;
#if TARGET_CARBON
        HMHelpContentRec tag ;
        tag.version = kMacHelpVersion;
        SetRect( &tag.absHotRect , m_position.x - 2 , m_position.y - 2 , m_position.x + 2 , m_position.y + 2 ) ;

        QDLocalToGlobalRect( GetWindowPort( m_window ) , &tag.absHotRect ) ;

        m_helpTextRef.Assign( m_label  , wxFONTENCODING_DEFAULT ) ;
        tag.content[kHMMinimumContentIndex].contentType = kHMCFStringContent ;
        tag.content[kHMMinimumContentIndex].u.tagCFString = m_helpTextRef ;
        tag.content[kHMMaximumContentIndex].contentType = kHMCFStringContent ;
        tag.content[kHMMaximumContentIndex].u.tagCFString = m_helpTextRef ;
        tag.tagSide = kHMDefaultSide;
        HMDisplayTag( &tag );
#else
        wxMacPortStateHelper help( (GrafPtr) GetWindowPort( m_window ) );
        FontFamilyID fontId ;
        Str255 fontName ;
        SInt16 fontSize ;
        Style fontStyle ;
        GetThemeFont(kThemeSmallSystemFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
        GetFNum( fontName, &fontId );
        
        TextFont( fontId ) ;
        TextSize( fontSize ) ;
        TextFace( fontStyle ) ;
        FontInfo fontInfo;
        ::GetFontInfo(&fontInfo);
        short lineh = fontInfo.ascent + fontInfo.descent + fontInfo.leading;
        short height = 0 ;
        
        int i = 0 ;
        int length = m_label.Length() ;
        int width = 0 ;
        int thiswidth = 0 ;
        int laststop = 0 ;
        wxCharBuffer text = m_label.mb_str( wxConvLocal)  ;

        while( i < length )
        {
            if( text[i] == 13 || text[i] == 10)
            {
                thiswidth = ::TextWidth( text , laststop , i - laststop ) ;
                if ( thiswidth > width )
                    width = thiswidth ;
                
                height += lineh ;
                laststop = i+1 ;
            }
            i++ ;
        }
        if ( i - laststop > 0 )
        {
            thiswidth = ::TextWidth( text , laststop , i - laststop ) ;
            if ( thiswidth > width )
                width = thiswidth ;
            height += lineh ;
        }
        
        m_rect.left = m_position.x + kTipOffset;
        m_rect.top = m_position.y + kTipOffset;
        m_rect.right = m_rect.left + width + 2 * kTipBorder;

        m_rect.bottom = m_rect.top + height + 2 * kTipBorder;
        Rect r ;
        GetPortBounds( GetWindowPort( m_window ) , &r ) ;
        if ( m_rect.top < 0 )
        {
            m_rect.bottom += -m_rect.top ;
            m_rect.top = 0 ;
        }
        if ( m_rect.left < 0 )
        {
            m_rect.right += -m_rect.left ;
            m_rect.left = 0 ;
        }
        if ( m_rect.right > r.right )
        {
            m_rect.left -= (m_rect.right - r.right ) ;
            m_rect.right = r.right ;
        }
        if ( m_rect.bottom > r.bottom )
        {
            m_rect.top -= (m_rect.bottom - r.bottom) ;
            m_rect.bottom = r.bottom ;
        }
        ClipRect( &m_rect ) ;
        BackColor( whiteColor ) ;
        ForeColor(blackColor ) ;
        GWorldPtr port ;            
        NewGWorld( &port , wxDisplayDepth() , &m_rect , NULL , NULL , 0 ) ;
        CGrafPtr    origPort ;
        GDHandle    origDevice ;
        
        GetGWorld( &origPort , &origDevice ) ;
        SetGWorld( port , NULL ) ;
        
        m_backpict = OpenPicture(&m_rect);
        
        CopyBits(GetPortBitMapForCopyBits(GetWindowPort(m_window)), 
            GetPortBitMapForCopyBits(port), 
            &m_rect, 
            &m_rect, 
            srcCopy, 
            NULL);
        ClosePicture();
        SetGWorld( origPort , origDevice ) ;
        DisposeGWorld( port ) ;
        PenNormal() ;
        
        RGBColor tooltipbackground = { 0xFFFF , 0xFFFF , 0xC000 } ;
        BackColor( whiteColor ) ;
        RGBForeColor( &tooltipbackground ) ;
        
        PaintRect( &m_rect ) ;
        ForeColor(blackColor ) ;
        FrameRect( &m_rect ) ;
        SetThemeTextColor(kThemeTextColorNotification,wxDisplayDepth(),true) ;
        ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder);
        
        i = 0 ;
        laststop = 0 ;
        height = 0 ;
        
        while( i < length )
        {
            if( text[i] == 13 || text[i] == 10)
            {
                ::DrawText( text , laststop , i - laststop ) ;
                height += lineh ;
                ::MoveTo( m_rect.left + kTipBorder , m_rect.top + fontInfo.ascent + kTipBorder + height );
                laststop = i+1 ;
            }
            i++ ;
        }
        ::DrawText( text , laststop , i - laststop ) ;
        ::TextMode( srcOr ) ;        
#endif
    }
}
コード例 #21
0
////////////////////////////////////////////////////////////////////////////////
// virtual
bool LLMediaImplQuickTime::sizeChanged()
{
	if ( ! mMovieHandle )
		return false;

	// sanitize size of movie
	Rect movie_rect;
	setMovieBoxEnhanced( &movie_rect );

	// we need this later
	int width = ( movie_rect.right - movie_rect.left );
	int height = ( movie_rect.bottom - movie_rect.top );

	std::cout << "LLMEDIA> size changed to " << width << " x " << height << std::endl;

	setMediaSize( width, height );

	// media depth won't change
	int depth_bits = getMediaDepth() * 8;

	GWorldPtr old_gworld_handle = mGWorldHandle;

	if (old_gworld_handle)
	{
		GWorldFlags result = UpdateGWorld( &mGWorldHandle, depth_bits, &movie_rect, NULL, NULL, 0 );
		if ( gwFlagErr == result )
		{
			// TODO: unrecoverable?? throw exception?  return something?
			return false;
		}
	}
	else
	{
		OSErr result = NewGWorld( &mGWorldHandle, depth_bits, &movie_rect, NULL, NULL, keepLocal | pixelsLocked );
		if ( noErr != result )
		{
			// ATODO: unrecoverable??  throw exception?  return something?
			return false;
		}

		// clear memory in GWorld to avoid random screen visual fuzz from uninitialized texture data
		if ( mGWorldHandle )
		{
			PixMapHandle pix_map_handle = GetGWorldPixMap( mGWorldHandle );
			unsigned char* ptr = ( unsigned char* )GetPixBaseAddr( pix_map_handle );
			memset( ptr, 0x00, height * QTGetPixMapHandleRowBytes( pix_map_handle ) );
		}
	}

	// point movie at GWorld if it's new
	if ( mMovieHandle && ! old_gworld_handle )
	{
		SetMovieGWorld( mMovieHandle, mGWorldHandle, GetGWorldDevice ( mGWorldHandle ) );
	}

	// update movie controller
	if ( mMovieController )
	{
		MCSetControllerPort( mMovieController, mGWorldHandle );
		MCPositionController( mMovieController, &movie_rect, &movie_rect,
							  mcTopLeftMovie | mcPositionDontInvalidate );
		MCMovieChanged( mMovieController, mMovieHandle );
	}

	// Emit event with size change so the calling app knows about it too
	LLMediaEvent event( this );
	mEventEmitter.update( &LLMediaObserver::onMediaSizeChange, event );

	return true;
}
コード例 #22
0
ファイル: sqMacPrinting.c プロジェクト: Geal/Squeak-VM
OSStatus DrawPage(PrintingLogicPtr printJob,CGContextRef printingContext)
{
    OSStatus status = noErr; 
    Rect	dstRect = { 0, 0, 0, 0 };
    Rect	srcRect = { 0, 0, 0, 0 };
	static CGColorSpaceRef colorspace = NULL;

	if (colorspace == NULL) {
			// Get the Systems Profile for the main display
		CMProfileRef sysprof = NULL;
		if (CMGetSystemProfile(&sysprof) == noErr) {
			// Create a colorspace with the systems profile
			colorspace = CGColorSpaceCreateWithPlatformColorSpace(sysprof);
			CMCloseProfile(sysprof);
		} else 
			colorspace = CGColorSpaceCreateDeviceRGB();
	}
    
		dstRect.top = printJob->offsetHeight;
        dstRect.left = printJob->offsetWidth;
        dstRect.right = printJob->width*printJob->scaleW + printJob->offsetWidth;
        dstRect.bottom = printJob->height*printJob->scaleH + printJob->offsetHeight;

	if (printJob->formBitMap != nil) {
    
        srcRect.right = printJob->width;
        srcRect.bottom = printJob->height;

        HLock((Handle)stPixMap);
        (*stPixMap)->baseAddr = (void *) printJob->formBitMap;
        (*stPixMap)->rowBytes = (((((printJob->width * printJob->depth) + 31) / 32) * 4) & 0x1FFF) | 0x8000;
        (*stPixMap)->bounds = srcRect;
        (*stPixMap)->pixelSize = printJob->depth;
    
        if (printJob->depth<=8) { 
            (*stPixMap)->cmpSize = printJob->depth;
            (*stPixMap)->cmpCount = 1;
        } else if (printJob->depth==16) {
            (*stPixMap)->cmpSize = 5;
            (*stPixMap)->cmpCount = 3;
        } else if (printJob->depth==32) {
            (*stPixMap)->cmpSize = 8;
            (*stPixMap)->cmpCount = 3;
        }

         
		{
            PixMapHandle thePix;
            int			pitch;
			CGDataProviderRef provider;			
			CGImageRef image;
			CGRect		clip;
			Ptr			baseAddr;
			
            if (printJob->depth == 32) {
				pitch =  (((((printJob->width * printJob->depth) + 31) / 32) * 4) & 0x1FFF);
				baseAddr =  (void *) printJob->formBitMap;
			} else {
				if (printJob->aGWorld == NULL)
					NewGWorld(&printJob->aGWorld, 32, &srcRect, stColorTable, NULL, keepLocal+useTempMem+pixelsLocked);
					
				thePix = GetGWorldPixMap (printJob->aGWorld);
				CopyBits((BitMap *) *stPixMap, (BitMap *) *thePix, &srcRect, &srcRect, srcCopy, NULL);
				
				pitch = GetPixRowBytes(thePix);
				baseAddr = GetPixBaseAddr(thePix);
			}
			
			provider = CGDataProviderCreateDirectAccess((void*)baseAddr, pitch * (srcRect.bottom-srcRect.top), &gProviderCallbacks);
			image = CGImageCreate( srcRect.right-srcRect.left, srcRect.bottom-srcRect.top, 8 /* bitsPerComponent */, 32 /* bitsPerPixel */, 
				pitch, colorspace, kCGImageAlphaNoneSkipFirst | (printJob->depth==32 ? kCGBitmapByteOrder32Host : 0), provider, NULL, 0, kCGRenderingIntentDefault);

			clip = CGRectMake(dstRect.left+(printJob->pageRect.left-printJob->paperRect.left),
				(printJob->paperRect.bottom-printJob->pageRect.bottom) + (printJob->pageRect.bottom - printJob->pageRect.top) - (dstRect.bottom-dstRect.top) - dstRect.top, 
				dstRect.right-dstRect.left, 
				dstRect.bottom-dstRect.top);
			
			CGContextDrawImage(printingContext, clip, image);
			CGContextFlush(printingContext);
			CGImageRelease(image);
			CGDataProviderRelease(provider);
       }
        HUnlock((Handle)stPixMap);
    }
	else {
	}
	
#if TARGET_API_MAC_CARBON	
     if (printJob->allowPostscript && printJob->postscriptLength > 0) {
	
		CGDataProviderRef provider,providerFakeImage;			
		CGImageRef image,imageFake;
		CGRect		clip;
		static long  dirt=0xBBBBBBBB;
		
		//PMPrinter  currentPrinter = NULL;
		//CFArrayRef mimeTypes;
		//status = PMSessionGetCurrentPrinter(printJob->printSession,&currentPrinter);
		//status = PMPrinterGetMimeTypes(currentPrinter,printJob->printSettings,&mimeTypes);
 		
		provider = CGDataProviderCreateDirectAccess((void*)printJob->postscript,printJob->postscriptLength, &gProviderCallbacks);
		providerFakeImage = CGDataProviderCreateDirectAccess((void*)&dirt,4, &gProviderCallbacks);
		
		//OK make fake image using tiny bit of data
		imageFake = CGImageCreate(1, 1, 8 /* bitsPerComponent */, 32 /* bitsPerPixel */, 4, colorspace, kCGImageAlphaNoneSkipFirst , providerFakeImage, NULL, 0, kCGRenderingIntentDefault);
		image = PMCGImageCreateWithEPSDataProvider(provider,imageFake);


		dstRect.top = 0;
		dstRect.left = 0;
		dstRect.bottom = CGImageGetHeight(image);
		dstRect.right = CGImageGetWidth(image);
		
		clip = CGRectMake(dstRect.left+(printJob->pageRect.left-printJob->paperRect.left),
			(printJob->paperRect.bottom-printJob->pageRect.bottom) + (printJob->pageRect.bottom - printJob->pageRect.top) - (dstRect.bottom-dstRect.top) - dstRect.top, 
			dstRect.right-dstRect.left, 
			dstRect.bottom-dstRect.top); 
			
		//PMPrinterPrintWithProvider
		
		CGContextDrawImage(printingContext, clip, image);
		CGContextFlush(printingContext);
		CGImageRelease(image);
		CGImageRelease(imageFake);
		CGDataProviderRelease(provider);
		CGDataProviderRelease(providerFakeImage);
    }   
#else
	return PrError();
#endif
		
    return status;
}	//	DrawPage
コード例 #23
0
ファイル: tiio_3gpM.cpp プロジェクト: AmEv7Fam/opentoonz
void TLevelWriter3gp::save(const TImageP &img, int frameIndex)
{
	if (m_cancelled)
		return;

	TRasterImageP image(img);
	int lx = image->getRaster()->getLx();
	int ly = image->getRaster()->getLy();
	//void *buffer = image->getRaster()->getRawData();
	int pixSize = image->getRaster()->getPixelSize();
	if (pixSize != 4)
		throw TImageException(getFilePath(), "Unsupported pixel type");

	QMutexLocker sl(&m_mutex);

	if (!m_properties)
		m_properties = new Tiio::MovWriterProperties();

	Tiio::MovWriterProperties *prop = (Tiio::MovWriterProperties *)(m_properties);

	//CodecType compression = StandardCompressionType;  prop->getCurrentCodec();
	//CodecQ quality = StandardQualityType;  prop->getCurrentQuality();

	if (!m_initDone) {
		//FSSpec fspec;
		Rect frame;
		long max_compressed_size;
		QDErr err;

		m_videoTrack = NewMovieTrack(m_movie, FixRatio((short)lx, 1), FixRatio((short)ly, 1), kNoVolume);

		if ((err = GetMoviesError() != noErr))
			throw TImageException(getFilePath(), "can't create video track");

		m_dataRef = nil;
		m_hMovieData = NewHandle(0);

		// Construct the Handle data reference
		err = PtrToHand(&m_hMovieData, &m_dataRef, sizeof(Handle));

		if ((err = GetMoviesError() != noErr))
			throw TImageException(getFilePath(), "can't create Data Ref");

		m_videoMedia = NewTrackMedia(m_videoTrack, VideoMediaType, (TINT32)m_frameRate, m_dataRef, HandleDataHandlerSubType);

		OpenADefaultComponent(MovieExportType, '3gpp', &m_myExporter);

		//  err = (short)MovieExportDoUserDialog(m_myExporter, m_movie, 0, 0, 0, &m_cancelled);

		//  if (m_cancelled)
		//	  throw TImageException(getFilePath(), "User abort of 3GP render");
		if ((err = GetMoviesError() != noErr))
			throw TImageException(getFilePath(), "can't create video media");
		if ((err = BeginMediaEdits(m_videoMedia)) != noErr)
			throw TImageException(getFilePath(), "can't begin edit video media");
		frame.left = 0;
		frame.top = 0;
		frame.right = lx;
		frame.bottom = ly;

#if 0
  if ((err = NewGWorld(&(m_gworld), pixSize * 8, &frame, 0, 0, 0))!=noErr)
#else /* Mac OSX 10.7 later */
		if ((err = QTNewGWorld(&(m_gworld), pixSize * 8, &frame, 0, 0, 0)) != noErr)
#endif
		throw TImageException(getFilePath(), "can't create movie buffer");
#ifdef WIN32
		LockPixels(m_gworld->portPixMap);
		if ((err = GetMaxCompressionSize(m_gworld->portPixMap, &frame, 0,
										 quality, compression, anyCodec,
										 &max_compressed_size)) != noErr)
			throw TImageException(getFilePath(), "can't get max compression size");

#else

#if 0
  PixMapHandle pixmapH = GetPortPixMap (m_gworld);
  LockPixels(pixmapH);
#else
		PixMapHandle pixmapH = NULL;
#endif
		max_compressed_size = lx * ly * 4 * 20;

/*if ((err = GetMaxCompressionSize(pixmapH, &frame, 0, 
                                quality,  compression,anyCodec, 
				 &max_compressed_size))!=noErr)
    throw TImageException(getFilePath(), "can't get max compression size");*/
#endif

		m_compressedData = NewHandle(max_compressed_size);

		if ((err = MemError()) != noErr)
			throw TImageException(getFilePath(), "can't allocate compressed data for movie");

		MoveHHi(m_compressedData);
		HLock(m_compressedData);
		if ((err = MemError()) != noErr)
			throw TImageException(getFilePath(), "can't allocate img handle");

#if 0
  m_pixmap = GetGWorldPixMap(m_gworld);
  
  
  if (!LockPixels(m_pixmap))
    throw TImageException(getFilePath(), "can't lock pixels");

  buf    = (PixelXRGB*) GetPixBaseAddr(m_pixmap);
#else
		m_pixmap = NULL;
		buf = NULL;
#endif
		buf_lx = lx;
		buf_ly = ly;

		m_initDone = true;
	}

	unsigned short rowBytes = (unsigned short)(((short)(*(m_pixmap))->rowBytes & ~(3 << 14)));

	Rect frame;
	ImageDescriptionHandle img_descr;
	Ptr compressed_data_ptr;
	QDErr err;

	frame.left = 0;
	frame.top = 0;
	frame.right = lx;
	frame.bottom = ly;

	TRasterP ras = image->getRaster();
#ifdef WIN32
	compressed_data_ptr = StripAddress(*(m_compressedData));
	copy(ras, buf, buf_lx, buf_ly);
#else
	compressed_data_ptr = *m_compressedData;
	copy(ras, buf, buf_lx, buf_ly, rowBytes);
#endif
	img_descr = (ImageDescriptionHandle)NewHandle(4);

#ifdef WIN32
	if ((err = CompressImage(m_gworld->portPixMap,
							 &frame,
							 quality, compression,
							 img_descr, compressed_data_ptr)) != noErr)
		throw TImageException(getFilePath(), "can't compress image");
#else

#if 0
 PixMapHandle pixmapH = GetPortPixMap (m_gworld);
 if ((err = CompressImage(pixmapH, 
	                 &frame, 
  			 codecNormalQuality, kJPEGCodecType,
			 img_descr, compressed_data_ptr))!=noErr)
	{
  throw TImageException(getFilePath(), "can't compress image");
}
#endif
#endif

	if ((err = AddMediaSample(m_videoMedia, m_compressedData, 0,
							  (*img_descr)->dataSize, 1,
							  (SampleDescriptionHandle)img_descr,
							  1, 0, 0)) != noErr)
		throw TImageException(getFilePath(), "can't add image to movie media");

	DisposeHandle((Handle)img_descr);
}
コード例 #24
0
short LoadMapPICT(
	PicHandle 			pict,
	unsigned long 		mapID,
	unsigned long 		mapSizeX,
	unsigned long 		mapSizeY,
	TQ3StoragePixmap 	*bMap)
{
	unsigned long 			*textureMap;
	unsigned long			*textureMapAddr;
	unsigned long 			*pictMap;
	unsigned long			pictMapAddr;
	register unsigned long 	row;
	register unsigned long 	col;
	Rect 					rectGW;
	GWorldPtr 				pGWorld;
	PixMapHandle 			hPixMap;
	unsigned long 			pictRowBytes;
	QDErr					err;
	GDHandle				oldGD;
	GWorldPtr				oldGW;
	short					success;
	
	mapID;		/* unused argument */
	
	/* save current port */
	GetGWorld(&oldGW, &oldGD);

	/* create the GWorld */
	SetRect(&rectGW, 0, 0, (unsigned short)mapSizeX, (unsigned short)mapSizeY);

	err = NewGWorld(&pGWorld, 32, &rectGW, 0, 0, useTempMem);
	if (err != noErr)
		return 0;

	success = 1;
	
	hPixMap = GetGWorldPixMap(pGWorld);
	pictMapAddr = (unsigned long)GetPixBaseAddr (hPixMap);
	pictRowBytes = (unsigned long)(**hPixMap).rowBytes & 0x3fff;
	
	/* put the PICT into the window */
	SetGWorld(pGWorld, nil);
	
	LockPixels(hPixMap);
	EraseRect(&rectGW);
	DrawPicture(pict, &rectGW);
		
	/* allocate an area of memory for the texture */
	textureMap = (unsigned long *)malloc(mapSizeX * mapSizeY * sizeof(unsigned long));
	if (textureMap == NULL) {
		success = 0;
		goto bail;
	}
	/* bMap->image = (char *)textureMap; */

	/* copy the PICT into the texture */
	textureMapAddr = textureMap;
	for (row = 0L; row < mapSizeY; row++) {
		pictMap = (unsigned long *)(pictMapAddr + (pictRowBytes * row));
		for (col = 0L; col < mapSizeX; col++) {
			*textureMap++ = (*pictMap++ | 0xff000000L);
		}
	}
		
	bMap->image = Q3MemoryStorage_New((const unsigned char *)textureMapAddr, 
								  mapSizeX * mapSizeY * sizeof(unsigned long));
								  
	if (bMap->image == NULL) {
		/* error */
		success = 0;
		goto bail;
	}

	UnlockPixels(hPixMap);
	
	bMap->width 	= mapSizeX;
	bMap->height	= mapSizeY;
	bMap->rowBytes 	= bMap->width * 4;
	bMap->pixelSize = 32;
	bMap->pixelType	= kQ3PixelTypeRGB32;
	bMap->bitOrder	= kQ3EndianBig;
	bMap->byteOrder	= kQ3EndianBig;
	
	/* Free junk */
bail:

	SetGWorld(oldGW, oldGD);
	
	DisposeGWorld(pGWorld);
	if (textureMapAddr != NULL)
		free(textureMapAddr);
	
	return success;
}
コード例 #25
0
TechkonDialog::TechkonDialog(ProfileDoc *dc,RawData *pD):InputDialog(dc,pD,1)
{
	short		iType;
	Handle		iHandle;
	Handle		sHandle;
	Rect 		iRect, r,pRect,tRect;	
	UserItemUPP  box3D;
	
	QDErr		error;
	GDHandle	oldGD;
	GWorldPtr	oldGW;
	RGBColor	c,oldbackcolor,oldforecolor;
	WindowPtr	oldP;
	OSErr			err;
	int32 		i,wi,hi;
	double w,h;
	short		gtsl_ids[] = GTSL_IDS;
	Str255		theString;
	PixMapHandle	bigPixMap;
	McoStatus  	state;
	
	for (i=0; i<NumInputIDS; i++) ids[i] = gtsl_ids[i];

	WinType = TechkonWindow;
	WinNum = 0;

	setDialog(Input_Dialog);
	frame_button(ids[Ok_Box]);	

	

	
	// Added by James, 3D the box
	threeD_box(ids[ThreeDBox]);
	
	HideDItem(dp,ids[Redo]);
	
	GetDItem ( dp,ids[Message], &iType, (Handle*)&iHandle, &iRect );
	GetIndString(theString,Message_List_ID,6);
	SetIText(iHandle,theString);
	
	Scramble = FALSE;	
	
	if (Scramble)
		{
		voice_set = 1;
		}	
	else
		{
		Disable(dp,ids[VoiceSet]);
		voice_set = 2;
		}

	// initialize comminications with the device
	state = doc->openInputDevice(0,0,0);
	if (state != MCO_SUCCESS) McoErrorAlert(state);
	
	// initialize the big gworld 
	GetDItem (dp, ids[Strip_Rect], &iType, (Handle*)&iHandle, &iRect);
	tRect = iRect;
	OffsetRect(&tRect,-iRect.left,-iRect.top);
	error = NewGWorld( &BigGW, 32, &tRect, 0, 0, 0 );
	if (error != 0) 
		{
		delete this;
		return;
		} 
	GetGWorld(&oldGW,&oldGD);
	SetGWorld(BigGW,nil);	
	
	
//	GetBackColor(&oldbackcolor);
	GetForeColor(&oldforecolor);
	c.red = 65535;
	c.green = 65535;
	c.blue = 65535;
	RGBBackColor(&c);
	c.red = 0;
	c.green = 0;
	c.blue = 0;
	RGBForeColor(&c);		
	bigPixMap = GetGWorldPixMap ( BigGW );
	if (LockPixels ( bigPixMap ))	EraseRect( &tRect );
	
	SetGWorld(oldGW,oldGD);	
//	RGBBackColor(&oldbackcolor);
	RGBForeColor(&oldforecolor);	

//	SetPort(oldP);
		
	GetDItem (dp, ids[Patch_Rect], &iType, (Handle*)&iHandle, &pRect);
	num_display_patch = (iRect.bottom-iRect.top)/(pRect.bottom-pRect.top);
	top_patch = 0;
						
//init the static members
	//current_patch = total_patches-1;
	//current_patch = 0;
	current_patch = 0;
	current_strip = 0;
	current_sheet = 0;
 		
 	_done = 0;
 	_waiting = 0;
	
	
	SetSheetStripText();
	
	current_top = current_patch - 2*num_display_patch/3;
	current_bottom = current_top + num_display_patch - 1;
	if (current_top < 0) 
		{
		current_top = 0;
		current_bottom = current_top + num_display_patch - 1;
		}
	if (current_bottom >= total_patches-1)
		{
		current_bottom = total_patches - 1;
		current_top = current_bottom - num_display_patch + 1;
		}
	
	current_disp = 2*num_display_patch/3;
	
	init();	
	getpatchRGB();
	
	
	Disable(dp,ids[Redo]);

	
	GetDItem (dp, ids[Slider], &iType, (Handle*)&iHandle, &pRect);
	SetCtlMin((ControlHandle)iHandle,0);
	SetCtlMax((ControlHandle)iHandle,total_patches-1);
	
	GetDItem(dp, ids[VoiceSet], &iType, (Handle*)&iHandle, &pRect);
	SetCtlValue((ControlHandle)iHandle,1);
	//voice_set = 1;
	checkFinished();
	DrawWindow();
}	
コード例 #26
0
ファイル: QutTexture.c プロジェクト: refnum/quesa
//-----------------------------------------------------------------------------
//		QutTexture_CreateGWorldFromPICT : Create a GWorld from a PICT.
//-----------------------------------------------------------------------------
GWorldPtr
QutTexture_CreateGWorldFromPICT(PicHandle thePicture, TQ3PixelType pixelType)
{	GWorldPtr			deepGWorld, theGWorld;
 	Boolean				shouldDither;
 	GDHandle			saveDevice;
	CGrafPtr			savePort;
	TQ3Uns32			theDepth;
	OSErr				theErr;



	// Work out the depth of GWorld, and if it should be dithered
	if (pixelType == kQ3PixelTypeARGB16 || pixelType == kQ3PixelTypeRGB16)
		theDepth = 16;
	else
		theDepth = 32;

	shouldDither = (theDepth == 16);



	// Create a GWorld to hold the image data
	theErr = NewGWorld(&theGWorld, theDepth, &(*thePicture)->picFrame, NULL, NULL,
		useTempMem | kQ3NativeEndianPixMap );
	if (theErr != noErr || theGWorld == NULL)
		return(NULL);



	// If we should dither, create a deep GWorld
	if (theDepth == 16 && shouldDither)
		theErr = NewGWorld(&deepGWorld, 32, &(*thePicture)->picFrame, NULL, NULL,
			useTempMem | kQ3NativeEndianPixMap );
	else
		deepGWorld = NULL;
		


	// If we have a deep GWorld, draw the image into that and then
	// copy it into the output GWorld. If we don't have a deep GWorld,
	// just draw it directly into the output GWorld.
	if (deepGWorld != NULL)
		{
		// Draw the picture into the deep GWorld
		GetGWorld(&savePort, &saveDevice);
		SetGWorld(deepGWorld, NULL);
		LockPixels(GetGWorldPixMap(deepGWorld));

		DrawPicture(thePicture, &(*thePicture)->picFrame);

		UnlockPixels(GetGWorldPixMap(deepGWorld));
		SetGWorld(savePort, saveDevice);



		// Copy this into the output GWorld
		GetGWorld(&savePort, &saveDevice);
		SetGWorld(theGWorld, NULL);
		LockPixels(GetGWorldPixMap(theGWorld));

		CopyBits(GetPortBitMapForCopyBits(deepGWorld),
				 GetPortBitMapForCopyBits(theGWorld),
				 &(*thePicture)->picFrame,
				 &(*thePicture)->picFrame,
				 ditherCopy, NULL);

		UnlockPixels(GetGWorldPixMap(theGWorld));
		SetGWorld(savePort, saveDevice);


		// Clean up
		DisposeGWorld(deepGWorld);
		deepGWorld = NULL;
		}
	else
		{
		// Draw the picture into the output GWorld
		GetGWorld(&savePort, &saveDevice);
		SetGWorld(theGWorld, NULL);
		LockPixels(GetGWorldPixMap(theGWorld));

		DrawPicture(thePicture, &(*thePicture)->picFrame);

		UnlockPixels(GetGWorldPixMap(theGWorld));
		SetGWorld(savePort, saveDevice);
		}
		
	return(theGWorld);
}
コード例 #27
0
void ofQtVideoSaver::setup( int width , int height, string movieName){

	w = width;
	h = height;
    
   
    fileName = (ofToDataPath(movieName));
    //pszFlatFilename = flatFileName;
    
    initializeQuicktime();
    	/*  Load the FSSpec structure to describe the receiving file.  For a 
    description of this and related calls see 
    http://developer.apple.com/quicktime/icefloe/dispatch004.html.
    ================================================================  */


	#ifdef TARGET_WIN32
		//FILE * pFile = NULL;
		//pFile = fopen (fileName.c_str(),"w");
		//fclose (pFile);
		char fileNameStr[255];
		sprintf(fileNameStr, "%s", fileName.c_str());
		osErr = NativePathNameToFSSpec (fileNameStr, &fsSpec, 0);
		
	#endif
	#ifdef TARGET_OSX
	
		/// kill a file and make a new one if needed:		
		FILE * pFile;
		pFile = fopen (fileName.c_str(),"w");
		fclose (pFile);
	
		Boolean isdir;
		osErr = FSPathMakeRef((const UInt8*)fileName.c_str(), &fsref, &isdir);
		osErr = FSGetCatalogInfo(&fsref, kFSCatInfoNone, NULL, NULL, &fsSpec, NULL);
	#endif

    if (osErr && (osErr != fnfErr))    /* File-not-found error is ok         */
      { 
      printf ("getting FSS spec failed %d\n", osErr); 
      goto bail; 
     }
	 

	/*  Step 1:  Create a new, empty movie file and a movie that references that 
    file (CreateMovieFile).  
    ======================================================================== */
            
    osErr = CreateMovieFile 
      (
      &fsSpec,                         /* FSSpec specifier                   */
      FOUR_CHAR_CODE('TVOD'),          /* file creator type, TVOD = QT player*/
      smCurrentScript,                 /* movie script system to use         */
      createMovieFileDeleteCurFile     /* movie file creation flags          */
        | createMovieFileDontCreateResFile,
      &sResRefNum,                     /* returned file ref num to data fork */
      &movie                           /* returned handle to open empty movie*/
                                       /*   that references the created file */
      );
    if (osErr) 
      { 
      printf ("CreateMovieFile failed %d\n", osErr); 
      goto bail; 
      }


	/*  Step 2:  Add a new track to that movie (NewMovieTrack).
    =======================================================  */

    track = NewMovieTrack 
      (
      movie,                           /* the movie to add track to          */
      ((long) w << 16),              /* width of track in pixels (Fixed)   */
      FixRatio (h, 1),               /* height of track in pixels (Fixed)  */ 
      kNoVolume                        /* default volume level               */
      );
    osErr = GetMoviesError ();
    if (osErr) 
      { 
      printf ("NewMovieTrack failed %d\n", osErr); 
      goto bail; 
      }
    

	/*  Step 3:  Add a new media to that track (NewTrackMedia).
    =======================================================  */
    
    media = NewTrackMedia 
      (
      track,                           /* the track to add the media to      */
      VideoMediaType,                  /* media type, e.g. SoundMediaType    */
      600,                             /* num media time units that elapse/sec*/
      NULL,                            /* ptr to file that holds media sampls*/
      0                                /* type of ptr to media samples       */
      );
    osErr = GetMoviesError ();
    if (osErr) 
      { 
      printf ("NewTrackMedia failed %d\n", osErr); 
      goto bail; 
      }

	/*  Step 4:  Add media samples to the media. 
    ========================================  */
    
    BeginMediaEdits (media);           /* Inform the Movie Toolbox that we   */
                                       /*   want to change the media samples */
                                       /*   referenced by a track's media.   */
                                       /*   This opens the media container   */
                                       /*   and makes it ready to receive    */
                                       /*   and/or remove sample data.       */
    
    
    

    // Step 5: setup graphics port for qt movie and compression type ---
    
    /*  Create a new offscreen graphics world that will hold the movie's
    drawing surface.  draw_image() copies the image of IceFlow to this
    surface with varying amounts of transparency.
    =================================================================  */
    
    MacSetRect (&rect, 0, 0, w, h);

    osErr = NewGWorld 
      (
      &pMovieGWorld,                   /* receives the new GWorld.           */
      24,                              /* pixel depth in bits/pixel          */
      &rect,                           /* desired size of the GWorld.        */
      NULL, 
      NULL, 
      (GWorldFlags) 0
      );
    if (osErr != noErr) 
      { 
      printf ("NewGWorld 1 failed %d\n", osErr); 
      goto bail; 
      }


/*  Retrieve the pixel map associated with that graphics world and lock 
    the pixel map in memory.  GetMaxCompressionSize() and CompressImage()
    only operate on pixel maps, not graphics worlds.
    =====================================================================  */
    
    pixMapHandle = GetGWorldPixMap (pMovieGWorld);
    if (pixMapHandle == NULL) 
      { 
      printf ("GetGWorldPixMap failed\n"); 
      goto bail; 
      }
    LockPixels (pixMapHandle);


/*  Get the maximum number of bytes required to hold an image having the 
    specified characteristics compressed using the specified compressor.
    ====================================================================  */

     
    osErr = GetMaxCompressionSize 
      (
      pixMapHandle,							/* the pixel map to compress from.    */
      &rect,								/* the image rectangle.               */
      0,									/* let ICM choose image bit depth.    */
      codecHighQuality,						/* compression quality specifier.     */
      kRawCodecType,						/* desired compression type           */   // < set to RAW in case we set to a new compression type...
      (CompressorComponent) anyCodec,		/* codec specifier.                   */
      &lMaxCompressionSize					/* receives max bytes needed for cmp. */
      );
    if (osErr != noErr) 
      { 
      printf ("GetMaxCompressionSize failed %d\n", osErr); 
      goto bail; 
      }


/*  Allocate a buffer to hold the compressed image data by creating a new
    handle.
    =====================================================================  */
    hCompressedData = NewHandle (lMaxCompressionSize);
    if (hCompressedData == NULL) 
      { 
      printf ("NewHandle(%ld) failed\n", lMaxCompressionSize); 
      goto bail; 
      }

/*  Lock the handle and then dereference it to obtain a pointer to the data 
    buffer because CompressImage() wants us to pass it a pointer, not a 
    handle. 
    =======================================================================  */

    HLockHi (hCompressedData);
    pCompressedData = *hCompressedData;

/*  Create an image description object in memory of minimum size to pass 
    to CompressImage().  CompressImage() will resize the memory as 
    necessary so create it small here.
    ====================================================================  */
    
    hImageDescription = (ImageDescriptionHandle) NewHandle (4);
    if (hImageDescription == NULL) 
      { 
      printf ("NewHandle(4) failed\n"); 
      goto bail; 
      }
	
	
	
	bSetupForRecordingMovie = true;
    return;
    
    
    
    
  bail:    
	printf("got to bail somehows \n");
    if (sResRefNum != 0) CloseMovieFile (sResRefNum);
    if (movie     != NULL) DisposeMovie (movie);

    //ExitMovies ();                     /* Finalize Quicktime                 */
    
    return;
}
コード例 #28
0
ファイル: QutTexture.c プロジェクト: refnum/quesa
//=============================================================================
//		QutTexture_CreateGWorldFromFile : Create a GWorld from a file.
//-----------------------------------------------------------------------------
GWorldPtr
QutTexture_CreateGWorldFromFile(const FSSpec *theFSSpec, TQ3PixelType pixelType)
{	CTabHandle					colourTableHnd;
	ImageDescriptionHandle		imageDescHnd;
	ComponentInstance			theImporter;
	GWorldPtr					theGWorld;
	TQ3Uns32					theDepth;
	Rect						theRect;
	OSErr						theErr;



	// Initialise ourselves
	theImporter    = NULL;
	theGWorld      = NULL;
	imageDescHnd   = NULL;
	colourTableHnd = NULL;
	theDepth       = (pixelType == kQ3PixelTypeARGB16 || pixelType == kQ3PixelTypeRGB16) ? 16 : 32;



	// Create the importer
	theErr = GetGraphicsImporterForFile(theFSSpec, &theImporter);



	// Query the importer for the information we need
	if (theErr == noErr)
		{
		GraphicsImportGetBoundsRect(theImporter, &theRect);
	
		theErr = GraphicsImportGetImageDescription(theImporter, &imageDescHnd);
		if (theErr == noErr)
			theErr = GetImageDescriptionCTable(imageDescHnd, &colourTableHnd);
		}



	// Create the GWorld
	if (theErr == noErr)
		theErr = NewGWorld(&theGWorld, theDepth, &theRect, colourTableHnd, NULL,
			useTempMem | kQ3NativeEndianPixMap );



	// Draw the image into the GWorld
	if (theErr == noErr)
		{
		GraphicsImportSetGWorld(theImporter, theGWorld, NULL);
		GraphicsImportDraw(theImporter);
		}



	// Clean up
	if (theImporter != NULL)
		CloseComponent(theImporter);
		
	if (imageDescHnd != NULL)
		DisposeHandle((Handle) imageDescHnd);
		
	if (colourTableHnd != NULL)
		DisposeCTable(colourTableHnd);

	return(theGWorld);
}
コード例 #29
0
ファイル: QTVideo.c プロジェクト: fruitsamples/qtcreatemovie
static void QTVideo_AddVideoSamplesToMedia (Media theMedia, const Rect *trackFrame)
{
	long maxCompressedSize;
	GWorldPtr theGWorld = nil;
	long curSample;
	Handle compressedData = nil;
	Ptr compressedDataPtr;
	ImageDescriptionHandle imageDesc = nil;
	CGrafPtr oldPort;
	GDHandle oldGDeviceH;
	OSErr err = noErr;



		err = NewGWorld (&theGWorld, 
						kPixelDepth,	/* pixel depth */
						trackFrame, 
						nil, 
						nil, 
						(GWorldFlags) 0 );
		CheckError (err, "NewGWorld error");

		LockPixels (theGWorld->portPixMap);
		err = GetMaxCompressionSize(theGWorld->portPixMap,
									trackFrame, 
									kMgrChoose, /* let ICM choose depth */
									codecNormalQuality, 
									kAnimationCodecType, 
									(CompressorComponent) anyCodec,
									&maxCompressedSize);
		CheckError (err, "GetMaxCompressionSize error" );

		compressedData = NewHandle(maxCompressedSize);
		CheckError( MemError(), "NewHandle error" );

		MoveHHi( compressedData );
		HLock( compressedData );
		compressedDataPtr = StripAddress( *compressedData );

		imageDesc = (ImageDescriptionHandle)NewHandle(4);
		CheckError( MemError(), "NewHandle error" );

		GetGWorld (&oldPort, &oldGDeviceH);
		SetGWorld (theGWorld, nil);

		for (curSample = 1; curSample <= kNumVideoFrames; curSample++) 
		{
			EraseRect (trackFrame);

			QTVideo_DrawFrame(trackFrame, curSample);

			err = CompressImage (theGWorld->portPixMap, 
								trackFrame, 
								codecNormalQuality,
								kAnimationCodecType,
								imageDesc, 
								compressedDataPtr );
			CheckError( err, "CompressImage error" );

			err = AddMediaSample(theMedia, 
								compressedData,
								kNoOffset,	/* no offset in data */
								(**imageDesc).dataSize, 
								kSampleDuration,	/* frame duration = 1/10 sec */
								(SampleDescriptionHandle)imageDesc, 
								kAddOneVideoSample,	/* one sample */
								kSyncSample,	/* self-contained samples */
								nil);
			CheckError( err, "AddMediaSample error" );
		}
		SetGWorld (oldPort, oldGDeviceH);

		if (imageDesc)
		{
			DisposeHandle ((Handle)imageDesc);
		}
		if (compressedData)
		{
			DisposeHandle (compressedData);
		}
		if (theGWorld)
		{
			DisposeGWorld (theGWorld);
		}
} 
コード例 #30
0
void do_missile_anim(short num_steps,location missile_origin,short sound_num) 
{
	Rect temp_rect,missile_origin_base = {1,1,17,17},active_area_rect,to_rect,from_rect;
	short i,store_missile_dir;
	Point start_point,finish_point[30];
	location screen_ul;
	
	short x1[30],x2[30],y1[30],y2[30],t; // for path paramaterization
	Rect missile_place_rect[30],missile_origin_rect[30],store_erase_rect[30];
	Point current_terrain_ul; 
	GWorldPtr temp_gworld;
	GrafPtr old_port;
	
	if ((have_missile == false) || (boom_anim_active == false)) {
		boom_anim_active = false;
		return;
		}
	
	for (i = 0; i < 30; i++)
		if (store_missiles[i].missile_type >= 0)
			i = 50;
	if (i == 30)
		return;

	// initialize general data
	if (in_startup_mode) {
		current_terrain_ul.h = 306;
		current_terrain_ul.v = 5;
	} else current_terrain_ul.h = current_terrain_ul.v = 5;
	
	// make terrain_template contain current terrain all nicely
	draw_terrain(1);
	GetPortBounds(terrain_screen_gworld,&to_rect);
	Rect oldBounds = to_rect;
	OffsetRect(&to_rect,current_terrain_ul.h, current_terrain_ul.v);
	rect_draw_some_item(terrain_screen_gworld,oldBounds,to_rect,ul);
			
	GetPort(&old_port);	
				
	// create and clip temporary anim template 
	GetPortBounds(terrain_screen_gworld,&temp_rect);
	NewGWorld(&temp_gworld,  0 /*8*/,&temp_rect, NULL, NULL, kNativeEndianPixMap);
	SetPort(temp_gworld);
	active_area_rect = temp_rect;
	InsetRect(&active_area_rect,13,13);
	ClipRect(&active_area_rect);
	SetPort(GetWindowPort(mainPtr));
	
	
	// init missile paths
	for (i = 0; i < 30; i++) {
		SetRect(&store_erase_rect[i],0,0,0,0);
		if ((store_missiles[i].missile_type >= 0) && (missile_origin == store_missiles[i].dest))
			store_missiles[i].missile_type = -1;
		}
	screen_ul.x = center.x - 4; screen_ul.y = center.y - 4;
	start_point.h = 13 + 14 + 28 * (short) (missile_origin.x - screen_ul.x);
	start_point.v = 13 + 18 + 36 * (short) (missile_origin.y - screen_ul.y);
	for (i = 0; i < 30; i++) 
		if (store_missiles[i].missile_type >= 0) {
			finish_point[i].h = 1 + 13 + 14 + store_missiles[i].x_adj + 28 * (short) (store_missiles[i].dest.x - screen_ul.x);
			finish_point[i].v = 1 + 13 + 18 + store_missiles[i].y_adj + 36 * (short) (store_missiles[i].dest.y - screen_ul.y);
			// note ... +1 at beginning is put in to prevent infinite slope
			
			if (store_missiles[i].missile_type < 7) {
				store_missile_dir = get_missile_direction(start_point,finish_point[i]);
				missile_origin_rect[i] = missile_origin_base;
				OffsetRect(&missile_origin_rect[i],18 * store_missile_dir,18 * store_missiles[i].missile_type);
				}
				else {
					missile_origin_rect[i] = missile_origin_base;
					OffsetRect(&missile_origin_rect[i],0,18 * store_missiles[i].missile_type);
					}
			
			// x1 slope x2 start pt
			x1[i] = finish_point[i].h - start_point.h;
			x2[i] = start_point.h;
			y1[i] = finish_point[i].v - start_point.v;
			y2[i] = start_point.v;
			}
			else missile_place_rect[i].top =missile_place_rect[i].left =missile_place_rect[i].bottom =missile_place_rect[i].right = 0;
	
	play_sound(-1 * sound_num);
	
	
	// Now, at last, launch missile
	for (t = 0; t < num_steps; t++) {
		for (i = 0; i < 30; i++) 
			if (store_missiles[i].missile_type >= 0) {
				// Where place?
				temp_rect = missile_origin_base;
				OffsetRect(&temp_rect,-8 + x2[i] + (x1[i] * t) / num_steps,
					-8 + y2[i] + (y1[i] * t) / num_steps);
				
				// now adjust for different paths
				if (store_missiles[i].path_type == 1)
				OffsetRect(&temp_rect,0,
					-1 * (t * (num_steps - t)) / 100);
				
				SectRect(&temp_rect,&active_area_rect,&missile_place_rect[i]);
				
				// Now put terrain in temporary;
				rect_draw_some_item(terrain_screen_gworld,missile_place_rect[i],
					temp_gworld,missile_place_rect[i]);
				// Now put in missile
				from_rect = missile_origin_rect[i];
				if (store_missiles[i].missile_type >= 7) 
					OffsetRect(&from_rect,18 * (t % 8),0);
				rect_draw_some_item(missiles_gworld,from_rect,
					temp_gworld,temp_rect,transparent);
				}
		// Now draw all missiles to screen
		for (i = 0; i < 30; i++) 
			if (store_missiles[i].missile_type >= 0) {
				to_rect = store_erase_rect[i];
				OffsetRect(&to_rect,current_terrain_ul.h,current_terrain_ul.v);
				rect_draw_some_item(terrain_screen_gworld,store_erase_rect[i],to_rect,ul);
				
				to_rect = missile_place_rect[i];
				store_erase_rect[i] = to_rect;
				OffsetRect(&to_rect,current_terrain_ul.h,current_terrain_ul.v);
				rect_draw_some_item(temp_gworld,missile_place_rect[i],to_rect,ul);
				}
		if ((PSD[SDF_GAME_SPEED] == 3) || ((PSD[SDF_GAME_SPEED] == 1) && (t % 4 == 0)) ||
			((PSD[SDF_GAME_SPEED] == 2) && (t % 3 == 0)))
			FlushAndPause(1);
		}
		
	// Exit gracefully, and clean up screen
	for (i = 0; i < 30; i++) 
		store_missiles[i].missile_type = -1;
	DisposeGWorld(temp_gworld);
	SetPort(old_port);

	GetPortBounds(terrain_screen_gworld,&to_rect);
	Rect oldRect = to_rect;
	OffsetRect(&to_rect,current_terrain_ul.h,current_terrain_ul.v);
	rect_draw_some_item(terrain_screen_gworld,oldRect,to_rect,ul);
}