// onLoaded( dic, is_async, is_error, error_mes ); エラーは // sync ( main thead ) void tTVPAsyncImageLoader::LoadRequest( iTJSDispatch2 *owner, tTJSNI_Bitmap* bmp, const ttstr &name ) { //tTVPBaseBitmap* dest = new tTVPBaseBitmap( 32, 32, 32 ); tTVPBaseBitmap dest( TVPGetInitialBitmap() ); iTJSDispatch2* metainfo = NULL; ttstr nname = TVPNormalizeStorageName(name); if( TVPCheckImageCache(nname,&dest,glmNormal,0,0,TVP_clNone,&metainfo) ) { // キャッシュ内に発見、即座に読込みを完了する bmp->CopyFrom( &dest ); bmp->SetLoading( false ); tTJSVariant param[4]; param[0] = tTJSVariant(metainfo,metainfo); if( metainfo ) metainfo->Release(); param[1] = 0; // false param[2] = 0; // false param[3] = TJS_W(""); // error_mes static ttstr eventname(TJS_W("onLoaded")); TVPPostEvent(owner, owner, eventname, 0, TVP_EPT_IMMEDIATE, 4, param); return; } if( TVPIsExistentStorage(name) == false ) { TVPThrowExceptionMessage(TVPCannotFindStorage, name); } ttstr ext = TVPExtractStorageExt(name); if(ext == TJS_W("")) { TVPThrowExceptionMessage(TJS_W("Filename extension not found/%1"), name); } PushLoadQueue( owner, bmp, nname ); }
//--------------------------------------------------------------------------- // iTVPSimpleImageProvider implementation //--------------------------------------------------------------------------- tjs_error TJS_INTF_METHOD tTVPSimpleImageProvider::LoadImage( /*in*/const tjs_char *name, /*in*/tjs_int bpp, /*in*/tjs_uint32 key, /*in*/tjs_uint w, /*in*/tjs_uint h, /*out*/iTVPScanLineProvider ** scpro) { if(bpp != 8 && bpp != 32) return TJS_E_FAIL; // invalid bitmap color depth tTVPBaseBitmap *bitmap = new tTVPBaseBitmap(TVPGetInitialBitmap()); try { TVPLoadGraphic(bitmap, name, key, w, h, bpp == 8 ? glmGrayscale : glmNormal); } catch(...) { delete bitmap; return TJS_E_FAIL; } if(scpro) *scpro = new tTVPScanLineProviderForBaseBitmap(bitmap, true); return TJS_S_OK; }
//--------------------------------------------------------------------------- // Image Provider Service for other plug-ins //--------------------------------------------------------------------------- iTVPScanLineProvider * TVPSLPLoadImage(const ttstr &name, tjs_int bpp, tjs_uint32 key, tjs_uint w, tjs_uint h) { if(bpp != 8 && bpp != 32) return NULL; // invalid bitmap color depth tTVPBaseBitmap *bitmap = new tTVPBaseBitmap(TVPGetInitialBitmap()); iTVPScanLineProvider *pro; try { TVPLoadGraphic(bitmap, name, key, w, h, bpp == 8 ? glmGrayscale : glmNormal); pro = new tTVPScanLineProviderForBaseBitmap(bitmap, true); } catch(...) { delete bitmap; throw; } return pro; }