| version 1.1, 2003/10/31 16:55:06 | version 1.4, 2003/11/13 18:17:42 | 
| Line 11 | Line 11 | 
 | #include "np2.h" | #include "np2.h" | 
 | #include "np2opening.h" | #include "np2opening.h" | 
 |  |  | 
| void openingNP2(void) { |  | 
| Rect                srt; |  | 
| GrafPtr             port; | static PicHandle getbmp(FSSpec fsc, Rect* srt) { | 
| CFURLRef    openingURL; | PicHandle   pict = NULL; | 
| char                buffer[1024]; |  | 
| FSRef               fsr; |  | 
| FSSpec              fsc; |  | 
| PicHandle   pict; |  | 
 | GraphicsImportComponent     gi; | GraphicsImportComponent     gi; | 
 |  |  | 
| GetPort(&port); | if (!GetGraphicsImporterForFile(&fsc, &gi)) { | 
| SetPortWindowPort(hWndMain); | if (!GraphicsImportGetNaturalBounds(gi, srt)) { | 
|  | OffsetRect( srt, -(*srt).left, -(*srt).top); | 
|  | GraphicsImportSetBoundsRect(gi, srt); | 
|  | GraphicsImportGetAsPicture(gi, &pict); | 
|  | } | 
|  | CloseComponent(gi); | 
|  | } | 
|  | return pict; | 
|  | } | 
|  |  | 
|  | PicHandle getBMPfromPath(char* path, Rect* srt) { | 
|  |  | 
|  | Str255              fname; | 
|  | FSSpec              fsc; | 
|  |  | 
|  | mkstr255(fname, path); | 
|  | FSMakeFSSpec(0, 0, fname, &fsc); | 
|  | return(getbmp(fsc, srt)); | 
|  | } | 
 |  |  | 
| openingURL=CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("nekop2"), CFSTR("bmp"), NULL); | bool getResourceFile(const char* name, FSSpec* fsc) { | 
| if (openingURL) { | CFURLRef    url = NULL; | 
| if (CFURLGetFSRef(openingURL, &fsr)) { | FSRef               fsr; | 
| FSPathMakeRef((const UInt8*)buffer, &fsr, NULL); | bool                ret = false; | 
| FSGetCatalogInfo(&fsr, kFSCatInfoNone, NULL, NULL, &fsc, NULL); |  | 
| if (!GetGraphicsImporterForFile(&fsc, &gi)) { | url=CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTRj(name), NULL, NULL); | 
| if (!GraphicsImportGetNaturalBounds(gi, &srt)) { | if (url) { | 
| OffsetRect( &srt, -srt.left, -srt.top); | if (CFURLGetFSRef(url, &fsr)) { | 
| GraphicsImportSetBoundsRect(gi, &srt); | if (FSGetCatalogInfo(&fsr, kFSCatInfoNone, NULL, NULL, fsc, NULL) == noErr) { | 
| GraphicsImportGetAsPicture(gi, &pict); | ret = true; | 
| OffsetRect(&srt, (640-srt.right)/2, (400-srt.bottom)/2); |  | 
| DrawPicture(pict,&srt); |  | 
| QDFlushPortBuffer(GetWindowPort(hWndMain), NULL); |  | 
| KillPicture(pict); |  | 
| } |  | 
| CloseComponent(gi); |  | 
 | } | } | 
 | } | } | 
| CFRelease(openingURL); | CFRelease(url); | 
|  | } | 
|  | return(ret); | 
|  | } | 
|  |  | 
|  |  | 
|  | PicHandle getBMPfromResource(const char* name, Rect* srt) { | 
|  | FSSpec              fsc; | 
|  | PicHandle   pict = NULL; | 
|  |  | 
|  | if (getResourceFile(name, &fsc)) { | 
|  | pict = getbmp(fsc, srt); | 
|  | } | 
|  | return(pict); | 
|  | } | 
|  |  | 
|  | void openingNP2(void) { | 
|  | Rect                srt; | 
|  | GrafPtr             port; | 
|  | PicHandle   pict = NULL; | 
|  |  | 
|  | pict = getBMPfromResource("nekop2.bmp", &srt); | 
|  | if (pict) { | 
|  | GetPort(&port); | 
|  | SetPortWindowPort(hWndMain); | 
|  | OffsetRect(&srt, (640-srt.right)/2, (400-srt.bottom)/2); | 
|  | DrawPicture(pict,&srt); | 
|  | QDFlushPortBuffer(GetWindowPort(hWndMain), NULL); | 
|  | SetPort(port); | 
|  | KillPicture(pict); | 
 | } | } | 
 | SetPort(port); |  | 
 | } | } |