### Basic CMake Project Setup Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/entry/src/main/cpp/CMakeLists.txt Sets the minimum required CMake version and defines the project name. This is a standard starting point for most CMake projects. ```cmake cmake_minimum_required(VERSION 3.5.0) project(unittest) ``` -------------------------------- ### C++ Image Loading Example Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/README.md Example demonstrating how to create an ImageKnifeOption, set loading parameters, create an ImageKnifeNode, and execute the image loading process. ```cpp // 1. Create ImageKnifeOption. auto imageKnifeOption = std::make_shared(); // 2. Set the image loading parameter options. Only the main image source loadSrc is mandatory. Other parameters are optional. imageKnifeOption->loadSrc.SetString("https://www.openharmony.cn/_nuxt/img/logo.dcf95b3.png"); imageKnifeOption->placeholderSrc.SetString("Placeholder"); imageKnifeOption->errorSrc.SetString("Error image"); imageKnifeOption->onLoadListener = std::make_shared(); imageKnifeOption->onLoadListener->onLoadStart = [](ImageInfo info) {}; imageKnifeOption->onLoadListener->onLoadFailed = [](std::string err, ImageInfo info) {}; imageKnifeOption->objectFit = ARKUI_OBJECT_FIT_COVER; // 3. Use options to create an image component and start image loading. auto imageKnifeNode = ImageKnifePro::ImageKnifeNode::CreateImageKnifeNode(imageKnifeOption); imageKnifeNode->SetWidth(200); imageKnifeNode->SetHeight(200); //4. Loading start. Set SyncLoad(true) if synchronous loading is need. imageKnifeNode->Execute(); //5. Obtain the original ArkUI_NodeHandle, which should be manually operated to mount the C API image node to the tree. ArkUI_NodeHandle handle = imageKnifeNode->GetHandle(); ``` -------------------------------- ### Display a Remote Image with ImageKnifeComponent Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/README.md Quick start example demonstrating how to configure ImageKnifeOption with a remote image URL, placeholder, and error image, then display it using the ImageKnifeComponent. ```typescript import { ImageKnifeComponent, ImageKnifeOption, ImageKnife } from '@ohos/imageknifepro' @Entry @Component struct QuickStartPage { // 1. Configure image loading options @State imageKnifeOption: ImageKnifeOption = { loadSrc: 'https://www.example.com/example.png', // Main image URL placeholderSrc: $r('app.media.loading'), // Placeholder errorSrc: $r('app.media.error'), // Error image } build() { Column() { // 2. Display image ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption }).width(200).height(200) } } } ``` -------------------------------- ### ImageKnifeComponentV2 Example Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/README.md Demonstrates how to use ImageKnifeComponentV2 with image loading options. ```typescript import { ImageKnifeComponentV2, ImageKnifeOptionV2, ImageKnife, ImageInfo } from '@ohos/imageknifepro' @Entry @ComponentV2 struct QuickStartPageV2 { // 1. Define image loading options as a single @Local option object @Local option: ImageKnifeOptionV2 = { loadSrc: 'https://www.example.com/example.png', placeholderSrc: $r('app.media.loading'), errorSrc: $r('app.media.error'), objectFit: ImageFit.Cover, border: { radius: 20 }, } build() { Column() { // 2. Display image using V2 component ImageKnifeComponentV2({ imageKnifeOption: this.option, }).width(200).height(200) } } } ``` -------------------------------- ### Custom Build Command for Installation Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/CMakeLists.txt Defines custom commands to copy include directories and libraries to an installation path when IMAGEKNIFEC_ENABLE_INSTALL is set. ```cmake if (IMAGEKNIFEC_ENABLE_INSTALL) set(IMAGEKNIFEC_INSTALL_PATH "${CMAKE_SOURCE_DIR}/../../../") add_custom_command(TARGET imageknifepro POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/include ${IMAGEKNIFEC_INSTALL_PATH}/include) if (IMAGEKNIFE_USING_LIBAVIF) add_custom_command(TARGET imageknifepro POST_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${IMAGEKNIFEC_INSTALL_PATH}/libs/${OHOS_ARCH} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/thirdparty/libavif/${OHOS_ARCH}/lib/libavif.so.16 ${IMAGEKNIFEC_INSTALL_PATH}/libs/${OHOS_ARCH}/libavif.so.16 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_SOURCE_DIR}/thirdparty/libyuv/${OHOS_ARCH}/lib/libyuv.so ${IMAGEKNIFEC_INSTALL_PATH}/libs/${OHOS_ARCH}/libyuv.so) endif() endif() ``` -------------------------------- ### ImageKnifeViewV2 Example Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/README.md Shows how to use ImageKnifeViewV2 with image loading options. ```typescript import { ImageKnifeViewV2, ImageKnifeOptionV2, ImageKnife } from '@ohos/imageknifepro' @Entry @ComponentV2 struct ViewV2Example { // 1. Define image loading options as a single @Local option object @Local option: ImageKnifeOptionV2 = { loadSrc: 'https://www.example.com/example.png', placeholderSrc: $r('app.media.loading'), errorSrc: $r('app.media.error'), } build() { Column() { ImageKnifeViewV2({ imageKnifeOption: this.option, }).width(200).height(200) } } } ``` -------------------------------- ### Install ImageKnifepro using ohpm Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/README.md Install the ImageKnifepro library using the OpenHarmony package manager (ohpm). ```bash ohpm install @ohos/imageknifepro ``` -------------------------------- ### AnimatorOption::onStart Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Callback triggered when the animation starts. ```cpp std::function onStart = nullptr; ``` -------------------------------- ### Initialize ImageKnifePro and Create Default Loader Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/README.md C++ code example demonstrating how to initialize the ImageKnifePro instance and create a default image loader. This is necessary if the napi init function is not called automatically. ```cpp // initialize. ImageKnifePro::ImageKnife::GetInstance().Init(); // create default loader and setup for global usage. auto imageLoader = ImageKnifePro::ImageKnifeLoader::CreateDefaultImageLoader(); ImageKnifePro::ImageKnife::GetInstance().SetDefaultImageKnifeLoader(imageLoader); ``` -------------------------------- ### Install ohpm HAR Dependency Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/README.md Install the ohpm HAR dependency for ImageKnifePro in the entry directory. ```shell cd entry ohpm install @ohos/imageknifepro ``` -------------------------------- ### Configure Build Options for ImageKnifePro Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/README.md Example of build options configuration in build-profile.json5, specifying external native options like CMakeLists.txt path, arguments, and ABI filters. This snippet shows how to disable AVIF support. ```json { "buildOption": { "externalNativeOptions": { "path": "./src/main/cpp/CMakeLists.txt", "arguments": "-DUSING_ON_AREA_CHANGE_EVENT=ON -DIMAGEKNIFE_USING_LIBAVIF=OFF", "cppFlags": "", "abiFilters": ["arm64-v8a", "x86_64"] } } } ``` -------------------------------- ### START Position Enum Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Represents the start of the responsibility chain. ```cpp START; ``` -------------------------------- ### TimeInfo: diskCheckStartTime field Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md The timestamp indicating when the file cache read operation started. ```cpp uint64_t diskCheckStartTime = 0; ``` -------------------------------- ### Initialize ImageKnifePro with File Caching Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/README.md Initialize ImageKnifePro in your Ability's onCreate method to enable file caching and optimize performance. This example sets up file cache limits and optionally adjusts memory cache and concurrent request limits. ```typescript import { CacheStrategy, ImageKnife } from '@ohos/imageknifepro'; export default class EntryAbility extends UIAbility { onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { // Initialize file cache: (context, max items, max size in bytes) ImageKnife.getInstance().initFileCache(this.context, 256, 256 * 1024 * 1024); // Optional: adjust memory cache limits (strategy, max items, max bytes) ImageKnife.getInstance().setCacheLimit(CacheStrategy.MEMORY, 256, 64 * 1024 * 1024); // Optional: set max concurrent requests ImageKnife.getInstance().setMaxRequests(9); } } ``` -------------------------------- ### TimeInfo: requestStartTime field Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Time when the request starts loading. The difference between this and executeTime indicates queuing time. For merged requests, this may be later than loading/decoding time if results were reused. ```cpp uint64_t requestStartTime = 0; ``` -------------------------------- ### CreateDefaultImageLoader Static Method Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Creates a default ImageKnifeLoader with pre-configured interceptors. This is a convenient way to get a fully functional loader. ```cpp static std::shared_ptr CreateDefaultImageLoader(); ``` -------------------------------- ### Custom Cache Key Generator Implementation Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/README.md Inherit from CacheKeyGenerator and implement GenerateFileKey and GenerateMemoryKey for custom cache key logic. This example provides a basic implementation for both file and memory keys. ```cpp class MyCacheKeyGenerator : public CacheKeyGenerator { public: std::string GenerateFileKey(const ImageSource *imageData, const std::string &signature = "") override { // Implement custom file key generation; the following is a simple example std::string fileKey; imageSrc->GetString(fileKey); fileKey += signature; return Md5String(fileKey); } std::string GenerateMemoryKey(MemoryKeyParams &memoryKeyParams) override { // Implement custom memory key generation; the following is a simple example std::string memoryKey; memoryKeyParams.imageSource->GetString(memoryKey); memoryKey += memoryKeyParams.transformationInfo + memoryKeyParams.downSamplingInfo + memoryKeyParams.signature; return memoryKey; } }; ``` -------------------------------- ### Pre-create ImageKnifeComponent Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/README.md Pre-creates and starts loading an ImageKnifeComponent with specified image content and transformations. Use a unique customId to link it for later binding. ```typescript // Pre-create a component with specified image content ImageKnife.getInstance().preCreateImageKnifeComponent("customId_1", { loadSrc: "http://www.example.com/exampleJpg", transformationOption: { type: TransformationType.GRAY_SCALE }, }) ``` -------------------------------- ### Custom File Type Parser Implementation Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/README.md Inherit from FileTypeParser and implement ParseFileTypeInfo to identify and extract information for custom file formats. This example checks for a custom format and sets basic file type information. ```cpp class MyFileTypeParser : public FileTypeParser { public: std::shared_ptr ParseFileTypeInfo(uint8_t *buffer, uint32_t length, std::shared_ptr imageSource) override { // Determine if the buffer's format matches the custom format and extract related info like dimensions and frame count std::string fileType = GetFileType(buffer, length); if (fileType.empty()) { // If the file is not in the custom format (i.e., it's a standard format), return nullptr to let the default parser handle it return nullptr; } // Return the file type information auto fileTypeInfo = std::make_shared(); fileTypeInfo->format = ImageFormat::CUSTOM_FORMAT; fileTypeInfo->customFormat = fileType; // Other file information example; set according to actual parsing results fileTypeInfo->frameCount = 22; fileTypeInfo->width = 200; fileTypeInfo->height = 200; return fileTypeInfo; } }; ``` -------------------------------- ### ImageKnifeNode::Execute() Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Based on the state settings, begins component measurement and image loading. Subsequent calls will be ignored if there are no changes in requests. ```APIDOC ## ImageKnifeNode::Execute() ### Description Based on the state settings, begins component measurement and image loading. Subsequent calls will be ignored if there are no changes in requests. ### Method virtual void Execute() ### Response #### Success Response No value is returned. ``` -------------------------------- ### Configure and Use Custom Loaders Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/README.md Shows how to create multiple ImageKnifeLoader instances, set a default loader, and use a specific loader for an image via ImageKnifeOption. It also covers registering a loader by name for ArkTS usage. ```cpp auto loader1 = ImageKnifePro::ImageKnifeLoader::CreateDefaultImageLoader(); auto loader2 = ImageKnifePro::ImageKnifeLoader::CreateDefaultImageLoader(); // Set the created loader as the global default loader to override the initial configuration. This loader will be applied globally. ImageKnifePro::ImageKnife::GetInstance().SetDefaultImageKnifeLoader(loader1); auto option = std::make_shared(); option->loadSrc.SetString("https://www.openharmony.cn/_nuxt/img/logo.dcf95b3.png"); // Use ImageKnifeOption to specify a specific loader to load images. option->imageKnifeLoader = loader2; auto imageNode = ImageKnifePro::ImageKnifeNode::CreateImageKnifeNode(option); imageNode->Execute(); // Register the loader so that ImageKnifeOption on ArkTS can select a specific loader by string name. ImageKnifePro::ImageKnife::GetInstance().RegisterLoader("loader2", loader2); ``` -------------------------------- ### Enable BiSheng Compiler for Optimization Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/README.md Configuration snippet for build-profile.json5 to enable the BiSheng native compiler. This enables O3-level optimization for smaller binary size and improved performance. ```json { "products": [ { "buildOption": { "strictMode": { "caseSensitiveCheck": true }, "nativeCompiler": "BiSheng" } } ] } ``` -------------------------------- ### Get Image Height Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Obtains the original height of the cached image from ImageDataCache. ```cpp virtual uint32_t GetImageHeight() const = 0; ``` -------------------------------- ### Get Image Width Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Obtains the original width of the cached image from ImageDataCache. ```cpp virtual uint32_t GetImageWidth() const = 0; ``` -------------------------------- ### Global Custom DNS Configuration Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/README.md Configure global static and dynamic DNS settings. Dynamic DNS takes precedence if both are set. Recommended to configure during the Ability's `onCreate` phase. ```APIDOC ## Global Custom DNS Configuration ### Description Supports global static and dynamic DNS settings. If both are configured, dynamic DNS takes precedence. Recommended to configure once during the Ability’s `onCreate` phase. ### Methods 1. **`setGlobalDnsOption(options: { staticDnsRule: Array<{ host: string, port: number, ipAddresses: Array }> })`** - Sets global static DNS rules. 2. **`setGlobalDynamicDns(callback: (host: string, port: number) => Promise>, timeout: number)`** - Sets a dynamic DNS callback function and a timeout in seconds. If the timeout occurs, normal download proceeds. ``` -------------------------------- ### Get Frame Count Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Obtains the total number of image frames from ImageData. ```cpp uint32_t GetFrameCount() const; ``` -------------------------------- ### Get Single-Frame Pixelmap Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Obtains the PixelMap address of a single frame from ImageData. ```cpp OH_PixelmapNative *GetPixelmap() const; ``` -------------------------------- ### OnLoadCallBack::onLoadStart Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Callback function invoked when the image loading process begins. ```cpp std::function onLoadStart = nullptr; ``` -------------------------------- ### Get ImageKnifeColorFilter Address Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Retrieves the memory address of the ColorFilter property data. ```cpp OH_Drawing_ColorFilter *GetColorFilter() const; ``` -------------------------------- ### AnimatorOption::onStart Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Callback function triggered when the animation begins. ```APIDOC ## AnimatorOption::onStart ### Description Callback triggered when the animation starts. ### Type std::function ``` -------------------------------- ### Status::COMPLETE Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Signifies that the main image has been successfully loaded. ```APIDOC ## Status::COMPLETE ### Description The main image is loaded successfully. ``` -------------------------------- ### TimeInfo: memoryCheckStartTime field Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md The timestamp indicating when the memory cache read operation started. ```cpp uint64_t memoryCheckStartTime = 0; ``` -------------------------------- ### Get ImageKnife Singleton Instance Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Obtains the singleton instance of ImageKnife. This is a static method. ```cpp static ImageKnife &GetInstance(); ``` -------------------------------- ### Use Custom Transformation in C++ Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/README.md Create an ImageKnifeOption, set the load source, assign your custom transformation object to the 'transformation' field, create an ImageKnifeNode, and execute it. ```cpp // 1. Create ImageKnifeOption and set the main image source loadSrc. auto imageKnifeOption = std::make_shared(); imageKnifeOption->loadSrc.SetString("https://www.openharmony.cn/_nuxt/img/logo.dcf95b3.png"); // 2. Construct a custom graphic transformation object and set the options. imageKnifeOption->transformation = std::make_shared(); // 3. Use options to create an image component and start image loading. auto imageKnifeNode = ImageKnifePro::ImageKnifeNode::CreateImageKnifeNode(imageKnifeOption); imageNode->Execute(); // 4. Obtain the original ArkUI_NodeHandle, which should be manually operated to mount the C API image node to the tree. ArkUI_NodeHandle handle = imageKnifeNode->GetHandle(); ``` -------------------------------- ### Get Delay Time List Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Obtains the array of playback durations for each frame in milliseconds from ImageData. ```cpp int *GetDelayTimeList() const; ``` -------------------------------- ### CreateImageKnifeNode Static Method Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Creates an ImageKnifeNode for displaying images. This method must be called on the main thread and requires manual management of component attachment/detachment. ```cpp static std::shared_ptr CreateImageKnifeNode(std::shared_ptr option); ``` -------------------------------- ### Init Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/README.md Initialize ImageKnife. This method should be called before using other ImageKnife APIs. ```APIDOC ## Init ### Description Initialize ImageKnife. This method should be called before using other ImageKnife APIs. ### Method (Implicitly called via the singleton instance) ### Endpoint N/A (Class method) ### Parameters None ### Request Example ```cpp ImageKnife::GetInstance()->Init(); ``` ### Response #### Success Response None (Initialization) #### Error Handling Behavior undefined if called multiple times or before GetInstance(). ``` -------------------------------- ### Get Multi-Frame Pixelmap List Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Obtains the PixelMap array address for an animated image from ImageData. ```cpp OH_PixelmapNative **GetPixelmapList() const; ``` -------------------------------- ### AddDecodeInterceptor Method Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Adds an interceptor to the decoding responsibility chain. The interceptor can be inserted at the start or end of the chain. ```cpp virtual void AddDecodeInterceptor(std::shared_ptr interceptor, Position position = Position::START) = 0; ``` -------------------------------- ### OptionData::GetResource Method Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Obtains data as a resource. Returns true on success, false if the type is incorrect. ```cpp bool GetResource(Resource &result) const; ``` -------------------------------- ### AddFileCacheInterceptor Method Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Adds an interceptor to the file cache responsibility chain. The interceptor can be inserted at the start or end of the chain. ```cpp virtual void AddFileCacheInterceptor(std::shared_ptr interceptor, Position position = Position::START) = 0; ``` -------------------------------- ### CreateImageKnifeNode for Static and Animated Images Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Use this function to create an ImageKnifeNode for displaying images. It supports both static and animated images and must be called on the main thread. Ensure ImageKnifeNode::DisposeNode() is called upon destruction. ```cpp static std::shared_ptr CreateImageKnifeNode(std::string componentId, ArkUI_NodeContentHandle contentSlot, std::shared_ptr option, std::shared_ptr animeOption = nullptr); ``` -------------------------------- ### AddMemoryCacheInterceptor Method Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Adds an interceptor to the memory cache responsibility chain. The interceptor can be inserted at the start or end of the chain. ```cpp virtual void AddMemoryCacheInterceptor(std::shared_ptr interceptor, Position position = Position::START) = 0; ``` -------------------------------- ### Initialize and Update Git Submodules Separately Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/README.md Initialize and update git submodules separately for the ImageKnifePro source dependency. ```shell cd entry/src/main/cpp git clone https://gitcode.com/CPF-ApplicationTPC/imageknifepro.git git submodule update --init # Initialize and update the submodules separately. ``` -------------------------------- ### Get Multiple Transformation Info Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Obtains information about multiple graphic transformations for generating memory cache keys. ```cpp std::string GetTransformInfo(); ``` -------------------------------- ### Construct ImageSource from URL Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Constructs an ImageSource object using a provided network image URL or a local file path. ```cpp explicit ImageSource(std::string url); ``` -------------------------------- ### Get Transformation Info Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Obtains transformation information for generating memory cache keys. Must be unique for each transformation. ```cpp virtual std::string GetTransformInfo() = 0; ``` -------------------------------- ### Initialize Small End File Cache Asynchronously Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Initializes the small end file cache asynchronously. Allows setting the maximum number of image entries and maximum disk usage. ```cpp virtual std::shared_future InitSmallEndFileCache(std::string cacheName, size_t maxSize = 128, size_t maxDiskUsage = 128 * 1024 * 1024) = 0; ``` -------------------------------- ### Get Image Format Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Obtains the original format of cached images (e.g., PNG, JPG, WebP) from ImageDataCache. ```cpp virtual ImageFormat GetImageFormat() const = 0; ``` -------------------------------- ### Configure CMakeLists.txt for Source Dependency Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/README.md Add the ImageKnifePro source dependency to your CMakeLists.txt file. ```cmake add_subdirectory(image-knife-pro) target_link_libraries(hello PUBLIC imageknifepro) ``` -------------------------------- ### Get Cache Limit Size Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/README.md Retrieves the maximum size configured for the cache. An optional cache type can be specified. ```APIDOC ## Get Cache Limit Size ### Description Obtains the maximum size of the cache. ### Method `getCacheLimitSize(cacheType?: CacheStrategy)` `GetCacheLimitSize(cacheStrategy: CacheStrategy)` ### Parameters - **cacheType** (CacheStrategy, optional) - The type of cache to query. If not provided, it might default to a general cache limit. ### Notes This operation is consistent across different overloads. ``` -------------------------------- ### Initialize ImageKnife Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Initializes ImageKnife. Must be called on the main thread. Call manually if the NAPI layer is not used. ```cpp virtual void Init() = 0; ``` -------------------------------- ### Apply Multiple Graphic Transformations Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/README.md Illustrates how to apply multiple graphic transformations (e.g., BRIGHTEN, BLUR, INVERT) in a specified sequence using MultiTransformation. The order in the MultiTransformation constructor determines the execution order. ```cpp // 1. Create ImageKnifeOption and set the main image source loadSrc. auto imageKnifeOption = std::make_shared(); imageKnifeOption->loadSrc.SetString("https://www.openharmony.cn/_nuxt/img/logo.dcf95b3.png"); // 2. Construct multiple graphic transformation objects. auto transOption = std::make_shared(); transOption->type = TransformationType::BRIGHTEN; // Select the brightening effect. transOption->f32 = {0.20}; // Set the brightness. auto brighten = TransformationFactory::CreateTransformation(transOption); transOption->type = TransformationType::BLUR; // Select the blur effect. transOption->f32 = {12, 0.003, 0.003}; // Set the blur parameters. auto blur = TransformationFactory::CreateTransformation(transOption); transOption->type = TransformationType::INVERT; // Select the invert effect. transOption->f32 = {}; // No parameter is required for the invert effect. auto invert = TransformationFactory::CreateTransformation(transOption); // 3. Construct MultiTransformation and set the execution sequence according to the array order of graphic transformation objects. imageKnifeOption->multiTransformation = std::make_shared({invert, brighten, blur}); // 4. Use options to create an image component and start image loading. auto imageNode = ImageKnifePro::ImageKnifeNode::CreateImageKnifeNode(option); imageNode->Execute(); // 5. Obtain the original ArkUI_NodeHandle, which should be manually operated to mount the C API image node to the tree. ArkUI_NodeHandle handle = imageKnifeNode->GetHandle(); ``` -------------------------------- ### Get Image Cache Size Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Obtains the memory size of the cached image from ImageDataCache. For animated images, this is the total size of all frames. ```cpp virtual uint32_t GetImageCacheSize() const = 0; ``` -------------------------------- ### ImageKnifeComponent Pre-creation and Binding Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/README.md Demonstrates how to pre-create an ImageKnifeComponent with specific image content and then bind it in a target page using a matching customId. ```APIDOC ## ImageKnifeComponent Pre-creation and Binding ### Description Pre-creates an `ImageKnifeComponent` instance ahead of time to reduce perceived load time when navigating to a page. The pre-created component is identified by a `customId` and behaves like a regular component once bound. ### Pre-creation Code Example ```typescript // Pre-create a component with specified image content ImageKnife.getInstance().preCreateImageKnifeComponent("customId_1", { loadSrc: "http://www.example.com/exampleJpg", transformationOption: { type: TransformationType.GRAY_SCALE }, }) ``` ### Target Page Binding Code Example ```typescript import { ImageKnifeComponent, ImageKnifeOption } from '@ohos/imageknifepro' @Entry @Component struct TestPage { @State imageKnifeOption: ImageKnifeOption = { loadSrc: "http://www.example.com/exampleJpg", transformationOption: { type: TransformationType.GRAY_SCALE }, } build() { Column() { ImageKnifeComponent({ imageKnifeOption: this.imageKnifeOption, customId: "customId_1" // Must match pre-created component's ID }).width(200).height(200) } } } ``` ``` -------------------------------- ### Get Image from Cache Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/README.md Retrieves image data from either the memory or file cache. Allows specifying cache strategy and signature. ```APIDOC ## Get Image from Cache ### Description Obtains image data from the memory or file cache. ### Method `getCacheImage(loadSrc: string, cacheType: CacheStrategy = CacheStrategy.Default, signature?: string, animator: boolean = false)` `GetCacheImage(loadSrc: std::string, cacheType: CacheStrategy = CacheStrategy::DEFAULT, signature: std::string = "", animator: bool = false)` ### Parameters - **loadSrc** (string) - The source identifier for the image. - **cacheType** (CacheStrategy, optional) - The type of cache to use. Defaults to `CacheStrategy.Default`. - **signature** (string, optional) - An optional signature for cache lookup. Defaults to an empty string. - **animator** (boolean, optional) - Flag to indicate if the image is for an animator. Defaults to false. ### Returns `std::shared_future>` - A future that resolves to the image data. ### Notes This operation is consistent across different overloads. ``` -------------------------------- ### Context::config Property Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Configuration object parsed from ArkTS-side Context.config, containing settings like dark mode and screen orientation. ```cpp ResourceManager_Configuration *config = nullptr; ``` -------------------------------- ### TimeInfo: executeTime field Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Time when a request is created and starts processing. For merged requests, this may be later than loading/decoding time if results were reused. ```cpp uint64_t executeTime = 0; ``` -------------------------------- ### Configure Global Static and Dynamic DNS Rules Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/README.md Set static DNS rules for specific hosts and ports, and configure a dynamic DNS callback function. Dynamic DNS takes precedence if both are set. The dynamic DNS callback has a configurable timeout. ```typescript // Set global static DNS rules ImageKnife.getInstance().setGlobalDnsOption({ staticDnsRule: [ { host: "www.example.com", port: 80, ipAddresses: ["192.168.1.254", "192.189.7.3"] }, { host: "www.test.com", port: 80, ipAddresses: ["192.168.88.24"] }, ] }) // Dynamic DNS callback: return IP list based on custom logic function dynamicDnsCallback(host: string, port: number): Promise> { return new Promise>((resolve) => { let arr: Array = [] if (host == "www.example.com") { arr.push("192.168.98.77") arr.push("192.168.198.27") } else { arr.push("192.168.19.22") } resolve(arr); }); } // Set global dynamic DNS with timeout (in seconds); if timeout, proceed with normal download ImageKnife.getInstance().setGlobalDynamicDns(dynamicDnsCallback, 60) ``` -------------------------------- ### Project and Library Definition Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/thirdparty/boundscheck/CMakeLists.txt Defines the project name and adds source files to create a static library named 'boundscheck'. It specifies the source file paths and include directories. ```cmake project(boundscheck) set(TAGET_BOUNDSCHECK_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR}/third_party_bounds_checking_function/src) add_library(boundscheck STATIC ${TAGET_BOUNDSCHECK_SRC_PATH}/memcpy_s.c ${TAGET_BOUNDSCHECK_SRC_PATH}/memset_s.c ${TAGET_BOUNDSCHECK_SRC_PATH}/strcpy_s.c ${TAGET_BOUNDSCHECK_SRC_PATH}/securecutil.c) include_directories(${TAGET_BOUNDSCHECK_SRC_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/third_party_bounds_checking_function/include ) target_link_libraries(boundscheck) ``` -------------------------------- ### ImageKnifeTask::GetDecodeImageSource Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Gets the image source object for decoding. This object is created by FileTypeParser::CreateDecodeImageSource and must be cast to its corresponding subclass for use. ```APIDOC ## ImageKnifeTask::GetDecodeImageSource() ### Description Gets the image source object for decoding. This object is created by FileTypeParser::CreateDecodeImageSource and must be cast to its corresponding subclass for use. ### Return Value - Returns the image source object for decoding. - If FileTypeParser::ParseFileTypeInfo returns nullptr or the file format is Unknown, the return value may be nullptr or an invalid object. ``` -------------------------------- ### ImageKnifeTask::GetDecodeFrameIndex Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Gets the index of the currently specified frame for decoding. The specified frame is determined according to the current decoding mode state. ```APIDOC ## ImageKnifeTask::GetDecodeFrameIndex() ### Description Gets the index of the currently specified frame for decoding. The specified frame is determined according to the current decoding mode state. ### Return Value - Returns the index. - For static images, returns 0, representing the first frame of the image. - Returns -1, indicating batch mode decoding, which requires decoding all frames of the image. - For frame-by-frame decoding, returns a specific index greater than or equal to 0. ``` -------------------------------- ### Apply Single Graphic Transformation Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/README.md Demonstrates how to apply a single graphic transformation (e.g., BRIGHTEN) to an image using ImageKnifeOption. Ensure TransformationFactory is used to create the transformation object. ```cpp // 1. Create ImageKnifeOption and set the main image source loadSrc. auto imageKnifeOption = std::make_shared(); imageKnifeOption->loadSrc.SetString("https://www.openharmony.cn/_nuxt/img/logo.dcf95b3.png"); // 2. Construct a single graphic transformation object and set the options. auto transOption = std::make_shared(); transOption->type = TransformationType::BRIGHTEN; // Select the brightening effect. transOption->f32 = {0.20}; // Set the brightness. imageKnifeOption->transformation = TransformationFactory::CreateTransformation(transOption); // 3. Use options to create an image component and start image loading. auto imageNode = ImageKnifePro::ImageKnifeNode::CreateImageKnifeNode(option); imageNode->Execute(); // 4. Obtain the original ArkUI_NodeHandle, which should be manually operated to mount the C API image node to the tree. ArkUI_NodeHandle handle = imageKnifeNode->GetHandle(); ``` -------------------------------- ### ImageKnifeNode::CreateImageKnifeNode Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Creates an ImageKnifeNode for displaying images, supporting both static and animated images. Requires manual UI tree management and main thread invocation. ```APIDOC ## ImageKnifeNode::CreateImageKnifeNode ### Description Creates an ImageKnifeNode for displaying images. Supports both static images and animated images. You must manually manage the component's attachment and detachment from the UI tree. Can only be called on the main thread, and ImageKnifeNode::DisposeNode() must be called when destroying the component. ### Signature ```cpp static std::shared_ptr CreateImageKnifeNode(std::shared_ptr option); ``` ### Parameters #### Parameters - **option** (std::shared_ptr) - Description: Image loading option, including parameters such as the image source. ``` -------------------------------- ### Get Current Cache Size Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Obtains the used space of the disk or memory. This API is valid only for the default file cache and memory cache. ```cpp virtual int64_t GetCurrentCacheSize(CacheStrategy cacheStrategy, std::string cacheName = "") = 0; ``` -------------------------------- ### Get Cache Limit Size Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Obtains the upper limit of the disk or memory cache. This API only applies to the default memory and file cache. ```cpp virtual int64_t GetCacheLimitSize(CacheStrategy cacheStrategy, std::string cacheName = "") = 0; ``` -------------------------------- ### CreateEmptyImageLoader Static Method Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Creates an ImageKnifeLoader with no pre-configured interceptors. You must manually add interceptors for it to function. ```cpp static std::shared_ptr CreateEmptyImageLoader(); ``` -------------------------------- ### LoadInterceptor::OnComplete Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Completion callback for detached download tasks, essential for resuming tasks after download. ```APIDOC ## LoadInterceptor::OnComplete(std::shared_ptr task, bool result) ### Description Completion callback for detached download tasks. After using the Detach interface, this method must be called upon download completion; otherwise, subsequent processes such as decoding will not proceed. ### Parameters #### Path Parameters - **task** (std::shared_ptr) - Description: The image loading task object. - **result** (bool) - Description: The result of the download, either success or failure. ``` -------------------------------- ### Get Cache Limits (Size in Bytes) Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/README.md Retrieves the maximum size (in bytes) allowed for memory or file cache. Use CacheStrategy.MEMORY or CacheStrategy.FILE. ```typescript // Get max memory usage (in bytes) for memory cache let memorySize = ImageKnife.getInstance().getCacheLimitSize(CacheStrategy.MEMORY) // Get max disk usage (in bytes) for file cache let fileSize = ImageKnife.getInstance().getCacheLimitSize(CacheStrategy.FILE) ``` -------------------------------- ### Project Directory Structure Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/README.md Overview of the project's directory structure, detailing modules for testing, library components, and shared resources. ```markdown imageknifepro/ ├── entry/ // Test module, provides examples and test cases │ ├── src/ │ │ ├── main/ │ │ │ ├── cpp/ // C interface testing related code │ │ │ ├── ets/ // ImageKnifePro ArkTs demo pages │ │ │ └── resource/ // Local image resources for testing │ │ └── ohosTest/ets/test/ // XTS test cases │ ├── build-profile.json5 │ └── oh-package.json5 // Test module dependency description ├── library/ // ImageKnifePro HAR package module │ ├── src/main/ │ │ ├── cpp/ // ImageKnifePro code directory │ │ │ ├── include/ // C interfaces provided by ImageKnifePro │ │ │ ├── thirdparty/ │ │ │ ├── README.md │ │ │ └── README_zh.md // C interface usage instructions │ │ └── ets/ // ArkTs interfaces provided by ImageKnifePro │ ├── build-profile.json5 │ └── oh-package.json5 ├── sharedlibrary/ // Used only to verify cross-module image reading; this module itself is empty │ ├── src/main/resource/ // Local image resources for testing │ ├── build-profile.json5 │ └── oh-package.json5 ├── CHANGELOG.md ├── LICENSE ├── README.md ├── README_zh.md └── README.OpenSource ``` -------------------------------- ### Get Cache Limits (Number of Images) Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/README.md Retrieves the maximum number of images allowed in memory or file cache. Use CacheStrategy.MEMORY or CacheStrategy.FILE. ```typescript // Get max number of images allowed in memory cache let memoryNum = ImageKnife.getInstance().getCacheLimitNum(CacheStrategy.MEMORY) // Get max number of images allowed in file cache let fileNum = ImageKnife.getInstance().getCacheLimitNum(CacheStrategy.FILE) ``` -------------------------------- ### Get Current Cache Usage (Size in Bytes) Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/README.md Retrieves the current size (in bytes) used by memory or file cache. Use CacheStrategy.MEMORY or CacheStrategy.FILE. ```typescript // Get current memory usage (in bytes) let currentMemorySize = ImageKnife.getInstance().getCurrentCacheSize(CacheStrategy.MEMORY) // Get current disk usage (in bytes) let currentFileSize = ImageKnife.getInstance().getCurrentCacheSize(CacheStrategy.FILE) ``` -------------------------------- ### Initialize ImageKnife ArkTS API Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Initializes the ImageKnife ArkTS API. This function must be called once to enable the ArkTS API. ```cpp virtual void InitImageKnifeArkTs(napi_env env, napi_value &exports) = 0; ``` -------------------------------- ### ImageKnife::Init Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Initializes ImageKnife. Must be called on the main thread. Called automatically by default, but if the ImageKnife NAPI layer is not used and the module's napi_init has not been invoked, this function must be manually called to perform initialization. ```APIDOC ## ImageKnife::Init() ### Description Initializes ImageKnife. Must be called on the main thread. Called automatically by default, but if the ImageKnife NAPI layer is not used and the module's napi_init has not been invoked, this function must be manually called to perform initialization. ### Parameters N/A ### Return Value None. ``` -------------------------------- ### Get Current Cache Usage (Number of Images) Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/README.md Retrieves the current number of images stored in memory or file cache. Use CacheStrategy.MEMORY or CacheStrategy.FILE. ```typescript // Get current number of images in memory cache let currentMemoryNum = ImageKnife.getInstance().getCurrentCacheNum(CacheStrategy.MEMORY) // Get current number of images in file cache let currentFileNum = ImageKnife.getInstance().getCurrentCacheNum(CacheStrategy.FILE) ``` -------------------------------- ### Get Decode Image Source Interface Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Retrieves the image source object for decoding. This object is created by FileTypeParser::CreateDecodeImageSource and may be nullptr if parsing fails. ```cpp virtual std::shared_ptr GetDecodeImageSource() const = 0; ``` -------------------------------- ### Configure CMakeLists.txt for ohpm Dependency Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/README.md Add the ImageKnifePro dependency to your CMakeLists.txt file when using ohpm. ```cmake set(IMAGEKNIFEPRO_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules/@ohos/imageknifepro) # Set the imageknifepro root path. set(CMAKE_MODULE_PATH ${IMAGEKNIFEPRO_ROOT_PATH}) find_package(ImageKnifePro REQUIRED) ... target_link_libraries(hello PUBLIC Imageknifepro::libimageknifepro) # link binary dependency and header file. ``` -------------------------------- ### ImageKnife::InitSmallEndFileCache Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Initializes the small end file cache asynchronously. ```APIDOC ## ImageKnife::InitSmallEndFileCache ### Description Initializes the small end file cache. Initialization proceeds asynchronously. ### Method ```cpp virtual std::shared_future InitSmallEndFileCache(std::string cacheName, size_t maxSize = 128, size_t maxDiskUsage = 128 * 1024 * 1024) = 0; ``` ### Return Value Returns an asynchronous future object. ### Parameters #### Parameters - **cacheName** (std::string) - Description: Name of the small end file cache to initialize. - **maxSize** (size_t) - Optional - Description: Sets the maximum number of image entries in the cache. - **maxDiskUsage** (size_t) - Optional - Description: Sets the maximum disk usage in bytes. ``` -------------------------------- ### ImageKnife::GetCacheLimitNum() Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Gets the upper limit on the number of images in file and memory caches. This interface only retrieves the limits for the default memory cache and file cache. ```APIDOC ## ImageKnife::GetCacheLimitNum() ### Description Gets the upper limit on the number of images in file and memory caches. This interface only retrieves the limits for the default memory cache and file cache. ### Method ```cpp virtual int64_t GetCacheLimitNum(CacheStrategy cacheStrategy, std::string cacheName = "") = 0; ``` ### Parameters #### Path Parameters - **cacheStrategy** (CacheStrategy) - Required - Specifies the type to query. CacheStrategy::FILE queries the file cache limit; other enum values query the memory cache limit. - **cacheName** (std::string) - Optional - Name of the file cache to operate on. Default is empty, meaning the operation targets the big end file cache; if not empty, it matches the specified small end file cache. ### Return Value - **int64_t** - The upper limit on the number of images in the file or memory cache. Returns -1 if failed to retrieve the file cache limit. ``` -------------------------------- ### Get Current Cache Number Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Obtains the number of images currently cached in the disk or memory. This API is valid only for the default file cache and memory cache. ```cpp virtual int64_t GetCurrentCacheNum(CacheStrategy cacheStrategy, std::string cacheName = "") = 0; ``` -------------------------------- ### AddLoadInterceptor Method Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Adds an interceptor to the loading responsibility chain, which handles network download and local resource image reading. The interceptor can be inserted at the start or end of the chain. ```cpp virtual void AddLoadInterceptor(std::shared_ptr interceptor, Position position = Position::START) = 0; ``` -------------------------------- ### Construct ImageSource from Resource Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Constructs an ImageSource object using a local resource mapped from ArkTS. ```cpp explicit ImageSource(Resource resource); ``` -------------------------------- ### ImageSource::ImageSource() (default constructor) Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Constructs an empty image source with an UNDEFINED type. ```APIDOC ## ImageSource::ImageSource() ### Description Constructs an empty image source with type UNDEFINED. ### Returns ImageSource object ``` -------------------------------- ### Get ImageKnifeNode by Component ID Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Retrieves a component object managed by ImageKnife using its unique ID. Components managing their own UI tree cannot be accessed via this interface. ```cpp static std::shared_ptr GetImageKnifeNode(std::string componentId); ``` -------------------------------- ### Get Cache Limit Number Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Retrieves the upper limit on the number of images in file and memory caches. This interface only retrieves limits for the default memory and file caches. ```cpp virtual int64_t GetCacheLimitNum(CacheStrategy cacheStrategy, std::string cacheName = "") = 0; ``` -------------------------------- ### OptionData::GetString Method Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Obtains data as a string. Returns true on success, false if the type is incorrect. ```cpp bool GetString(std::string &result) const; ``` -------------------------------- ### Execute Component Measurement and Image Loading Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/library/src/main/cpp/interfaces.md Initiates component measurement and image loading based on current state settings. Subsequent calls are ignored if no changes in requests are detected. ```cpp virtual void Execute() = 0; ``` -------------------------------- ### Get Named File Cache Limits (Size in Bytes) Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/README.md Retrieves the maximum disk usage (in bytes) for a specific named file cache. Requires specifying the cache name. ```typescript // Get max disk usage (bytes) for the "small end" file cache let fileSize = ImageKnife.getInstance().getCacheLimitSize(CacheStrategy.FILE, "small end") ``` -------------------------------- ### 1.5mb Image Loading Test Results Source: https://github.com/cpf-applicationtpc/imageknifepro/blob/master/README.md Performance metrics for loading 1.5mb images, comparing ImageKnifePro, ImageKnife, and System Image. Includes network downloading, decoding, memory reading, file reading, and total times. ```markdown | Component | NetWork Downloading Time | Image Decoding Time | Memory Reading Time | File Reading Time | Excluding NetWork | Total Time | |---------------|--------------------------|---------------------|---------------------|-------------------|-------------------|-------------------| | ImageKnifePro | 7s981ms341us30ns | 97ms614us501ns | 7us299ns | 21us988ns | 107ms61us | 8s88ms915us924ns | | ImageKnifePro | 7s933ms515us892ns | 99ms117us512ns | 4us817ns | 13us859ns | 110ms19us | 8s43ms694us66ns | | ImageKnife | 7s886ms973us612ns | 97ms932us259ns | 19us159ns | 155us924ns | 157ms99us | 8s44ms961us317ns | | ImageKnife | 8s8ms522us385ns | 102ms407us690ns | 21us930ns | 158us854ns | 158ms4us | 8s166ms921us873ns | | System Image | 8s135ms240us184ns | 105ms608us227ns | - | - | 105ms66us | 8s240ms904us206ns | | System Image | 7s974ms420us482ns | 98ms917us423ns | - | - | 98ms98us | 8s73ms401us97ns | ```