Image resource calling method, device, electronic device and storage medium

By using the access information of the public image resource library in the application software, the problems of large package size and storage space occupation caused by configuring multiple image resource libraries in different software layers are solved, and more efficient resource calling and maintenance are achieved.

CN116842206BActive Publication Date: 2025-10-03HANGZHOU EZVIZ SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310716948.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-06-15
Publication Date
2025-10-03
Estimated Expiration
2043-06-15

AI Technical Summary

Technical Problem

When application software is jointly developed using multiple development technologies, each software layer needs to be configured with a different image resource library, resulting in a large package size and excessive storage space usage.

Method used

The native layer calls the interface provided by the first software layer to obtain access information of the public image resource library, thereby calling image resources in the public resource library, reducing the configuration of image resource libraries in different software layers.

Benefits of technology

It reduces the package size and storage space occupied by application software, and reduces the maintenance difficulty and developer resource investment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116842206B_ABST
    Figure CN116842206B_ABST
Patent Text Reader

Abstract

The embodiments of the present application provide a method, device, electronic device, and storage medium for calling an image resource, and relate to the field of data processing technology, and in particular, to a method, device, electronic device, and storage medium for calling an image resource. The specific implementation scheme is as follows: obtaining identification information of an image resource to be called; if the software layer that needs to call the image resource is not the first software layer, then based on the identification information, calling the image resource information acquisition interface provided by the first software layer through the native layer, obtaining access information of the image resource provided by the first software layer in the public image resource library, the first software layer being a software layer configured with a public image resource library; based on the access information, calling the first image resource acquisition method provided by the native layer, and calling the image resource from the public image resource library. Applying the scheme provided by the embodiments of the present application can reduce the package size of the application software and reduce the storage space occupied.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method, device, electronic device, and storage medium for calling image resources. Background Art

[0002] When developing application software, developers are increasingly using multiple development technologies to jointly develop the same application software. For example, they can use native development technologies of operating systems such as iOS (iPhone Operating System) and Android, Flutter (an open source toolkit for building user interfaces) development technology, and React Native (an open source mobile application development framework) development technology to jointly develop the same application software.

[0003] In this way, there are different software layers in the application software. Different software layers correspond to different development technologies. The software layers include software codes developed using the corresponding technologies. For example, the software layer corresponding to native development technology can be called the native layer, and the software layer corresponding to Flutter development technology can be called the Flutter layer.

[0004] During the running process of application software, it may need to call image resources, and calling image resources may occur at various software layers. To ensure that each software layer can successfully call image resources, a corresponding image resource library is currently configured for each software layer during software development. In this way, when the application software is running, each software layer can call image resources from its corresponding image resource library to complete the image resource call.

[0005] Although the above-mentioned image resource calling method can ensure that image resources are successfully called during the operation of the application software, since the implementation of the above-mentioned image resource calling method requires configuring different image resource libraries for different software layers, this results in a large application software package size and occupies a large storage space. Summary of the Invention

[0006] The purpose of the embodiments of the present application is to provide a method, device, electronic device, and storage medium for calling image resources to solve the problem of large application software packages and large storage space occupation. The specific technical solution is as follows:

[0007] According to one aspect of an embodiment of the present application, a method for calling an image resource is provided, the method comprising:

[0008] Get the identification information of the image resource to be called;

[0009] If the software layer that needs to call the image resource is not the first software layer, then based on the identification information, calling the image resource information acquisition interface provided by the first software layer through the native layer to obtain access information of the image resource provided by the first software layer in the public image resource library, wherein the first software layer is the software layer configured with the public image resource library;

[0010] According to the access information, a first image resource obtaining method provided by the native layer is called to call the image resource from the public image resource library.

[0011] In one embodiment of the present application, if the software layer that needs to call the image resource is not the first software layer, calling the image resource information acquisition interface provided by the first software layer through the native layer to obtain access information of the public image resource library provided by the first software layer includes:

[0012] If the software layer that needs to call the image resource is a software layer other than the native layer and the first software layer, calling the bridge code in the other software layer to establish a bridge between the other software layer and the native layer, and calling the image resource information acquisition interface provided by the first software layer in the bridge to obtain access information of the public image resource library provided by the first software layer;

[0013] The calling, according to the access information, a first image resource obtaining method provided by the native layer, and calling the image resource from the public image resource library includes:

[0014] According to the access information, a first image resource obtaining method provided by the native layer is called in the bridge to call the image resource from the public image resource library.

[0015] In one embodiment of the present application, based on the identification information, calling the image resource information acquisition interface provided by the first software layer through the native layer to obtain access information of the image resource provided by the first software layer in the public image resource library includes:

[0016] Based on the identification information, the native layer calls the picture resource information acquisition interface provided by the first software layer to obtain the access information of the picture resource identifiable by the native layer in the public picture resource library, wherein the access information is obtained by the first software layer converting the storage path of the picture resource in the public picture resource library based on the operating system corresponding to the native layer.

[0017] In one embodiment of the present application, the access information includes at least one of the following information:

[0018] The path of the image resource in the operating system;

[0019] The path of the image resource in the public image resource library;

[0020] The file descriptor of the image resource.

[0021] In one embodiment of the present application, the public image resource library stores multi-scale image resources of image resources;

[0022] The calling of the picture resource from the public picture resource library includes:

[0023] Get the current display magnification of the display;

[0024] Selecting the picture resource closest to the current display magnification from the public picture resource library;

[0025] Call the image resource.

[0026] In one embodiment of the present application, the method further includes:

[0027] If the software layer that needs to call the image resource is the first software layer, the image resource is called from the public image resource library according to the identification information.

[0028] In one embodiment of the present application, calling the image resource from the public image resource library according to the identification information includes:

[0029] Based on the identification information, the picture display component of the picture resource is called to call the picture resource, wherein the picture display component is generated in the following manner: based on the identification information, searching for a path of the picture resource from the public picture resource library; based on the search result, obtaining a storage path of the picture resource in the public picture resource library; and based on the storage path, generating the picture display component of the picture resource;

[0030] or,

[0031] Based on the identification information, a storage path of the picture resource in the public picture resource library is obtained; based on the storage path, a picture display component of the picture resource is generated; and the picture display component is called to call the picture resource.

[0032] In one embodiment of the present application, the picture resources in the public picture resource library are: picture resources obtained from a picture resource database;

[0033] The image resources in the image resource database are updated in the following manner:

[0034] After the management device detects that the image resources in the resource update library are updated, it triggers the component packaging machine deployed by the management device to package the updated image resources, generate a packaging result of the updated image resources, and upload the packaging result to the image resource database.

[0035] In one embodiment of the present application, the method further includes:

[0036] According to the identifier of the image resource to be obtained, the first software layer calls a second image resource obtaining method provided by the native layer to obtain the image resource to be obtained from a native image resource library, wherein the native image resource library is an image resource library configured by the native layer;

[0037] The obtained image resources are stored in the public image resource library through the first software layer.

[0038] According to another aspect of an embodiment of the present application, a device for calling a picture resource is provided, the device comprising:

[0039] An identification information obtaining module is used to obtain the identification information of the image resource to be called;

[0040] an access information obtaining module for, when the software layer requiring the image resource to be called is not the first software layer, invoking, through the native layer, an image resource information obtaining interface provided by the first software layer based on the identification information, to obtain access information of the image resource in a public image resource library provided by the first software layer, wherein the first software layer is the software layer configured with the public image resource library;

[0041] The first image resource calling module is used to call the first image resource obtaining method provided by the native layer according to the access information, and call the image resource from the public image resource library.

[0042] In one embodiment of the present application, the access information obtaining module is specifically configured to, when the software layer that needs to call the image resource is a software layer other than the native layer and the first software layer, call the bridging code in the other software layer to establish a bridge between the other software layer and the native layer, and call the image resource information obtaining interface provided by the first software layer in the bridge to obtain access information of the public image resource library provided by the first software layer;

[0043] The first image resource calling module is specifically configured to call the first image resource obtaining method provided by the native layer in the bridge according to the access information, and call the image resource from the public image resource library.

[0044] In one embodiment of the present application, the access information acquisition module is specifically used to call the image resource information acquisition interface provided by the first software layer through the native layer based on the identification information, to obtain the access information of the image resource identifiable by the native layer in the public image resource library, wherein the access information is obtained by the first software layer converting the storage path of the image resource in the public image resource library based on the operating system corresponding to the native layer.

[0045] In one embodiment of the present application, the access information includes at least one of the following information:

[0046] The path of the image resource in the operating system;

[0047] The path of the image resource in the public image resource library;

[0048] The file descriptor of the image resource.

[0049] In one embodiment of the present application, the public image resource library stores multi-scale image resources of image resources;

[0050] The first image resource calling module is specifically used to obtain the current display magnification of the display screen; select the image resource closest to the current display magnification from the public image resource library; and call the image resource.

[0051] In one embodiment of the present application, the device further comprises:

[0052] The second image resource calling module is configured to call the image resource from the public image resource library according to the identification information when the software layer that needs to call the image resource is the first software layer.

[0053] In one embodiment of the present application, the second image resource calling module is specifically configured to call the image display component of the image resource according to the identification information to call the image resource, wherein the image display component is generated in the following manner: based on the identification information, searching for the path of the image resource from the public image resource library; obtaining the storage path of the image resource in the public image resource library based on the search result; and generating the image display component of the image resource based on the storage path;

[0054] or,

[0055] Based on the identification information, a storage path of the picture resource in the public picture resource library is obtained; based on the storage path, a picture display component of the picture resource is generated; and the picture display component is called to call the picture resource.

[0056] In one embodiment of the present application, the picture resources in the public picture resource library are: picture resources obtained from a picture resource database;

[0057] The image resources in the image resource database are updated in the following manner:

[0058] After the management device detects that the image resources in the resource update library are updated, it triggers the component packaging machine deployed by the management device to package the updated image resources, generate a packaging result of the updated image resources, and upload the packaging result to the image resource database.

[0059] In one embodiment of the present application, the device further comprises:

[0060] The picture resource storage module is used to call the second picture resource acquisition method provided by the native layer through the first software layer according to the identifier of the picture resource to be obtained, and obtain the picture resource to be obtained from the native picture resource library, wherein the native picture resource library is the picture resource library configured by the native layer; through the first software layer, the obtained picture resource is stored in the public picture resource library.

[0061] According to another aspect of the embodiments of the present application, an electronic device is provided, including:

[0062] Memory for storing computer programs;

[0063] The processor is configured to implement any of the steps of the above-mentioned image resource calling method when executing the program stored in the memory.

[0064] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium. When the computer program is executed by a processor, the steps of any of the above-mentioned image resource calling methods are implemented.

[0065] According to another aspect of the embodiments of the present application, a computer program product including instructions is provided, which, when executed on a computer, enables the computer to execute any of the above-mentioned image resource calling methods.

[0066] Beneficial effects of the embodiments of the present application:

[0067] As can be seen from the above, in the solution provided by the embodiment of the present application, when a software layer other than the first software layer calls an image resource, it can obtain the access information of the image resource in the public image resource library through the native layer based on the identification information of the image resource, and then call the image resource from the public resource library based on the access information. In this way, different software layers in the application software can call image resources from the public resource library. Therefore, there is no need to configure different image resource libraries for different software layers, which reduces the number of image resource libraries, thereby reducing the package size of the application software and reducing the occupied storage space.

[0068] Of course, it is not necessary to achieve all the advantages described above at the same time when implementing any product or method of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0069] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other embodiments can also be obtained based on these drawings.

[0070] Figure 1 A flowchart of a method for calling image resources provided in an embodiment of the present application;

[0071] Figure 2 A schematic diagram of a public image resource library provided in an embodiment of the present application;

[0072] Figure 3 A flowchart of another method for calling image resources provided in an embodiment of the present application;

[0073] Figure 4 A signaling diagram for updating image resources provided in an embodiment of the present application;

[0074] Figure 5 A schematic diagram of the calling relationship between various software layers and a public image resource library provided in an embodiment of the present application;

[0075] Figure 6 A schematic diagram of the structure of a device for calling image resources provided in an embodiment of the present application;

[0076] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0077] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field based on this application are within the scope of protection of this application.

[0078] The following describes the background technology of the embodiments of the present application.

[0079] When developing applications, developers are increasingly using multiple development technologies to jointly develop the same application. For example, these technologies can include native development technologies for operating systems such as iOS and Android, Flutter development technology, React Native development technology, Hybrid development technology (a hybrid development technology based on native development technology and HTML (HyperText Markup Language)5), and Weex development technology (a framework for building cross-platform mobile UIs).

[0080] In this way, the application software has different software layers, and different software layers correspond to different development technologies. Corresponding to the development technologies in the above example, for example, the above software layers can be the native layer, Flutter layer, React Native layer, Hybrid layer, and Weex layer, etc.

[0081] Dividing software into multiple layers helps developers better develop and manage application code. This allows for a clearer distinction between different software layers and development technologies, allowing developers to be assigned to different layers. For example, developers familiar with Flutter development can develop and maintain the Flutter layer of an application. Dividing application code into different layers improves code maintainability and flexibility.

[0082] However, there are many differences between the various software layers. For example, different software layers typically use different code languages. For example, the Flutter layer typically uses Dart (a computer programming language), the React Native layer typically uses JavaScript (a computer programming language), the Hybrid layer typically uses HTML, CSS (Cascading Style Sheets), and JavaScript, and the Weex layer typically uses Vue.js (a computer programming language). Furthermore, different software layers typically run in different processes, and different software layers have different compatibility with operating systems.

[0083] During the operation of the application software, each software layer may need to call image resources. Due to the above differences between the various software layers, in order to ensure that each software layer can successfully call image resources, each software layer is configured with a corresponding image resource library. In this way, when each software layer in the application software calls image resources, it can complete the image resource call by calling the image resources from its corresponding image resource library. However, the software package of such application software needs to include multiple image resource libraries, resulting in a large package size and a large amount of storage space occupied. To solve this technical problem, the embodiments of the present application provide a method, device, electronic device and storage medium for calling image resources.

[0084] The following describes the execution subject of the embodiment of the present application.

[0085] The execution subject of the embodiment of the present application can be an application software or a terminal installed with the application software. The various software layers mentioned below are software layers in the application software. Among them, the above-mentioned application software can be an application software developed by mixing native development technology and Flutter development technology based on operating systems such as iOS and Android.

[0086] The following describes in detail the image resource calling method provided in the embodiment of the present application through specific examples.

[0087] In one embodiment of the present application, see Figure 1 , Figure 1 A flowchart of a method for calling an image resource is provided. The method includes the following steps S101-S103.

[0088] Step S101: Obtain identification information of the image resource to be called.

[0089] The identification information of the image resource may be a unique identifier of the image resource, used to distinguish different image resources, such as the name of the image resource, the package name of the image resource, or the ID of the image resource.

[0090] The following describes the method of obtaining identification information in step S101.

[0091] In one scenario, when a user clicks to enter a user interface, the application software can determine the identification information of the image resource to be displayed in the user interface based on the preset image resource information of the user interface. For example, the application software can define an identification information acquisition function, and the user clicking the user interface can trigger the call of the information acquisition function, which then obtains the identification information of the image resource to be displayed.

[0092] Step S102: If the software layer that needs to call the image resource is not the first software layer, based on the identification information, the native layer calls the image resource information acquisition interface provided by the first software layer to obtain the access information of the image resource provided by the first software layer in the public image resource library.

[0093] Among them, the first software layer is a software layer configured with a public image resource library.

[0094] The access information is explained below.

[0095] The access information is information about the image resource, and is used to enable the native layer to determine the information of the image resource to be called based on the access information. Specifically, the access information can be used to locate the storage location of the image resource. The access information may include the unique identifier of the image resource, path information, file length, offset, file type, etc. After the native layer calls the image resource information provided by the first software layer based on the identification information to obtain the interface, the first software layer can determine the information of the image resource represented by the identification information based on the above identification information, and generate access information that can be originally identified based on the above information. In this way, the native layer can call the image resource based on the unique identifier of the image resource.

[0096] For example, the first software layer may be a Flutter layer. In this case, the public image resource library may be an image resource library configured for the Flutter layer.

[0097] The public image resource library is described below.

[0098] The public image resource library is used to store various types of image resources. For example, image resources can be divided into icons, images, and fonts. Specifically, for image resources such as fonts, icons, and images, a fonts folder can be created to store font image resources, an icons folder to store icon image resources, and an images folder to store image image resources. The above three folders can be located in the assets folder of the application software. Here, fonts, icons, images, and assets are folder names.

[0099] The implementation method of obtaining access information in step S102 will be described below and will not be described in detail here.

[0100] Step S103: Based on the access information, the first image resource obtaining method provided by the native layer is called to call image resources from the public image resource library.

[0101] The first image resource acquisition method provided by the native layer can be used to acquire the image resource indicated by the access information according to the access information. Specifically, the image resource acquisition method can be related to the operating system.

[0102] In one case, if the native layer's operating system is iOS, that is, the application runs on iOS, then the application's native layer can use access information as a parameter to call image resources from the public image resource library through mainBundle (a resource call method in iOS). If the application runs on Android, then the application's native layer can use access information as a parameter to call image resources from the public image resource library through the AssetManager API (resource manager interface). In this case, the native layer can directly call image resources using the above method.

[0103] Other implementations of calling the image resource in step S103 will be described below and will not be described in detail here.

[0104] As can be seen from the above, in the solution provided by the embodiment of the present application, when a software layer other than the first software layer calls an image resource, it can obtain the access information of the image resource in the public image resource library through the native layer based on the identification information of the image resource, and then call the image resource from the public resource library based on the access information. In this way, different software layers in the application software can call image resources from the public resource library. Therefore, there is no need to configure different image resource libraries for different software layers, which reduces the number of image resource libraries, thereby reducing the package size of the application software and reducing the occupied storage space.

[0105] This way, different software layers can access image resources from the public image resource library, eliminating the need to configure a separate image resource library for each software layer. This also eliminates the need for developers in each software layer to maintain the image resource library for each software layer, reducing maintenance effort and developer human resources.

[0106] Furthermore, as can be seen above, when the first software layer is the Flutter layer, the hybrid development characteristics of Flutter technology can be utilized to enable the aforementioned image resource call method to be used in both iOS and Android systems. This allows iOS and Android systems to share a common image resource library, eliminating the need for separate maintenance for iOS and Android. This reduces maintenance complexity and reduces developer human resources.

[0107] An implementation of obtaining access information in step S102 is described below.

[0108] In one embodiment of the present application, based on the identification information, the native layer calls the picture resource information acquisition interface provided by the first software layer to obtain access information of the picture resources identifiable by the native layer in the public picture resource library.

[0109] The access information is obtained by the first software layer by converting the storage path of the image resource in the public image resource library based on the operating system corresponding to the native layer.

[0110] Specifically, the first software layer can provide an interface for obtaining image resource information. For example, if the first software layer is the Flutter layer, a plug-in in the Flutter layer can provide the above-mentioned image resource information acquisition interface, such as "flutterImageWithName:" and "flutterImageWitherName:fromPackage:". After calling these interfaces in the native layer, the above-mentioned access information can be obtained.

[0111] The following describes how to obtain access information in the Flutter layer.

[0112] After calling the above interface in the native layer, in the Flutter layer, the application software can determine the path of the image resource in the public image resource library through the identification information of the image resource, and then the operating system corresponding to the native layer converts the above path to obtain access information.

[0113] Specifically, if the operating system running the application software is iOS, in the Flutter layer, the application software can use the identification information of the image resource as an input parameter, and use the lookupKeyForAsset (a storage path acquisition method) or lookupKeyForAsset:fromPackage: (a storage path acquisition method) of pathForResource:ofType: to obtain the storage path of the image resource indicated by the above identification information in the public image resource library, and then convert the obtained storage path into access information that can be recognized by the iOS system.

[0114] If the operating system running the application software is Android, in the Flutter layer, the application software can use the identification information of the image resource as an input parameter and use the lookupKeyForAsset of PluginRegistry.Registrar (a storage path acquisition method) to obtain the storage path of the image resource indicated by the above identification information in the public image resource library. Then, through the openFd of AssetManager (a method for obtaining access information), the obtained storage path is converted into access information that can be recognized by the Android system.

[0115] For the native layer, access information can be obtained according to an implementation method of obtaining access information in an embodiment of the present application, and the image resource can be directly called according to the method of the above step S103.

[0116] As can be seen from the above, using the first software layer to convert the storage path of the image resource in the public image resource library to obtain access information can enable the access information to accurately represent the storage location of the image resource, and enable the native layer to accurately identify the access information, thereby improving the accuracy of calling the image resource.

[0117] The following describes the information included in the access information.

[0118] The access information includes at least one of the following information: a path of the image resource in the operating system, a path of the image resource in the public image resource library, and a file descriptor of the image resource.

[0119] When the operating system running the application software is Android, the access information may include a file descriptor of the image resource.

[0120] When the operating system running the application software is iOS, the access information may include the path of the image resource in the public image resource library. The path of the image resource in the public image resource library is the path of the image resource relative to the public image resource library, which is the relative path of the image resource.

[0121] In addition, when the operating system running the application software is iOS, Android or other operating systems, the access information may include the path of the image resource in the operating system, that is, the absolute path of the image resource.

[0122] In this way, the native layer can accurately call image resources for various situations when the application software runs on various operating systems.

[0123] Another implementation of obtaining access information in step S102 is described below.

[0124] In another embodiment of the present application, if the software layer that needs to call the image resource is other than the native layer and the first software layer, the bridging code in the other software layer is called to establish a bridge between the other software layer and the native layer, and the image resource information acquisition interface provided by the first software layer is called in the bridge to obtain the access information of the public image resource library provided by the first software layer.

[0125] Bridging code is used to enable data transfer and code calls between other software layers and the native layer. For example, you can use the bridge mechanism provided by React Native development technology to bridge the React Native layer and the native layer. For other software layers, different bridging codes can be used to establish a bridge with the native layer to call image resources.

[0126] Other software layers can call the bridging code in other software layers to call the image resource information acquisition interface provided by the first software layer, thereby obtaining access information to the public image resource library provided by the first software layer. After the other software layers call the bridging code to call the image resource information acquisition interface provided by the first software layer, the first software layer obtains access information in the same manner as the Flutter layer in the above embodiment, and will not be described in detail here.

[0127] In an embodiment of the present application, step S103 can call the image resource in the following manner.

[0128] According to the access information, the first image resource obtaining method provided by the native layer is called in the bridge to call the image resource from the public image resource library.

[0129] In one implementation, the bridge code is called in another software layer, with the access information as an input parameter. The first image resource acquisition method provided by the native layer is invoked to retrieve image resources from the public image resource library. Specifically, the implementation of invoking the first image resource acquisition method provided by the native layer to retrieve image resources from the public image resource library is the same as that of step S103 above and will not be further described here.

[0130] By using bridging code to connect other software layers to the native layer, other software layers can use the native layer to call the image resource information acquisition interface provided by the first software layer to obtain access information to the public image resource library. Furthermore, other software layers can also use the bridging code to call the native layer's image resource acquisition method to obtain images. This eliminates the need for other software layers to configure separate image resource libraries, further reducing the application package size and storage space occupied.

[0131] The following describes an implementation method for calling image resources in another case of step S103.

[0132] In another case, the public image resource library stores multiple-scale image resources. Figure 2 A schematic diagram of a public image resource library is provided. The images folder shown in the figure includes: 2.0× and 3.0× folders, wherein the above-mentioned multi-magnification image resources can be stored in folders of corresponding magnifications according to the magnifications of the image resources. In addition, the icons folder may also include folders such as 2.0× and 3.0× folders, and may even include 4.0× and 5.0×, etc., which is not limited in the embodiments of the present application. The font image resources in the fonts folder can be vector format image resources, and the application software can display the font image resources at any magnification. Therefore, only vector format image resources of fonts can be stored in the fonts folder, and multi-magnification image resources of fonts do not need to be stored.

[0133] Image resources of different categories can be distinguished by their names. For example, image resources can be named in the format of "AAA_BBB". Among them, "AAA" represents the category of the image resource, and "BBB" represents the custom name of the image resource. For example, the image resource is named image_error and placed in the images folder, where "image" indicates that the image resource is an image-type image resource, and "error" is the custom name of the image resource. For another example, the image resource is named icon_left_back and placed in the icons folder, where "icon" indicates that the image resource is an image-type image resource, and "left_back" is the custom name of the image resource. The two words can also be separated by "_" in the custom name.

[0134] Image resources with different magnifications can also be distinguished by name. For example, image resources can be named in the format of "AAA_BBB@C×". The "C" in "C×" represents the magnification of the image resource. For example, "icon_left_back@2×" and "icon_left_back@3×" can be used to distinguish image resources with different magnifications by reading the image name.

[0135] Additionally, image resources of any magnification must be stored in the images, fonts, and icons folders. The magnification factor must not be included in the image resource names. For example, image resources should be named in the format "AAA_BBB." Furthermore, image resource names in the public image resource library must be unique.

[0136] Figure 2The other folders in are only examples and have nothing to do with the content in the embodiments of this application.

[0137] When multiple magnification image resources are stored, the image resources can be called in the following way: obtain the current display magnification of the display screen, select the image resource closest to the current display magnification from the public image resource library, and call the image resource.

[0138] For details, see Figure 3 , Figure 3 A flowchart of another method for calling image resources is provided. The image resource calling method of step S103 above can be implemented through the following steps S301-S306.

[0139] Step S301: Obtain the current display magnification of the display screen.

[0140] The current display magnification may be determined according to the size of the display screen, or may be the current display magnification set by the user.

[0141] Step S302: Determine whether the current display magnification is greater than the default magnification.

[0142] If the judgment is yes, execute step S304; if the judgment is no, execute step S303.

[0143] The default magnification is the smallest magnification among the multi-magnification image resources stored in the public image resource library. For example, if the public image resource library stores image resources with magnifications of 1x, 2x, and 3x, the default magnification is 1x. In step S302, it can be determined whether the current display magnification is greater than 1.

[0144] Step S303: searching for image resources with a default magnification from a public image resource library.

[0145] After executing step S303, execute step S306.

[0146] Step S304: searching for image resources of the current display magnification from the public image resource library.

[0147] If the current display magnification is greater than the default magnification, it means that the default magnification may not be the image resource closest to the current display magnification. Therefore, search for image resources with the current display magnification from the public image resource library.

[0148] If the image resource of the current display magnification can be found, step S306 is executed; if the image resource of the current display magnification cannot be found, step S305 is executed.

[0149] Step S305: Subtract 1 from the current display magnification.

[0150] After executing step S305, execute step S302.

[0151] Step S306: Call the found image resource.

[0152] As can be seen from the above, by searching for the image resource closest to the current display magnification and calling it, the called image resource can be made as clear as possible or adapted to the user's display screen as much as possible, thereby improving the user's experience of using the application software.

[0153] The following describes an implementation method for calling image resources when the software layer that needs to call image resources is the first software layer.

[0154] In one embodiment of the present application, if the software layer that needs to call the image resource is the first software layer, the image resource is called from the public image resource library according to the identification information.

[0155] Since the public image resource library is configured for the first software layer, the first software layer can directly call image resources from the public image resource library according to the identification information, so that the image resources can be called accurately and conveniently.

[0156] The following describes how the first software layer calls image resources.

[0157] In one implementation, based on identification information, a picture display component of a picture resource is called to call the picture resource, wherein the picture display component is generated in the following manner: based on the identification information, the path of the picture resource is searched from a public picture resource library; based on the search result, the storage path of the picture resource in the public picture resource library is obtained; based on the storage path, the picture display component of the picture resource is generated.

[0158] For example, when the first software layer is Flutter, the image display component may be an Image Widget (a type of image display component). The image display component may generate an image display component of an image resource in advance under the storage path of the image resource.

[0159] It can be seen that directly calling the pre-generated image display component can make calling image resources more convenient.

[0160] In another implementation, based on the identification information, the storage path of the image resource in the public image resource library is obtained; based on the storage path, an image display component of the image resource is generated; and the image display component is called to call the image resource.

[0161] For ungenerated image display components, you can generate them based on the storage path when needed. Furthermore, during the generation process, you can customize the properties of the image display component to meet your needs. For example, you can set image properties such as width and height, fill mode, and color blending mode. This improves the operability of calling image resources and enhances customization capabilities.

[0162] In one embodiment of the present application, the picture resources in the public picture resource library are: picture resources obtained from a picture resource database.

[0163] The image resource database can be a database in the version control system of the development side. The public image resource library can obtain image resources from the image resource database of the development side.

[0164] The image resources in the image resource database are updated in the following manner:

[0165] After the management device detects that the image resources in the resource update library are updated, it triggers the component packager deployed by the management device to package the updated image resources, generate a packaging result of the updated image resources, and upload the packaging result to the image resource database.

[0166] The following combination Figure 4 The following describes how to update the above image resources.

[0167] See also Figure 4 , Figure 4 A signaling diagram for image resource updates is provided. For example, a user interface developer might update an image resource in a resource update repository. Upon detecting that the image resource in the resource update repository has been updated, a management device triggers a component packager deployed on the management device to retrieve the updated image resource, generate a packaged result for the updated image resource, and upload the packaged result to the image resource database.

[0168] in addition, Figure 4 Also included: Code library. The component bundler can also upload image resources to the code library for development, debugging, and backup purposes.

[0169] As can be seen from the above, the present disclosure is an embodiment in which multiple software layers can call image resources in the public image resource library. In this way, developers only need to maintain the public image resource library, that is, maintain the resource update library, image resource database, and public image resource library as a set of databases, thereby reducing subsequent maintenance costs. In addition, the public image resource library can be updated automatically, and developers do not need to update manually, which reduces the difficulty of updating the public image resource library. Designers other than developers can also use the solution of the embodiment of this application to update the public image resource library, which can improve development efficiency.

[0170] Since there is no need to update the image resource libraries corresponding to other software layers, the problem of inconsistent image resources caused by new omissions during the update process is reduced, and the problem of inconsistency in image quality, image style, and image size caused by multiple image resource libraries using different formats to save image resources is reduced.

[0171] In one embodiment of the present application, a method for storing image resources of a native layer in a public image resource library is provided: the application software can call a second image resource acquisition method provided by the native layer through a first software layer according to the identifier of the image resource to be obtained, obtain the image resource to be obtained from the native image resource library, and store the obtained image resource in the public image resource library through the first software layer.

[0172] Among them, the native image resource library is the image resource library configured in the native layer.

[0173] For example, when the first software layer is the Flutter layer, the Platform Channel mechanism provided by the Flutter development technology can be used. In the Flutter layer, the getImageFromPlatform: method is called in the native layer through the channel method to obtain image resources in the native image resource library in the native layer.

[0174] See also Figure 5 , Figure 5 A schematic diagram illustrating the calling relationship between various software layers and a public image resource library is provided. In the diagram, the first software layer is configured with a public image resource library, so the public image resource library can be considered the image resource library of the first software layer. The native layer and other software layers need to call image resources from the public image resource library corresponding to the first software layer. Furthermore, the first software layer can also store images stored in the native image resource library in the public image resource library.

[0175] It can be seen that the public image resource library can also store image resources in the native image resource library. In this way, when the image resources in the native image resource library are updated, the public image resource library is updated, enriching the image resources in the public image resource library.

[0176] According to another aspect of the embodiment of the present application, see Figure 6 , Figure 6 A schematic diagram of the structure of a device for calling image resources is provided, the device comprising:

[0177] The identification information obtaining module 601 is used to obtain the identification information of the image resource to be called.

[0178] The access information acquisition module 602 is used to call the picture resource information acquisition interface provided by the first software layer through the native layer based on the identification information when the software layer that needs to call the picture resource is not the first software layer, and obtain the access information of the picture resource provided by the first software layer in the public picture resource library, wherein the first software layer is a software layer configured with a public picture resource library.

[0179] The first image resource calling module 603 is used to call the first image resource obtaining method provided by the native layer according to the access information, and call the image resource from the public image resource library.

[0180] As can be seen from the above, in the solution provided by the embodiment of the present application, when a software layer other than the first software layer calls an image resource, it can obtain the access information of the image resource in the public image resource library through the native layer based on the identification information of the image resource, and then call the image resource from the public resource library based on the access information. In this way, different software layers in the application software can call image resources from the public resource library. Therefore, there is no need to configure different image resource libraries for different software layers, which reduces the number of image resource libraries, thereby reducing the package size of the application software and reducing the occupied storage space.

[0181] In one embodiment of the present application, the access information obtaining module 602 is specifically configured to, when the software layer requiring access to image resources is a software layer other than the native layer and the first software layer, call a bridging code in the other software layer to establish a bridge between the other software layer and the native layer, and, within the bridge, call an image resource information obtaining interface provided by the first software layer to obtain access information of a public image resource library provided by the first software layer.

[0182] The first image resource calling module 603 is specifically configured to call the first image resource obtaining method provided by the native layer in the bridge according to the access information, and call the image resource from the public image resource library.

[0183] By using bridging code to connect other software layers to the native layer, other software layers can use the native layer to call the image resource information acquisition interface provided by the first software layer to obtain access information to the public image resource library. Furthermore, other software layers can also use the bridging code to call the native layer's image resource acquisition method to obtain images. This eliminates the need for other software layers to configure separate image resource libraries, further reducing the application package size and storage space occupied.

[0184] In one embodiment of the present application, the access information acquisition module 602 is specifically used to call the image resource information acquisition interface provided by the first software layer through the native layer based on identification information, to obtain access information of image resources identifiable by the native layer in the public image resource library, wherein the access information is obtained by the first software layer by converting the storage path of the image resources in the public image resource library based on the operating system corresponding to the native layer.

[0185] As can be seen from the above, using the first software layer to convert the storage path of the image resource in the public image resource library to obtain access information can enable the access information to accurately represent the storage location of the image resource, and enable the native layer to accurately identify the access information, thereby improving the accuracy of calling the image resource.

[0186] In one embodiment of the present application, the access information includes at least one of the following information:

[0187] The path of the image resource in the operating system;

[0188] The path of the image resource in the public image resource library;

[0189] The file descriptor of the image resource.

[0190] In this way, the native layer can accurately call image resources for various situations when the application software runs on various operating systems.

[0191] In one embodiment of the present application, the public image resource library stores multi-scale image resources of image resources;

[0192] The first image resource calling module 603 is specifically configured to obtain the current display magnification of the display screen; select an image resource closest to the current display magnification from a public image resource library; and call the image resource.

[0193] As can be seen from the above, by searching for the image resource closest to the current display magnification and calling it, the called image resource can be made as clear as possible or adapted to the user's display screen as much as possible, thereby improving the user's experience of using the application software.

[0194] In one embodiment of the present application, the apparatus further comprises:

[0195] The second image resource calling module is used to call the image resource from the public image resource library according to the identification information when the software layer that needs to call the image resource is the first software layer.

[0196] Since the public image resource library is configured for the first software layer, the first software layer can directly call image resources from the public image resource library according to the identification information, so that the image resources can be called accurately and conveniently.

[0197] In one embodiment of the present application, the second image resource calling module is specifically configured to call an image display component of an image resource based on identification information to call the image resource, wherein the image display component is generated in the following manner: based on the identification information, searching for a path of the image resource from a public image resource library; obtaining a storage path of the image resource in the public image resource library based on the search result; and generating an image display component of the image resource based on the storage path;

[0198] or,

[0199] Based on the identification information, the storage path of the image resource in the public image resource library is obtained; based on the storage path, an image display component of the image resource is generated; and the image display component is called to call the image resource.

[0200] It can be seen that directly calling the pre-generated image display component can make the way of calling image resources more convenient. For the image display component that has not been generated, the image display component of the image resource can be generated based on the storage path when it is needed. Furthermore, in the process of generating the image display component of the image resource, the properties of the image display component can be customized to meet the usage requirements. For example, set the width and height, fill mode, color blending mode and other properties of the image. In this way, the operability of calling image resources can be improved and the customization capability can be improved.

[0201] In one embodiment of the present application, the picture resources in the public picture resource library are: picture resources obtained from a picture resource database;

[0202] The image resources in the image resource database are updated in the following manner:

[0203] After the management device detects that the image resources in the resource update library are updated, it triggers the component packager deployed by the management device to package the updated image resources, generate a packaging result of the updated image resources, and upload the packaging result to the image resource database.

[0204] As can be seen from the above, the present disclosure is an embodiment in which multiple software layers can call image resources in the public image resource library. In this way, developers only need to maintain the public image resource library, that is, maintain the resource update library, image resource database, and public image resource library as a set of databases, thereby reducing subsequent maintenance costs. In addition, the public image resource library can be updated automatically, and developers do not need to update manually, which reduces the difficulty of updating the public image resource library. Designers other than developers can also use the solution of the embodiment of this application to update the public image resource library, which can improve development efficiency.

[0205] In one embodiment of the present application, the apparatus further comprises:

[0206] The image resource storage module is used to obtain the image resource to be obtained from the native image resource library by calling the second image resource acquisition method provided by the native layer through the first software layer according to the identifier of the image resource to be obtained, wherein the native image resource library is the image resource library configured by the native layer; and store the obtained image resource in the public image resource library through the first software layer.

[0207] It can be seen that the public image resource library can also store image resources in the native image resource library. In this way, when the image resources in the native image resource library are updated, the public image resource library is updated, enriching the image resources in the public image resource library.

[0208] The present application also provides an electronic device, such as Figure 7 Shown, including:

[0209] Memory 701, used for storing computer programs;

[0210] The processor 702 is configured to implement the steps of any one of the image resource calling methods in the above embodiments when executing the program stored in the memory 701 .

[0211] Furthermore, the electronic device may further include a communication bus and / or a communication interface, and the processor 702, the communication interface, and the memory 701 communicate with each other via the communication bus.

[0212] The communication bus mentioned in the electronic device mentioned above may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.

[0213] The communication interface is used for communication between the above electronic device and other devices.

[0214] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.

[0215] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.

[0216] In another embodiment provided by the present application, a computer-readable storage medium is further provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned image resource calling methods are implemented.

[0217] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute any one of the image resource calling methods in the above embodiments.

[0218] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or other media (e.g., a solid-state drive (SSD)).

[0219] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.

[0220] Each embodiment in this specification is described in a related manner. Similar portions between the various embodiments can be referenced to each other. Each embodiment focuses on the differences between the other embodiments. In particular, the method, apparatus, electronic device, and storage medium embodiments are generally similar to the method embodiments, so their descriptions are relatively simple. For related portions, reference can be made to the descriptions of the method embodiments.

[0221] The above description is only a preferred embodiment of the present application and is not intended to limit the scope of protection of the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present application are included in the scope of protection of the present application.

Claims

1. A method for calling image resources, characterized in that: The method comprises: Get the identification information of the image resource to be called; If the software layer that needs to call the image resource is not the first software layer, then based on the identification information, calling the image resource information acquisition interface provided by the first software layer through the native layer to obtain access information of the image resource provided by the first software layer in the public image resource library, wherein the first software layer is the software layer configured with the public image resource library; According to the access information, calling the first image resource obtaining method provided by the native layer to call the image resource from the public image resource library; If the software layer that needs to call the image resource is not the first software layer, based on the identification information, calling the image resource information acquisition interface provided by the first software layer through the native layer to obtain access information of the image resource provided by the first software layer in the public image resource library, including: If the software layer that needs to call the image resource is a software layer other than the native layer and the first software layer, calling the bridge code in the other software layer to establish a bridge between the other software layer and the native layer, and calling the image resource information acquisition interface provided by the first software layer in the bridge to obtain access information of the public image resource library provided by the first software layer; The calling, according to the access information, a first image resource obtaining method provided by the native layer, and calling the image resource from the public image resource library includes: According to the access information, a first image resource obtaining method provided by the native layer is called in the bridge to call the image resource from the public image resource library.

2. The method according to claim 1, characterized in that The step of calling the picture resource information obtaining interface provided by the first software layer through the native layer based on the identification information to obtain access information of the picture resource provided by the first software layer in the public picture resource library includes: Based on the identification information, the native layer calls the picture resource information acquisition interface provided by the first software layer to obtain the access information of the picture resource identifiable by the native layer in the public picture resource library, wherein the access information is: the first software layer converts the storage path of the picture resource in the public picture resource library based on the operating system corresponding to the native layer.

3. The method according to claim 2, characterized in that The access information includes at least one of the following information: The path of the image resource in the operating system; The path of the image resource in the public image resource library; The file descriptor of the image resource.

4. The method according to any one of claims 1 to 3, characterized in that The public image resource library stores multiple-rate image resources of image resources; The calling of the picture resource from the public picture resource library includes: Get the current display magnification of the display; Selecting the picture resource closest to the current display magnification from the public picture resource library; Call the image resource.

5. The method according to any one of claims 1 to 3, characterized in that The method further comprises: If the software layer that needs to call the image resource is the first software layer, the image resource is called from the public image resource library according to the identification information.

6. The method according to claim 5, characterized in that The calling the picture resource from the public picture resource library according to the identification information includes: Based on the identification information, the picture display component of the picture resource is called to call the picture resource, wherein the picture display component is generated in the following manner: based on the identification information, searching for a path of the picture resource from the public picture resource library; based on the search result, obtaining a storage path of the picture resource in the public picture resource library; and based on the storage path, generating the picture display component of the picture resource; or, Based on the identification information, a storage path of the picture resource in the public picture resource library is obtained; based on the storage path, a picture display component of the picture resource is generated; and the picture display component is called to call the picture resource.

7. The method according to any one of claims 1 to 3, characterized in that The picture resources in the public picture resource library are: picture resources obtained from the picture resource database; The image resources in the image resource database are updated in the following manner: After the management device detects that the image resources in the resource update library are updated, it triggers the component packaging machine deployed by the management device to package the updated image resources, generate a packaging result of the updated image resources, and upload the packaging result to the image resource database.

8. The method according to any one of claims 1 to 3, characterized in that The method further comprises: According to the identifier of the image resource to be obtained, the first software layer calls a second image resource obtaining method provided by the native layer to obtain the image resource to be obtained from a native image resource library, wherein the native image resource library is an image resource library configured by the native layer; The obtained image resources are stored in the public image resource library through the first software layer.

9. A device for calling image resources, characterized in that: The device comprises: An identification information obtaining module is used to obtain the identification information of the image resource to be called; an access information obtaining module for, when the software layer requiring the image resource to be called is not the first software layer, invoking, through the native layer, an image resource information obtaining interface provided by the first software layer based on the identification information, to obtain access information of the image resource in a public image resource library provided by the first software layer, wherein the first software layer is the software layer configured with the public image resource library; A first image resource calling module is configured to call a first image resource obtaining method provided by the native layer according to the access information, and call the image resource from the public image resource library; The access information acquisition module is specifically used to call the bridging code in the other software layer when the software layer that needs to call the image resource is a software layer other than the native layer and the first software layer, establish a bridge between the other software layer and the native layer, and call the image resource information acquisition interface provided by the first software layer in the bridge to obtain access information of the public image resource library provided by the first software layer; the first image resource calling module is specifically used to call the first image resource acquisition method provided by the native layer in the bridge according to the access information, and call the image resource from the public image resource library.

10. The device according to claim 9, characterized in that The access information acquisition module is specifically configured to, based on the identification information, call the image resource information acquisition interface provided by the first software layer through the native layer to obtain access information of the image resource identifiable by the native layer in the public image resource library, wherein the access information is information obtained by the first software layer converting the storage path of the image resource in the public image resource library based on the operating system corresponding to the native layer; or, The access information includes at least one of the following information: the path of the image resource in the operating system; the path of the image resource in the public image resource library; the file descriptor of the image resource; or, The public image resource library stores image resources with multiple magnifications; the first image resource calling module is specifically used to obtain the current display magnification of the display screen; select the image resource closest to the current display magnification from the public image resource library; and call the image resource; or, The apparatus further includes: a second image resource calling module, configured to call the image resource from the public image resource library according to the identification information when the software layer that needs to call the image resource is the first software layer; or, The second picture resource calling module is specifically configured to call the picture display component of the picture resource according to the identification information to call the picture resource, wherein the picture display component is generated in the following manner: based on the identification information, searching for the path of the picture resource from the public picture resource library; based on the search result, obtaining the storage path of the picture resource in the public picture resource library; based on the storage path, generating the picture display component of the picture resource; or, based on the identification information, obtaining the storage path of the picture resource in the public picture resource library; based on the storage path, generating the picture display component of the picture resource; and calling the picture display component to call the picture resource; or, The image resources in the public image resource library are image resources obtained from an image resource database; wherein the image resources in the image resource database are updated in the following manner: after a management device detects that an image resource in a resource update library has been updated, it triggers a component packager deployed by the management device to package the updated image resource, generates a packaged result of the updated image resource, and uploads the packaged result to the image resource database; or, The device also includes: a picture resource storage module, which is used to call the second picture resource acquisition method provided by the native layer through the first software layer according to the identifier of the picture resource to be obtained, and obtain the picture resource to be obtained from the native picture resource library, wherein the native picture resource library is the picture resource library configured by the native layer; and store the obtained picture resource in the public picture resource library through the first software layer.

11. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the method according to any one of claims 1 to 8 when executing a program stored in a memory.

12. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

Citation Information

Patent Citations

  • Component calling method and device and component data processing method and device

    CN107957911A

  • Heterogeneous ecosystem calling method and device, electronic equipment and storage medium

    CN109522111A