dw_handle DWENTRY DWStruct( dw_client cli, uint kind ) { dw_handle new_hdl; new_hdl = NewHandle( cli ); CreateExtra( cli, new_hdl )->structure.kind = kind; return( new_hdl ); }
static void InitReqList (int first, int last, ReqListRec ***reqlistptr) { register i; (*reqlistptr) = (ReqListRec**) (NewHandle (sizeof(ReqListRec) + (last-first)*sizeof(short))); (**reqlistptr)->reqLSize = last-first; for (i=first; i<=last; i++) (**reqlistptr)->reqLData[i-first] = i; }
CacheEntryHandle* CacheEntry::NewWriteHandle() { mozilla::MutexAutoLock lock(mLock); // Ignore the OPEN_SECRETLY flag on purpose here, which should actually be // used only along with OPEN_READONLY, but there is no need to enforce that. BackgroundOp(Ops::FRECENCYUPDATE); return (mWriter = NewHandle()); }
dw_handle DWENTRY DWHandle( dw_client cli, uint kind ) { dw_handle new_hdl; kind = kind; new_hdl = NewHandle( cli ); return( new_hdl ); }
// CompressRLE // Main compress routine, this function will call the appropriate RLE compression // method depending on the pixel depth of the source image. OSErr CompressPixMapRLE(PixMapHandle pixMapHdl, Ptr compressBuffer, Size *compressBufferSizePtr) { Handle hdl = NULL; Ptr tempPtr = NULL,srcData; Ptr pixBaseAddr = GetPixBaseAddr(pixMapHdl); OSType pixelFormat = GETPIXMAPPIXELFORMAT(*pixMapHdl); int depth = QTGetPixelSize(pixelFormat); long rowBytes = QTGetPixMapHandleRowBytes(pixMapHdl); int width = (**pixMapHdl).bounds.right - (**pixMapHdl).bounds.left; int i, height = (**pixMapHdl).bounds.bottom - (**pixMapHdl).bounds.top; Size widthByteSize = (depth * (long)width + 7) >> 3; OSErr err = noErr; // need to remove padding between rows? if(widthByteSize != rowBytes){ // Make a temp buffer for the source hdl = NewHandle(height * widthByteSize); err = MemError(); if (err) goto bail; HLock(hdl); srcData = tempPtr = *hdl; // Get rid of row bytes padding for (i = 0; i < height; i++) { BlockMoveData(pixBaseAddr, tempPtr, widthByteSize); tempPtr += widthByteSize; pixBaseAddr += rowBytes; } }else srcData = pixBaseAddr; // Compress switch (depth) { case 1: CompressRLE8((UInt8*)srcData, height * widthByteSize, compressBuffer, compressBufferSizePtr); break; case 8: CompressRLE8((UInt8*)srcData, height * widthByteSize, compressBuffer, compressBufferSizePtr); break; case 16: CompressRLE16((UInt16*)srcData, height * (widthByteSize >> 1), compressBuffer, compressBufferSizePtr); break; case 32: CompressRLE32((UInt32*)srcData, height * (widthByteSize >> 2), compressBuffer, compressBufferSizePtr); break; } bail: if (hdl) DisposeHandle(hdl); return err; }
void MovieGlHap::allocateVisualContext() { // Load HAP Movie if( HapQTQuickTimeMovieHasHapTrackPlayable( getObj()->mMovie ) ) { // QT Visual Context attributes OSStatus err = noErr; QTVisualContextRef * visualContext = (QTVisualContextRef*)&getObj()->mVisualContext; CFDictionaryRef pixelBufferOptions = HapQTCreateCVPixelBufferOptionsDictionary(); const CFStringRef keys[] = { kQTVisualContextPixelBufferAttributesKey }; CFDictionaryRef visualContextOptions = ::CFDictionaryCreate(kCFAllocatorDefault, (const void**)&keys, (const void**)&pixelBufferOptions, sizeof(keys)/sizeof(keys[0]), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); err = QTPixelBufferContextCreate( kCFAllocatorDefault, visualContextOptions, visualContext ); ::CFRelease( pixelBufferOptions ); ::CFRelease( visualContextOptions ); if( err != noErr ) { CI_LOG_E( "HAP ERROR :: " << err << " couldnt create visual context." ); return; } // Set the movie's visual context err = SetMovieVisualContext( getObj()->mMovie, *visualContext ); if( err != noErr ) { CI_LOG_E( "HAP ERROR :: " << err << " SetMovieVisualContext." ); return; } } // Get codec name for (long i = 1; i <= GetMovieTrackCount(getObj()->mMovie); i++) { Track track = GetMovieIndTrack(getObj()->mMovie, i); Media media = GetTrackMedia(track); OSType mediaType; GetMediaHandlerDescription(media, &mediaType, NULL, NULL); if (mediaType == VideoMediaType) { // Get the codec-type of this track ImageDescriptionHandle imageDescription = (ImageDescriptionHandle)NewHandle(0); // GetMediaSampleDescription will resize it GetMediaSampleDescription(media, 1, (SampleDescriptionHandle)imageDescription); OSType codecType = (*imageDescription)->cType; DisposeHandle((Handle)imageDescription); switch (codecType) { case 'Hap1': mCodec = Codec::HAP; break; case 'Hap5': mCodec = Codec::HAP_A; break; case 'HapY': mCodec = Codec::HAP_Q; break; default: mCodec = Codec::UNSUPPORTED; break; } } } // Set framerate callback this->setNewFrameCallback( updateMovieFPS, (void*)this ); }
static int srVerNo(void* p_void) { char cVersionStr[200]; srUtiVerNo(cVersionStr); long LenVersionStr = strlen(cVersionStr); Handle VersionStr = NewHandle(LenVersionStr); strncpy(*VersionStr, cVersionStr, LenVersionStr); ((srTIgorVersionStruct*)p_void)->result = VersionStr; return 0; }
/*============================================ SUMiscUtils::DuplicateHandle ==============================================*/ Handle SUMiscUtils::DuplicateHandle( Handle source ) { ThrowIf_ ( !source || !*source ); SInt32 numBytes = GetHandleSize( source ); Handle result = NewHandle( numBytes ); ThrowIfMemFail_( result ); BlockMoveData( *source, *result, numBytes ); return( result ); }
//_______________________________________________________________________________ void WritePos (WindowPtr win, short resFile) { Handle h = NewHandle (sizeof(Point)); if (h) { Point *p = (Point *)*h; SetPort(win); p->h = win->portRect.left; p->v = win->portRect.top; LocalToGlobal(p); WriteRsrc (h, kWinPosRsrc, kWinposID, resFile); } }
void write_setting_filename(void *handle, const char *key, Filename fn) { int fd = *(int *)handle; AliasHandle h; int id; OSErr error; Str255 pkey; UseResFile(fd); if (ResError() != noErr) fatalbox("Failed to open saved session (%d)", ResError()); if (filename_is_null(fn)) { /* Generate a special "null" alias */ h = (AliasHandle)NewHandle(sizeof(**h)); if (h == NULL) fatalbox("Failed to create fake alias"); (*h)->userType = 'pTTY'; (*h)->aliasSize = sizeof(**h); } else { error = NewAlias(NULL, &fn.fss, &h); if (error == fnfErr) { /* * NewAlias can't create an alias for a nonexistent file. * Create an alias for the directory, and record the * filename as well. */ FSSpec tmpfss; FSMakeFSSpec(fn.fss.vRefNum, fn.fss.parID, NULL, &tmpfss); error = NewAlias(NULL, &tmpfss, &h); if (error != noErr) fatalbox("Failed to create alias"); (*h)->userType = 'pTTY'; SetHandleSize((Handle)h, (*h)->aliasSize + fn.fss.name[0] + 1); if (MemError() != noErr) fatalbox("Failed to create alias"); memcpy((char *)*h + (*h)->aliasSize, fn.fss.name, fn.fss.name[0] + 1); } if (error != noErr) fatalbox("Failed to create alias"); } /* Put the data in a resource. */ id = Unique1ID(rAliasType); if (ResError() != noErr) fatalbox("Failed to get ID for resource %s (%d)", key, ResError()); c2pstrcpy(pkey, key); AddResource((Handle)h, rAliasType, id, pkey); if (ResError() != noErr) fatalbox("Failed to add resource %s (%d)", key, ResError()); }
static HRESULT QT_Process_Audio_Track(QTSplitter* filter, Track trk) { AM_MEDIA_TYPE amt; WAVEFORMATEX* pvi; PIN_INFO piOutput; HRESULT hr = S_OK; static const WCHAR szwAudioOut[] = {'A','u','d','i','o',0}; Media audioMedia; SoundDescriptionHandle aDesc = (SoundDescriptionHandle) NewHandle(sizeof(SoundDescription)); audioMedia = GetTrackMedia(trk); GetMediaSampleDescription(audioMedia, 1, (SampleDescriptionHandle)aDesc); ZeroMemory(&amt, sizeof(amt)); amt.formattype = FORMAT_WaveFormatEx; amt.majortype = MEDIATYPE_Audio; amt.subtype = MEDIASUBTYPE_PCM; amt.bTemporalCompression = 0; amt.cbFormat = sizeof(WAVEFORMATEX); amt.pbFormat = CoTaskMemAlloc(amt.cbFormat); ZeroMemory(amt.pbFormat, amt.cbFormat); pvi = (WAVEFORMATEX*)amt.pbFormat; pvi->cbSize = sizeof(WAVEFORMATEX); pvi->wFormatTag = WAVE_FORMAT_PCM; pvi->nChannels = ((SoundDescription)**aDesc).numChannels; if (pvi->nChannels < 1 || pvi->nChannels > 2) pvi->nChannels = 2; pvi->nSamplesPerSec = (((SoundDescription)**aDesc).sampleRate/65536); if (pvi->nSamplesPerSec < 8000 || pvi->nChannels > 48000) pvi->nSamplesPerSec = 44100; pvi->wBitsPerSample = ((SoundDescription)**aDesc).sampleSize; if (pvi->wBitsPerSample < 8 || pvi->wBitsPerSample > 32) pvi->wBitsPerSample = 16; pvi->nBlockAlign = (pvi->nChannels * pvi->wBitsPerSample) / 8; pvi->nAvgBytesPerSec = pvi->nSamplesPerSec * pvi->nBlockAlign; DisposeHandle((Handle)aDesc); piOutput.dir = PINDIR_OUTPUT; piOutput.pFilter = &filter->filter.IBaseFilter_iface; lstrcpyW(piOutput.achName,szwAudioOut); hr = QT_AddPin(filter, &piOutput, &amt, FALSE); if (FAILED(hr)) ERR("Failed to add Audio Track\n"); else TRACE("Audio Pin %p\n",filter->pAudio_Pin); return hr; }
static OSErr QT_GetCodecSettingsFromScene(RenderData *rd, ReportList *reports) { Handle myHandle = NULL; ComponentResult myErr = noErr; QuicktimeCodecData *qcd = rd->qtcodecdata; /* if there is codecdata in the blendfile, convert it to a Quicktime handle */ if (qcd) { myHandle = NewHandle(qcd->cdSize); PtrToHand(qcd->cdParms, &myHandle, qcd->cdSize); } /* restore codecsettings to the quicktime component */ if (qcd->cdParms && qcd->cdSize) { myErr = SCSetSettingsFromAtomContainer((GraphicsExportComponent)qtdata->theComponent, (QTAtomContainer)myHandle); if (myErr != noErr) { BKE_report(reports, RPT_ERROR, "Quicktime: SCSetSettingsFromAtomContainer failed"); goto bail; } /* update runtime codecsettings for use with the codec dialog */ SCGetInfo(qtdata->theComponent, scDataRateSettingsType, &qtdata->aDataRateSetting); SCGetInfo(qtdata->theComponent, scSpatialSettingsType, &qtdata->gSpatialSettings); SCGetInfo(qtdata->theComponent, scTemporalSettingsType, &qtdata->gTemporalSettings); /* Fill the render QuicktimeCodecSettigns struct */ rd->qtcodecsettings.codecTemporalQuality = (qtdata->gTemporalSettings.temporalQuality * 100) / codecLosslessQuality; /* Do not override scene frame rate (qtdata->gTemporalSettings.framerate) */ rd->qtcodecsettings.keyFrameRate = qtdata->gTemporalSettings.keyFrameRate; rd->qtcodecsettings.codecType = qtdata->gSpatialSettings.codecType; rd->qtcodecsettings.codec = (int)qtdata->gSpatialSettings.codec; rd->qtcodecsettings.colorDepth = qtdata->gSpatialSettings.depth; rd->qtcodecsettings.codecSpatialQuality = (qtdata->gSpatialSettings.spatialQuality * 100) / codecLosslessQuality; rd->qtcodecsettings.bitRate = qtdata->aDataRateSetting.dataRate; rd->qtcodecsettings.minSpatialQuality = (qtdata->aDataRateSetting.minSpatialQuality * 100) / codecLosslessQuality; rd->qtcodecsettings.minTemporalQuality = (qtdata->aDataRateSetting.minTemporalQuality * 100) / codecLosslessQuality; /* Frame duration is already known (qtdata->aDataRateSetting.frameDuration) */ } else { BKE_report(reports, RPT_ERROR, "Quicktime: QT_GetCodecSettingsFromScene failed"); } bail: if (myHandle != NULL) DisposeHandle(myHandle); return((OSErr)myErr); }
static void InitMacColorTable (int first, int last, CTabHandle *ctabptr) { register i; CTabHandle ctab; *ctabptr = ctab = (CTabHandle) NewHandle (sizeof(ColorTable) + (last-first)*sizeof(ColorSpec)); (*ctab)->ctSize = last-first; (*ctab)->ctSeed = GetCTSeed(); (*ctab)->ctFlags = (short) (((unsigned short)(-1))<<15); for (i=first; i<=last; i++) (*ctab)->ctTable[i-first].value = i; }
static Handle handle_from_c_string (char *str) { int len; Handle retval; len = strlen (str); retval = NewHandle (len); BlockMove (str, *retval, len); return retval; }
void CAComponent::SetCompInfo () const { if (!mCompInfo) { Handle h1 = NewHandle(4); CAComponentDescription desc; OSStatus err = GetComponentInfo (Comp(), &desc, 0, h1, 0); if (err) return; HLock (h1); const_cast<CAComponent*>(this)->mCompInfo = CFStringCreateWithPascalString(NULL, (const unsigned char*)*h1, kCFStringEncodingMacRoman); DisposeHandle (h1); } }
/*--------------------------------------------------------------------- * FUNCTION NAME * allocBufferHandle (Macintosh Version) * * DESCRIPTION * This function allocates a buffer and returns a handle to it. The * DOS implementation fakes all this out, of course. * * AUTHOR * Peter Tracy * * DATE CREATED * May 24, 1991 * ---------------------------------------------------------------------*/ KpHandle_t allocBufferHandle (KpInt32_t numBytes) { Size blockSize; /* size of memory to allocate */ Handle hBuffer; /* handle to allocated buffer */ OSErr err; blockSize = (Size) numBytes; hBuffer = NewHandle (blockSize); err = MemError(); if ((err != noErr) && (err != memFullErr)) { DEBUGTRAP("\p allocBufferHandle NewHandle") hBuffer = NULL; }
int TkSelGetSelection( Tcl_Interp *interp, /* Interpreter to use for reporting * errors. */ Tk_Window tkwin, /* Window on whose behalf to retrieve * the selection (determines display * from which to retrieve). */ Atom selection, /* Selection to retrieve. */ Atom target, /* Desired form in which selection * is to be returned. */ Tk_GetSelProc *proc, /* Procedure to call to process the * selection, once it has been retrieved. */ ClientData clientData) /* Arbitrary value to pass to proc. */ { int result; long length, offset = 0; Handle handle; if ((selection == Tk_InternAtom(tkwin, "CLIPBOARD")) && (target == XA_STRING)) { /* * Get the scrap from the Macintosh global clipboard. */ handle = NewHandle(1); length = GetScrap(handle, 'TEXT', &offset); if (length > 0) { Tcl_DString encodedText; SetHandleSize(handle, (Size) length + 1); HLock(handle); (*handle)[length] = '\0'; Tcl_ExternalToUtfDString(NULL, *handle, length, &encodedText); result = (*proc)(clientData, interp, Tcl_DStringValue(&encodedText)); Tcl_DStringFree(&encodedText); HUnlock(handle); DisposeHandle(handle); return result; } DisposeHandle(handle); } Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection), " selection doesn't exist or form \"", Tk_GetAtomName(tkwin, target), "\" not defined", (char *) NULL); return TCL_ERROR; }
void DrawUsingCGImage( void ) { OSErr err = noErr; Handle hOpenTypeList = NewHandle(0); long numTypes = 0; FSSpec theFSSpec; Rect bounds = { 45, 10, 100, 100 }; GraphicsImportComponent importer = 0; CGImageRef imageRef = 0; CGContextRef context = NULL; CGRect rect; BuildGraphicsImporterValidFileTypes( hOpenTypeList, &numTypes ); HLock( hOpenTypeList ); err = GetOneFileWithPreview(numTypes, (OSTypePtr)*hOpenTypeList, &theFSSpec, NULL); DisposeHandle( hOpenTypeList ); if ( err ) return; // locate and open a graphics importer component which can be used to draw the // selected file. If a suitable importer is not found the ComponentInstance // is set to NULL. err = GetGraphicsImporterForFile( &theFSSpec, // specifies the file to be drawn &importer ); // pointer to the returned GraphicsImporterComponent window = NewCWindow( NULL, &bounds, "\pDraw Using CGImage", false, documentProc, (WindowPtr)-1, true, 0); // import the image as a CGImage err = GraphicsImportCreateCGImage( importer, &imageRef, kGraphicsImportCreateCGImageUsingCurrentSettings ); if (err) return; SizeWindow( window, CGImageGetWidth( imageRef ), CGImageGetHeight( imageRef ), false ); ShowWindow(window); // create a Core Graphics Context from the window port err = QDBeginCGContext(GetWindowPort(window), &context); if (err) return; // make a rectangle designating the location and dimensions in user space of the bounding box in which to draw the image rect = CGRectMake( 0, 0, CGImageGetWidth( imageRef ), CGImageGetHeight( imageRef ) ); // draw the image CGContextDrawImage( context, rect, imageRef ); // end the the context we had for the port QDEndCGContext(GetWindowPort(window), &context); // close the importer instance CloseComponent( importer ); }
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(); }
// SGSettingsDialog with the "Compression" panel removed static OSErr MinimalSGSettingsDialog(SeqGrabComponent seqGrab, SGChannel sgchanVideo, WindowPtr gMonitor) { OSErr err; Component *panelListPtr = NULL; UInt8 numberOfPanels = 0; ComponentDescription cd = { SeqGrabPanelType, VideoMediaType, 0, 0, 0 }; Component c = 0; Component *cPtr = NULL; numberOfPanels = CountComponents(&cd); panelListPtr = (Component *) NewPtr(sizeof(Component) * (numberOfPanels + 1)); cPtr = panelListPtr; numberOfPanels = 0; CFStringRef compressionCFSTR = CFSTR("Compression"); do { ComponentDescription compInfo; c = FindNextComponent(c, &cd); if (c) { Handle hName = NewHandle(0); GetComponentInfo(c, &compInfo, hName, NULL, NULL); CFStringRef nameCFSTR = CFStringCreateWithPascalString(kCFAllocatorDefault, (unsigned char *)(*hName), kCFStringEncodingASCII); if (CFStringCompare (nameCFSTR, compressionCFSTR, kCFCompareCaseInsensitive) != kCFCompareEqualTo) { *cPtr++ = c; numberOfPanels++; } DisposeHandle(hName); } } while (c); if ((err = SGSettingsDialog(seqGrab, sgchanVideo, numberOfPanels, panelListPtr, seqGrabSettingsPreviewOnly, (SGModalFilterUPP) NewSGModalFilterUPP(SeqGrabberModalFilterProc), (long)gMonitor))) { return err; } return 0; }
static void DeleteCheatItem (void) { OSStatus err; HIViewRef ctl, root; HIViewID cid; Handle selectedItems; ItemCount selectionCount; selectedItems = NewHandle(0); if (!selectedItems) return; err = GetDataBrowserItems(dbRef, kDataBrowserNoItem, true, kDataBrowserItemIsSelected, selectedItems); selectionCount = (GetHandleSize(selectedItems) / sizeof(DataBrowserItemID)); if (selectionCount == 0) { DisposeHandle(selectedItems); return; } err = RemoveDataBrowserItems(dbRef, kDataBrowserNoItem, selectionCount, (DataBrowserItemID *) *selectedItems, kDataBrowserItemNoProperty); for (unsigned int i = 0; i < selectionCount; i++) { citem[((DataBrowserItemID *) (*selectedItems))[i] - 1].valid = false; citem[((DataBrowserItemID *) (*selectedItems))[i] - 1].enabled = false; numofcheats--; } DisposeHandle(selectedItems); root = HIViewGetRoot(wRef); cid.id = 0; if (numofcheats < MAC_MAX_CHEATS) { cid.signature = kNewButton; HIViewFindByID(root, cid, &ctl); err = ActivateControl(ctl); } if (numofcheats == 0) { cid.signature = kAllButton; HIViewFindByID(root, cid, &ctl); err = DeactivateControl(ctl); } }
/* FillWinMenu(MenuHandle theMenu, char *match, char *options, int afterItem) Puts names of Igor windows into theMenu. match and options are as for the Igor WinList() function: match = "*" for all windows options = "" for all windows options = "WIN: 1" for all graphs ( bit 0 selects graphs) options = "WIN: 2" for all tables ( bit 1 selects graphs) options = "WIN: 4" for all layouts ( bit 2 selects graphs) options = "WIN: 3" for all graphs and tables afterItem is as for FillMenu, described above. In contrast to Macintosh menu manager routines, this routine does not treat any characters as meta-characters. NOTE: You should not call this routine to update the contents of an existing dialog popup menu item. Use FillWindowPopMenu instead. Thread Safety: FillWinMenu is not thread-safe. */ int FillWinMenu(MenuHandle theMenu, const char *match, const char *options, int afterItem) { Handle listHandle; int result; if (!CheckRunningInMainThread("FillWinMenu")) return NOT_IN_THREADSAFE; listHandle = NewHandle(0L); result = WinList(listHandle, match, ";", options); FillMenuNoMeta(theMenu, *listHandle, (int)GetHandleSize(listHandle), afterItem); DisposeHandle(listHandle); return(result); }
list_t ListCreate (int elementSize) { list_t list; list = (list_t) (NewHandle (sizeof (ListStruct))); /* create empty list */ if (list) { (*list)->signature = LIST_SIGNATURE; (*list)->numItems = 0; (*list)->listSize = 0; (*list)->itemSize = elementSize; (*list)->percentIncrease = kDefaultAllocationPercentIncrease; (*list)->minNumItemsIncrease = kDefaultAllocationminNumItemsIncrease; } return list; }
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; }
void wxMacDataItemBrowserControl::GetItems(const wxMacDataItem* container, bool recurse , DataBrowserItemState state, wxArrayMacDataItemPtr &items) const { Handle handle = NewHandle(0); verify_noerr( wxMacDataBrowserControl::GetItems( (DataBrowserItemID)container , recurse , state, handle) ); int itemCount = GetHandleSize(handle)/sizeof(DataBrowserItemID); HLock( handle ); wxMacDataItemPtr* itemsArray = (wxMacDataItemPtr*) *handle; for ( int i = 0; i < itemCount; ++i) { items.Add(itemsArray[i]); } HUnlock( handle ); DisposeHandle( handle ); }
bool wxBitmapDataObject::SetData( size_t nSize , const void* pBuf ) { Clear(); PicHandle picHandle = (PicHandle) NewHandle( nSize ) ; memcpy( *picHandle , pBuf , nSize ) ; m_pictHandle = picHandle ; m_pictCreated = false ; Rect frame = (**picHandle).picFrame ; m_bitmap.SetPict( picHandle ) ; m_bitmap.SetWidth( frame.right - frame.left ) ; m_bitmap.SetHeight( frame.bottom - frame.top ) ; return m_bitmap.Ok(); }
static Handle read_handle_from_file( short refNum, long offset, long length) { OSErr error= noErr; Handle data= NULL; if (refNum!=-1) { if (data= NewHandle(length)) { ParamBlockRec param; HLock(data); param.ioParam.ioCompletion= (IOCompletionUPP) NULL; param.ioParam.ioRefNum= refNum; param.ioParam.ioBuffer= *data; param.ioParam.ioReqCount= length; param.ioParam.ioPosMode= fsFromStart; param.ioParam.ioPosOffset= offset; error= PBReadSync(¶m); if (error==noErr) { HUnlock(data); } else { DisposeHandle(data); data= NULL; } } else { error= MemError(); } } vwarn(error==noErr, csprintf(temporary, "read_handle_from_file() got error #%d", error)); return data; }
void CAComponent::SetCompNames () const { if (!mCompName) { Handle h1 = NewHandle(4); CAComponentDescription desc; OSStatus err = GetComponentInfo (Comp(), &desc, h1, 0, 0); if (err) { DisposeHandle(h1); return; } HLock(h1); char* ptr1 = *h1; // Get the manufacturer's name... look for the ':' character convention int len = *ptr1++; char* displayStr = 0; const_cast<CAComponent*>(this)->mCompName = CFStringCreateWithPascalString(NULL, (const unsigned char*)*h1, kCFStringEncodingMacRoman); for (int i = 0; i < len; ++i) { if (ptr1[i] == ':') { // found the name ptr1[i] = 0; displayStr = ptr1; break; } } if (displayStr) { const_cast<CAComponent*>(this)->mManuName = CFStringCreateWithCString(NULL, displayStr, kCFStringEncodingMacRoman); //move displayStr ptr past the manu, to the name // we move the characters down a index, because the handle doesn't have any room // at the end for the \0 int i = strlen(displayStr), j = 0; while (displayStr[++i] == ' ' && i < len) ; while (i < len) displayStr[j++] = displayStr[i++]; displayStr[j] = 0; const_cast<CAComponent*>(this)->mAUName = CFStringCreateWithCString(NULL, displayStr, kCFStringEncodingMacRoman); } DisposeHandle (h1); } }
static Handle getnewhandle (long ctbytes, boolean fltemp) { /* 2.1b3 dmb: new fltemp parameter. if true, try temp memory first, then our heap. */ register Handle h; OSErr err; #ifdef MACVERSION if (fltemp) { /*try grabbing temp memory first*/ h = TempNewHandle (ctbytes, &err); if (h != nil) { #ifdef fldebug ++cttemphandles; tempzone = HandleZone (h); #endif return (h); } } #endif if (hsafetycushion == nil) { /*don't allocate new stuff w/out safety cushion*/ if (!getsafetycushion ()) return (nil); } flholdsafetycushion = true; h = NewHandle (ctbytes); flholdsafetycushion = false; return (h); } /*getnewhandle*/
static char *QTUtils_GetUserDataPrefixedValue (UserData theUserData, OSType theType, char *thePrefix) { long myIndex = 0; Handle myData = NULL; long myLength = 0; long myOffset = 0; char *myString = NULL; OSErr myErr = noErr; if (theUserData == NULL) goto bail; // allocate a handle for GetUserData myData = NewHandle(0); if (myData == NULL) goto bail; myIndex = QTUtils_FindUserDataItemWithPrefix(theUserData, theType, thePrefix); if (myIndex > 0) { myErr = GetUserData(theUserData, myData, theType, myIndex); if (myErr == noErr) { if ((*myData)[strlen(thePrefix)] == '"') { myLength = GetHandleSize(myData) - strlen(thePrefix) - 2; myOffset = 1; } else { myLength = GetHandleSize(myData) - strlen(thePrefix); myOffset = 0; } myString = malloc(myLength + 1); if (myString != NULL) { memcpy(myString, *myData + strlen(thePrefix) + myOffset, myLength); myString[myLength] = '\0'; } } } bail: if (myData != NULL) DisposeHandle(myData); return(myString); }