| 63 | } |
| 64 | |
| 65 | static napi_value LoadFromAssets(napi_env env, napi_callback_info info) { |
| 66 | size_t argc = 2; |
| 67 | napi_value args[2] = {nullptr}; |
| 68 | napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); |
| 69 | NativeResourceManager* mNativeResMgr = OH_ResourceManager_InitNativeResourceManager(env, args[0]); |
| 70 | size_t strSize; |
| 71 | char srcBuf[1024]; |
| 72 | napi_get_value_string_utf8(env, args[1], srcBuf, sizeof(srcBuf), &strSize); |
| 73 | auto data = LoadDataFromAsset(mNativeResMgr, srcBuf); |
| 74 | if (data == NULL) { |
| 75 | return nullptr; |
| 76 | } |
| 77 | return JPAGImage::ToJs(env, PAGImage::FromBytes(data->data(), data->length())); |
| 78 | } |
| 79 | |
| 80 | static napi_value Width(napi_env env, napi_callback_info info) { |
| 81 | napi_value jsPAGImage = nullptr; |
nothing calls this directly
no test coverage detected