在ArkTS中,从pixelmap获取的buffer已经是解码后的数据,不应该传入imagesource,imagesource是用来对未解码数据进行解码的。此处应该直接创建PixelMap:void *buffer_data = NULL; size_t byte_length = 0; napi_get_arraybuffer_info(env, args[0], &buffer_data, &byte_length); uint8_t* data = static_cast<uint8_t*>(buffer_data); OH_Pixelmap_InitializationOptions *createOpts; OH_PixelmapInitializationOptions_Create(&createOpts); OH_PixelmapInitializationOptions_SetWidth(createOpts, 20); OH_PixelmapInitializationOptions_SetHeight(createOpts, 20); OH_PixelmapInitializationOptions_SetPixelFormat(createOpts, PIXEL_FORMAT_RGBA_8888); OH_PixelmapInitializationOptions_SetAlphaType(createOpts, PIXELMAP_ALPHA_TYPE_UNKNOWN);
在ArkTS中,从pixelmap获取的buffer已经是解码后的数据,不应该传入imagesource,imagesource是用来对未解码数据进行解码的。此处应该直接创建PixelMap: