Element typesetting method and device and storage medium

By obtaining the cropping and non-clipping strategies of elements to be typed, combined with scaling, splicing and grouping methods, the problem that element typesetting in the existing technology cannot balance content proportion and area filling is solved, and a better layout effect is achieved.

CN120495463APending Publication Date: 2025-08-15ZHUHAI KINGSOFT OFFICE SOFTWARE +2
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510333071.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-20
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

The lack of effective element layout schemes in the prior art is unable to balance maintaining content proportions and reasonably filling target areas, and cannot cope with complex typesetting needs.

Method used

By obtaining the layout strategies of the elements to be typed, including cropping and non-clipping strategies, combined with scaling, splicing and grouping, typesetting in the target area to ensure that the content proportion and area filling of the elements reach an ideal balance.

Benefits of technology

A perfect balance between maintaining content proportion and properly filling the target area is achieved, and the layout effect is improved, and it can cope with complex typesetting needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120495463A_ABST
    Figure CN120495463A_ABST
Patent Text Reader

Abstract

The invention relates to an element typesetting method and device and a storage medium. The method comprises the steps of obtaining at least one to-be-typeset element; determining a typesetting strategy of at least one to-be-typeset element; and typesetting the at least one to-be-typeset element in a target area according to the typesetting strategy of the at least one to-be-typeset element. In this way, based on the typesetting strategy of the to-be-typeset elements, at least one to-be-typeset element is typeset in the target area, an ideal balance can be achieved between content proportion keeping and reasonable filling of the target area, the typesetting effect is improved, and the complex typesetting requirement can be met.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an element typesetting method, device, and storage medium. Background Art

[0002] With the rapid development of computer technology, the internet has become an integral part of our daily lives. People use the internet for work, entertainment, shopping, and socializing. In many scenarios, users need to layout elements. Specifically, when creating presentations for work, they need to layout images and text within them; when using social media apps and wanting to share photos on websites, they also need to layout photos. Therefore, a solution for element layout is urgently needed. Summary of the Invention

[0003] In order to solve the above-mentioned technical problem of urgently needing an element layout solution that can realize element layout, the embodiments of the present application provide an element layout method, device, electronic device and storage medium. The specific technical solution is as follows:

[0004] In a first aspect of an embodiment of the present application, a method for typesetting an element is first provided, the method comprising:

[0005] Get at least one element to be typeset;

[0006] Determining a layout strategy for at least one of the elements to be typeset;

[0007] At least one of the elements to be typeset is typeset in a target area according to the typesetting strategy of the at least one element to be typeset.

[0008] In an optional implementation, determining a layout strategy for at least one of the elements to be typeset includes:

[0009] Determining a layout strategy for at least one element to be typeset based on the acquired at least one element to be typeset; wherein the layout strategy includes a cropping layout strategy and a non-croppable layout strategy;

[0010] Determining a layout strategy for at least one element to be typeset based on the acquired at least one element to be typeset includes:

[0011] Obtaining a typesetting attribute characteristic of at least one element to be typeset, and determining a typesetting strategy for at least one element to be typeset based on the typesetting attribute characteristic of the at least one element to be typeset; wherein the typesetting attribute characteristic includes at least one of an element addition and cropping attribute and an element source;

[0012] Determining the layout strategy of at least one element to be typeset according to the layout attribute characteristics of at least one element to be typeset includes:

[0013] In a case where the element source of at least one of the elements to be typeset is a preset source and / or the clipping attribute added to the element is non-clippable, determining the non-clippable typesetting strategy as the typesetting strategy of the at least one element to be typeset;

[0014] When the element source of at least one of the elements to be typeset is not a preset source and the element added cropping attribute is not non-cropable, a croppable typesetting strategy is determined as the typesetting strategy of the at least one element to be typeset.

[0015] In an optional embodiment, before typeset at least one element to be typeset in a target area according to the typesetting strategy of at least one element to be typeset, the method further includes:

[0016] According to a preset scaling rule, at least one of the elements to be typeset is scaled proportionally, and the at least one element to be typeset obtained after scaling is used as the element to be typeset.

[0017] In an optional embodiment, typeset at least one element to be typeset in a target area according to the typesetting strategy of at least one element to be typeset, including:

[0018] When the typesetting strategy is a non-croppable typesetting strategy, the elements to be typeset are typeset in the target area by splicing; wherein the typeset elements after typeset maintain the element content and the original element ratio of the elements to be typeset;

[0019] Alternatively, when the layout strategy is a cropping layout strategy, the elements to be layouted are layouted in the target area by grouping; wherein the grouping is based on at least one of the area, aspect ratio, height, and width of the elements to be layouted; or the grouping is based on the number of elements to be layout, and at least one of the area, aspect ratio, height, and width.

[0020] In an optional embodiment, typeset the elements to be typeset in the target area by splicing, including:

[0021] Obtaining N element layout strategies, where N is a positive integer and the N element layout strategies are different; selecting a target element layout strategy from the N element layout strategies based on a strategy screening feature of at least one element to be typeset; and typeset at least one element to be typeset in a target area according to the target element layout strategy to obtain a layout result;

[0022] Alternatively, N element layout strategies are obtained, where N is a positive integer, and the N element layout strategies are different; for any of the element layout strategies, at least one of the elements to be layouted is layouted in the target area according to the element layout strategy to obtain a first layout result; a first target layout result is selected from the N first layout results, and the first target layout result is determined as the layout result of at least one of the elements to be layouted in the target area.

[0023] In an optional embodiment, the element layout strategy includes a layout direction strategy;

[0024] The step of typeset at least one element to be typeset in a target area according to the element typeset strategy to obtain a first typeset result includes:

[0025] Store at least one element to be typeset into an element list, and iteratively perform the following steps until the element list is empty, thereby obtaining a first typeset result:

[0026] Determine, according to the typesetting direction strategy, an area in the target area that is not typeset in the current round, where the area that is not typeset in the current round is an untypesetting area of the current column / row corresponding to the typesetting direction strategy;

[0027] A target element is selected from the element list, the target element is laid out in the area according to the layout direction strategy, and the target element is removed from the element list.

[0028] In an optional embodiment, the element layout strategy further includes an initial element selection strategy;

[0029] The selecting a target element from the element list, typeset the target element to the area according to the typesetting direction strategy, and removing the target element from the element list includes:

[0030] According to the initial element selection strategy, an initial element is selected from the element list, according to the layout direction strategy, the initial element is layouted to the area, and the initial element is removed from the element list.

[0031] In an optional embodiment, the layout of the initial element to the area according to the layout direction strategy includes:

[0032] When the first form parameter of the initial element exceeds the first form parameter of the region, the initial element is scaled proportionally according to the first form parameter of the region; and the scaled initial element is laid out in the region according to the layout direction strategy;

[0033] Alternatively, when the first formal parameter of the initial element does not exceed the first formal parameter of the region, the following processing is performed:

[0034] According to the layout direction strategy, the initial element is laid out in the area, and the initial element is removed from the element list;

[0035] According to the second parameter of the initial element, the remaining elements in the element list are scaled proportionally to obtain a target element list;

[0036] A supplementary element is selected from the target element list, the supplementary element is laid out in the remaining area of the area according to the layout direction strategy, and the supplementary element is removed from the target element list.

[0037] In an optional embodiment, selecting the supplementary element from the target element list, typeset the supplementary element to the remaining area of the area according to the typesetting direction strategy, and removing the supplementary element from the target element list includes:

[0038] Detecting whether there is a first supplementary element in the target element list, where the first supplementary element is an element in the target element list with the smallest scaling ratio and a first formal parameter obtained after scaling that is less than or equal to a first formal parameter of a remaining area of the area;

[0039] If the first supplementary element exists, typeset the first supplementary element to the remaining area of the region according to the typesetting direction strategy, and remove the first supplementary element from the target element list; if the target element list is not empty and the remaining area of the region is not empty, perform the step of detecting whether the first supplementary element exists in the target element list;

[0040] Alternatively, if the first supplementary element does not exist, the following processing is performed:

[0041] Selecting a second supplementary element from the target element list, where the second supplementary element is the element with the smallest scaling ratio in the target element list;

[0042] According to the layout direction strategy, layout the second supplementary element to the remaining area of the region, and remove the second supplementary element from the target element list;

[0043] According to the first shape parameter of the region, the target elements in the region are proportionally scaled so that the sum of the first shape parameters of the scaled target elements is the same as the first shape parameter of the region.

[0044] In an optional embodiment, the method further comprises:

[0045] When the element list is empty, detecting whether there is any remaining area in the last round of untypesetting area in the target area;

[0046] If there is a remaining area in the target area that has not been typeset in the last round, the following processing is performed:

[0047] According to the first formal parameter of the last round of untypesetted area, the target elements in the last round of untypesetted area are proportionally scaled so that the sum of the first formal parameters of the target elements in the last round of untypesetted area after scaling is the same as the first formal parameter of the last round of untypesetted area.

[0048] In an optional implementation, when the layout strategy is a cropping layout strategy, the elements to be layouted are layouted in a target area by grouping, including:

[0049] In the case where the typesetting strategy is a tailorable typesetting strategy, detecting the number of the elements to be typeset;

[0050] Typesetting at least one of the elements to be typeset in a target area according to the quantity;

[0051] The step of typeset at least one of the elements to be typeset in the target area according to the quantity includes:

[0052] When the number is one, scaling and / or cropping one of the elements to be typeset according to the size of the target area, and typeset the element in the target area;

[0053] Alternatively, when the number is two, determining a first area ratio between the two elements to be typeset; and typeset the two elements to be typeset in a target area according to the first area ratio;

[0054] Alternatively, when the number is more than two, the elements to be typeset are typeset in the target area by grouping.

[0055] In an optional embodiment, typeset the two elements to be typeset in a target area according to the first area ratio, including:

[0056] determining a first segmentation line of the target area according to the first area ratio;

[0057] dividing the target area into a first area and a second area according to the first dividing line;

[0058] Based on the first area and the second area, typeset the two elements to be typeset;

[0059] Wherein, dividing the target area into a first area and a second area according to the first dividing line includes:

[0060] Determining the sum of the first aspect ratios of the two elements to be typeset;

[0061] comparing the sum of the first aspect ratios with the aspect ratio of the target area;

[0062] determining a first segmentation strategy for the target area according to the comparison result;

[0063] dividing the target area into a first area and a second area according to the first segmentation strategy and the first segmentation line;

[0064] The step of typeset-ing the two elements to be typeset based on the first area and the second area includes:

[0065] scaling and / or cropping one of the two elements to be typeset according to the size of the first area, and typeset the element in the first area;

[0066] The other of the two elements to be typeset is scaled and / or cropped according to the size of the second area, and is typeset in the second area.

[0067] In an optional embodiment, determining the first segmentation strategy for the target area according to the comparison result includes:

[0068] In a case where the sum of the first aspect ratios is greater than the aspect ratio of the target area, determining horizontal segmentation as a first segmentation strategy for the target area;

[0069] Alternatively, when the sum of the first aspect ratios is less than or equal to the aspect ratio of the target area, vertical segmentation is determined as the first segmentation strategy for the target area.

[0070] In an optional embodiment, typeset the elements to be typeset in a target area by grouping, including:

[0071] Obtaining a preset grouping strategy set, wherein the preset grouping strategy set includes M grouping strategies, where M is a positive integer and each of the M grouping strategies is different; selecting a target grouping strategy from the preset grouping strategy set based on the strategy screening features of the two or more elements to be typeset; typeset the two or more elements to be typeset according to the target grouping strategy to obtain a typeset result;

[0072] Alternatively, obtain a preset grouping strategy set, which includes M grouping strategies, where M is a positive integer, and the M grouping strategies are different; traverse the grouping strategies in the preset grouping strategy set, and use the grouping strategies to typeset two or more elements to be typeset in the target area to obtain a second typesetting result; select a second target typesetting result from the M second typesetting results, and determine the second target typesetting result as the typesetting result of the two or more elements to be typeset in the target area.

[0073] In an optional embodiment, the adopting the grouping strategy to typeset two or more elements to be typeset in a target area to obtain a second typeset result includes:

[0074] Grouping the two or more elements to be typeset using the grouping strategy to obtain a first group and a second group;

[0075] determining a second area ratio between the sum of the areas of the elements to be typeset in the first group and the sum of the areas of the elements to be typeset in the second group;

[0076] dividing the target area into a first sub-area and a second sub-area according to the second area ratio;

[0077] When the number of elements in the first group is a preset value, the elements to be typeset in the first group are scaled and / or cropped according to the size of the first sub-area, and are typeset in the first sub-area; and / or when the number of elements in the second group is a preset value, the elements to be typeset in the second group are scaled and / or cropped according to the size of the second sub-area, and are typeset in the second sub-area, to obtain a second typeset result.

[0078] In an optional embodiment, dividing the target area into a first sub-area and a second sub-area according to the second area ratio includes:

[0079] determining a second segmentation line of the target area according to the second area ratio;

[0080] dividing the target area into a first sub-area and a second sub-area according to the second dividing line;

[0081] Partitioning the target area into a first sub-area and a second sub-area according to the second dividing line includes:

[0082] Determining the sum of the second aspect ratios of the elements to be typeset in the first group and the second group, and comparing the sum of the second aspect ratios with the aspect ratio of the target area;

[0083] determining a second segmentation strategy for the target area according to the comparison result;

[0084] The target area is divided into a first sub-area and a second sub-area according to the second segmentation strategy and the second segmentation line.

[0085] In an optional embodiment, determining the second segmentation strategy for the target area according to the comparison result includes:

[0086] In a case where the sum of the second aspect ratios is greater than the aspect ratio of the target area, determining horizontal segmentation as a second segmentation strategy for the target area;

[0087] Alternatively, when the sum of the second aspect ratios is less than or equal to the aspect ratio of the target area, vertical segmentation is determined as the second segmentation strategy for the target area.

[0088] In an optional embodiment, the method further comprises:

[0089] When the number of elements in the first group is not a preset value, the elements to be typeset in the first group are regarded as two or more elements to be typeset, and the step of grouping the two or more elements to be typeset using the grouping strategy to obtain the first group and the second group is performed;

[0090] When the number of elements in the second group is not a preset value, the elements to be typeset in the second group are regarded as two or more elements to be typeset, and the step of grouping the two or more elements to be typeset using the grouping strategy to obtain the first group and the second group is performed.

[0091] In an optional embodiment, the adopting the grouping strategy to group the two or more elements to be typeset to obtain a first group and a second group includes:

[0092] Obtain all combinations of a first group and a second group obtained by grouping two or more of the elements to be typeset;

[0093] For any of the combinations, determining a first total area of the elements to be typeset in a first group and a second total area of the elements to be typeset in a second group in the combination;

[0094] determining an area difference between the first area sum and the second area sum;

[0095] The smallest area difference is selected from all the area differences, and the first group and the second group in the combination corresponding to the smallest area difference are determined.

[0096] In an optional embodiment, the adopting the grouping strategy to group the two or more elements to be typeset to obtain a first group and a second group includes:

[0097] Obtaining the sum of aspect ratios of the two or more elements to be typeset, and determining the product of the sum of aspect ratios and a preset threshold;

[0098] adding some of the elements to be typeset to the first group, so that the difference between the sum of the aspect ratios of the elements to be typeset in the first group and the product is smaller than a preset difference;

[0099] Another portion of the elements to be typeset is added to the second group.

[0100] In an optional embodiment, the adopting the grouping strategy to group the two or more elements to be typeset to obtain a first group and a second group includes:

[0101] sorting the two or more elements to be typeset according to their areas, and allocating the two or more elements to be typeset to a first group and a second group in sequence according to the sorting results;

[0102] Alternatively, the two or more elements to be typeset are sorted according to their widths, and according to the sorting results, the two or more elements to be typeset are sequentially allocated to the first group and the second group;

[0103] Alternatively, the two or more elements to be typeset are sorted according to their heights, and according to the sorting results, the two or more elements to be typeset are sequentially allocated to the first group and the second group.

[0104] In a second aspect of the embodiments of the present application, an element layout device is further provided, the device comprising:

[0105] An element acquisition module, used to acquire at least one element to be typeset;

[0106] A strategy determination module, configured to determine a layout strategy for at least one of the elements to be typeset;

[0107] An element layout module is configured to layout at least one element to be typeset in a target area according to the layout strategy of the at least one element to be typeset.

[0108] In a third aspect of the embodiments of the present application, an electronic device is further provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;

[0109] Memory for storing computer programs;

[0110] The processor is configured to implement any of the element layout methods described in the first aspect when executing a program stored in the memory.

[0111] In a fourth aspect of the embodiments of the present application, a storage medium is further provided, wherein instructions are stored in the storage medium, and when the storage medium is run on a computer, the computer executes any one of the element typesetting methods described in the first aspect above.

[0112] In a fifth aspect of the embodiments of the present application, a computer program product comprising instructions is also provided, which, when executed on a computer, enables the computer to execute any of the above-described element typesetting methods.

[0113] The technical solution provided by the embodiment of the present application obtains at least one element to be typeset, determines a typeset strategy for at least one element to be typeset, and typesets at least one element to be typeset in a target area according to the typeset strategy for at least one element to be typeset.

[0114] By determining the typesetting strategy of at least one element to be typeset, and typeset at least one element to be typeset in the target area according to the typesetting strategy, at least one element to be typeset is typeset in the target area based on the typesetting strategy of the element to be typeset. This can achieve an ideal balance between maintaining the content proportion and reasonably filling the target area, thereby improving the typesetting effect and being able to cope with complex typesetting requirements. BRIEF DESCRIPTION OF THE DRAWINGS

[0115] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0116] 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, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0117] One or more embodiments are exemplarily illustrated by pictures in the corresponding drawings. These exemplifications do not constitute limitations on the embodiments. Elements with the same reference numerals in the drawings are represented as similar elements. Unless otherwise stated, the figures in the drawings do not constitute proportional limitations.

[0118] Figure 1 This is a schematic diagram of an implementation flow of an element typesetting method shown in an embodiment of the present application;

[0119] Figure 2 This is a schematic diagram of an implementation flow of another element typesetting method shown in an embodiment of the present application;

[0120] Figure 3 This is a schematic diagram of an implementation flow of another element typesetting method shown in an embodiment of the present application;

[0121] Figure 4 This is a schematic diagram of the effect of typesetting using a non-croppable typesetting strategy shown in an embodiment of the present application;

[0122] Figure 5 This is a schematic diagram of an implementation flow of another element typesetting method shown in an embodiment of the present application;

[0123] Figure 6 This is a schematic diagram of an implementation flow of another element typesetting method shown in an embodiment of the present application;

[0124] Figure 7 This is a schematic diagram of the effect of a picture to be typeset shown in an embodiment of the present application;

[0125] Figure 8 This is a schematic diagram of the effect of typesetting using a tailorable typesetting strategy shown in an embodiment of the present application;

[0126] Figure 9 This is a schematic diagram of another typesetting effect using a cuttable typesetting strategy shown in an embodiment of the present application;

[0127] Figure 10 This is a structural diagram of an element typesetting device shown in an embodiment of the present application;

[0128] Figure 11 This is a schematic structural diagram of an electronic device shown in an embodiment of the present application. DETAILED DESCRIPTION

[0129] To make the purpose, technical solutions, and advantages of the embodiments of this application more clear, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are 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 without making creative efforts are within the scope of protection of this application.

[0130] The disclosure below provides many different embodiments or examples for implementing different structures of the present application. In order to simplify the disclosure of the present application, the components and settings of specific examples are described below. Of course, these are merely examples and are not intended to limit the present application. In addition, the present application may repeat reference numbers and / or letters in different examples. Such repetition is for the purpose of simplicity and clarity and does not in itself indicate the relationship between the various embodiments and / or settings discussed.

[0131] like Figure 1 FIG. 1 is a schematic diagram of an implementation flow of an element typesetting method provided in an embodiment of the present application. The method is applied to an electronic device and may specifically include the following steps:

[0132] S101: Obtain at least one element to be typeset.

[0133] In an embodiment of the present application, at least one element to be typeset is obtained. The sizes of the at least one element to be typeset may be the same or different. Specifically, the element to be typeset may be an image, text, and / or a table, etc. This means that the present embodiment obtains elements to be typeset of different types, which is not limited in the present embodiment.

[0134] S102: Determine a layout strategy for at least one element to be typeset.

[0135] In an embodiment of the present application, a layout strategy for at least one element to be typeset may be determined. The determination of the layout strategy for the at least one element to be typeset may refer to at least one of the element source of the element to be typeset, element clipping attributes added to the element to be typeset, user permissions, and user settings during typesetting.

[0136] Based on this, a typesetting strategy of the at least one element to be typeset is determined based on the at least one element to be typeset, and the typesetting strategy includes a cropping typesetting strategy and a non-croppable typesetting strategy. Typesetting attribute characteristics of the at least one element to be typeset are obtained, and the typesetting strategy of the at least one element to be typeset is determined based on the typesetting attribute characteristics of the at least one element to be typeset, and the typesetting attribute characteristics include at least one of element added cropping attributes, element source, user permissions, and user settings during typesetting.

[0137] Specifically, for the element source and / or element added cropping attribute of at least one element to be typeset, when the element source is a preset source and / or the element added cropping attribute is non-cropable, the non-cropable typesetting strategy is determined as the typesetting strategy of at least one element to be typeset; when the element source of at least one element to be typeset is not a preset source and the element added cropping attribute is not non-cropable, the croppable typesetting strategy is determined as the typesetting strategy of at least one element to be typeset.

[0138] It should be noted that for a non-croppable typesetting strategy, it means that cropping cannot be performed on the elements to be typeset during the typesetting process, which means that the elements to be typeset provided by the user cannot be cropped, while for a croppable typesetting strategy, it means that cropping can be performed on the elements to be typeset during the typesetting process. The embodiments of the present application do not limit this.

[0139] In addition, in one embodiment of the present application, the preset source may refer to the user, that is, the user provides at least one element to be typeset. And there are priorities for element-added cropping attributes, element sources, user permissions, user settings during typeset, etc. For example, the first priority is the element source, that is, the priority is the element source, followed by the second priority being user permissions, the third priority being the user settings during typeset, and the fourth priority being element-added cropping attributes. If the source does not meet the cropping requirements, cropping is not allowed during typeset, regardless of other settings. Alternatively, the first priority is user permissions. If the user does not have the right to crop, cropping is not allowed during typeset, regardless of other settings. This embodiment of the present application does not limit this.

[0140] S103: Typesetting the at least one element to be typeset in the target area according to the typesetting strategy of the at least one element to be typeset.

[0141] In an embodiment of the present application, for the typesetting strategy of at least one element to be typeset, at least one element to be typeset can be typeset in the target area according to the typesetting strategy of at least one element to be typeset, so as to achieve a balance between maintaining the content proportion and reasonably filling the target area.

[0142] Through the above description of the technical solution provided in the embodiment of the present application, by determining the typesetting strategy of at least one element to be typeset, and according to the typesetting strategy, typeset at least one element to be typeset in the target area, based on the typesetting strategy of the element to be typeset, at least one element to be typeset is typeset in the target area, which can achieve an ideal balance between maintaining the content proportion and reasonably filling the target area, thereby improving the typesetting effect and being able to cope with complex typesetting requirements.

[0143] In the embodiment of the present application, due to the different element sources and / or element added clipping attributes of the elements to be typeset, the corresponding typesetting strategies of the elements to be typeset are different. Therefore, when the element source of the element to be typeset is a preset source and / or the element added clipping attribute is non-clippable, the non-clippable typesetting strategy is determined as the typesetting strategy of at least one element to be typeset, so that in the process of typeset at least one element to be typeset in the target area, the element to be typeset cannot be clipped. Based on this, if Figure 2 FIG. 1 is a schematic diagram of an implementation flow of another element layout method provided in an embodiment of the present application. The method is applied to an electronic device and may specifically include the following steps:

[0144] S201: Obtain at least one element to be typeset.

[0145] In the embodiment of the present application, this step is similar to the above-mentioned step S101, and the embodiment of the present application will not be described in detail here.

[0146] S202: Determine a layout strategy for at least one element to be typeset.

[0147] In an embodiment of the present application, for the element source and / or element added cropping attribute of at least one element to be typeset, when the element source is a preset source and / or the element added cropping attribute is non-croppable, the non-croppable typesetting strategy is determined as the typesetting strategy of at least one element to be typeset; when the element source of at least one element to be typeset is not a preset source and the element added cropping attribute is not non-croppable, the croppable typesetting strategy is determined as the typesetting strategy of at least one element to be typeset.

[0148] S203: scaling the at least one element to be typeset in equal proportion according to a preset scaling rule, and using the at least one element to be typeset obtained after scaling as the element to be typeset.

[0149] In an embodiment of the present application, before typeset at least one element to be typeset, preprocessing is required. The so-called preprocessing is to proportionally scale at least one element to be typeset according to a preset scaling rule, and use the at least one element to be typeset obtained after scaling as the element to be typeset, and subsequently typeset at least one element to be typeset.

[0150] For example, for at least one element to be typeset, it is proportionally scaled to 0.5 times of its original size according to a preset scaling rule, and the at least one element to be typeset obtained after scaling is used as the element to be typeset, and then the at least one element to be typeset is typeset.

[0151] In addition, for at least one element to be typeset, preprocessing is not required, that is, at least one element to be typeset does not need to be proportionally scaled according to a preset scaling rule. Instead, at least one element to be typeset is directly typeset in the target area according to the typesetting strategy of at least one element to be typeset, thereby omitting step S203. This embodiment of the present application does not limit this.

[0152] In addition, the at least one element to be typeset obtained in the above steps may be typeset in the target area according to the typesetting strategy of the at least one element to be typeset. The typesetting strategy of the element to be typeset may be different depending on the element source and element addition and clipping attributes of the element to be typeset.

[0153] Based on this, for the element source and element added cropping attribute of at least one element to be typeset, if its element source is a preset source and / or the element added cropping attribute is non-croppable, then the typesetting strategy of at least one element to be typeset is a non-croppable typesetting strategy. When the typesetting strategy is a non-croppable typesetting strategy, it means that the element to be typeset cannot be cropped. At this time, the element to be typeset is typeset in the target area by splicing. Specifically, for typeset the element to be typeset in the target area by splicing, reference can be made to the execution process of steps S204 to S206.

[0154] It should be noted that during the process of typeset elements in the target area, the typeset elements need to maintain the content and original element ratio of the elements to be typeset. This means that for the elements to be typeset, the content and original element ratio before and after typeset remain unchanged. For example, for an image, the content and original image ratio before and after typeset remain unchanged, but this is not limited to this in the present embodiment.

[0155] S204: When the layout strategy is a non-clippable layout strategy, obtain N element layout strategies, where N is a positive integer and the N element layout strategies are different.

[0156] In an embodiment of the present application, when the layout strategy is a non-clippable layout strategy, N element layout strategies are obtained, where N is a positive integer, and the N element layout strategies are different.

[0157] It should be noted that the element layout strategy is a combination of the layout direction strategy and the initial element selection strategy. For example, the layout direction strategy can include row-priority layout and / or column-priority layout, and the initial element selection strategy can include at least one of the largest area priority, largest height priority, and largest width priority. By combining the layout direction strategy and the initial element selection strategy in this way, up to six different element layout strategies can be obtained.

[0158] S205 : For any element layout strategy, layout at least one element to be layouted in a target area according to the element layout strategy to obtain a first layout result.

[0159] In the embodiment of the present application, for any of the N element layout strategies, at least one element to be layouted is layouted in the target area according to the element layout strategy to obtain a first layout result. In this way, N first layout results can be obtained. The first layout result forms a rectangle, and the width or height of the rectangle can exceed or be less than the width or height of the given target area.

[0160] For the process of typeset at least one element to be typeset in the target area using each element typeset strategy, please refer to the following for details. Figure 3 As shown in the method. Figure 3 FIG. 1 is a schematic diagram of an implementation flow of another element layout method provided in an embodiment of the present application. The method is applied to an electronic device and may specifically include the following steps:

[0161] S301: Store at least one element to be typeset into an element list, and iteratively perform the following steps until the element list is empty, thereby obtaining a first typeset result.

[0162] In an embodiment of the present application, for at least one element to be typeset, at least one element to be typeset can be stored in an element list, and then the following steps S302 to S303 are iteratively executed until the element list is empty, which means that all elements to be typeset have been typeset, thereby obtaining a first typesetting result.

[0163] It should be noted that for a given target area, if the area gradually becomes empty during the iterative execution of steps S302 to S303, but the element list is not empty at this time, the given target area can be extended to ensure that all elements to be typeset are typeset. For example, if the typesetting direction strategy is column-first typesetting, then the given target area can be extended horizontally, but this embodiment of the application does not limit this.

[0164] S302: Determine, according to the layout direction strategy, an area in the target area that has not been layouted in the current round.

[0165] In the embodiments of the present application, the element layout strategy includes a layout direction strategy, which indicates which direction the layout is prioritized. For example, there are two layout direction strategies, row-first layout and column-first layout, which respectively indicate that the layout is prioritized in the horizontal direction and in the vertical direction.

[0166] Based on this, for the typesetting direction strategy, the untypesetting area of the current round in the target area can be determined according to the typesetting direction strategy. The untypesetting area of the current round is the untypesetting area of the current column / row corresponding to the typesetting direction strategy. For example, for the typesetting direction strategy: column-first typesetting, the untypesetting area of the current column of the current round in the target area can be determined accordingly (that is, the untypesetting area of the current column of the current round in the target area from a vertical perspective).

[0167] It should be noted that due to different layout direction strategies, the corresponding target area's non-layout area for the current round will also be different. For example, for column-first layout, the corresponding target area is the non-layout area of the current column in the current round, while for row-first layout, the corresponding target area is the non-layout area of the current row in the current round. This embodiment of the present application is not limited to this.

[0168] S303: Select a target element from the element list, layout the target element to a region according to a layout direction strategy, and remove the target element from the element list.

[0169] In an embodiment of the present application, for an element list, a target element can be selected from the element list, and according to the typesetting direction strategy, the target element can be typeset to the untypesettered area of the current column / row corresponding to the current round and the typesetting direction strategy determined above, and the target element can be removed from the element list, at which point the current round of iteration ends.

[0170] For the unlayout area of the current column / row corresponding to the current round and typesetting direction strategy determined above, the initial element can be first considered for typesetting, that is, the first element in the unlayout area of the current column / row corresponding to the current round and typesetting direction strategy determined above can be first considered for typesetting. For this purpose, the initial element selection strategy is used here, that is, the element typesetting strategy also includes the initial element selection strategy.

[0171] Based on this, according to the initial element selection strategy, the initial element is selected from the element list, and according to the typesetting direction strategy, the initial element is typeset to the untypesetted area of the current column / row corresponding to the current round and typesetting direction strategy determined above, and the initial element is removed from the element list.

[0172] For example, if the initial element selection strategy is the maximum height priority selection, then the element with the largest height is selected from the element list as the initial element, and according to the column-priority typesetting, the initial element is typeset to the untypesetted area of the current column corresponding to the current round and typesetting direction strategy determined above, and the initial element is removed from the element list.

[0173] Among them, for the selected initial element, it is also necessary to consider whether it is sufficient to fill the unlayout area of the current column / row corresponding to the current round and typesetting direction strategy determined above. If it is sufficient, then the initial element will be typeset to the unlayout area of the current column / row corresponding to the current round and typesetting direction strategy determined above, and the initial element will be removed from the element list. At this time, the current round iteration ends. Otherwise, it is necessary to select supplementary elements to fill the remaining area of the unlayout area of the current column / row corresponding to the current round and typesetting direction strategy determined above.

[0174] Based on this, when the first formal parameter of the initial element exceeds the first formal parameter of the untypesetter area of the current column / row corresponding to the current round and typesetting direction strategy determined above, the initial element is scaled proportionally according to the first formal parameter of the untypesetter area of the current column / row corresponding to the current round and typesetting direction strategy determined above, and the scaled initial element is typeset to the untypesetter area of the current column / row corresponding to the current round and typesetting direction strategy according to the typesetting direction strategy, at which point the current round iteration ends. Among them, the first formal parameter is related to the typesetting direction strategy. For example, if the typesetting direction strategy is column-first typesetting, then the first formal parameter is the height; if the typesetting direction strategy is row-first typesetting, then the first formal parameter is the width.

[0175] For example, if the typesetting direction strategy is column-first typesetting, then when the height of the initial element exceeds the height of the untypesetting area of the current column corresponding to the current round and typesetting direction strategy determined above, it means that the initial element is sufficient to fill the untypesetting area of the current column corresponding to the current round and typesetting direction strategy determined above. At this time, the initial element is scaled proportionally according to the height of the untypesetting area of the current column corresponding to the current round and typesetting direction strategy determined above. According to the column-first typesetting, the scaled initial element is typeset to the untypesetting area of the current column corresponding to the current round and typesetting direction strategy. At this time, the current round iteration ends.

[0176] In addition, when the selected initial elements are not sufficient to fill the untypesetter area of the current column / row corresponding to the current round and typesetting direction strategy determined above, it is necessary to select additional supplementary elements to fill the remaining area of the untypesetter area of the current column / row corresponding to the current round and typesetting direction strategy determined above. Based on this, when the first parameter of the initial element does not exceed the first parameter of the untypesetter area of the current column / row corresponding to the current round and typesetting direction strategy, the following processing is performed: according to the typesetting direction strategy, the initial element is typeset to the untypesetter area of the current column / row corresponding to the current round and typesetting direction strategy, and the initial element is removed from the element list; according to the second parameter of the initial element, the remaining elements in the element list are scaled proportionally to obtain a target element list; supplementary elements are selected from the target element list, and according to the typesetting direction strategy, the supplementary elements are typeset to the remaining area of the untypesetter area of the current column / row corresponding to the current round and typesetting direction strategy, and the supplementary elements are removed from the target element list. Among them, the second parameter is related to the typesetting direction strategy. For example, if the typesetting direction strategy is column-first typesetting, the second parameter is the width; if the typesetting direction strategy is row-first typesetting, the second parameter is the height.

[0177] For example, if the typesetting direction strategy is column-first typesetting, then when the height of the initial element does not exceed the height of the untypesetting area of the current column corresponding to the current round and typesetting direction strategy determined above, it means that the initial element is insufficient to fill the untypesetting area of the current column corresponding to the current round and typesetting direction strategy determined above. At this time, the following processing is performed: according to column-first typesetting, the initial element is typeset to the untypesetting area of the current column corresponding to the current round and typesetting direction strategy determined above, and the initial element is removed from the element list. Then, according to the width of the initial element, the remaining elements in the element list are proportionally scaled (proportional scaling is performed here to ensure that the width of the remaining elements after scaling is the same as the width of the initial element) to obtain a target element list, that is, the remaining elements in the element list are proportionally scaled until the width of the remaining elements in the element list is the same as the width of the initial element, and then a target element list is obtained; supplementary elements are selected from the target element list, and according to column-first typesetting, the supplementary elements are typeset to the remaining area of the untypesetting area of the current column corresponding to the current round and typesetting direction strategy, and the supplementary elements are removed from the target element list. In one embodiment of the present application, before scaling the remaining elements in the element list proportionally according to the width of the initial element, the process further includes: determining whether the widths of the remaining elements in the element list are not equal to the width of the initial element; if the widths of the remaining elements in the element list are not equal to the width of the initial element, scaling the remaining elements in the element list proportionally according to the width of the initial element to obtain a target element list; if the widths of the remaining elements in the element list are equal to the width of the initial element, typeset the remaining elements with widths equal to the width of the initial element as supplementary elements to the remaining area of the untypesetted area of the current column corresponding to the current round and the typesetting direction strategy, and removing the supplementary elements from the element list. Similarly, if the typesetting direction strategy is row-first typesetting, scaling the remaining elements in the element list proportionally until the heights of the remaining elements in the element list are the same as the heights of the initial elements, and obtaining a target element list; selecting supplementary elements from the target element list, typeset the supplementary elements according to row-first typesetting to the remaining area of the untypesetted area of the current row corresponding to the current round and the typesetting direction strategy, and removing the supplementary elements from the target element list.

[0178] Among them, for the supplementary elements, priority is given to the elements with the smallest scaling ratio and the first parameter obtained after scaling is less than or equal to the first parameter of the remaining area of the untypesetting area of the current column / row corresponding to the current round and typesetting direction strategy determined above. Based on this, it is detected whether there is a first supplementary element in the target element list. The first supplementary element is the element with the smallest scaling ratio in the target element list and the first parameter is less than or equal to the first parameter of the remaining area of the untypesetting area of the current column / row corresponding to the current round and typesetting direction strategy determined above. That is, the supplementary element with the smallest scaling ratio is searched from the target element list, and it is determined whether the first parameter of the supplementary element is less than or equal to the first parameter of the remaining area of the untypesetting area of the current column / row corresponding to the current round and typesetting direction strategy determined above. If the first parameter of the supplementary element is less than or equal to the first parameter of the remaining area of the untypesetting area of the current column / row corresponding to the current round and typesetting direction strategy determined above, the supplementary element is determined as the first supplementary element. If the first parameter of the supplementary element is greater than the first parameter of the remaining area of the untypesetting area of the current column / row corresponding to the current round and typesetting direction strategy determined above, it means that the first supplementary element does not exist and it is necessary to search for the second supplementary element. The second supplementary element will be explained later. When the first supplementary element exists, according to the typesetting direction strategy, the first supplementary element is typeset to the remaining area of the untypesetter area of the current column / row corresponding to the current round and the typesetting direction strategy, and the first supplementary element is removed from the target element list. When the target element list is not empty and the remaining area of the untypesetter area of the current column / row corresponding to the current round and the typesetting direction strategy determined above is not empty, the step of detecting whether the first supplementary element exists in the target element list is executed until the target element list is empty or the remaining area of the area determined above is empty, at which point the current round of iteration ends.

[0179] For example, if the typesetting direction strategy is column-first typesetting, then it is detected whether there is a first supplementary element in the target element list. The first supplementary element is the element with the smallest scaling ratio in the target element list (the remaining elements in the element list are scaled proportionally according to the width of the initial element to obtain the target element list, so each element in the target element list here has a corresponding scaling ratio) and the height obtained after scaling is less than or equal to the height of the remaining area of the untypesetting area of the current column corresponding to the current round and typesetting direction strategy determined above. If the first supplementary element exists, according to column-first typesetting, the first supplementary element is typeset to the remaining area of the untypesetting area of the current column corresponding to the current round and typesetting direction strategy determined above, and the first supplementary element is removed from the target element list. If the target element list is not empty and the remaining area of the untypesetting area of the current column corresponding to the current round and typesetting direction strategy determined above is not empty, the step of detecting whether there is the first supplementary element in the target element list is performed until the target element list is empty, or the remaining area of the untypesetting area of the current column corresponding to the current round and typesetting direction strategy determined above is empty, at which time the current round iteration ends.

[0180] In addition, for the supplementary elements, it is possible that there is no element with the smallest scaling ratio and the first parameter obtained after scaling is less than or equal to the first parameter of the remaining area of the area determined above, that is, there is no first supplementary element. In this case, it is necessary to select the element with the smallest scaling ratio as the second supplementary element. To this end, when the first supplementary element does not exist, the second supplementary element is searched, that is, the following processing is performed: the second supplementary element is selected from the target element list, and the second supplementary element is the element with the smallest scaling ratio in the target element list; according to the typesetting direction strategy, the second supplementary element is typeset to the remaining area of the untypesetted area of the current column / row corresponding to the current round and typesetting direction strategy determined above, and the second supplementary element is removed from the target element list; according to the first parameter of the untypesetted area of the current column / row corresponding to the current round and typesetting direction strategy, the target element of the untypesetted area of the current column / row corresponding to the current round and typesetting direction strategy is proportionally scaled so that the sum of the first parameters of the scaled target elements is the same as the first parameter of the untypesetted area of the current column / row corresponding to the current round and typesetting direction strategy determined above, and the current round iteration ends at this time. The target element here can be the initial element, the second supplementary element, or the initial element, the first supplementary element, and the second supplementary element.

[0181] For example, if the typesetting direction strategy is column-first typesetting, and the first supplementary element does not exist, the following processing is performed: select the second supplementary element from the target element list, where the second supplementary element is the element with the smallest scaling ratio in the target element list; according to the column-first typesetting, typeset the second supplementary element to the remaining area of the untypesetter area of the current column corresponding to the current round and typesetting direction strategy determined above, and remove the second supplementary element from the target element list, and scale the target elements of the area proportionally according to the height of the untypesetter area of the current column corresponding to the current round and typesetting direction strategy determined above, so that the sum of the first parameters of the scaled target elements is the same as the first parameter of the untypesetter area of the current column corresponding to the current round and typesetting direction strategy determined above, at which point the current round iteration ends.

[0182] In addition, in an embodiment of the present application, after all the elements to be typeset have been typeset, the last round of untypesetted area may be blank, and the target elements in the last round of untypesetted area need to be scaled proportionally to avoid the phenomenon of blank areas in the last round of untypesetted area in the target area. To this end, when the element list is empty, it is detected whether there is a remaining area in the last round of untypesetted area in the target area; when there is a remaining area in the last round of untypesetted area in the target area, the following processing is performed: according to the first formal parameter of the last round of untypesetted area, the target elements in the last round of untypesetted area are scaled proportionally so that the sum of the first formal parameters of the target elements in the scaled last round of untypesetted area is the same as the first formal parameter of the last round of untypesetted area.

[0183] In this way, by utilizing each element layout strategy, in the process of layouting at least one element to be layouted in the target area, the non-croppable layout strategy can ensure the integrity and original proportion of the element to be layouted, and give priority to selecting the element with the smallest scaling ratio for layout, which can ensure the minimum overall scaling amount.

[0184] S206 , selecting a first target typesetting result from the N first typesetting results, and determining the first target typesetting result as a typesetting result of at least one element to be typeset in a target area.

[0185] In the embodiment of the present application, after the above steps, N first layout results can be obtained, and a first target layout result can be selected from the N first layout results, and the first target layout result is determined as the layout result of at least one element to be layouted in the target area. For the first target layout result, if Figure 4 shown.

[0186] Among them, for the first target layout result, it will form a rectangle. If the width or height of the rectangle exceeds or is less than the width or height of the given target area, then the first target layout result can be scaled as a whole according to the size of the given target area, so that the width or height of the rectangle formed by the scaled first target layout result is the same as the width or height of the given target area. The embodiment of the present application does not limit this.

[0187] In addition, for each of the above first typesetting results, if the rectangle formed by it is closest to the given target area, then the first typesetting result can be determined as the first target typesetting result, thereby realizing the selection of the first target typesetting result from N first typesetting results.

[0188] By adopting a non-croppable layout strategy to typeset the elements to be typeset, the integrity and original proportion of the elements to be typeset can be guaranteed, so that the rectangle formed by the elements to be typeset after typeset is as close as possible to the given target area, and the elements with the smallest scaling ratio are preferentially selected for typeset, which can ensure that the overall scaling amount is minimized.

[0189] In an embodiment of the present application, after the above steps, N first typesetting results can be obtained. A first target typesetting result can be selected from the N first typesetting results, and the first target typesetting result can be determined as the typesetting result of at least one element to be typeset in a target area. In addition, the element typesetting strategy can be screened based on the strategy screening features of the element to be typeset, and then the at least one element to be typeset is typeset in the target area accordingly to obtain a typesetting result, without generating N first typesetting results.

[0190] Based on this, N element layout strategies are obtained, where N is a positive integer and each of the N element layout strategies is different; based on the strategy screening characteristics of at least one element to be typeset, a target element layout strategy is selected from the N element layout strategies; based on the target element layout strategy, the at least one element to be typeset is typeset in a target area to obtain a layout result. The process of typeset at least one element to be typeset in a target area to obtain a layout result based on the target element layout strategy is similar to step S205 above and will not be further described in detail in this embodiment of the present application.

[0191] It should be noted that the strategy screening features for the elements to be typeset may be, for example, width, height, area, or aspect ratio. For example, if the aspect ratio of the element to be typeset is 2:1, then the target element typesetting strategy selected may be a combination of row-first typesetting and maximum height priority. If the aspect ratio of the element to be typeset is 1:2, then the target element typesetting strategy selected may be a combination of column-first typesetting and maximum width priority. This embodiment of the present application does not limit this.

[0192] In addition, in the embodiment of the present application, due to the different element sources and / or element added clipping attributes of the elements to be typeset, the typesetting strategies of the corresponding elements to be typeset are different. Therefore, when the element source of the element to be typeset is not the preset source and the element added clipping attribute is not non-clippable, the clippable typesetting strategy is determined as the typesetting strategy of at least one element to be typeset, so that in the process of typeset at least one element to be typeset in the target area, the element to be typeset can be clipped. Based on this, if Figure 5 FIG. 1 is a schematic diagram of an implementation flow of another element layout method provided in an embodiment of the present application. The method is applied to an electronic device and may specifically include the following steps:

[0193] S501: Obtain at least one element to be typeset.

[0194] In the embodiment of the present application, this step is similar to the above-mentioned step S101, and the embodiment of the present application will not be described in detail here.

[0195] S502: Determine a layout strategy for at least one element to be typeset.

[0196] In the embodiment of the present application, this step is similar to the above-mentioned step S202, and the embodiment of the present application will not be described in detail here.

[0197] S503: scaling the at least one element to be typeset in equal proportion according to a preset scaling rule, and using the at least one element to be typeset obtained after scaling as the element to be typeset.

[0198] In the embodiment of the present application, this step is similar to the above-mentioned step S203, and the embodiment of the present application will not be repeated here.

[0199] In addition, for at least one element to be typeset, preprocessing is not required, that is, at least one element to be typeset does not need to be proportionally scaled according to a preset scaling rule. Instead, at least one element to be typeset is directly typeset in the target area according to the typesetting strategy of at least one element to be typeset, thereby omitting step S503. This embodiment of the present application does not limit this.

[0200] In addition, the at least one element to be typeset obtained in the above steps may be typeset in the target area according to the typesetting strategy of the at least one element to be typeset. The typesetting strategy of the element to be typeset may be different depending on the element source and element addition and clipping attributes of the element to be typeset.

[0201] Based on this, for the element source and element added clipping attribute of at least one element to be typeset, if its element source is not a preset source and the element added clipping attribute is not non-clippable, then the typesetting strategy of at least one element to be typeset is a clippable typesetting strategy. When the typesetting strategy is a clippable typesetting strategy, it indicates that the element to be typeset is clippable. At this time, the elements to be typeset are typeset in the target area by grouping. Specifically, for typeset in the target area by grouping, reference can be made to the execution process of steps S404 to S405.

[0202] It should be noted that the elements to be typeset are typeset in the target area by grouping, and the grouping is based on at least one of the area, aspect ratio, height, and width of the elements to be typeset; or the grouping is based on the number of elements to be typeset, and at least one of the area, aspect ratio, height, and width. The embodiments of the present application do not limit this.

[0203] S504: When the layout strategy is a clippable layout strategy, the number of elements to be layouted is detected.

[0204] In an embodiment of the present application, when the typesetting strategy is a croppable typesetting strategy, the number of elements to be typeset is detected, and then different methods are selected according to the number to typeset at least one element to be typeset in the target area.

[0205] S505: Typesetting at least one element to be typeset in the target area according to the quantity.

[0206] In the embodiment of the present application, for the number of elements to be typeset, different methods can be selected according to the number of elements to be typeset to typeset at least one element to be typeset in the target area.

[0207] Wherein, when the number of elements to be typeset is one, the element to be typeset is scaled and / or cropped according to the size of the target area, and typeset in the target area. Here, it is necessary to retain the key content of the element to be typeset, and after scaling and / or cropping, the size of the element to be typeset remains the same as that of the target area. Wherein, the scaling and / or cropping can be selected according to the actual situation. For example, under the premise of retaining the key content of the element to be typeset, the element to be typeset can be cropped according to the size of the target area, and typeset in the target area.

[0208] It should be noted that the key content of the element to be typeset can be retained by using a method based on content analysis, a method based on visual importance, or a method based on user interaction or prior knowledge. Among them, for the method based on content analysis, the subject content can be identified. For example, if the element to be typeset is an image, the main object therein can be determined by image recognition technology, and these main objects can be completely retained in the processed element during the cropping and / or scaling process. Alternatively, in the process of cropping and / or scaling, a method of cropping from the periphery to the center can be adopted to obtain the processed element, and the pixel points containing the main content in the processed element account for a threshold ratio of the overall pixel points of the main object in the original image, and the threshold ratio can be 90%. If it is text content, the key semantic parts of the text can be analyzed by natural language processing technology, and during the cropping process, it is ensured that these key semantic parts are not cropped. For the method based on visual importance, the visual attention mechanism is used to simulate the attention of the human visual system to different areas, and the visual importance weight of each area in the element to be typeset is calculated. During the process of cropping and / or scaling, priority is given to retaining areas of high visual importance. For example, areas of an image with high contrast, bright colors, and rich textures usually have high visual importance. For methods based on user interaction or prior knowledge, users can manually specify key content or key areas in the elements to be typeset. During the process of cropping and / or scaling, the user's specifications are strictly followed to ensure that the parts that the user considers important are retained. Alternatively, based on specific application scenarios and design specifications, determine which content is key content, and retain this key content during the cropping and / or scaling process. For example, when designing product promotional posters, product images and key slogans are usually key content; when making ID photos, the person's face is key content, and these key contents are retained according to the corresponding standards and specifications.

[0209] When there are two elements to be typeset, the target area is divided into two parts, one of which typesets one element to be typeset, and the other part typesets another element to be typeset. Based on this, when there are two elements to be typeset, a first area ratio between the two elements to be typeset is determined, and the two elements to be typeset are typeset in the target area according to the first area ratio.

[0210] Among them, according to the first area ratio, the two elements to be typeset are typeset in the target area. Specifically, according to the first area ratio, the first dividing line of the target area is determined, and according to the first dividing line, the target area is divided into a first area and a second area. Based on the first area and the second area, the two elements to be typeset are typeset.

[0211] According to the first dividing line, the target area is divided into the first area and the second area. Specifically, the sum of the first aspect ratios of the two elements to be typeset is determined, and the sum of the first aspect ratios is compared with the aspect ratio of the target area; according to the comparison result, the first segmentation strategy of the target area is determined, and according to the first segmentation strategy and the first dividing line, the target area is divided into the first area and the second area.

[0212] Based on the first area and the second area, the two elements to be typeset are typeset. Specifically, one of the two elements to be typeset is scaled and / or cropped according to the size of the first area and typeset in the first area; the other of the two elements to be typeset is scaled and / or cropped according to the size of the second area and typeset in the second area. Specifically, for the elements to be typeset, on the premise of retaining the key content of the elements to be typeset, one of the two elements to be typeset can be cropped according to the size of the first area, and the other of the two elements to be typeset can be cropped according to the size of the second area. Otherwise, scaling can be performed. This embodiment of the present application does not limit this.

[0213] It should be noted that the area ratio between the first area and the second area is the same as the above-mentioned first area ratio, and the area ratio between the elements to be typeset in the first area and the elements to be typeset in the second area conforms to the above-mentioned first area ratio. The embodiment of the present application does not limit this.

[0214] When the sum of the first aspect ratios is greater than the aspect ratio of the target area, horizontal division is determined as the first division strategy of the target area, so that the two elements to be typeset after scaling are arranged in the upper and lower positions, or, when the sum of the first aspect ratios is less than or equal to the aspect ratio of the target area, vertical division is determined as the first division strategy of the target area, so that the two elements to be typeset after scaling are arranged in the left and right positions.

[0215] When the number of elements to be typeset is more than two, a recursive approach is used for typeset. To this end, when the number of elements to be typeset is more than two, the elements to be typeset are typeset in the target area by grouping them. For details, see Figure 6 As shown in the method. Figure 6 FIG. 1 is a schematic diagram of an implementation flow of another element layout method provided in an embodiment of the present application. The method is applied to an electronic device and may specifically include the following steps:

[0216] S601: Obtain a preset grouping strategy set, where the preset grouping strategy set includes M grouping strategies, where M is a positive integer, and each of the M grouping strategies is different.

[0217] In an embodiment of the present application, a preset grouping strategy set is obtained, wherein the preset grouping strategy set includes M grouping strategies, where M is a positive integer and each of the M grouping strategies is different.

[0218] For example, in the embodiment of the present application, six grouping strategies are provided, and each grouping strategy is described below:

[0219] Grouping strategy 1: based on minimizing area differences

[0220] Core idea: Divide the elements to be typeset into two groups so that the total area of the two groups is as close as possible to achieve balanced distribution and reduce imbalance during cropping.

[0221] Specific steps: Obtain all combinations of the first group and the second group obtained by grouping two or more elements to be typeset, that is, iteratively perform the following steps until all combinations of the first group and the second group are obtained: obtain two or more elements to be typeset, group the two or more elements to be typeset, and obtain the first group and the second group. For any combination, determine the first sum of the areas of the elements to be typeset in the first group and the second sum of the areas of the elements to be typeset in the second group in the combination, determine the area difference between the first sum and the second sum, select the smallest area difference from all area differences, and determine the first group and the second group in the combination corresponding to the smallest area difference.

[0222] Grouping strategy 2: Grouping based on the closest aspect ratio

[0223] Core idea: Divide the elements to be typeset into two groups according to their aspect ratio, so that the sum of the aspect ratios of the two groups is as close as possible. This is suitable for when the target area has specific aspect ratio requirements, ensuring that the layout of the elements to be typeset is more in line with the overall proportion.

[0224] Specific steps: obtain the sum of the aspect ratios of two or more elements to be typeset, and determine the product between the sum of the aspect ratios and a preset threshold value (for example, 0.5), and add some of the elements to be typeset (from all the elements to be typeset, select several elements and put them into the first group by continuously trying different combinations, until the difference between the sum of the aspect ratios of these elements in the first group and the product calculated previously meets the requirement of being less than the preset difference, then these elements selected to be put into the first group are referred to as "part of the elements to be typeset" here) to the first group, so that the difference between the sum of the aspect ratios of the elements to be typeset in the first group and the product is less than the preset difference (for example, 1), and add another part of the elements to be typeset to the second group.

[0225] Grouping strategy 3: Grouping based on area from large to small

[0226] Core idea: prioritize assigning elements with larger areas to two groups, and try to ensure that the sum of the areas of the two groups is close. This helps to deal with elements with large differences in area and reduce over-cropping.

[0227] Specific steps: Sort two or more elements to be typed by area, and assign the two or more elements to be typed to the first group and the second group in turn according to the sorting results. Specifically, after the elements to be typed are sorted by area, starting with the first element after sorting, the elements are assigned to the first group and the second group one by one in turn in order. For example, the first element after sorting is assigned to the first group first, then the second element is assigned to the second group, then the third element is assigned to the first group, the fourth element is assigned to the second group, and so on, until all elements to be typed are assigned to the two groups.

[0228] Grouping strategy 4: Grouping based on width from large to small

[0229] Core idea: Sort the elements to be typeset by width from largest to smallest and assign them to two groups, ensuring that the total width of the two groups is close, which is suitable for scenarios where the target area is divided horizontally.

[0230] Specific steps: Sort two or more elements to be typeset by width, and assign the two or more elements to be typeset to the first group and the second group in turn according to the sorting results. Specifically, after the elements to be typeset are sorted by width, starting with the first element after sorting, assign the elements to the first group and the second group one by one in turn in order. For example, first assign the first element after sorting to the first group, then assign the second element to the second group, then assign the third element to the first group, and the fourth element to the second group, and so on, until all elements to be typeset are assigned to these two groups.

[0231] Grouping strategy 5: Grouping based on height from large to small

[0232] Core idea: Sort the elements to be typeset from largest to smallest according to their height and assign them to two groups, ensuring that the total height of the two groups is close, which is suitable for scenarios where the target area is divided vertically.

[0233] Specific steps: Sort two or more elements to be typeset by height, and assign the two or more elements to be typeset to the first group and the second group in turn according to the sorting results. Specifically, after the elements to be typeset are sorted by height, starting with the first element after sorting, assign the elements to the first group and the second group one by one in turn in order. For example, first assign the first element after sorting to the first group, then assign the second element to the second group, then assign the third element to the first group, and the fourth element to the second group, and so on, until all elements to be typeset are assigned to these two groups.

[0234] Grouping strategy 6: Equal grouping

[0235] Core idea: Divide the elements to be typeset into two groups in equal amounts, so that each group contains the same or similar number of elements to be typeset. This helps to evenly distribute the number of elements to be typeset, avoiding too many or too few elements in one group, thereby achieving visual balance during division and splicing.

[0236] Specific steps: Sort two or more elements to be typeset by area, width or height, and assign the two or more elements to be typeset to the first group and the second group in turn according to the sorting results. Specifically, after the elements to be typeset are sorted by area, width or height, starting from the first element after sorting, the elements are assigned to the first group and the second group one by one in turn in order. For example, first assign the first element after sorting to the first group, then assign the second element to the second group, then assign the third element to the first group, and the fourth element to the second group, and so on, until all elements to be typeset are assigned to these two groups.

[0237] S602: traverse the grouping strategies in the preset grouping strategy set, and use the grouping strategies to typeset two or more elements to be typeset in the target area to obtain a second typeset result.

[0238] In an embodiment of the present application, for a preset grouping strategy set, the grouping strategies in the preset grouping strategy set can be traversed, and the grouping strategies can be used to layout two or more elements to be layouted in the target area to obtain a second layout result. In this way, M types of second layout results can be obtained.

[0239] Here, for typeset two or more elements to be typeset in the target area using each grouping strategy, the specific steps may be as follows:

[0240] A grouping strategy is used to group two or more elements to be typeset to obtain a first group and a second group; a second area ratio between the area sum of the elements to be typeset in the first group and the area sum of the elements to be typeset in the second group is determined; based on the second area ratio, a target area is divided into a first sub-area and a second sub-area; when the number of elements in the first group is a preset value (for example, 1), the elements to be typeset in the first group are scaled and / or cropped according to the size of the first sub-area, and typeset in the first sub-area; and / or when the number of elements in the second group is a preset value (for example, 1), the elements to be typeset in the second group are scaled and / or cropped according to the size of the second sub-area, and typeset in the second sub-area to obtain a second typesetting result.

[0241] When the number of elements in the first group is not a preset value, the elements to be typeset in the first group are regarded as more than two elements to be typeset, and the grouping strategy is used to group the two or more elements to be typeset to obtain the first group and the second group. The recursive process is continued until the number of elements in the group is the preset value; when the number of elements in the second group is not a preset value, the elements to be typeset in the second group are regarded as more than two elements to be typeset, and the grouping strategy is used to group the two or more elements to be typeset to obtain the first group and the second group. The recursive process is continued until the number of elements in the group is the preset value.

[0242] A second dividing line of the target area is determined based on the second area ratio, and the target area is divided into a first sub-area and a second sub-area based on the second dividing line. Specifically, the sum of the second aspect ratios of the elements to be typeset in the first group and the second group is determined, and the sum of the second aspect ratios is compared with the aspect ratio of the target area; based on the comparison result, a second segmentation strategy for the target area is determined, and the target area is divided into the first sub-area and the second sub-area based on the second segmentation strategy and the second dividing line.

[0243] When the sum of the second aspect ratios is greater than the aspect ratio of the target area, horizontal segmentation is determined as the second segmentation strategy for the target area; or when the sum of the second aspect ratios is less than or equal to the aspect ratio of the target area, vertical segmentation is determined as the second segmentation strategy for the target area.

[0244] S603: Select a second target typesetting result from the M second typesetting results, and determine the second target typesetting result as a typesetting result of two or more elements to be typeset in a target area.

[0245] In an embodiment of the present application, after the above steps, M second typesetting results can be obtained, and a second target typesetting result can be selected from the M second typesetting results, and the second target typesetting result can be determined as the typesetting result of two or more elements to be typeset in the target area.

[0246] For example, for two or more pictures to be typeset, Figure 7 As shown in FIG, including test pictures, test picture-1, test picture-2, test picture-3, and test picture-4, the second target layout results obtained after the above layout steps can be divided into two categories. One category is that although a croppable layout strategy is adopted to layout the elements to be layouted, the elements to be layouted are not actually cropped (meaning only scaled), and the results are as follows: Figure 8 The second target typesetting result shown in FIG. 1 is to use a typesetting strategy that can be cut to typeset the elements to be typeset, and to cut the elements to be typeset, so as to obtain the following: Figure 9 The second target layout result is shown.

[0247] Among them, for each second typesetting result, the cropping area of each element to be typeset can be counted to obtain the total cropping area, and then the second typesetting result corresponding to the smallest total cropping area is selected as the second target typesetting result. The embodiment of this application does not limit this.

[0248] Furthermore, in an embodiment of the present application, after the above steps, M second typesetting results can be obtained. A second target typesetting result can be selected from the M second typesetting results, and the second target typesetting result can be determined as the typesetting result of two or more elements to be typeset in the target area. Furthermore, it is also possible to select a target grouping strategy from a preset grouping strategy set based on the strategy screening features of the elements to be typeset, and then typeset at least one element to be typeset in the target area accordingly to obtain a typesetting result, without generating M second typesetting results.

[0249] Based on this, a preset grouping strategy set is obtained, where the preset grouping strategy set includes M grouping strategies, where M is a positive integer and each of the M grouping strategies is different; a target grouping strategy is selected from the preset grouping strategy set based on the strategy screening characteristics of the two or more elements to be typeset; and the two or more elements to be typeset are typeset according to the target grouping strategy to obtain a typeset result. The process of typeseting the two or more elements to be typeset according to the target grouping strategy to obtain a typeset result is similar to step S602 above and will not be further described in detail in this embodiment of the present application.

[0250] It should be noted that the strategy screening features for the elements to be typeset may be, for example, width, height, area, or aspect ratio. For example, if the variance of the width of the elements to be typeset is less than a certain threshold, the target grouping strategy selected may be grouping strategy 4 described above, which is not limited in this embodiment of the present application.

[0251] In this way, based on the element source of the element to be typeset and / or the clipping attributes added to the element, it is decided whether to adopt a clippable typesetting strategy or a non-clipping typesetting strategy. When using a clippable typesetting strategy to typeset the elements to be typeset, you can choose to clip appropriately to strictly match the target area. When using a non-clipping typesetting strategy to typeset the elements to be typeset, you can ensure the integrity and original proportion of the elements to be typeset, so that the rectangle formed by the elements to be typeset after typeset is as close as possible to the given target area, and give priority to selecting the element with the smallest scaling ratio for typeset, which can ensure the minimum overall scaling amount. In this way, based on the element source of the element to be typeset and / or the clipping attributes added to the element, typeset at least one element to be typeset in the target area, you can achieve an ideal balance between maintaining the content proportion and reasonably filling the target area, improve the typesetting effect, and cope with complex typesetting needs.

[0252] Corresponding to the above method embodiment, the present application embodiment also provides an element typesetting device, such as Figure 10 As shown, the device may include: an element acquisition module 1010 , a strategy determination module 1020 , and an element layout module 1030 .

[0253] The element acquisition module 1010 is used to acquire at least one element to be typeset;

[0254] A strategy determination module 1020 is configured to determine a layout strategy for at least one element to be typeset;

[0255] The element layout module 1030 is configured to layout at least one element to be typeset in a target area according to the layout strategy of the at least one element to be typeset.

[0256] In an optional implementation, the policy determination module is specifically configured to:

[0257] Determining a layout strategy for at least one element to be typeset based on the acquired at least one element to be typeset; wherein the layout strategy includes a cropping layout strategy and a non-croppable layout strategy;

[0258] Determining a layout strategy for at least one element to be typeset based on the acquired at least one element to be typeset includes:

[0259] Obtaining a typesetting attribute characteristic of at least one element to be typeset, and determining a typesetting strategy for at least one element to be typeset based on the typesetting attribute characteristic of the at least one element to be typeset; wherein the typesetting attribute characteristic includes at least one of an element addition and cropping attribute and an element source;

[0260] Determining the layout strategy of at least one element to be typeset according to the layout attribute characteristics of at least one element to be typeset includes:

[0261] In a case where the element source of at least one of the elements to be typeset is a preset source and / or the clipping attribute added to the element is non-clippable, determining the non-clippable typesetting strategy as the typesetting strategy of the at least one element to be typeset;

[0262] When the element source of at least one of the elements to be typeset is not a preset source and the element added cropping attribute is not non-cropable, a croppable typesetting strategy is determined as the typesetting strategy of the at least one element to be typeset.

[0263] In an optional embodiment, the device further comprises:

[0264] The element scaling module is used to scale at least one of the elements to be typeset in equal proportion according to a preset scaling rule, and use the at least one element to be typeset obtained after scaling as the element to be typeset.

[0265] In an optional embodiment, the element layout module specifically includes:

[0266] A splicing and typesetting submodule is used to typeset the elements to be typeset in a target area by splicing when the typesetting strategy is a non-croppable typesetting strategy; wherein the typeset elements after typeset maintain the element content and the original element ratio of the elements to be typeset;

[0267] The grouping layout submodule is used for, either, when the layout strategy is a cropping layout strategy, laying out the elements to be typeset in a target area by grouping; wherein the grouping is based on at least one of the area, aspect ratio, height, and width of the elements to be typeset; or the grouping is based on the number of elements to be typeset, and at least one of the area, aspect ratio, height, and width.

[0268] In an optional embodiment, the splicing and typesetting submodule specifically includes:

[0269] a typesetting result generating unit configured to obtain N element typesetting strategies, where N is a positive integer and each of the N element typesetting strategies is different; select a target element typesetting strategy from the N element typesetting strategies based on a strategy screening feature of at least one element to be typeset; and typeset at least one element to be typeset in a target area based on the target element typesetting strategy to obtain a typesetting result;

[0270] a strategy acquisition unit, configured to acquire N element layout strategies, where N is a positive integer and each of the N element layout strategies is different;

[0271] an element layout unit, configured to layout at least one of the elements to be layouted in a target area according to any of the element layout strategies, to obtain a first layout result;

[0272] The layout result selection unit is used to select a first target layout result from the N first layout results, and determine the first target layout result as the layout result of at least one of the elements to be typeset in the target area.

[0273] In an optional embodiment, the element layout strategy includes a layout direction strategy; the element layout unit specifically includes:

[0274] The iterator unit is configured to store at least one element to be typeset into an element list, and iteratively perform the following steps until the element list is empty, thereby obtaining a first typeset result:

[0275] An area determination subunit is configured to determine, according to the typesetting direction strategy, an area in the target area that has not been typeset in the current round, where the area that has not been typeset in the current round is an area that has not been typeset in the current column / row corresponding to the typesetting direction strategy;

[0276] The element layout subunit is used to select a target element from the element list, layout the target element to the area according to the layout direction strategy, and remove the target element from the element list.

[0277] In an optional embodiment, the element layout strategy further includes an initial element selection strategy; the element layout subunit is specifically configured to:

[0278] According to the initial element selection strategy, an initial element is selected from the element list, according to the layout direction strategy, the initial element is layouted to the area, and the initial element is removed from the element list.

[0279] In an optional embodiment, the element layout subunit is specifically used to:

[0280] When the first form parameter of the initial element exceeds the first form parameter of the region, the initial element is scaled proportionally according to the first form parameter of the region; and the scaled initial element is laid out in the region according to the layout direction strategy;

[0281] Alternatively, when the first formal parameter of the initial element does not exceed the first formal parameter of the region, the following processing is performed:

[0282] According to the layout direction strategy, the initial element is laid out in the area, and the initial element is removed from the element list;

[0283] According to the second parameter of the initial element, the remaining elements in the element list are scaled proportionally to obtain a target element list;

[0284] A supplementary element is selected from the target element list, the supplementary element is laid out in the remaining area of the area according to the layout direction strategy, and the supplementary element is removed from the target element list.

[0285] In an optional embodiment, the element layout subunit is specifically used to:

[0286] Detecting whether there is a first supplementary element in the target element list, where the first supplementary element is an element in the target element list with the smallest scaling ratio and a first formal parameter obtained after scaling that is less than or equal to a first formal parameter of a remaining area of the area;

[0287] If the first supplementary element exists, typeset the first supplementary element to the remaining area of the region according to the typesetting direction strategy, and remove the first supplementary element from the target element list; if the target element list is not empty and the remaining area of the region is not empty, perform the step of detecting whether the first supplementary element exists in the target element list;

[0288] Alternatively, if the first supplementary element does not exist, the following processing is performed:

[0289] Selecting a second supplementary element from the target element list, where the second supplementary element is the element with the smallest scaling ratio in the target element list;

[0290] According to the layout direction strategy, layout the second supplementary element to the remaining area of the region, and remove the second supplementary element from the target element list;

[0291] According to the first shape parameter of the region, the target elements in the region are proportionally scaled so that the sum of the first shape parameters of the scaled target elements is the same as the first shape parameter of the region.

[0292] In an optional embodiment, the element layout unit is further configured to:

[0293] When the element list is empty, detecting whether there is any remaining area in the last round of untypesetting area in the target area;

[0294] If there is a remaining area in the target area that has not been typeset in the last round, the following processing is performed:

[0295] According to the first formal parameter of the last round of untypesetted area, the target elements in the last round of untypesetted area are proportionally scaled so that the sum of the first formal parameters of the target elements in the last round of untypesetted area after scaling is the same as the first formal parameter of the last round of untypesetted area.

[0296] In an optional embodiment, the group layout submodule specifically includes:

[0297] a quantity detection unit, configured to detect the quantity of the elements to be typeset when the typesetting strategy is a cuttable typesetting strategy;

[0298] an element layout unit, configured to layout at least one of the elements to be typeset in a target area according to the quantity;

[0299] The element layout unit specifically includes:

[0300] A first element layout subunit is configured to, when the number is one, scale and / or crop the element to be layout according to the size of the target area, and layout the element in the target area;

[0301] an area ratio determining subunit, configured to, when the number is two, determine a first area ratio between the two elements to be typeset;

[0302] A second element layout subunit is configured to layout the two elements to be layouted in a target area according to the first area ratio;

[0303] The third element layout subunit is used for, alternatively, when the number is more than two, layouting the elements to be typeset in a target area by grouping.

[0304] In an optional embodiment, the second element typesetting subunit is specifically configured to:

[0305] determining a first segmentation line of the target area according to the first area ratio;

[0306] dividing the target area into a first area and a second area according to the first dividing line;

[0307] Based on the first area and the second area, typeset the two elements to be typeset;

[0308] Wherein, dividing the target area into a first area and a second area according to the first dividing line includes:

[0309] Determining the sum of the first aspect ratios of the two elements to be typeset;

[0310] comparing the sum of the first aspect ratios with the aspect ratio of the target area;

[0311] determining a first segmentation strategy for the target area according to the comparison result;

[0312] dividing the target area into a first area and a second area according to the first segmentation strategy and the first segmentation line;

[0313] The step of typeset-ing the two elements to be typeset based on the first area and the second area includes:

[0314] scaling and / or cropping one of the two elements to be typeset according to the size of the first area, and typeset the element in the first area;

[0315] The other of the two elements to be typeset is scaled and / or cropped according to the size of the second area, and is typeset in the second area.

[0316] In an optional embodiment, the second element typesetting subunit is specifically configured to:

[0317] In a case where the sum of the first aspect ratios is greater than the aspect ratio of the target area, determining horizontal segmentation as a first segmentation strategy for the target area;

[0318] Alternatively, when the sum of the first aspect ratios is less than or equal to the aspect ratio of the target area, vertical segmentation is determined as the first segmentation strategy for the target area.

[0319] In an optional embodiment, the third element typesetting subunit is specifically configured to:

[0320] Obtaining a preset grouping strategy set, wherein the preset grouping strategy set includes M grouping strategies, where M is a positive integer and each of the M grouping strategies is different; selecting a target grouping strategy from the preset grouping strategy set based on the strategy screening features of the two or more elements to be typeset; typeset the two or more elements to be typeset according to the target grouping strategy to obtain a typeset result;

[0321] Alternatively, obtain a preset grouping strategy set, which includes M grouping strategies, where M is a positive integer, and the M grouping strategies are different; traverse the grouping strategies in the preset grouping strategy set, and use the grouping strategies to typeset two or more elements to be typeset in the target area to obtain a second typesetting result; select a second target typesetting result from the M second typesetting results, and determine the second target typesetting result as the typesetting result of the two or more elements to be typeset in the target area.

[0322] In an optional embodiment, the third element typesetting subunit is specifically configured to:

[0323] Grouping the two or more elements to be typeset using the grouping strategy to obtain a first group and a second group;

[0324] determining a second area ratio between the sum of the areas of the elements to be typeset in the first group and the sum of the areas of the elements to be typeset in the second group;

[0325] dividing the target area into a first sub-area and a second sub-area according to the second area ratio;

[0326] When the number of elements in the first group is a preset value, the elements to be typeset in the first group are scaled and / or cropped according to the size of the first sub-area, and are typeset in the first sub-area; and / or when the number of elements in the second group is a preset value, the elements to be typeset in the second group are scaled and / or cropped according to the size of the second sub-area, and are typeset in the second sub-area, to obtain a second typeset result.

[0327] In an optional embodiment, the third element typesetting subunit is specifically configured to:

[0328] determining a second segmentation line of the target area according to the second area ratio;

[0329] dividing the target area into a first sub-area and a second sub-area according to the second dividing line;

[0330] Partitioning the target area into a first sub-area and a second sub-area according to the second dividing line includes:

[0331] Determining the sum of the second aspect ratios of the elements to be typeset in the first group and the second group, and comparing the sum of the second aspect ratios with the aspect ratio of the target area;

[0332] determining a second segmentation strategy for the target area according to the comparison result;

[0333] The target area is divided into a first sub-area and a second sub-area according to the second segmentation strategy and the second segmentation line.

[0334] In an optional embodiment, the third element typesetting subunit is specifically configured to:

[0335] In a case where the sum of the second aspect ratios is greater than the aspect ratio of the target area, determining horizontal segmentation as a second segmentation strategy for the target area;

[0336] Alternatively, when the sum of the second aspect ratios is less than or equal to the aspect ratio of the target area, vertical segmentation is determined as the second segmentation strategy for the target area.

[0337] In an optional embodiment, the third element typesetting subunit is specifically configured to:

[0338] When the number of elements in the first group is not a preset value, the elements to be typeset in the first group are regarded as two or more elements to be typeset, and the step of grouping the two or more elements to be typeset using the grouping strategy to obtain the first group and the second group is performed;

[0339] When the number of elements in the second group is not a preset value, the elements to be typeset in the second group are regarded as two or more elements to be typeset, and the step of grouping the two or more elements to be typeset using the grouping strategy to obtain the first group and the second group is performed.

[0340] In an optional embodiment, the third element typesetting subunit is specifically configured to:

[0341] Obtain all combinations of a first group and a second group obtained by grouping two or more of the elements to be typeset;

[0342] For any of the combinations, determining a first total area of the elements to be typeset in a first group and a second total area of the elements to be typeset in a second group in the combination;

[0343] determining an area difference between the first area sum and the second area sum;

[0344] The smallest area difference is selected from all the area differences, and the first group and the second group in the combination corresponding to the smallest area difference are determined.

[0345] In an optional embodiment, the third element typesetting subunit is specifically configured to:

[0346] Obtaining the sum of aspect ratios of the two or more elements to be typeset, and determining the product of the sum of aspect ratios and a preset threshold;

[0347] adding some of the elements to be typeset to the first group, so that the difference between the sum of the aspect ratios of the elements to be typeset in the first group and the product is smaller than a preset difference;

[0348] Another portion of the elements to be typeset is added to the second group.

[0349] In an optional embodiment, the third element typesetting subunit is specifically configured to:

[0350] sorting the two or more elements to be typeset according to their areas, and allocating the two or more elements to be typeset to a first group and a second group in sequence according to the sorting results;

[0351] Alternatively, the two or more elements to be typeset are sorted according to their widths, and according to the sorting results, the two or more elements to be typeset are sequentially allocated to the first group and the second group;

[0352] Alternatively, the two or more elements to be typeset are sorted according to their heights, and according to the sorting results, the two or more elements to be typeset are sequentially allocated to the first group and the second group.

[0353] The present application also provides an electronic device, such as Figure 11 As shown, it includes a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.

[0354] Memory 113, for storing computer programs;

[0355] The processor 111 is configured to execute the program stored in the memory 113 by performing the following steps:

[0356] Acquire at least one element to be typeset; determine a typeset strategy for at least one element to be typeset; and typeset at least one element to be typeset in a target area according to the typeset strategy for at least one element to be typeset.

[0357] 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.

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

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

[0360] 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.

[0361] In another embodiment provided by the present application, a storage medium is further provided, in which instructions are stored. When the storage medium is run on a computer, the computer executes any one of the element layout methods in the above embodiments.

[0362] 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 element layout methods in the above embodiments.

[0363] 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 storage medium or transmitted from one storage medium to another. 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 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 a semiconductor medium (e.g., a solid-state drive (SSD)).

[0364] 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.

[0365] Each embodiment in this specification is described in a related manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiment is generally similar to the method embodiment, so the description is relatively simple. For related parts, refer to the description of the method embodiment.

[0366] 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 modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the scope of protection of the present application.

Claims

1. A method for typesetting an element, characterized in that: The method comprises: Get at least one element to be typeset; Determining a layout strategy for at least one of the elements to be typeset; At least one of the elements to be typeset is typeset in a target area according to the typesetting strategy of the at least one element to be typeset.

2. The method according to claim 1, characterized in that Determining a layout strategy for at least one of the elements to be typeset includes: Determining a layout strategy for at least one element to be typeset based on the acquired at least one element to be typeset; wherein the layout strategy includes a cropping layout strategy and a non-croppable layout strategy; Determining a layout strategy for at least one element to be typeset based on the acquired at least one element to be typeset includes: Obtaining a typesetting attribute characteristic of at least one element to be typeset, and determining a typesetting strategy for at least one element to be typeset based on the typesetting attribute characteristic of the at least one element to be typeset; wherein the typesetting attribute characteristic includes at least one of an element addition and cropping attribute and an element source; Determining the layout strategy of at least one element to be typeset according to the layout attribute characteristics of at least one element to be typeset includes: In a case where the element source of at least one of the elements to be typeset is a preset source and / or the clipping attribute added to the element is non-clippable, determining the non-clippable typesetting strategy as the typesetting strategy of the at least one element to be typeset; Alternatively, when the element source of at least one of the elements to be typeset is not a preset source and the element added cropping attribute is not non-croppable, the croppable typesetting strategy is determined as the typesetting strategy of at least one of the elements to be typeset.

3. The method according to claim 1, characterized in that Before typeset at least one element to be typeset in a target area according to the typesetting strategy of at least one element to be typeset, the method further includes: According to a preset scaling rule, at least one of the elements to be typeset is scaled proportionally, and the at least one element to be typeset obtained after scaling is used as the element to be typeset.

4. The method according to claim 1, wherein The step of typeset at least one element to be typeset in a target area according to the typesetting strategy of the at least one element to be typeset includes: When the typesetting strategy is a non-croppable typesetting strategy, the elements to be typeset are typeset in the target area by splicing; wherein the typeset elements after typeset maintain the element content and the original element ratio of the elements to be typeset; Alternatively, when the layout strategy is a cropping layout strategy, the elements to be layouted are layouted in the target area by grouping; wherein the grouping is based on at least one of the area, aspect ratio, height, and width of the elements to be layouted; or the grouping is based on the number of elements to be layout, and at least one of the area, aspect ratio, height, and width.

5. The method according to claim 4, characterized in that The step of typeset the elements to be typeset in the target area by splicing includes: Obtaining N element layout strategies, where N is a positive integer and the N element layout strategies are different; selecting a target element layout strategy from the N element layout strategies based on a strategy screening feature of at least one element to be typeset; and typeset at least one element to be typeset in a target area according to the target element layout strategy to obtain a layout result; Alternatively, N element layout strategies are obtained, where N is a positive integer, and the N element layout strategies are different; for any of the element layout strategies, at least one of the elements to be layouted is layouted in the target area according to the element layout strategy to obtain a first layout result; a first target layout result is selected from the N first layout results, and the first target layout result is determined as the layout result of at least one of the elements to be layouted in the target area.

6. The method according to claim 5, characterized in that The element layout strategy includes a layout direction strategy; The step of typeset at least one element to be typeset in a target area according to the element typeset strategy to obtain a first typeset result includes: Store at least one element to be typeset into an element list, and iteratively perform the following steps until the element list is empty, thereby obtaining a first typeset result: Determine, according to the typesetting direction strategy, an area in the target area that is not typeset in the current round, where the area that is not typeset in the current round is an untypesetting area of the current column / row corresponding to the typesetting direction strategy; A target element is selected from the element list, the target element is laid out in the area according to the layout direction strategy, and the target element is removed from the element list.

7. The method according to claim 6, characterized in that The element layout strategy also includes an initial element selection strategy; The selecting a target element from the element list, typeset the target element to the area according to the typesetting direction strategy, and removing the target element from the element list includes: According to the initial element selection strategy, an initial element is selected from the element list, according to the layout direction strategy, the initial element is layouted to the area, and the initial element is removed from the element list.

8. The method according to claim 7, characterized in that The step of placing the initial element in the area according to the layout direction strategy includes: When the first form parameter of the initial element exceeds the first form parameter of the region, the initial element is scaled proportionally according to the first form parameter of the region; and the scaled initial element is laid out in the region according to the layout direction strategy; Alternatively, when the first formal parameter of the initial element does not exceed the first formal parameter of the region, the following processing is performed: According to the layout direction strategy, the initial element is laid out in the area, and the initial element is removed from the element list; According to the second parameter of the initial element, the remaining elements in the element list are scaled proportionally to obtain a target element list; A supplementary element is selected from the target element list, the supplementary element is laid out in the remaining area of the area according to the layout direction strategy, and the supplementary element is removed from the target element list.

9. The method according to claim 8, characterized in that The selecting a supplementary element from the target element list, typeset the supplementary element to a remaining area of the area according to the typesetting direction strategy, and removing the supplementary element from the target element list includes: Detecting whether there is a first supplementary element in the target element list, where the first supplementary element is an element in the target element list with the smallest scaling ratio and a first formal parameter obtained after scaling that is less than or equal to a first formal parameter of a remaining area of the area; If the first supplementary element exists, typeset the first supplementary element to the remaining area of the region according to the typesetting direction strategy, and remove the first supplementary element from the target element list; if the target element list is not empty and the remaining area of the region is not empty, perform the step of detecting whether the first supplementary element exists in the target element list; Alternatively, if the first supplementary element does not exist, the following processing is performed: Selecting a second supplementary element from the target element list, where the second supplementary element is the element with the smallest scaling ratio in the target element list; According to the layout direction strategy, layout the second supplementary element to the remaining area of the region, and remove the second supplementary element from the target element list; According to the first shape parameter of the region, the target elements in the region are proportionally scaled so that the sum of the first shape parameters of the scaled target elements is the same as the first shape parameter of the region.

10. The method according to claim 6, characterized in that The method further comprises: When the element list is empty, detecting whether there is any remaining area in the last round of untypesetting area in the target area; If there is a remaining area in the target area that has not been typeset in the last round, the following processing is performed: According to the first formal parameter of the last round of untypesetted area, the target elements in the last round of untypesetted area are proportionally scaled so that the sum of the first formal parameters of the target elements in the last round of untypesetted area after scaling is the same as the first formal parameter of the last round of untypesetted area.

11. The method according to claim 4, characterized in that In the case where the layout strategy is a cropping layout strategy, the elements to be layouted are layouted in a target area by grouping, including: In the case where the typesetting strategy is a tailorable typesetting strategy, detecting the number of the elements to be typeset; Typesetting at least one of the elements to be typeset in a target area according to the quantity; The step of typeset at least one of the elements to be typeset in the target area according to the quantity includes: When the number is one, scaling and / or cropping the element to be typeset according to the size of the target area, and typeset it in the target area; Alternatively, when the number is two, determining a first area ratio between the two elements to be typeset; and typeset the two elements to be typeset in a target area according to the first area ratio; Alternatively, when the number is more than two, the elements to be typeset are typeset in the target area by grouping.

12. The method according to claim 11, characterized in that The step of typeset-ing the two elements to be typeset in a target area according to the first area ratio includes: determining a first segmentation line of the target area according to the first area ratio; dividing the target area into a first area and a second area according to the first dividing line; Based on the first area and the second area, typeset the two elements to be typeset; Wherein, dividing the target area into a first area and a second area according to the first dividing line includes: Determining the sum of the first aspect ratios of the two elements to be typeset; comparing the sum of the first aspect ratios with the aspect ratio of the target area; determining a first segmentation strategy for the target area according to the comparison result; dividing the target area into a first area and a second area according to the first segmentation strategy and the first segmentation line; The step of typeset-ing the two elements to be typeset based on the first area and the second area includes: scaling and / or cropping one of the two elements to be typeset according to the size of the first area, and typeset the element in the first area; The other of the two elements to be typeset is scaled and / or cropped according to the size of the second area, and is typeset in the second area.

13. The method according to claim 12, characterized in that Determining a first segmentation strategy for the target area according to the comparison result includes: In a case where the sum of the first aspect ratios is greater than the aspect ratio of the target area, determining horizontal segmentation as a first segmentation strategy for the target area; Alternatively, when the sum of the first aspect ratios is less than or equal to the aspect ratio of the target area, vertical segmentation is determined as the first segmentation strategy for the target area.

14. The method according to claim 11, characterized in that The step of typeset-ing the elements to be typeset in a target area by grouping includes: Obtaining a preset grouping strategy set, wherein the preset grouping strategy set includes M grouping strategies, where M is a positive integer and each of the M grouping strategies is different; selecting a target grouping strategy from the preset grouping strategy set based on the strategy screening features of the two or more elements to be typeset; typeset the two or more elements to be typeset according to the target grouping strategy to obtain a typeset result; Alternatively, obtain a preset grouping strategy set, which includes M grouping strategies, where M is a positive integer, and the M grouping strategies are different; traverse the grouping strategies in the preset grouping strategy set, and use the grouping strategies to typeset two or more elements to be typeset in the target area to obtain a second typesetting result; select a second target typesetting result from the M second typesetting results, and determine the second target typesetting result as the typesetting result of the two or more elements to be typeset in the target area.

15. The method according to claim 14, characterized in that The step of typeset-ing the two or more elements to be typeset in the target area using the grouping strategy to obtain a second typeset result includes: Grouping the two or more elements to be typeset using the grouping strategy to obtain a first group and a second group; determining a second area ratio between the sum of the areas of the elements to be typeset in the first group and the sum of the areas of the elements to be typeset in the second group; dividing the target area into a first sub-area and a second sub-area according to the second area ratio; When the number of elements in the first group is a preset value, the elements to be typeset in the first group are scaled and / or cropped according to the size of the first sub-area, and are typeset in the first sub-area; and / or when the number of elements in the second group is a preset value, the elements to be typeset in the second group are scaled and / or cropped according to the size of the second sub-area, and are typeset in the second sub-area, to obtain a second typeset result.

16. The method according to claim 15, characterized in that The step of dividing the target area into a first sub-area and a second sub-area according to the second area ratio includes: determining a second segmentation line of the target area according to the second area ratio; dividing the target area into a first sub-area and a second sub-area according to the second dividing line; Partitioning the target area into a first sub-area and a second sub-area according to the second dividing line includes: Determining the sum of the second aspect ratios of the elements to be typeset in the first group and the second group, and comparing the sum of the second aspect ratios with the aspect ratio of the target area; determining a second segmentation strategy for the target area according to the comparison result; The target area is divided into a first sub-area and a second sub-area according to the second segmentation strategy and the second segmentation line.

17. The method according to claim 16, characterized in that Determining a second segmentation strategy for the target area according to the comparison result includes: In a case where the sum of the second aspect ratios is greater than the aspect ratio of the target area, determining horizontal segmentation as a second segmentation strategy for the target area; Alternatively, when the sum of the second aspect ratios is less than or equal to the aspect ratio of the target area, vertical segmentation is determined as the second segmentation strategy for the target area.

18. The method according to claim 15, characterized in that The method further comprises: When the number of elements in the first group is not a preset value, the elements to be typeset in the first group are regarded as two or more elements to be typeset, and the step of grouping the two or more elements to be typeset using the grouping strategy to obtain the first group and the second group is performed; When the number of elements in the second group is not a preset value, the elements to be typeset in the second group are regarded as two or more elements to be typeset, and the step of grouping the two or more elements to be typeset using the grouping strategy to obtain the first group and the second group is performed.

19. The method according to claim 15 or 18, characterized in that The adopting the grouping strategy to group the two or more elements to be typeset to obtain a first group and a second group includes: Obtain all combinations of a first group and a second group obtained by grouping two or more of the elements to be typeset; For any of the combinations, determining a first total area of the elements to be typeset in a first group and a second total area of the elements to be typeset in a second group in the combination; determining an area difference between the first area sum and the second area sum; The smallest area difference is selected from all the area differences, and the first group and the second group in the combination corresponding to the smallest area difference are determined.

20. The method according to claim 15 or 18, characterized in that The adopting the grouping strategy to group the two or more elements to be typeset to obtain a first group and a second group includes: Obtaining the sum of aspect ratios of the two or more elements to be typeset, and determining the product of the sum of aspect ratios and a preset threshold; adding some of the elements to be typeset to the first group, so that the difference between the sum of the aspect ratios of the elements to be typeset in the first group and the product is smaller than a preset difference; Another portion of the elements to be typeset is added to the second group.

21. The method according to claim 15 or 18, characterized in that The adopting the grouping strategy to group the two or more elements to be typeset to obtain a first group and a second group includes: sorting the two or more elements to be typeset according to their areas, and allocating the two or more elements to be typeset to a first group and a second group in sequence according to the sorting results; Alternatively, the two or more elements to be typeset are sorted according to their widths, and according to the sorting results, the two or more elements to be typeset are sequentially allocated to the first group and the second group; Alternatively, the two or more elements to be typeset are sorted according to their heights, and according to the sorting results, the two or more elements to be typeset are sequentially allocated to the first group and the second group.

22. An element typesetting device, characterized in that: The device comprises: An element acquisition module, used to acquire at least one element to be typeset; A strategy determination module, configured to determine a layout strategy for at least one of the elements to be typeset; An element layout module is configured to layout at least one element to be typeset in a target area according to the layout strategy of the at least one element to be typeset.

23. A storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 21 is implemented.

Citation Information

Cited By

  • Method and device for chip typesetting and medium

    CN120745543A