CN109978972B - Method and device for editing characters in picture - Google Patents

Method and device for editing characters in picture Download PDF

Info

Publication number
CN109978972B
CN109978972B CN201910210972.6A CN201910210972A CN109978972B CN 109978972 B CN109978972 B CN 109978972B CN 201910210972 A CN201910210972 A CN 201910210972A CN 109978972 B CN109978972 B CN 109978972B
Authority
CN
China
Prior art keywords
character string
target
style
input
characters
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910210972.6A
Other languages
Chinese (zh)
Other versions
CN109978972A (en
Inventor
姜兴兵
李涛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhengzhou Apas Technology Co ltd
Original Assignee
Zhengzhou Apas Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhengzhou Apas Technology Co ltd filed Critical Zhengzhou Apas Technology Co ltd
Priority to CN201910210972.6A priority Critical patent/CN109978972B/en
Publication of CN109978972A publication Critical patent/CN109978972A/en
Application granted granted Critical
Publication of CN109978972B publication Critical patent/CN109978972B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/103Formatting, i.e. changing of presentation of documents
    • G06F40/106Display of layout of documents; Previewing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/166Editing, e.g. inserting or deleting
    • G06F40/186Templates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/60Editing figures and text; Combining figures or text

Abstract

The embodiment of the application provides a method for editing characters in pictures, which belongs to the field of picture editing. The method comprises the following steps: loading a given target template in the candidate picture; randomly selecting from a preset style library in real time, and determining a character style corresponding to a current character string in the target template, wherein the current character string is formed by extracting characters input by a third-party input method in real time; rendering the current character string according to the character style to form a target character string; and displaying the target character strings row by row in the target template. When the edited picture is added with characters, the input target characters are automatically displayed in various random patterns, a user does not need to manually operate and select the character patterns, the typesetting effect of the multiple character patterns can be rapidly achieved, the display information of the edited picture is enriched, the operation efficiency of the user is improved, and the personalized requirements of the user are met.

Description

Method and device for editing characters in picture
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a method and an apparatus for editing embedded text in a picture.
Background
With the rapid development of network technology, the variety and functions of network applications are becoming more and more abundant. Taking a camera application as an example, the camera application can meet entertainment requirements of users such as photographing, video recording and the like. In addition, the current camera also supports various picture editing operations such as beauty, mapping, multi-style effect and the like, when adding text content, typesetting operation can only be carried out on input text in a fixed format, and the style needs to be continuously adjusted during editing, so that the style is single during text typesetting, and the operation is too complicated.
Disclosure of Invention
The embodiment of the application aims to provide a method and a device for editing characters in pictures, so as to meet the requirement of a user for quickly editing characters in pictures obtained by photographing.
In order to solve the technical problems, the embodiment of the application is realized as follows:
according to a first aspect of embodiments of the present application, there is provided a method for editing text in a picture, applied to a terminal device, the method including:
loading a given target template in the candidate picture;
randomly selecting from a preset style library in real time, and determining a text style corresponding to a current character string in the target template; the current character string is formed by extracting characters input by a third-party input method in real time;
Rendering the current character string according to the character style to form a target character string;
and displaying the target character strings row by row in the target template. In an embodiment of the present application, the method further includes:
the text style is defined according to the display attribute of the characters, and the display attribute at least comprises: color, font size, whether background shadow is included, whether underline is included, whether inclination is performed;
and after the display attributes are respectively packaged, storing the display attributes in a preset style library in json mode.
In an embodiment of the present application, the method further includes:
detecting a time interval correspondingly generated when the third input method is input;
dividing the time interval; when the time interval is longer than the set time length, character patterns are selected randomly from the pattern library to render the current character string in real time;
and when the time interval is smaller than the set duration, rendering the current character string according to the text style of the current application.
In an embodiment of the present application, the method further includes:
and calculating the current character string according to single characters, and respectively and randomly selecting character patterns from the pattern library for real-time rendering of the single characters of the current character string.
In an embodiment of the present application, when the rendering is performed on the current character string according to the text style, the method further includes:
calling the text style, and respectively loading each display attribute corresponding to the text style on the current character string;
and respectively rendering each character in the current character string according to the display attribute to form the target character string.
In an embodiment of the present application, when the displaying the target character string row by row, the method further includes:
acquiring the real-time corresponding size and/or character number of the target character string;
and scaling and line-wrapping the target character string according to the display area in the target template and the corresponding size of the target character string, so that the input target character string fills the display area in the target template.
In an embodiment of the present application, when scaling and line wrapping are performed on the target string, the method further includes:
extracting the number of characters corresponding to a display area and an input target character string in the target template, and when the number of characters is larger than the number of characters correspondingly accommodated in the display area, line feed and reduction are carried out on the word size corresponding to the target character string;
And extracting the corresponding size of the display area and the corresponding size of the target character string in the target template, and when the corresponding size of the display area is smaller than the corresponding size of the target character string, wrapping and shrinking the target character string according to the corresponding size of the display area.
According to a second aspect of embodiments of the present application, there is provided an apparatus for text editing in a picture, the apparatus including:
the loading module is used for loading a given target template in the candidate pictures;
the selecting module is used for randomly selecting from a preset style library in real time and determining a text style corresponding to a current character string in the target template; the current character string is formed by extracting characters input by a third-party input method in real time;
the rendering module is used for rendering the current character string according to the character style to form a target character string;
and the display module is used for displaying the target character strings row by row in the target template.
In an embodiment of the present application, the text style is defined according to display attributes of characters, where the display attributes at least include: color, font size, whether background shadow is included, whether underline is included, whether inclination is performed;
And after the display attributes are respectively packaged, storing the display attributes in a json form in a style library.
In an embodiment of the present application, the apparatus further includes:
the detection unit is used for detecting a time interval correspondingly generated when the third input method is input;
the character string processing unit is used for dividing the time interval; when the time interval is longer than the set time length, character patterns are selected randomly from the pattern library to render the current character string in real time;
and when the time interval is smaller than the set duration, rendering the current character string according to the text style of the current application.
In an embodiment of the present application, the apparatus further includes:
and the single character processing unit is used for calculating the current character string according to single characters and rendering the single characters of the current character string in real time by randomly selecting the text styles from the style library.
In one embodiment of the present application, the rendering module specifically includes,
the style calling unit is used for calling the text style and loading each display attribute corresponding to the text style on the current character string respectively;
and the character rendering unit is used for respectively rendering each character in the current character string according to the display attribute to form the target character string.
In one embodiment of the present application, the display module specifically includes,
the acquisition unit is used for acquiring the size and/or the character number corresponding to the target character string in real time;
and the adjusting unit is used for scaling and line-wrapping the target character string according to the display area in the target template and the corresponding size of the target character string, so that the input target character string fills the display area in the target template.
In one embodiment of the present application, the adjusting unit specifically includes,
the first reduction unit is used for extracting the display area in the target template and the number of characters corresponding to the input target character string, and when the number of characters is larger than the number of characters correspondingly accommodated in the display area, line feed and reduction are carried out on the word size corresponding to the target character string;
and the second shrinking unit is used for extracting the corresponding size of the display area and the corresponding size of the target character string in the target template, and when the corresponding size of the display area is smaller than the corresponding size of the target character string, the target character string is subjected to line feed and shrinking according to the corresponding size of the display area.
As can be seen from the technical solutions provided in the embodiments of the present application, when text input is performed on a picture, a predetermined target template is loaded in a candidate picture; randomly selecting from a preset style library in real time, and determining a character style corresponding to a current character string in the target template, wherein the current character string is formed by extracting characters input by a third-party input method in real time; rendering the current character string according to the character style to form a target character string; and displaying the target character strings row by row in the target template. According to the embodiment of the application, when the edited picture is added with the characters, the input target characters are automatically displayed in various random patterns, a user does not need to manually operate and select the character patterns, the typesetting effect of the multiple character patterns can be rapidly achieved, the display information of the edited picture is enriched, the operation efficiency of the user is improved, and the personalized requirements of the user are met.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments described in the present specification, and that other drawings may be obtained according to these drawings without inventive effort to a person skilled in the art.
FIG. 1 is a flow chart of a method of text editing in a picture of one embodiment of the present application;
FIG. 2 is a schematic diagram of an editing example of a method of text editing in a picture according to one embodiment of the present application;
FIG. 3 is an example schematic diagram of a method of text editing in a picture of one embodiment of the present application as it continues to edit;
FIG. 4 is an example schematic diagram of the method of text editing in a picture at the completion of editing in accordance with one embodiment of the present application;
FIG. 5 is a schematic diagram of an editing example of a method of text editing in a picture according to another embodiment of the present application;
FIG. 6 is a schematic diagram of an example of the method of text editing in a picture at the completion of editing according to another embodiment of the present application;
FIG. 7 is a schematic diagram of a text editing corresponding electronic device in a picture according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of an apparatus for text editing in a picture according to an embodiment of the present application.
Detailed Description
In order to make the technical solutions in the present specification better understood by those skilled in the art, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only some embodiments of the present specification, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are intended to be within the scope of the present disclosure.
The embodiment of the application provides a method and a device for editing characters in a picture.
The following first describes a method for editing characters in a picture provided in an embodiment of the present application.
It should be noted that, the method provided in the embodiment of the present application is applicable to a terminal device, and in practical application, the terminal device may include: smartphones, tablet computers, smartwatches, notebook/desktop computers, etc., to which embodiments of the present application are not limited.
FIG. 1 is a flow chart of a method of text editing in a picture of an embodiment of the present application, as shown in FIG. 1, the method may include the steps of:
in step 101, a predetermined target template is loaded in a candidate picture.
In this embodiment of the present application, one or more images may be pre-stored in the terminal device, where in an optional implementation manner, the step 101 may include:
step 101: and loading a given target template in the candidate pictures.
In this embodiment, when performing text editing on a picture to be edited, a layer is set above the picture to be edited, a predetermined input frame is called in the layer to serve as a target template, the input frame may be in various shapes, such as a rectangle, a rounded rectangle, a circle, etc., a display area including editable characters is included in the input frame, after the characters input by a subsequent third-party input method are extracted, the characters are filled in the display area in real time, and thus a target character string input by the third-party input method in real time can be displayed in the target template.
After loading the target character string in the target template, displaying the layer of the target template above the picture to be edited, and displaying the effect of character editing in the picture to be edited.
Step 102: randomly selecting from a preset style library in real time, and determining a text style corresponding to a current character string in the target template, wherein the current character string is formed by extracting characters input by a third-party input method in real time.
A style library for storing a plurality of character styles is prestored in the terminal, the character styles represent various corresponding styles of input characters, and each character style is structurally stored in the style library. The text style is defined according to the display attribute of the characters, wherein the display attribute at least comprises: the color, the font size, the bottom shadow, the underline, the inclination and other corresponding attributes represent the appearance style of the characters, so that when the characters are added into the picture to be edited for typesetting, the display effect of displaying various styles for the target character string is obtained, and the user experience is enriched.
Extracting the current character string in real time from a third-party input method which is being used by a user, and randomly selecting a text style from a style library to apply the current character string.
1. For the Chinese input method, extracting the first candidate item as the current character string and inputting the current character string into the display area of the target template, randomly selecting the first candidate item from the style library in real time, and subsequently applying the selected character style to the first candidate item, thereby displaying the first candidate item in the target template in various character attributes of Chinese form, such as colors, fonts, word sizes and the like.
In other embodiments, when the first candidate is not the character string that the user wants to get on the screen, the user may also use the screen as a trigger to get the current character string when the user inputs. Extracting the Chinese characters on the screen from the input method, randomly selecting corresponding text patterns from the pattern library in real time, and displaying the Chinese characters on the screen in the target template according to the text patterns.
In another embodiment, each Chinese character in the first candidate item and/or the Chinese character on the screen is respectively used as a current character string, the character patterns of the current character string are randomly selected from the pattern library for rendering in real time, namely, each Chinese character is used as a unit, the corresponding character pattern is called from the pattern library for rendering, and the display patterns of each Chinese character are different in each target template, so that various display effects are formed, and the visual experience and the user experience of the user are improved.
2. For the English input method, candidate current character strings are input into a display area of a target template in real time, simultaneously, the candidate current character strings are randomly selected from a style library in real time, and then the selected character styles are applied to the current character strings in the display area, so that the current character strings are displayed in the target template in various English colors, fonts, character sizes and other character attributes.
In other embodiments, detecting a time interval corresponding to the third input method when the third input method is input;
dividing the time interval; when the time interval is longer than the set duration, the third party input method is stopped in the input process, the possibility of sentence breaking is high, a text pattern is selected from the pattern library at random, the next sentence input again after the time interval is rendered by adopting other text patterns, and the next sentence rendered by adopting other text patterns is displayed in the target template;
when the time interval is smaller than the set time length, the third-party input method is indicated to be free from pause in the input process, the possibility of sentence breaking is low, the current character string is continuously rendered according to the currently applied character style, the current character string keeps the character style unchanged, and the consistency of the character style is maintained.
In another embodiment, the current character string is calculated according to single words, namely, the single words of the current character string are calculated respectively, the text patterns are randomly selected from the pattern library respectively, and the words are rendered in real time respectively. Specifically, when the third-party input method is detected to be input into a space or a punctuation, corresponding text patterns are randomly selected from a pattern library in real time, character strings input after the space or the punctuation are rendered, and the character strings input into a target template are displayed in different text patterns by taking words as units.
Specifically, when character patterns are randomly selected from a given pattern library, each character pattern is selected in a random mapping mode, namely each character pattern in the pattern library is mapped to a section of 0-1 in an associated mode according to a corresponding sequence number mark. When the character patterns are selected, a random number generation algorithm is adopted to generate a 0-1 random number, and the random number is mapped to a certain character pattern, so that the character patterns in a pattern library are selected randomly.
Step 103: rendering the current character string according to the character style to form a target character string;
in this embodiment, the text style encapsulates the display attribute corresponding to the character in json form, including: color, font size, whether bottom shadow is included, whether underline is included, whether inclination is performed, whether bottom shadow is present, whether thickening is performed, and the like;
the style library is stored in the terminal local, the character attributes are arranged in a permutation and combination mode, and the style library is packaged in a json mode uniformly after the arrangement is finished and stored in the style library. When the current character string is rendered, the json is called to analyze, the display attribute in the json is analyzed and the current character string is applied, and the current character string is applied according to the attribute such as color, bottom shadow, font size and the like defined in the json to form a rendered target character string, so that a richer visual effect is provided.
Step 104: and displaying the target character strings row by row in the target template.
And filling the rendered target character string into an editing area of the target template. Because the size and the size of the editing area are fixed, the system API is called to zoom and line feed the target character string and other character strings which are input into the editing area, so that the target character string and the other character strings which are input into the editing area are all displayed in the target template.
In this embodiment, the specific steps are:
acquiring the real-time corresponding size and/or character number of the target character string;
and scaling and line-wrapping the target character string according to the display area in the target template and the corresponding size of the target character string, so that the input target character string fills the display area in the target template.
When scaling and line feed are carried out, the input characters can be compared with the corresponding sizes of the display areas according to the number of the input characters, and the details are as follows:
extracting a display area in the target template and the number of characters corresponding to the input target character string, and calling a system API to perform line feed and reduction on the word size corresponding to the target character string when the number of characters is larger than the number of characters correspondingly accommodated in the display area, so that the input target character string fills the display area in the target template;
And extracting the corresponding size of the display area in the target template and the corresponding size of the target character string, and when the corresponding size of the display area is smaller than the corresponding size of the target character string, wrapping and shrinking the target character string according to the corresponding size of the display area, so that the input target character string fills the display area in the target template.
Extracting a display area in the target template and the number of characters corresponding to the input target character string, and calling a system API to amplify the word size corresponding to the target character string when the number of characters is larger than the number of characters correspondingly accommodated in the display area, so that the input target character string fills the display area in the target template;
and extracting the corresponding size of the display area in the target template and the corresponding size of the target character string, and amplifying the target character string according to the corresponding size of the display area when the corresponding size of the display area is larger than the corresponding size of the target character string, so that the input target character string fills the display area in the target template.
The input target character string fills the display area in the target template, specifically:
The filling ratio of the input target character string in the display area of the target template is smaller than the first preset ratio and larger than the second preset ratio.
For example: setting the filling ratio of the input target character string in the display area of the target template to be smaller than 80% or larger than 120%, and if the input target character string is not in the preset filling ratio range, scaling the target character string until the input target character string in the display area of the target template accords with the preset filling ratio.
After loading the target character string in the target template, displaying the layer of the target template above the picture to be edited, and displaying the effect of performing text editing in the picture to be edited. Of course, after the target character string is displayed in the target template, the candidate picture can also be triggered by the user again. Specifically, a layer is newly built above the layer where the target template is located, and other templates are loaded in the newly built layer for character string input by a user, so that a plurality of target character strings are displayed in the candidate pictures, and display information of the edited pictures is enriched.
In this embodiment, a predetermined target template is loaded in a candidate picture; randomly selecting from a preset style library in real time, and determining a text style corresponding to a current character string in the target template; the current character string is formed by extracting characters input by a third-party input method in real time; rendering the current character string according to the character style to form a target character string; and displaying the target character strings row by row in the target template. According to the embodiment of the application, when the edited picture is added with the characters, the input target characters are automatically displayed in various random patterns, a user does not need to manually operate and select the character patterns, the typesetting effect of the multiple character patterns can be rapidly achieved, the display information of the edited picture is enriched, the operation efficiency of the user is improved, and the personalized requirements of the user are met.
In another alternative embodiment, the character input is performed in the candidate pictures,
step 201: loading a given target template in the candidate picture on the candidate picture;
in this embodiment, the user performs text editing on the picture shown in fig. 2 as a candidate picture, invokes a hexagonal input frame as a target template,
step 202: randomly selecting from a preset style library in real time, and determining a text style corresponding to a current character string in the target template;
the corresponding json style is selected in real time by adopting a random number generation mode, and the display attribute corresponding to the json style selected in the embodiment is as follows: font: bold, word size: 30pt, color: black, background: no, underlined: no, tilt: no. … …
Detecting a corresponding time interval when the third party input method is input, wherein in the embodiment, the set time interval is 0.3s, and extracting the "laughter of haha" input in real time from the third party input method, namely, the text style corresponding to the current character string "laughter of haha" is: font: bold, word size: 30pt, color: black, background: no, underlined: no, tilt: no … … and the time interval for detecting each character input does not exceed 0.3s.
Step 203: rendering the 'laugh with the haha' according to the character style, loading the display attributes corresponding to the haha's laugh with the haha's laugh, the haha's laugh with the haha's no laugh, the haha's no underline, and the haha's no inclination, as shown in fig. 2.
Step 204: displaying the target character string row by row in the target template
In this embodiment, the width corresponding to the target character string, that is, the width occupied by 7 character sizes of 30pt in the target character string "haha joke" is 210pt. In an initial state, the display area in the hexagonal target template is 3 rows, the width of the first row is 100pt, the width of the second row is 160pt, and then the system API is called to start line feed of the fourth character laugh of the target character string, the first row displays the laugh, and the second row displays the laugh continuously, so that the laugh continuously of the target character string is displayed in the hexagonal target template.
As shown in fig. 3, when the character 'true lovely' input by the user in the third input method in real time is continuously extracted, detecting a time interval correspondingly generated when the third input method is input; in this embodiment, the time interval is set to 0.3s,
After detecting that the user inputs the character string 'haha laugh is continuously stopped' for 0.4s, randomly selecting the character string from a style library, and determining the character style corresponding to the current character string 'true lovely'. In this embodiment, the display attribute corresponding to the json style selected is: font: bold, word size: 36pt, color: dark green, bottom shadow: no, underlined: has, slope: … … is provided with
Rendering the current character string 'true lovely' according to the display attribute corresponding to the json style, namely setting the font of the current character string 'true lovely' as a bold type, setting the font size as 36pt, setting the color as dark green, setting the underlined and inclined style, and obtaining the rendered target character string 'true lovely'.
Meanwhile, the width corresponding to the target character string is acquired, namely the width occupied by 3 character sizes of 36pt in the target character string 'true lovely' is 108pt. In an initial state, the width of the second line is 160pt, the last character string is "haha laugh is continuously" 120pt in the second line, then a 36pt character can be contained in the remaining 40pt of the second line, namely, the second character of the target character string can be changed by calling the system API, the second line shows "true", and the third line shows "lovely", so that the target character string can be shown in the hexagonal target template.
When continuously extracting characters 'good want to strongly and strongly to the one-touch' input by a user in real time by a third-party input method, detecting a time interval correspondingly generated when the third-party input method is input;
as shown in fig. 4, if a pause of 0.5s is detected after the user inputs the character string "true lovely", a random selection is additionally performed from the style library, and the text style corresponding to the current character string "good-looking deep one-touch" is determined. In this embodiment, the display attribute corresponding to the json style selected is: font: regular script, word size: 30pt, color: red, coarsening: there are, underlines: no, tilt: no. … …
Rendering the current character string 'good want to strongly and strongly to the first aspect' according to the display attribute corresponding to the json style, namely setting the font of the current character string 'good want to strongly and strongly to the first aspect' as a regular script, setting the font size as 30pt, setting the color as red, and setting a thickened style to obtain the rendered target character string 'good want to strongly to the first aspect'.
Meanwhile, the width corresponding to the target character string is obtained, namely, the width occupied by 8 character sizes of 30pt in the target character string 'good want to strongly surround' is 240pt. In the initial state, the width of the third line is 100pt, the last character string is "true lovely" and 80pt is already occupied in the second line, and 240pt of the target character string which is not lower is accommodated in the remaining 20pt of the second line. At this time, the system API is called to scale the display area in the initial state, that is, to increase the number of lines in the display area, and at the same time, to uniformly typeset the inputted character strings, to uniformly scale the inputted character strings according to the size of the original characters, and to count the number of inputted characters and the width corresponding to each character, in this embodiment, to reduce each character to 80% of the original, as shown in fig. 4, the inputted target character string "like strongly and strongly to one touch" is completely displayed in the display area in the hexagonal input template in another text style.
In this embodiment, when adding text, a predetermined text style is randomly called from a style library, and at the same time, a time interval generated correspondingly when a user inputs in real time is detected, a current character string is divided by taking an input pause as a unit, and a corresponding text style is called to render the current character string, so that each corresponding clause when inputting pause is automatically displayed in a target template in different text styles, and the user can quickly realize typesetting effect of multiple text styles without manually editing the text styles, thereby enriching display information of the edited picture, improving operation efficiency of the user, and meeting individual requirements of the user.
In another embodiment, when character input is performed in the candidate picture,
step 301: loading a given target template in the candidate picture on the candidate picture;
in the embodiment, when the user edits the candidate pictures, a layer is arranged on the candidate pictures, a target template which is hexagonal in shape and gray in background is called,
step 302: randomly selecting from a preset style library in real time, and determining a text style corresponding to a current character string in the target template;
In this embodiment, characters input in real time by the third-party input method are extracted in real time, the input character strings are segmented in units of rows, the character strings in the rows are used as current character strings, real-time selection is randomly performed in the json library, and the obtained random character patterns correspond to texts in each row respectively.
Specifically, the json library in this embodiment is as follows:
Figure BDA0002000467010000111
/>
Figure BDA0002000467010000121
/>
Figure BDA0002000467010000131
and randomly calling the corresponding json from the json library as the current line, namely the text style corresponding to the current character string.
In other embodiments, the current character string may be calculated according to a single character, and the single characters of the current character string may be respectively and randomly selected from the style library to perform real-time rendering, that is, the display attribute of each character loaded is different, then the target character strings forming different character styles are displayed in the target template, so that the display effect is enriched, meanwhile, the process of editing and typesetting characters by the user is omitted, and the input efficiency of the user is improved.
Step 303: rendering the current character string according to the character style to form a target character string;
in this embodiment, as a user continuously performs character input, rendering is performed on a current character string of each row by calling a corresponding text style in units of rows, that is, each display attribute corresponding to the text style is loaded on the current character string, and each character in the current character string is rendered to form a target character string.
If the current character string is input to the last row, the realization is performed. ", and the sixth row randomly selected text style is:
"type":0,
"textSize":20,
"textColor":"#FFFF0000",
"colorGroup":0,
"font":"fonts/Orbitron-Medium.ttf"
the sixth row is implemented according to the display attribute therein. "font size is set to 20 (" textSize ": 20), font is set to Orbitron-Medium (" font ":" nts/Orbitron-Medium. Ttf "), and text color is yellow (" textColor ":" # FFFFFF00 "), forming the target string" implementation as shown in fig. 5. "
Step 304: displaying the target character string row by row in the target template
In this embodiment, the height of the area required for drawing the current text is compared, and if the height of the current area is less than 80% of the height of the display area corresponding to the target template or greater than 120% of the height of the display area corresponding to the target template, the text sizes of all the rows are enlarged or reduced again. As shown in fig. 6, if the corresponding height of the displayed 6 rows of target strings is less than 80% of the display area, the word sizes corresponding to all the target strings are enlarged to 1.2 times of the original word sizes, rendering is performed again, and the updated target strings are loaded into the target template.
And displaying the target template on the top layer of the picture to be edited, so that the effect of performing text editing on the picture to be edited is formed.
In this embodiment, when adding text, the edited picture randomly calls a predetermined text style from the style library, and the input target character is automatically displayed in the target template in a row unit, so that the user does not need to manually edit the text style, and the typesetting effect of multiple text styles can be quickly realized, the display information of the edited picture is enriched, the operation efficiency of the user is improved, and the personalized requirement of the user is met.
Fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application. Referring to fig. 7, at the hardware level, the electronic device includes a processor, and optionally an internal bus, a network interface, and a memory. The Memory may include a Memory, such as a Random-Access Memory (RAM), and may further include a non-volatile Memory (non-volatile Memory), such as at least 1 disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, network interface, and memory may be interconnected by an internal bus, which may be an ISA (Industry Standard Architecture ) bus, a PCI (Peripheral Component Interconnect, peripheral component interconnect standard) bus, or EISA (Extended Industry Standard Architecture ) bus, among others. The buses may be classified as address buses, data buses, control buses, etc. For ease of illustration, only one bi-directional arrow is shown in FIG. 7, but not only one bus or type of bus.
And the memory is used for storing programs. In particular, the program may include program code including computer-operating instructions. The memory may include memory and non-volatile storage and provide instructions and data to the processor.
The processor reads the corresponding computer program from the nonvolatile memory to the memory and then runs the computer program to form the device for embedding the expression into the input method candidate on the logic level. The processor is used for executing the programs stored in the memory and is specifically used for executing the following operations:
loading a given target template in the candidate picture;
randomly selecting from a preset style library in real time, and determining a text style corresponding to a current character string in the target template; the current character string is formed by extracting characters input by a third-party input method in real time;
rendering the current character string according to the character style to form a target character string;
and displaying the target character strings row by row in the target template.
The method executed by the text editing apparatus in the picture disclosed in the embodiment shown in fig. 7 of the present application may be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or by instructions in the form of software. The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processor, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The disclosed methods, steps, and logic blocks in the embodiments of the present application may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of a method disclosed in connection with the embodiments of the present application may be embodied directly in hardware, in a decoded processor, or in a combination of hardware and software modules in a decoded processor. The software modules may be located in a random access memory, flash memory, read only memory, programmable read only memory, or electrically erasable programmable memory, registers, etc. as well known in the art. The storage medium is located in a memory, and the processor reads the information in the memory and, in combination with its hardware, performs the steps of the above method.
The electronic device may also execute the method of fig. 1, and implement the function of the embodiment shown in fig. 1 of the text editing device in the picture, which is not described herein again.
Of course, in addition to the software implementation, the electronic device in this specification does not exclude other implementations, such as a logic device or a combination of software and hardware, that is, the execution subject of the following process is not limited to each logic unit, but may also be hardware or a logic device.
The present embodiments also provide a computer readable storage medium storing one or more programs, the one or more programs comprising instructions, which when executed by a portable electronic device comprising a plurality of application programs, enable the portable electronic device to perform the method of the embodiment of fig. 1, and in particular to perform the method of:
loading a given target template in the candidate picture;
randomly selecting from a preset style library in real time, and determining a text style corresponding to a current character string in the target template; the current character string is formed by extracting characters input by a third-party input method in real time;
Rendering the current character string according to the character style to form a target character string;
and displaying the target character strings row by row in the target template.
Fig. 8 is a schematic structural diagram of a text editing apparatus in a picture according to an embodiment of the present application. Referring to fig. 8, in a software embodiment, a text editing apparatus 800 in a picture may include: a loading module 801, a selection module 802, a rendering module 803, and a presentation module 804, wherein,
a loading module 801, configured to load a predetermined target template in a candidate picture;
a selecting module 802, configured to randomly select, in real time, from a preset style library, and determine a text style corresponding to a current character string in the target template; the current character string is formed by extracting characters input by a third-party input method in real time;
a rendering module 803, configured to render the current character string according to the text style to form a target character string;
and the display module 804 is configured to display the target character string row by row in the target template.
The text style is defined according to the display attribute of the characters, and the display attribute at least comprises: color, font size, whether background shadow is included, whether underline is included, whether inclination is performed;
And after the display attributes are respectively packaged, storing the display attributes in a json form in a style library.
The apparatus 800 further comprises:
the detection unit is used for detecting a time interval correspondingly generated when the third input method is input;
the character string processing unit is used for dividing the time interval; when the time interval is longer than the set duration, character patterns are selected from the pattern library randomly, and the character strings input after the time interval are rendered in real time;
and when the time interval is smaller than the set duration, continuing to render the current character string according to the text style of the current application.
The apparatus 800 further comprises:
and the single character processing unit is used for calculating the current character string according to single characters and rendering the single characters of the current character string in real time by randomly selecting the text styles from the style library.
The rendering module 803 specifically includes,
the style calling unit is used for calling the text style and loading each display attribute corresponding to the text style on the current character string respectively;
and the character rendering unit is used for respectively rendering each character in the current character string according to the display attribute to form the target character string.
The display module 804 specifically includes a display module,
the acquisition unit is used for acquiring the size and/or the character number corresponding to the target character string in real time;
and the adjusting unit is used for scaling and line-wrapping the target character string according to the display area in the target template and the corresponding size of the target character string, so that the input target character string completely fills the display area in the target template.
The said adjusting unit comprises in particular a control unit,
the first reduction unit is used for extracting the display area in the target template and the number of characters corresponding to the input target character string, and when the number of characters is larger than the number of characters correspondingly accommodated in the display area, line feed and reduction are carried out on the word size corresponding to the target character string;
and the second shrinking unit is used for extracting the corresponding size of the display area and the corresponding size of the target character string in the target template, and when the corresponding size of the display area is smaller than the corresponding size of the target character string, the target character string is subjected to line feed and shrinking according to the corresponding size of the display area.
In summary, the foregoing description is only a preferred embodiment of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification should be included in the protection scope of the present specification.
The system, apparatus, module or unit set forth in the above embodiments may be implemented in particular by a computer chip or entity, or by a product having a certain function. One typical implementation is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article or apparatus that comprises the element.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for system embodiments, since they are substantially similar to method embodiments, the description is relatively simple, as relevant to see a section of the description of method embodiments.

Claims (11)

1. A method for text editing in a picture, the method comprising:
loading a given target template in the candidate picture;
Randomly selecting from a preset style library in real time, and determining a text style corresponding to a current character string in the target template; the current character string is formed by extracting characters input by a third-party input method in real time;
rendering the current character string according to the character style to form a target character string;
displaying the target character strings row by row in the target template;
the method further comprises the steps of:
detecting a time interval correspondingly generated when the third input method is input;
dividing the time interval; when the time interval is longer than the set duration, character patterns are selected from the pattern library randomly, and the character strings input after the time interval are used as current character strings to be rendered in real time;
and when the time interval is smaller than the set duration, continuing to render the current character string according to the text style of the current application.
2. The method according to claim 1, characterized in that it comprises:
the text style is defined according to the display attribute of the characters, and the display attribute at least comprises: color, font size, whether background shadow is included, whether underline is included, whether inclination is performed;
and after the display attributes are respectively packaged, storing the display attributes in a preset style library in json mode.
3. The method according to claim 1 or 2, characterized in that the method further comprises:
and calculating the current character string according to single characters, and respectively and randomly selecting character patterns from the pattern library for real-time rendering of the single characters of the current character string.
4. The method according to claim 1 or 2, wherein when rendering the current character string according to the text style, further comprising:
calling the text style, and respectively loading each display attribute corresponding to the text style on the current character string;
and respectively rendering each character in the current character string according to the display attribute to form the target character string.
5. The method of claim 1, wherein the displaying the target string row by row further comprises:
acquiring the real-time corresponding size and/or character number of the target character string;
and scaling and line-wrapping the target character string according to the display area in the target template and the corresponding size of the target character string, so that the input target character string fills the display area in the target template.
6. The method of claim 5, wherein scaling and wrapping the target string further comprises:
Extracting the number of characters corresponding to a display area and an input target character string in the target template, and when the number of characters is larger than the number of characters correspondingly accommodated in the display area, line feed and reduction are carried out on the word size corresponding to the target character string;
and extracting the corresponding size of the display area and the corresponding size of the target character string in the target template, and when the corresponding size of the display area is smaller than the corresponding size of the target character string, wrapping and shrinking the target character string according to the corresponding size of the display area.
7. An apparatus for text editing in a picture, the apparatus comprising:
the loading module is used for loading a given target template in the candidate pictures;
the selecting module is used for randomly selecting from a preset style library in real time and determining a text style corresponding to a current character string in the target template; the current character string is formed by extracting characters input by a third-party input method in real time;
the rendering module is used for rendering the current character string according to the character style to form a target character string;
the display module is used for displaying the target character strings row by row in the target template;
The apparatus further comprises:
the detection unit is used for detecting a time interval correspondingly generated when the third input method is input;
the character string processing unit is used for dividing the time interval; when the time interval is longer than the set duration, character patterns are selected from the pattern library randomly, and the character strings input after the time interval are rendered in real time;
and when the time interval is smaller than the set duration, continuing to render the current character string according to the text style of the current application.
8. The apparatus according to claim 7, comprising:
the text style is defined according to the display attribute of the characters, and the display attribute at least comprises: color, font size, whether background shadow is included, whether underline is included, whether inclination is performed;
and after the display attributes are respectively packaged, storing the display attributes in a json form in a style library.
9. The apparatus according to claim 7 or 8, characterized in that the apparatus further comprises:
and the single character processing unit is used for calculating the current character string according to single characters and rendering the single characters of the current character string in real time by randomly selecting the text styles from the style library.
10. The apparatus according to claim 7 or 8, wherein the rendering module comprises in particular,
the style calling unit is used for calling the text style and loading each display attribute corresponding to the text style on the current character string respectively;
and the character rendering unit is used for respectively rendering each character in the current character string according to the display attribute to form the target character string.
11. The apparatus of claim 7, wherein the display module comprises,
the acquisition unit is used for acquiring the size and/or the character number corresponding to the target character string in real time;
and the adjusting unit is used for scaling and line-wrapping the target character string according to the display area in the target template and the corresponding size of the target character string, so that the input target character string fills the display area in the target template.
CN201910210972.6A 2019-03-20 2019-03-20 Method and device for editing characters in picture Active CN109978972B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910210972.6A CN109978972B (en) 2019-03-20 2019-03-20 Method and device for editing characters in picture

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910210972.6A CN109978972B (en) 2019-03-20 2019-03-20 Method and device for editing characters in picture

Publications (2)

Publication Number Publication Date
CN109978972A CN109978972A (en) 2019-07-05
CN109978972B true CN109978972B (en) 2023-04-25

Family

ID=67079613

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910210972.6A Active CN109978972B (en) 2019-03-20 2019-03-20 Method and device for editing characters in picture

Country Status (1)

Country Link
CN (1) CN109978972B (en)

Families Citing this family (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110850996A (en) * 2019-09-29 2020-02-28 上海萌家网络科技有限公司 Picture/video processing method and device applied to input method
CN112749529A (en) * 2019-10-29 2021-05-04 西安诺瓦星云科技股份有限公司 Method and device for character self-adaption special-shaped edit box
CN110929496B (en) * 2019-11-15 2023-06-16 北京乐蜜科技有限责任公司 Text template generation method and device
CN112825079B (en) * 2019-11-20 2024-04-05 北京沃东天骏信息技术有限公司 Information display method and device
CN110889267A (en) * 2019-11-29 2020-03-17 北京金山安全软件有限公司 Method and device for editing characters in picture, electronic equipment and storage medium
CN110990747A (en) * 2019-12-17 2020-04-10 北京思维造物信息科技股份有限公司 Image generation method, device, equipment and storage medium
CN111144073B (en) * 2019-12-30 2021-11-16 文思海辉智科科技有限公司 Blank character visualization method and device in online text display system
CN111401001B (en) * 2020-03-13 2023-05-26 浙江学海教育科技有限公司 TextView linear scaling method, textView linear scaling device, textView linear scaling equipment and TextView linear scaling medium
CN113298741B (en) * 2020-11-13 2024-01-12 阿里巴巴集团控股有限公司 Picture synthesis method and device and electronic equipment
CN112330774B (en) * 2020-11-24 2023-09-08 携程旅游网络技术(上海)有限公司 Method and device for synthesizing pictures in batches, electronic equipment and storage medium
CN112507670A (en) * 2020-12-14 2021-03-16 北京字跳网络技术有限公司 Text editing method and device, electronic equipment and storage medium
CN113705156A (en) * 2021-08-30 2021-11-26 上海哔哩哔哩科技有限公司 Character processing method and device
CN113989404A (en) * 2021-11-05 2022-01-28 北京字节跳动网络技术有限公司 Picture processing method, device, equipment, storage medium and program product
CN116740235A (en) * 2023-08-14 2023-09-12 福昕鲲鹏(北京)信息科技有限公司 Text annotation rendering method and device based on format document

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1327325C (en) * 2004-07-30 2007-07-18 招商银行股份有限公司 Graphics keyboard based security input method for computer information
CN105787335B (en) * 2016-02-25 2019-06-18 东莞盛世科技电子实业有限公司 Interface for password input method for handover control and device

Also Published As

Publication number Publication date
CN109978972A (en) 2019-07-05

Similar Documents

Publication Publication Date Title
CN109978972B (en) Method and device for editing characters in picture
US10380227B2 (en) Generating layout for content presentation structures
US11507727B2 (en) Font rendering method and apparatus, and computer-readable storage medium
US20150039996A1 (en) System and method for dynamically converting webpage, and computer-readable recording medium
US20210312679A1 (en) Method for generating identification pattern and terminal device
CN109743613B (en) Subtitle processing method, device, terminal and storage medium
US20210166457A1 (en) Graphic drawing method and apparatus, device, and storage medium
US10572572B2 (en) Dynamic layout generation for an electronic document
CN107707965B (en) Bullet screen generation method and device
US20220383381A1 (en) Video generation method, apparatus, terminal and storage medium
CN110750664A (en) Picture display method and device
WO2020186837A1 (en) Text animation control method and device, storage medium and processor
CN110471700B (en) Graphic processing method, apparatus, storage medium and electronic device
CN112449230B (en) Character string display processing method, device, terminal and storage medium
CN110321190B (en) Method and device for optimizing icons in desktop
CN111047673A (en) PPT file generation method and device based on hand-drawn video
CN113095058B (en) Method and device for processing page turning of streaming document, electronic equipment and storage medium
CN113268301A (en) Animation generation method, device, equipment and storage medium
CN103309878A (en) Method and device used for layout in webpage displaying
CN111401165A (en) Station caption extraction method, display device and computer-readable storage medium
WO2018133633A1 (en) Landing page display content displaying method, device, computing device, and storage medium
CN111651969B (en) style migration
CN112712574A (en) Chart generation method and device and electronic equipment
CN115630250A (en) Virtual key display method and device, electronic equipment and storage medium
CN114299984A (en) Audio visualization method and device, projection equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right

Effective date of registration: 20220718

Address after: No.16 and 17, unit 1, North District, Kailin center, No.51 Jinshui East Road, Zhengzhou area (Zhengdong), Henan pilot Free Trade Zone, Zhengzhou City, Henan Province, 450000

Applicant after: Zhengzhou Apas Technology Co.,Ltd.

Address before: E301-27, building 1, No.1, hagongda Road, Tangjiawan Town, Zhuhai City, Guangdong Province

Applicant before: ZHUHAI TIANYAN TECHNOLOGY Co.,Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant