void DrawTriangle(Rect box, short bullet) { #ifdef MAC Rect frame; PicHandle p; p = GetPicture(bullet == BULLET_OPENTRIANGLE ? OPENLEPICT : CLOSEDLEPICT); if (!p) { SysBeep(1); return; } //frame = (**p).picFrame; frame = GetPICTFrame(p); MyOffsetRect(&frame, box.left - 1, box.top - 2); if (bullet == BULLET_OPENTRIANGLE) MyOffsetRect(&frame, 0, 2); else MyOffsetRect(&frame, 2, 0); DrawPicture(p, &frame); #else POINT points[3]; if (bullet == BULLET_OPENTRIANGLE) { points[0] = MakePOINT(box.left - 1, (box.top + box.bottom) / 2 - 1); points[1] = MakePOINT(box.right + 1, (box.top + box.bottom) / 2 - 1); points[2] = MakePOINT((box.right + box.left) / 2, box.bottom - 1); Polygon(currentHDC, points, 3); } else { MyMoveTo(box.left, box.top - 2); MyLineTo(box.right - 1, (box.top + box.bottom) / 2); MyLineTo(box.left, box.bottom + 1); MyLineTo(box.left, box.top - 2); } #endif }
void _HYPlatformGraphicPane::_DrawPicRes (_HYRect& r, long id) { PicHandle aPic = GetPicture (id); if (aPic) { Rect aRect = HYRect2Rect (r); PictInfo pInfo; GetPictInfo (aPic,&pInfo,0,0,0,0); if (aRect.right-aRect.left<=0) r.right = aRect.right = aRect.left + pInfo.sourceRect.right - pInfo.sourceRect.left; if (aRect.bottom-aRect.top<=0) r.bottom = aRect.bottom = aRect.top + pInfo.sourceRect.bottom - pInfo.sourceRect.top; DrawPicture (aPic, &aRect); ReleaseResource ((Handle)aPic); } else { _String errMsg = _String ("No picture resource with ID ") & id; ReportWarning (errMsg); } }
LRESULT CButtonGenPage::OnClickedDisabled(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) { if (GetPicture(m_hWnd, &m_pPictureDisabled)) m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY); UpdateClearButtons(); return 0; }
static int open_PlayerWin() /*success-> return 0;*/ { int i; OSErr err; RGBColor back={0,0,0}, fore={65535,65535,65535}; open_window( &win, kPlayerWinID); position_window(&win); SetPortWindowPort(win.ref); RGBForeColor(&fore); RGBBackColor(&back); logo= GetPicture(128); logoDown= GetPicture(132); for(i=0; i<6; i++) button[i]= GetCIcon(i+200); iconPlay=GetCIcon(210); iconPause=GetCIcon(211); iconVol=GetCIcon(206); iconTab=GetCIcon(207); iconNotLoop=GetCIcon(208); iconLoop=GetCIcon(209); if(gHasDragMgr) { receiveRgn=NewRgn(); if( receiveRgn ) { GetWindowContentRgn(win.ref, receiveRgn); err=InstallTrackingHandler(NewDragTrackingHandlerProc(DragTrackingProc), (WindowPtr)win.ref, 0); if(err) ExitToShell(); err=InstallReceiveHandler(NewDragReceiveHandlerProc(DragReceiveFunc), (WindowPtr)win.ref, 0); if(err) ExitToShell(); } } return 0; }
static void update_PlayerWin() { short y=((double)mac_amplitude/255)*(rVol.bottom-rVol.top-20); Rect rFrame,rTab; SetPortWindowPort(win.ref); DrawButton(); skin_f_repeat? PlotCIcon(&rLoop, iconLoop):PlotCIcon(&rLoop, iconNotLoop); PlotCIcon(&rVol, iconVol); SetRect(&rTab, rVol.left+2, rVol.top+49-y, rVol.right-2, rVol.top+59-y); PlotCIcon(&rTab, iconTab); rFrame=rFileName; InsetRect(&rFrame, -2, -2); DrawPicture(GetPicture(129), &rFrame); rFrame=rTime; InsetRect(&rFrame, -2, -2); DrawPicture(GetPicture(130), &rFrame); DrawPicture(logo, &rLogo); DrawTimeStr(); DrawFileStr(); }
void ShowLogo(Boolean bEraseRect) { short reserr; Rect derefd, logoRect; PicHandle logoPicH; Handle logoRectH; /* draw the image well */ ControlHandle imgWellH = GetNewControl(rLogoImgWell, gWPtr); if (!imgWellH) { ErrorHandler(eMem, nil); return; } /* initialize Netscape logo */ logoPicH = GetPicture(rNSLogo); reserr = ResError(); if (reserr == noErr) { /* draw Netscape logo */ if (logoPicH != nil) { logoRectH = GetResource('RECT', rNSLogoBox); reserr = ResError(); if (reserr == noErr && logoRectH) { HLock(logoRectH); derefd = (Rect) **((Rect**)logoRectH); SetRect(&logoRect, derefd.left, derefd.top, derefd.right, derefd.bottom); HUnlock(logoRectH); reserr = ResError(); if (reserr == noErr) { if (bEraseRect) { EraseRect(&logoRect); InvalRect(&logoRect); } DrawPicture(logoPicH, &logoRect); ReleaseResource((Handle)logoPicH); } ReleaseResource((Handle)logoRectH); } } } if (reserr != noErr) ErrorHandler(reserr, nil); }
McoStatus BlankTwTab::UpdateWindow(void) { PicHandle pict; Rect r1; short iType; Handle iHandle; pict = GetPicture(WAIT_PICT); GetDItem (dp, WAIT_ID+startNum, &iType, (Handle*)&iHandle, &r1); if (pict != 0L) { DrawPicture(pict,&r1); ReleaseResource((Handle)pict); } return MCO_SUCCESS; }
void StartButtonInit(int height) { Picture *p = NULL; int pw; /* some defaults */ if (StartName == NULL) UpdateString(&StartName, "Start"); if (StartPopup == NULL) UpdateString(&StartPopup, "StartMenu"); if (StartIconName == NULL) UpdateString(&StartIconName, "mini-start.xpm"); p = GetPicture(dpy, Root, IconPath, PixmapPath, StartIconName); StartButton = (Button *)ButtonNew(StartName, p, BUTTON_UP, 0); if (p != NULL) pw = p->width+3; else pw = 0; StartButtonWidth = XTextWidth(ButtonFont, StartName, strlen(StartName)) + pw + 14; StartButtonHeight = height; }
void Kamera::Run(const String& command) { if(!command.IsEmpty()) { Uri commandUri; commandUri.SetUri(command); String method = commandUri.GetHost(); StringTokenizer strTok(commandUri.GetPath(), L"/"); if(strTok.GetTokenCount() < 1) { AppLogException("Not enough params"); return; } strTok.GetNextToken(callbackId); if(method == "com.phonegap.Camera.getPicture" && !callbackId.IsEmpty()) { GetPicture(); } } }
void DrawLobsterPICTtoGWorld(CGrafPtr destGWorld, Rect *srcRect) { // put the overlay into the GWorld, move the picture to the bottom right of the movie PicHandle pict = GetPicture(129); if (pict) { CGrafPtr oldPort; GDHandle oldDevice; Rect frame = (**pict).picFrame; GetGWorld(&oldPort, &oldDevice); SetGWorld(destGWorld, nil); // normalize coordinates OffsetRect(&frame, -frame.left, -frame.left); // grow frame to be as big as source rect OffsetRect(&frame, srcRect->right - frame.right, srcRect->bottom - frame.bottom); DrawPicture(pict, &frame); SetGWorld(oldPort, oldDevice); ReleaseResource((Handle)pict); } }
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 } }
bool SUIPictureManager::LoadFromString( SPString stringStream ) { SPString picturesString = SPStringHelper::XMLExcludeFrom(stringStream, L"Pictures"); stringStream = SPStringHelper::XMLRemoveFirst(stringStream, L"Pictures"); while(picturesString.size() > 0) { SPString pictureString = SPStringHelper::XMLExcludeFrom(picturesString, L"SUIPL"); picturesString = SPStringHelper::XMLRemoveFirst(picturesString, L"SUIPL"); SPString propertiesString = SPStringHelper::XMLExcludeFrom(pictureString, L"Properties"); pictureString = SPStringHelper::XMLRemoveFirst(pictureString, L"Properties"); VariableMap properties = SScriptHelper::StringToVariables(propertiesString); SScriptFunctionPtr buildPicture = new SSFPicture(); buildPicture->Function(properties, false); SPString mixImagesString = SPStringHelper::XMLExcludeFrom(pictureString, L"MPS"); pictureString = SPStringHelper::XMLRemoveFirst(pictureString, L"MPS"); SScriptFunctionPtr mixPicture = new SSFMixPicture(); while(mixImagesString.size() > 0) { SPString mixImageString = SPStringHelper::XMLExcludeFrom(mixImagesString, L"SUIMI"); mixImagesString = SPStringHelper::XMLRemoveFirst(mixImagesString, L"SUIMI"); VariableMap miProperties = SScriptHelper::StringToVariables(mixImageString); mixPicture->Function(miProperties, false); } } SPString currentPictureString = SPStringHelper::XMLExcludeFrom(stringStream, L"CurrentPictureName"); stringStream = SPStringHelper::XMLRemoveFirst(stringStream, L"CurrentPictureName"); currentPicture = GetPicture(currentPictureString); return true; }
Boolean DrawScaledPic(short pic, Rect *theRect) { PicHandle thePic; // Firstly, see if we can get the pic, if not then it's not there so exit thePic=GetPicture(pic); if (!thePic) return false; if (!theRect) { *theRect=(**thePic).picFrame; BigEndianRectToNative(*theRect); } EraseRect(theRect); ScalePic(thePic,theRect,false); DrawPicture(thePic,theRect); ReleaseResource((Handle)thePic); // Can get rid of that picture now it's on the screen return true; }
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; }
OSErr SpriteUtils_AddPICTImageToKeyFrameSample (QTAtomContainer theKeySample, short thePictID, RGBColor *theKeyColor, QTAtomID theID, FixedPoint *theRegistrationPoint, StringPtr theImageName) { PicHandle myPicture = NULL; Handle myCompressedPicture = NULL; ImageDescriptionHandle myImageDesc = NULL; OSErr myErr = noErr; // get picture from resource myPicture = (PicHandle)GetPicture(thePictID); if (myPicture == NULL) myErr = resNotFound; if (myErr != noErr) goto bail; DetachResource((Handle)myPicture); // convert it to image data compressed by the animation compressor myErr = ICUtils_RecompressPictureWithTransparency(myPicture, theKeyColor, NULL, &myImageDesc, &myCompressedPicture); if (myErr != noErr) goto bail; // add it to the key sample HLock(myCompressedPicture); myErr = SpriteUtils_AddCompressedImageToKeyFrameSample(theKeySample, myImageDesc, GetHandleSize(myCompressedPicture), *myCompressedPicture, theID, theRegistrationPoint, theImageName); bail: if (myPicture != NULL) KillPicture(myPicture); if (myCompressedPicture != NULL) DisposeHandle(myCompressedPicture); if (myImageDesc != NULL) DisposeHandle((Handle)myImageDesc); return(myErr); }
static void DrawToolBox (GRAPH_WINDOW *gw, INT tool) { Rect r,dstRect; CGrafPtr myPort; PicHandle toolBox; WindowPtr theWindow; theWindow = MAC_WIN(gw); myPort = GetWindowPort(theWindow); SetPort(myPort); GetPortBounds(myPort,&r); toolBox = GetPicture(TOOLBOX_RSRC_ID); if (toolBox!=NULL) { SetRect(&dstRect,r.right-120,r.bottom-15,r.right-15,r.bottom); DrawPicture(toolBox,&dstRect); } SetRect(&dstRect,r.right-119+tool*15,r.bottom-14,r.right-104+tool*15,r.bottom); InvertRect(&dstRect); }
void StartButtonInit(int height) { Picture *p = NULL; int pw; /* some defaults */ if (StartName == NULL) UpdateString(&StartName, "Start"); if (StartPopup == NULL) UpdateString(&StartPopup, "StartMenu"); if (StartIconName == NULL) UpdateString(&StartIconName, "mini-start.xpm"); /** FIXME: what should the colour limit be? I put in -1, which apparently imposes NO limit. **/ p = GetPicture(dpy, win, ImagePath, StartIconName, -1); StartButton = (Button *)ButtonNew(StartName, p, BUTTON_UP,0); if (p != NULL) pw = p->width+3; else pw = 0; StartButtonWidth = XTextWidth(ButtonFont, StartName, strlen(StartName)) + pw + 14; StartButtonHeight = height; }
/* アイコンプレビューのアップデート */ void DrawIPIconPreview(const IPIconRec *ipIcon) { PicHandle previewPict; Rect r; Pattern pat; Boolean drawLarge=false,drawSmall=false,drawThumbnail=false; Handle h; OSErr err; IconSuiteRef iconSuite=NULL; IconRef iconRef; Rect picRect; /* プレビューの大きさ */ GetWindowPortBounds(gPreviewWindow,&r); /* まず背景 */ switch (gListBackground) { case iBackWhite: EraseRect(&r); break; case iBackGray: GetIndPattern(&pat,0,4); FillRect(&r,&pat); break; case iBackBlack: PaintRect(&r); break; case iBackDesktop: #if !TARGET_API_MAC_CARBON { PixPatHandle ppat; UseResFile(0); // ppat=GetPixPat(16); ppat=LMGetDeskCPat(); if (ppat==nil) { LMGetDeskPattern(&pat); FillRect(&r,&pat); } else { FillCRect(&r,ppat); // DisposePixPat(ppat); } UseResFile(gApplRefNum); } #else EraseRect(&r); #endif break; default: EraseRect(&r); break; } if (ipIcon!=NULL) { err=GetDataFromIPIcon(&h,ipIcon,kL1Data); drawLarge=(h!=nil); err=GetDataFromIPIcon(&h,ipIcon,kS1Data); drawSmall=(h!=nil); err=GetDataFromIPIcon(&h,ipIcon,kT32Data); drawThumbnail=(h!=nil); } if (drawThumbnail) previewPict = GetPicture(142); else previewPict = GetPicture(141); QDGetPictureBounds(previewPict, &picRect); DrawPicture(previewPict,&picRect); if (ipIcon==NULL) return; if (!isThumbnailIconsAvailable || !drawThumbnail) { iconSuite = ipIcon->iconSuite; } else { IconFamilyHandle iconFamily; err=IPIconToIconFamily(ipIcon,&iconFamily); err=RegisterIconRefFromIconFamily(kIconPartyCreator,'TEMP',iconFamily,&iconRef); // DisposeHandle((Handle)iconFamily); } if (isThumbnailIconsAvailable && drawThumbnail) { err=PlotIconRef(&iconPreviewRect[12],kAlignNone,kTransformNone,kIconServicesNormalUsageFlag, iconRef); err=ReleaseIconRef(iconRef); } else { if (iconSuite != NULL) { PlotIconSuite(&iconPreviewRect[0],kAlignNone,kTransformNone,iconSuite); PlotIconSuite(&iconPreviewRect[1],kAlignNone,kTransformSelected,iconSuite); if (drawLarge) { PlotIconSuite(&iconPreviewRect[4],kAlignNone,kTransformOpen,iconSuite); PlotIconSuite(&iconPreviewRect[5],kAlignNone,kTransformSelectedOpen,iconSuite); PlotIconSuite(&iconPreviewRect[8],kAlignNone,kTransformOffline,iconSuite); PlotIconSuite(&iconPreviewRect[9],kAlignNone,kTransformSelectedOffline,iconSuite); } PlotIconSuite(&iconPreviewRect[2],kAlignNone,kTransformNone,iconSuite); PlotIconSuite(&iconPreviewRect[3],kAlignNone,kTransformSelected,iconSuite); if (drawSmall) { PlotIconSuite(&iconPreviewRect[6],kAlignNone,kTransformOpen,iconSuite); PlotIconSuite(&iconPreviewRect[7],kAlignNone,kTransformSelectedOpen,iconSuite); PlotIconSuite(&iconPreviewRect[10],kAlignNone,kTransformOffline,iconSuite); PlotIconSuite(&iconPreviewRect[11],kAlignNone,kTransformSelectedOffline,iconSuite); } } } }
void init() { RgnHandle tempRgn; Rect BaseRect; OSErr err; long QDfeature/*, OSfeature*/; GDHandle SaveGD; CGrafPtr SavePort; /* Initialize Managaer. */ //InitGraf(&qd.thePort); //InitWindows(); //InitDialogs(nil); InitCursor(); FlushEvents(everyEvent, 0); /* Set up menus. */ mymenu0 = GetMenu(appleID); //AppendResMenu(mymenu0, 'DRVR'); InsertMenu(mymenu0,0); mymenu1 = GetMenu(fileID); InsertMenu(mymenu1,0); DrawMenuBar(); DoneFlag = false; ThePict = GetPicture(PictID); if (ThePict == nil) DoneFlag = true; /* Use Gestalt to find is QuickDraw is avaiable. */ /*if ((GetOSTrapAddress(Gestalttest) != GetOSTrapAddress(NoTrap))) { err = Gestalt(gestaltQuickdrawVersion, &QDfeature); if (err) DoneFlag = true; err = Gestalt(gestaltSystemVersion, &OSfeature); if (err) DoneFlag = true; if (!DoneFlag && (QDfeature & 0x0f00) != 0x0200 && OSfeature < 0x0605) DoneFlag = true; } else DoneFlag = true;*/ err = Gestalt(gestaltQuickdrawVersion, &QDfeature); if (err != noErr || QDfeature < gestalt32BitQD) DoneFlag = true; /* Set Rects. */ SetRect(&BaseRect, 40, 60, 472, 282); SetRect(&WinMinusScroll, BaseRect.left-40, BaseRect.top-60, BaseRect.right-60, BaseRect.bottom - 80); SetRect(&InitWindowSize, WinMinusScroll.left, WinMinusScroll.top, WinMinusScroll.right, WinMinusScroll.bottom); tempRgn = GetGrayRgn(); HLock ((Handle) tempRgn); //TotalRect = (**tempRgn).rgnBBox; GetRegionBounds(tempRgn, &TotalRect); /*SetRect(&minRect, 80, 80, (**tempRgn).rgnBBox.right - 40, (**tempRgn).rgnBBox.bottom - 40);*/ SetRect(&minRect, 80, 80, TotalRect.right - 40, TotalRect.bottom - 40); HUnlock ((Handle) tempRgn); /* Open window and set up picture. */ GetGWorld (&SavePort, &SaveGD); mycolors = GetCTable (clutID); (*mycolors)->ctFlags |= 0x4000; myWindow = NewCWindow(nil, &BaseRect, (ConstStr255Param)"", true, zoomDocProc, (WindowPtr) -1, true, 150); SetGWorld(GetWindowPort(myWindow), SaveGD); DrawGrowIcon (myWindow); srcPalette = NewPalette (((**mycolors).ctSize)+1, mycolors, pmTolerant + pmExplicit + pmAnimated, 0); SetPalette ((WindowPtr) myWindow, srcPalette, true); GetGWorld (&SavePort, &SaveGD); err = NewGWorld (&offscreenGWorld, 8, &InitWindowSize, mycolors, nil, 0); if (err) Debugger(); SetGWorld (offscreenGWorld, nil); EraseRect (&InitWindowSize); DrawPicture (ThePict, &InitWindowSize); SetGWorld (SavePort, SaveGD); }
short DrawBullet(ListItem item, RECTPTR r, Boolean draw, RECTPTR box) { Rect b; Rect frame; PicHandle p = nil; #ifdef MAC MySetRect(&b, 5 + item.indent * 12, r->top + 4, 5 + item.indent * 12 + 6, r->bottom - 4); #else MySetRect(&b, 7 + item.indent * 12, r->top + 4, 7 + item.indent * 12 + 6, r->bottom - 5); #endif if (draw) { PenNormal(); RGBForeColor(&colors[BLACK]); switch (item.bullet) { case BULLET_DASH: MyMoveTo(b.left, (b.top + b.bottom) / 2); MyLineTo(b.right, (b.top + b.bottom) / 2); break; case BULLET_EMPTYBOX: b.left+=1;b.right+=1; #ifdef MAC p = GetPicture (EMPTYBOXPICT); if (!p) { SysBeep(1);break; } //frame = (**p).picFrame; frame = GetPICTFrame(p); MyOffsetRect(&frame, b.left, b.top); DrawPicture(p, &frame); #else MyFrameRect(&b); #endif b.left-=1;b.right-=1; break; case BULLET_FILLEDBOX: b.left+=1;b.right+=1; #ifdef MAC p = GetPicture (FILLEDBOXPICT); if (!p) { SysBeep(1);break; } //frame = (**p).picFrame; frame = GetPICTFrame(p); MyOffsetRect(&frame, b.left, b.top); DrawPicture(p, &frame); #else PaintRect(&b); #endif // MyFrameRect(&b); // MyMoveTo(b.left,b.top); // MyLineTo(b.right-1,b.bottom-1); // MyMoveTo(b.right-1,b.top); // MyLineTo(b.left,b.bottom-1); b.left-=1;b.right-=1; break; case BULLET_OPENTRIANGLE: case BULLET_CLOSEDTRIANGLE: DrawTriangle(b, item.bullet); break; } } if (box) (*box) = b; // line up the text with an indented bullet b.right += 3; // mac tweek by sohail return b.right; }
void CreateSprites (void) { long lIndex; PicHandle hpicImage; OSErr nErr; RGBColor rgbcKeyColor; SetRect(&gDestRects[0], 132, 132, 132 + kSpaceShipWidth, 132 + kSpaceShipHeight); SetRect(&gDestRects[1], 50, 50, 50 + kSpaceShipWidth, 50 + kSpaceShipHeight); SetRect(&gDestRects[2], 100, 100, 100 + kSpaceShipWidth, 100 + kSpaceShipHeight); SetRect(&gDestRects[3], 130, 130, 130 + kSpaceShipWidth, 130 + kSpaceShipHeight); gDeltas[0].h = -3; gDeltas[0].v = 0; gDeltas[1].h = -5; gDeltas[1].v = 3; gDeltas[2].h = 4; gDeltas[2].v = -6; gDeltas[3].h = 6; gDeltas[3].v = 4; gCurrentImages[0] = 0; gCurrentImages[1] = kNumSpaceShipImages / 4; gCurrentImages[2] = kNumSpaceShipImages / 2; gCurrentImages[3] = kNumSpaceShipImages * 4 / 3; rgbcKeyColor.red = 0; rgbcKeyColor.green = 0; rgbcKeyColor.blue = 0; // recompress PICT images to make them transparent for (lIndex = 0; lIndex < kNumSpaceShipImages; lIndex++) { hpicImage = (PicHandle)GetPicture(lIndex + kFirstSpaceShipPictID); DetachResource((Handle)hpicImage); nErr = RecompressPictureWithTransparency(hpicImage, &rgbcKeyColor, nil, &gImageDescriptions[lIndex], &gCompressedPictures[lIndex]); KillPicture(hpicImage); } // create the sprites for the sprite world for (lIndex = 0; lIndex < kNumSprites; lIndex++) { MatrixRecord matrix; SetIdentityMatrix(&matrix); matrix.matrix[2][0] = ((long)gDestRects[lIndex].left << 16); matrix.matrix[2][1] = ((long)gDestRects[lIndex].top << 16); nErr = NewSprite(&(gSprites[lIndex]), /* on return, the ID of the new sprite */ gSpriteWorld, /* the sprite world for this sprite */ gImageDescriptions[lIndex], /* image description of the spriteÕs image. */ *gCompressedPictures[lIndex], /* sprite image data */ &matrix, /* sprite matrix */ true, /* is sprite visible? */ lIndex); /* sprite layer */ } }
pascal PicHandle SafeGetPicture(short picID) { StAcroResourceContext resContext; return GetPicture(picID); }
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); }
//--------------------------------------------------------------------------- void tTVPSusiePicturePlugin::Load(void *callbackdata, tTVPGraphicSizeCallback sizecallback, tTVPGraphicScanLineCallback scanlinecallback, tTJSBinaryStream *src, tjs_int keyidx, tTVPGraphicLoadMode mode) { bool bitmaplocked = false; HLOCAL bitmap = NULL; bool infolocked = false; HLOCAL info = NULL; // load source to memory tjs_uint64 size = src->GetSize(); tjs_uint8 * source = new tjs_uint8[(tjs_int)size]; try { src->ReadBuffer(source, static_cast<tjs_uint>(size) ); // call GetPicture int r = GetPicture((LPSTR)source, (long)size, 0x01, &info, &bitmap, (FARPROC)ProgressCallback, 0); if((r&0xff) != 0) TVPThrowExceptionMessage(TVPSusiePluginError, ttstr(r)); // setup bitmapinfoheader TVP_WIN_BITMAPINFOHEADER bi; memset(&bi, 0, sizeof(bi)); BITMAPINFOHEADER *srcbi = (BITMAPINFOHEADER *)LocalLock(info); infolocked = true; tjs_int datasize = LocalSize(bitmap); void * data = (void*) LocalLock(bitmap); bitmaplocked = true; if(srcbi->biSize == 12) { // OS/2 bitmap header bi.biSize = srcbi->biSize; bi.biWidth = srcbi->biWidth; bi.biHeight = srcbi->biHeight; bi.biPlanes = srcbi->biPlanes; bi.biBitCount = srcbi->biBitCount; bi.biClrUsed = 0; bi.biCompression = BI_RGB; } else if(srcbi->biSize == 40) { // Windows bitmap header bi.biSize = srcbi->biSize; bi.biWidth = srcbi->biWidth; bi.biHeight = srcbi->biHeight; bi.biPlanes = srcbi->biPlanes; bi.biBitCount = srcbi->biBitCount; bi.biCompression = srcbi->biCompression; bi.biSizeImage = srcbi->biSizeImage; bi.biXPelsPerMeter = srcbi->biXPelsPerMeter; bi.biYPelsPerMeter = srcbi->biYPelsPerMeter; bi.biClrUsed = srcbi->biClrUsed; bi.biClrImportant = srcbi->biClrImportant; } else { // not supported bitmap format TVPThrowExceptionMessage(TVPImageLoadError, TJS_W("Non-supported bitmap header was given from susie plug-in.")); } // create reference memory stream for bitmap pixel data tTVPMemoryStream memstream(data, datasize); if(bi.biClrUsed == 0 && bi.biBitCount <= 8) bi.biClrUsed = 1 << bi.biBitCount; // pass information to TVPInternalLoadBMP TVPInternalLoadBMP(callbackdata, sizecallback, scanlinecallback, bi, ((tjs_uint8*)srcbi) + bi.biSize, &memstream, keyidx, AlphaType, mode); } catch(...) { delete [] source; if(bitmaplocked) LocalUnlock(bitmap); if(bitmap) LocalFree(bitmap); if(infolocked) LocalUnlock(info); if(info) LocalFree(info); throw; } delete [] source; if(bitmaplocked) LocalUnlock(bitmap); if(bitmap) LocalFree(bitmap); if(infolocked) LocalUnlock(info); if(info) LocalFree(info); }
/******************************************************************************* ** 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: ; }
__declspec(dllexport) int __stdcall GetPreview(const char* filename, int len, unsigned flag, HLOCAL* hbi, HLOCAL* hbm, void* lpPrgressCallback, int lData) { return GetPicture(filename, len, flag, hbi, hbm, lpPrgressCallback, lData); }