CN101216944B - A method and device for morphing shading in the process of typeset - Google Patents

A method and device for morphing shading in the process of typeset Download PDF

Info

Publication number
CN101216944B
CN101216944B CN2008100557062A CN200810055706A CN101216944B CN 101216944 B CN101216944 B CN 101216944B CN 2008100557062 A CN2008100557062 A CN 2008100557062A CN 200810055706 A CN200810055706 A CN 200810055706A CN 101216944 B CN101216944 B CN 101216944B
Authority
CN
China
Prior art keywords
gradient
color data
template bitmap
area
information
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.)
Expired - Fee Related
Application number
CN2008100557062A
Other languages
Chinese (zh)
Other versions
CN101216944A (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.)
Peking University Founder Group Co Ltd
Beijing Founder Electronics Co Ltd
Original Assignee
Peking University Founder Group Co Ltd
Beijing Founder Electronics 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 Peking University Founder Group Co Ltd, Beijing Founder Electronics Co Ltd filed Critical Peking University Founder Group Co Ltd
Priority to CN2008100557062A priority Critical patent/CN101216944B/en
Publication of CN101216944A publication Critical patent/CN101216944A/en
Application granted granted Critical
Publication of CN101216944B publication Critical patent/CN101216944B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Image Generation (AREA)

Abstract

The invention discloses a method of realizing gradual changing shadings in typesetting and a device thereof. The method comprises the following steps of: generating a gradual changing template bitmap according to a gradual changing angle, a gradual changing center, a gradual changing radius of the template bitmap, and the color data of every pixel point in the template bitmap; obtaining covering the template bitmap of the object with the obtained gradual changing template bitmap according to the matrix containing the new information of the object and the size of the valid region of the object. The inventive technical proposal has the advantages of accurately realizing the gradual changing shadings with smoother gradual changing color after image magnification; adding the gradual changing types of the gradual changing shadings and enriching the art effect of the layout; reducing the calculation amount via using optimization algorithm according to the symmetry of the object; and improving the display speed of the gradual changing shadings via calculating the color data of the pixel points in the valid region of the object.

Description

Method and device for realizing gradient shading in typesetting process
Technical Field
The invention relates to the technical field of image processing, in particular to a technology for realizing gradient shading in a typesetting process.
Background
In the fields of plane design, advertisement production, commercial printing, typesetting and the like, in order to enrich the artistic effect of the layout, the gradient colors are set for character blocks, picture element blocks and image blocks, and the gradient shading with different gradient types is filled by the set gradient colors.
The fading is a group of colors consisting of a plurality of fading points, and a fading center exists between two adjacent fading points. The first gradual change point is determined as the starting point of gradual change, the last gradual change point is determined as the ending point of gradual change, and the position corresponding to the change of 50% from the starting point to the ending point of gradual change is determined as the central point of gradual change.
The so-called gradient shading is filled with gradient colors and corresponds to different gradient types of shading.
There are many methods for filling a gradient shading with a gradient color in the current typesetting field, and the following methods are generally available:
(1) the gradient shading to be filled is segmented to form a plurality of small rectangular area blocks, the color value corresponding to each rectangular area block is calculated, the color corresponding to each rectangular area block is found according to the obtained color value, all pixel points of the rectangular area block are filled into one color, the gradient shading obtained by filling is not smooth enough in color gradient, the color change has jumping feeling, and the image can be distorted after being amplified.
(2) The types of gradation existing in the field of typesetting are mainly a linear type of gradation and a circular type of gradation. Both of the two gradient types need to calculate color values of a starting point and an ending point of the gradient, and the obtained color values are used as input parameters of a system function. If the positions of the starting point and the ending point of the gradient color are close, color data of each pixel point of the object at different angles can be obtained only by carrying out multiple operations, the calculation amount is huge, and the display speed of the gradient shading is influenced; if the starting point and the end point are far away, the shading template is linearly filled according to the colors corresponding to the color values of the gradient color starting point and the end point, the color change is not smooth enough, and the color change has a jumping feeling.
(3) And directly calculating the shading bitmap of the object, wherein the pixel points of the shading bitmap are generally more, so that when the color data of the pixel points of the bitmap are calculated, the calculated amount is larger, and the calculation speed is slower.
With the rapid development of the typesetting technology, higher and higher requirements are provided for the function and effect of image processing in the typesetting process, the existing linear and circular gradient types cannot meet the requirements of the typesetting technology on the typesetting layout and the accuracy of the effect of generating the gradient shading, and the display speed of generating the gradient shading also needs to be improved.
Disclosure of Invention
The invention provides a method and a device for realizing the gradual change shading in the typesetting process, which increase the gradual change type of the gradual change shading, improve the display speed of the gradual change shading, ensure that the realization effect of the gradual change shading is more accurate, and the color gradual change is smoother after the image is amplified.
The embodiment of the invention is realized by the following technical scheme:
the embodiment of the invention provides a method for realizing gradually changed shading in a typesetting process, which comprises the following steps:
obtaining a matrix containing object information; obtaining the size of an object outsourcing frame and the size of a screen display area;
calculating the effective area of the object according to the obtained matrix containing the object information, the size of the object outsourcing frame and the size of the screen display area;
calculating the scaling of the effective area of the object relative to a template bitmap with a set size, and obtaining a gradient angle, a gradient central point and a gradient radius of the template bitmap according to the obtained scaling and the gradient angle, the gradient central point and the gradient radius which are set by a user; calculating the color data of each pixel point in the template bitmap according to the gradient type set by the user;
generating a gradient template bitmap according to the gradient angle, the gradient central point, the gradient radius of the template bitmap and the color data of each pixel point in the template bitmap, performing secondary linear interpolation processing on the generated gradient template bitmap when the scaling ratio is determined to be not 1, and generating a corresponding gradient template bitmap according to the interpolation processing result;
calculating a matrix containing new information of the object according to the obtained matrix containing the information of the object; and covering the generated gradient template bitmap on the bitmap of the object according to the matrix containing the new information of the object and the scaling.
The embodiment of the invention also provides a device for realizing the gradually changed shading, which comprises: the device comprises a matrix obtaining unit, an effective area obtaining unit, a gradual change information obtaining unit, a color data obtaining unit, a template bitmap generating unit and a covering unit;
the device comprises a matrix obtaining unit, a matrix obtaining unit and a matrix selecting unit, wherein the matrix obtaining unit is used for obtaining a matrix containing object information; obtaining the size of an object outsourcing frame and the size of a screen display area;
an effective area obtaining unit, configured to calculate an effective area of the object according to the obtained matrix including the object information, the size of the object outsourcing frame, and the size of the screen display area;
the gradual change information acquisition unit is used for calculating the scaling of the effective area of the object relative to the template bitmap with the set size, and obtaining the gradual change angle, the gradual change central point and the gradual change radius of the template bitmap according to the obtained scaling and the gradual change angle, the gradual change central point and the gradual change radius which are set by a user;
the color data obtaining unit is used for calculating the color data of each pixel point in the template bitmap according to the gradient type set by the user;
the template bitmap generation unit is used for generating a gradual change template bitmap according to the gradual change angle, the gradual change central point and the gradual change radius of the template bitmap and the color data of each pixel point in the template bitmap;
the template bitmap processing unit is used for carrying out secondary linear interpolation processing on the generated gradient template bitmap when the scaling ratio is not equal to 1, and generating a corresponding gradient template bitmap according to the result of the secondary linear interpolation processing;
the covering unit is used for calculating a matrix containing the new information of the object according to the obtained matrix containing the information of the object; and covering the generated gradient template bitmap on the bitmap of the object according to the matrix containing the new information of the object and the scaling.
Through the technical scheme, the template bitmap with the size far smaller than that of the object is arranged, so that the complexity of calculating the color data of each pixel point is greatly reduced, and the display speed of the gradient shading is improved; meanwhile, by calculating the color data of each pixel point in the template bitmap, the realization effect of the gradient shading is more accurate while the display speed is ensured, and the color gradient is smoother after the image is amplified.
Drawings
FIG. 1 is a flowchart of a method for implementing a gradient shading during a typesetting process according to a first embodiment of the present invention;
FIG. 2 is a flowchart of calculating color data for each pixel point in a standard gradient stencil bitmap for linear and circular gradient types according to a first embodiment of the present invention;
FIG. 3 is a flowchart of calculating color data for each pixel point in a standard gradient stencil bitmap of square and diamond gradient types according to a first embodiment of the present invention;
FIG. 4 is a flowchart of the calculation of color data for each pixel point in a standard gradient stencil bitmap for cone and biconical gradient types according to the first embodiment of the present invention;
FIG. 5 is an effect diagram of a single line-shaped gradient shading according to the first embodiment of the present invention;
FIG. 6 is an effect diagram of a double-line gradient shading according to the first embodiment of the present invention;
FIG. 7 is an effect diagram of a circular gradient shading according to the first embodiment of the present invention;
FIG. 8 is an effect diagram of a square gradient shading according to the first embodiment of the present invention;
FIG. 9 is an effect diagram of a diamond-shaped gradient shading according to the first embodiment of the present invention;
FIG. 10 is an effect diagram of a tapered shading according to the first embodiment of the present invention;
FIG. 11 is an effect graph of a double tapered gradient shading of the first embodiment of the present invention;
FIG. 12 is a schematic diagram of an apparatus for implementing a gradient shading during typesetting according to a second embodiment of the present invention.
Detailed Description
The invention provides a method and a device for realizing gradient shading in a typesetting process, and provides the following technical scheme aiming at the problems of less types of gradient shading, distortion after image amplification and unsatisfactory realization effect in the prior art, wherein the technology is described in detail by combining the attached drawings and specific embodiments of the specification:
the first embodiment of the present invention provides a method for implementing a gradual shading in a typesetting process, which is described in detail with reference to the flow chart of fig. 1:
s101, obtaining a matrix containing object information, and calculating the matrix containing the new information of the object according to the obtained matrix containing the object information; and obtaining the size of the object outsourcing frame and the size of the screen display area, and calculating the effective area of the object according to the obtained size of the object outsourcing frame and the size of the screen display area.
Obtaining a matrix Mo containing object information of a current object Device Context (DC) through a system function;
obtaining the scaling information of the object from the matrix Mo, putting the obtained scaling information into the matrix Mg, and participating in calculation: and Mn is Mo Mg ', wherein the matrix Mn is a matrix containing the new information of the object, and Mg' is an inverse matrix of the matrix Mg.
Respectively obtaining a central point Pm of the object outer frame in millimeter unit and a central point Pp of the object outer frame in pixel unit through a system function, converting the unit of Pm from millimeter to pixel, calculating the difference value of Pm and Pp in pixel unit, and putting the difference value into a matrix Mn containing new information of the object as the horizontal and vertical conversion deviation of the object.
Calculating the effective area of the object, mainly comprising the following steps:
obtaining a rectangular area Ro representing the size of an object outline and a rectangular area Rs representing the size of a screen display area from a system, wherein the rectangular areas Ro and Rs represent the size of the area in millimeters;
converting the unit of the area size represented by the rectangular areas Ro and Rs from millimeter to pixel by using a system function, and retrieving the rectangular area Ro representing the size of the object outline and the rectangular area Rs representing the size of the screen display area, wherein the area size represented by the rectangular areas Ro and Rs is in pixel;
from the obtained vertex coordinates of the rectangular region Ro and Rs indicating the pixel unit region size, the intersection region of Rs and Ro is calculated, and the obtained intersection region is set as the target effective region Rv, which is in units of pixels.
If the object is rotated or miscut, processing a rectangular region Rs representing the size of the screen display region according to specific information contained in a matrix containing object information, and calculating a cross region according to a new rectangular region obtained after the processing, wherein the specific processing process comprises the following steps:
when the matrix containing the object information contains the rotation information, multiplying a rectangular area Rs representing the size of a screen display area by an inverse matrix of the matrix containing the rotation information to obtain a new rectangular area, calculating an intersection area of the obtained new rectangular area and a rectangular area Ro representing the size of an object outer frame, and taking the obtained intersection area as an effective area of the object;
or,
when the matrix containing the object information contains the miscut information, multiplying a rectangular area Rs representing the size of a screen display area by an inverse matrix of the matrix containing the miscut information to obtain a new rectangular area, calculating an intersection area of the obtained new rectangular area and a rectangular area Ro representing the size of an object outer frame, and taking the obtained intersection area as an effective area of the object;
or,
when the matrix containing the object information contains the rotation information and the miscut information, a new rectangular area is obtained by multiplying a rectangular area Rs representing the size of the screen display area by an inverse matrix of the matrix containing the rotation information and the miscut information, the intersection area of the obtained new rectangular area and a rectangular area Ro representing the size of an object bounding box is calculated, and the obtained intersection area is used as an effective area of the object.
S102, obtaining the horizontal and vertical scaling eta of the effective region Rv relative to a template bitmap with a set size according to the effective region Rv of the object, and obtaining a gradient angle, a gradient radius and a gradient central point of the template bitmap according to the obtained scaling eta and the gradient angle, the gradient radius and the gradient central point set by a user;
wherein the size of the template bitmap is set to 128 x 128 pixels.
S103, calculating color data of each pixel point in the template bitmap according to the gradient type set by the user. The method specifically comprises the following steps:
determining a central point, a starting point and an end point of gradient of a template bitmap corresponding to the gradient type according to the gradient type set by a user;
and obtaining the position proportion of the gradual change color change of the corresponding position of the pixel point according to the determined central point, the starting point and the ending point of the gradual change color, obtaining the color data of the corresponding position of the pixel point according to the obtained position proportion and the gradual change color information in the system, and taking the obtained color data of the corresponding position as the color data of the pixel point.
The following respectively describes in detail the process of calculating color data of each pixel point in the stencil bitmap, taking a single line-shaped gradient type, a double line-shaped gradient type, a circular gradient type, a square gradient type, a diamond gradient type, a cone gradient type, and a double cone gradient type as examples:
single line type of transition:
taking the gradient central point of the template bitmap obtained in the step S102 as the central point of the single-line gradient type gradient color, and taking the two ends of the gradient diameter of the template bitmap as the starting point and the ending point of the single-line gradient type gradient color respectively, wherein the gradient diameter is calculated according to the object bounding box and the scaling ratio, and the gradient range of the gradient color is determined according to the gradient diameter;
obtaining the position proportion of the gradual change color change of the corresponding position of the pixel point according to the determined central point, the starting point and the ending point of the gradual change color, obtaining the color data of the corresponding position of the pixel point according to the obtained position proportion and the gradual change color information in the system, taking the obtained color data of the corresponding position as the color data of the pixel point, and explaining the process in detail by combining with a flow chart of fig. 2:
s201, constructing a right triangle to obtain a reference gradient line of the single-line-shaped gradient type template bitmap, wherein the specific process comprises the following steps:
creating a right triangle by taking the gradually-changed central point of the template bitmap obtained in the step S102 as the middle point of the hypotenuse of the triangle, the gradually-changed diameter as the length of the hypotenuse and the gradually-changed angle as the included angle between the hypotenuse and the horizontal side; and calculating coordinates of two vertexes of the bevel edge, connecting the two vertexes to obtain a connecting line which is a reference gradient line, and judging that one end of the reference gradient line is a starting point of the gradient color and the other end of the reference gradient line is a termination point of the gradient color according to the gradient angle.
S202, judging whether the object is symmetrical or not, and if the object is not symmetrical, executing a step S203; it is determined that the object is symmetrical about the x-axis or y-axis or the dot, step S208 is performed.
The symmetry of the object may be determined from the determined center point, start point and end point of the gradient.
S203, calculating color data of the first pixel point of the nth line in the object.
Taking the first pixel point of the nth row of the object, making a perpendicular line from the pixel point to the reference gradient line to obtain a foot, connecting the obtained foot with the starting point of the gradient color of the reference gradient line to obtain a line segment, calculating the proportion of the obtained line segment to the diameter, and taking the obtained proportion as the position proportion of the gradient color change of the corresponding position of the pixel point;
and obtaining color data of the corresponding position of the pixel point according to the obtained position proportion and the gradual change color information in the system, and taking the obtained color data of the corresponding position as the color data of the pixel point.
And S204, calculating the gradual change step length between adjacent pixel points in the nth row. The method comprises the following steps:
the gradual change step length between the adjacent pixel points is according to a formula: and c, calculating cosd x, wherein d is a gradual change angle, and x is the difference value of two adjacent pixel points in the x direction.
S205, color data of other pixel points in the nth row are calculated in sequence according to the obtained color data of the first pixel point in the nth row and the gradual change step length between the adjacent pixel points in the nth row.
S206, line n + 1.
S207, judging whether the calculation is finished or not, and finishing the calculation if the color data of each row of pixel points in the object is completely calculated; otherwise, step S203 is executed.
S208, determining the symmetry of the object according to the determined central point, the starting point and the ending point of the gradient color, and calculating the color data of each pixel point by adopting an optimization algorithm according to the determined symmetry.
When the object is determined to be symmetrical about the x axis, calculating the color data of the first pixel point in each line of the object and the gradient step length between the adjacent pixel points of 1/2 lines of the object in each line, sequentially calculating the color data of other pixel points of 1/2 lines of the object in each line according to the obtained color data of the first pixel point in each line and the obtained gradient step length, and obtaining the color data of all the pixel points of the template bitmap according to the symmetry;
or,
when the object is determined to be symmetrical about the y axis, calculating the color data of a first pixel point in each column of the object and the gradient step length between 1/2 columns of adjacent pixel points of each column of the object, sequentially calculating the color data of 1/2 columns of other pixel points of each column of the object according to the obtained color data of the first pixel point in each column and the obtained gradient step length, and obtaining the color data of all the pixel points of the template bitmap according to the symmetry;
or,
when it is determined that the object is symmetric about the dots, the object 1/4 region is taken according to the object's symmetry, and color data of each pixel point in the object in this 1/4 region is calculated. The method specifically comprises the following steps:
calculating the color data of the first pixel point of each line in the 1/4 area object and the gradual change step length between the adjacent pixel points of each line in the 1/4 area object, calculating the color data of other pixel points in the 1/4 area in sequence according to the obtained color data of the first pixel point of each line and the obtained gradual change step length between the adjacent pixel points of each line, and obtaining the color data of all the pixel points of the template bitmap according to symmetry;
or,
and calculating the color data of the first pixel point of each column in the 1/4 region object and the gradual change step length between the adjacent pixel points of each column in the 1/4 region object, calculating the color data of other pixel points in the 1/4 region in sequence according to the obtained color data of the first pixel point of each column and the obtained gradual change step length between the adjacent pixel points of each column, and obtaining the color data of all the pixel points of the template bitmap according to symmetry.
Bilinear gradation type:
taking the gradient central point of the template bitmap obtained in the step S102 as the starting point of the gradient of the double-line gradient, and taking the two ends of the gradient diameter of the template bitmap as the ending points of the gradient of the double-line gradient;
and obtaining the position proportion of the gradual change of the corresponding position of the pixel point according to the determined gradual change starting point and the determined gradual change end point, obtaining the color data of the corresponding position of the pixel point according to the obtained position proportion and gradual change information in the system, and taking the obtained color data of the corresponding position as the color data of the pixel point, wherein the specific calculation process is the same as the calculation process of the color data of each pixel point in the single-line gradual change type template bitmap, and the detailed description is not repeated here.
It should be noted that the template bitmap with double line-shaped gradual change is symmetrical by taking the gradual change center point as a symmetry axis, while the template bitmap with single line-shaped gradual change does not have the symmetry.
Circular gradation type:
taking the gradient central point of the template bitmap obtained in the step S102 as the central point of the circular gradient color and the starting point of the circular gradient color, and taking the other end of the gradient radius as the end point of the gradient color;
and obtaining the position proportion of the gradual change of the corresponding position of the pixel point according to the determined central point, the starting point and the ending point of the gradual change, obtaining the color data of the corresponding position of the pixel point according to the obtained position proportion and gradual change information in the system, taking the obtained color data of the corresponding position as the color data of the pixel point, wherein the specific calculation process is the same as the calculation process of the color data of each pixel point in the single-line gradual change type template bitmap, and the detailed description is not repeated here.
It should be noted that before calculating the color data of each pixel point in the template bitmap with gradually changing circle, it is to be determined whether the pixel point to be calculated is in the gradually changing region, which specifically includes:
judging whether a line segment obtained by connecting a pixel point to be calculated with a gradual change central point of the template bitmap is larger than a radius or not, if the obtained line segment is larger than or equal to the radius, taking the pixel point as a gradual change end point, and taking color data of the end point as color data of the pixel point; and if the obtained line segment is smaller than the radius, calculating the color data of each pixel point according to the method for calculating the color data of each pixel point in the linear gradient type template bitmap.
Square gradation type:
taking the gradient center point of the standard gradient template bitmap obtained in the step S102 as the center point of the gradient color of the square gradient, wherein one end of the gradient radius of the standard gradient template bitmap is the end point of the gradient color, and the gradient radius is half of the square of the linear gradient radius;
obtaining the position proportion of the gradual change color change of the corresponding position of the pixel point according to the determined central point and the starting point of the gradual change color, obtaining the color data of the corresponding position of the pixel point according to the obtained position proportion and the gradual change color information in the system, taking the obtained color data of the corresponding position as the color data of the pixel point, and explaining the calculation process in detail by combining with a flow chart in fig. 3:
s301, determining a gradient area of the gradient template bitmap of the square gradient type, wherein the specific process comprises the following steps:
taking the gradient diameter of the template bitmap obtained in the step S102 as the gradient diameter of the square gradient, calculating four starting points a1, a2, A3 and a4 of the square gradient according to the above information, and connecting four points to form a rectangular area, which is the gradient area of the standard gradient template bitmap of the square gradient type.
S302, judging whether the object is symmetrical or not, and executing a step S303 if the object is determined to be asymmetrical; it is determined that the object is symmetrical about the x-axis or y-axis or the dot, step S309 is performed.
The symmetry of the object can be judged according to the determined central point, the starting point and the end point of the gradient.
S303, taking the coordinate of the mth row pixel point of the nth row, judging whether the coordinate is in the rectangular area formed in the step S301, and if the coordinate is not in the rectangular area, executing the step S304; if within the rectangular area, step S305 is performed.
S304, setting the pixel point of which the coordinate is not in the rectangular area as a gradient termination point, taking the color data of the termination point as the color data of the pixel point of which the coordinate is not in the rectangular area, and then turning to the step S306.
S305, calculating the longer ratio of the radius in the horizontal and vertical distances from the nth row and the mth column of pixel points to the gradual change central point according to the gradual change angle, taking the obtained ratio as the position ratio of the gradual change color change of the corresponding position of the pixel point, obtaining the color data of the corresponding position of the pixel point according to the obtained position ratio and the gradual change color information in the system, and taking the obtained color data of the corresponding position as the color data of the pixel point.
And S306, sequentially calculating the color data of the pixels on the nth row and other columns.
S307, line n + 1.
S308, judging whether the color data of all the pixel points are calculated, and if not, executing the step S303; if the calculation is finished, the flow ends.
S309, determining the symmetry of the object according to the determined central point, the starting point and the ending point of the gradient color, and calculating the color data of each pixel point by adopting an optimization algorithm according to the determined symmetry.
The specific process of the optimization algorithm is consistent with the method for calculating the color data of the pixel points in the step S305, when the object is determined to be symmetric about the x axis, only the color data of 1/2 rows of pixel points in each row of the object needs to be calculated, and then the color data of all the pixel points of the object is determined according to the symmetry; when the object is determined to be symmetrical about the y axis, only color data of 1/2 rows of pixel points of each row of the object is needed to be calculated, and then color data of all pixel points of the object is determined according to the symmetry; when the object is determined to be symmetrical about the dots, the object 1/4 area is taken according to the symmetry, then the color data of the pixel points in the 1/4 area is calculated, and then the color data of all the pixel points of the object is obtained according to the symmetry.
Diamond taper type:
the arrangement of the central point and the end point of the gradient color is the same as that of the square gradient type, and the gradient radius of the template bitmap of the diamond gradient type is
Figure GSB00000521343000121
Wherein R is the gradient radius of the template bitmap of the square gradient type;
and obtaining the position proportion of the gradual change of the corresponding position of the pixel point according to the determined central point and the determined end point of the gradual change, obtaining the color data of the corresponding position of the pixel point according to the obtained position proportion and gradual change information in the system, and taking the obtained color data of the corresponding position as the color data of the pixel point, wherein the specific calculation process is the same as the calculation process of the color data of each pixel point in the template bitmap of the square gradual change type, and the detailed description is not repeated here.
It should be noted that the transition angle corresponding to the diamond transition type is equal to the transition angle + pi/4 corresponding to the square transition type.
Tapered gradation type:
taking the gradient central point of the template bitmap obtained in the step S102 as the central point of the gradient color of the conical gradient;
obtaining the position proportion of the gradual change color change of the corresponding position of the pixel point according to the determined central point of the gradual change color, obtaining the color data of the corresponding position of the pixel point according to the obtained position proportion and the gradual change color information in the system, taking the obtained color data of the corresponding position as the color data of the pixel point, and explaining the calculation process in detail by combining with a flow chart of fig. 4:
s401, obtaining coordinates of the gradually-changed central point of the template bitmap, and sequentially calculating an included angle between a line segment and an x axis, wherein the line segment is obtained by connecting each pixel point and the central point in the nth row according to the obtained coordinates.
S402, taking the obtained angle/2 pi of each pixel point in the nth row as the position proportion of the gradual change color change of the corresponding position of the pixel point, obtaining color data of the corresponding position of the pixel point according to the obtained position proportion and gradual change color information in a system, and taking the obtained color data of the corresponding position as the color data of the pixel point;
and sequentially calculating the color data of each pixel point in the nth row.
And S403, taking the n-th line as n + 1.
S404, judging whether the calculation is finished or not, and finishing the calculation if the calculation is finished; otherwise, step S401 is executed.
Biconical taper type:
taking the gradient center point of the template bitmap obtained in the step S102 as the center point of the double-cone gradient color, changing angle/2 pi in the step S402 to agle/pi to obtain the position proportion of the gradient color change of the corresponding position of the pixel point, and the other calculation processes are the same as the process of calculating the color data of each pixel point in the cone gradient type template bitmap, and are not described in detail here.
And S104, generating a gradual change template bitmap according to the color data of each pixel point in the obtained template bitmap and the gradual change angle, gradual change radius and gradual change central point of the template bitmap obtained in the step S102.
And S105, judging whether the object is zoomed according to the zooming ratio eta obtained in the step S102. If η is not equal to 1, go to step S106; if η is equal to 1, step S107 is performed.
And S106, when the scaling ratio is not equal to 1, performing secondary linear interpolation processing on the gradient template bitmap generated in the step S104, and generating a corresponding gradient template bitmap according to the result of the secondary linear interpolation processing.
Step S106 specifically includes:
calculating the effective area of the gradient template bitmap generated in the step S104 according to the scaling and the effective area of the object obtained in the step S101;
and zooming the effective area of the obtained gradient template bitmap according to the effective area of the object, performing secondary linear interpolation processing on the effective area of the obtained gradient template bitmap in the zooming process, and generating a corresponding gradient template bitmap according to the result of the secondary linear interpolation processing.
S107, setting the matrix Mn containing the horizontal and vertical scaling information of the object obtained in the step S101 on the current DC, and covering the bitmap of the object with the gradient template bitmap generated in the step S103 if the scaling is equal to 1; otherwise, the new gradient template bitmap generated in step S106 is overlaid on the bitmap of the object.
By the method, the gradual-change template bitmap of the corresponding type can be generated according to the gradual-change type set by the user, the generated gradual-change template bitmap is used for covering the bitmap of the object, and the graphs in the figures 5 to 11 respectively correspond to the effect graphs of the gradual-change shading of the single-line gradual-change type, the double-line gradual-change type, the circular gradual-change type, the square gradual-change type, the diamond gradual-change type, the cone gradual-change type and the double-cone gradual-change type.
A second embodiment of the present invention provides an apparatus for implementing a gradient shading in a typesetting process, as shown in fig. 12, including: the device comprises a matrix obtaining unit, an effective area obtaining unit, a gradual change information obtaining unit, a color data obtaining unit, a template bitmap generating unit and a covering unit;
the device comprises a matrix obtaining unit, a matrix obtaining unit and a matrix selecting unit, wherein the matrix obtaining unit is used for obtaining a matrix containing object information; obtaining the size of an object outsourcing frame and the size of a screen display area;
an effective area obtaining unit, configured to calculate an effective area of the object according to the obtained matrix including the object information, the size of the object outsourcing frame, and the size of the screen display area;
the gradual change information acquisition unit is used for calculating the scaling of the effective area of the object relative to the template bitmap with the set size, and obtaining the gradual change angle, the gradual change central point and the gradual change radius of the template bitmap according to the obtained scaling and the gradual change angle, the gradual change central point and the gradual change radius which are set by a user;
the color data obtaining unit is used for calculating the color data of each pixel point in the template bitmap according to the gradient type set by the user;
the template bitmap generation unit is used for generating a gradual change template bitmap according to the gradual change angle, the gradual change central point and the gradual change radius of the template bitmap and the color data of each pixel point in the template bitmap;
the covering unit is used for calculating a matrix containing the new information of the object according to the obtained matrix containing the information of the object; and covering the generated gradient template bitmap on the bitmap of the object according to the matrix containing the new information of the object and the scaling.
According to a difference of information included in the matrix including the object information, the effective region obtaining unit may include: the effective area obtains a first subunit, or the effective area obtains a second subunit, or the effective area obtains a third subunit;
the effective area obtaining unit is used for obtaining a new rectangular area by multiplying a rectangular area which represents the pixel unit size of a screen display area by an inverse matrix of a matrix which contains the rotation information when the matrix which contains the object information contains the rotation information, calculating the intersection area of the obtained new rectangular area and the rectangular area which represents the pixel unit size of the object outer frame, and taking the obtained intersection area as the effective area of the object;
or,
the effective area obtaining second subunit is used for obtaining a new rectangular area by multiplying a rectangular area which represents the pixel unit size of the screen display area by an inverse matrix of a matrix which contains the miscut information when the matrix which contains the object information contains the miscut information, calculating an intersection area of the obtained new rectangular area and the rectangular area which represents the pixel unit size of the object outer frame, and taking the obtained intersection area as the effective area of the object;
or,
and an effective area obtaining third subunit, configured to, when the matrix including the object information includes the rotation information and the miscut information, obtain a new rectangular area by multiplying a rectangular area indicating a pixel unit size of the screen display area by an inverse matrix of the matrix including the rotation information and the miscut information, and calculate an intersection area of the obtained new rectangular area and the rectangular area indicating the pixel unit size of the object bounding box, and use the obtained intersection area as the effective area of the object.
The color data obtaining unit includes: a gradation color information determination subunit and a color data calculation subunit;
the device comprises a gradient color information determining subunit, a gradient color information determining unit and a gradient color information determining unit, wherein the gradient color information determining subunit is used for determining a central point, a starting point and an end point of gradient color of a template bitmap corresponding to a gradient type according to the gradient type set by a user;
and the color data calculation subunit is used for obtaining the position proportion of the gradual change color change of the corresponding position of the pixel point according to the determined central point, the starting point and the ending point of the gradual change color, obtaining the color data of the corresponding position of the pixel point according to the obtained position proportion and gradual change color information in the system, and taking the obtained color data of the corresponding position as the color data of the pixel point.
The color data obtaining unit, according to symmetry of the object, includes:
and the optimization subunit is used for determining the symmetry of the object according to the determined central point, the determined starting point and the determined end point of the gradient corresponding to the gradient type, and calculating the color data of each pixel point in the template bitmap according to the determined symmetry.
The optimization subunit further includes: a first optimization module, or a second optimization module, or a third optimization module;
the first optimization module is used for calculating color data of 1/2 lines of pixel points of each line of object when the object is determined to be symmetrical about the x axis, and obtaining the color data of all the pixel points of the template bitmap according to the symmetry;
or,
the second optimization module is used for calculating color data of 1/2 columns of pixel points of each column of objects when the objects are determined to be symmetrical about the y axis, and obtaining the color data of all the pixel points of the template bitmap according to the symmetry;
or,
and the third optimization module is used for calculating the color data of each pixel point in the object 1/4 area when the object is determined to be symmetrical about the dots, and obtaining the color data of all the pixel points of the template bitmap according to the symmetry.
According to the scaling, the gradient shading implementation device further comprises:
and the template bitmap processing unit is used for carrying out secondary linear interpolation processing on the generated gradient template bitmap when the scaling ratio is not equal to 1, and generating a corresponding gradient template bitmap according to the result of the secondary linear interpolation processing.
The template bitmap processing unit comprises: the effective area obtaining subunit and the template bitmap processing subunit;
the effective area obtaining subunit is configured to calculate an effective area of the generated gradient template bitmap according to the scaling and the effective area of the object;
and the template bitmap processing subunit is used for scaling the effective area of the obtained gradient template bitmap according to the effective area of the object, performing secondary linear interpolation processing on the effective area of the gradient template bitmap in the scaling process, and generating a corresponding gradient template bitmap according to the result of the secondary linear interpolation processing.
By the technical scheme, the realization effect of the gradient shading is more accurate, and the color gradient is smoother after the image is amplified; in addition, the linear and circular gradient types are provided, and the square gradient type, the diamond gradient type, the conical and the biconical gradient type are also provided, so that the artistic effect of the layout is enriched; in addition, the color data of each pixel point is calculated by adopting an optimization algorithm according to the symmetry of the object, so that the calculation amount is reduced; in addition, the display speed of the gradient shading is improved by calculating the color data of the pixel points in the effective region of the object.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (13)

1. A method for realizing gradual shading in the typesetting process is characterized by comprising the following steps:
obtaining a matrix containing object information; obtaining the size of an object outsourcing frame and the size of a screen display area;
calculating the effective area of the object according to the obtained matrix containing the object information, the size of the object outsourcing frame and the size of the screen display area;
calculating the scaling of the effective area of the object relative to a template bitmap with a set size, and obtaining a gradient angle, a gradient central point and a gradient radius of the template bitmap according to the obtained scaling and the gradient angle, the gradient central point and the gradient radius which are set by a user; calculating the color data of each pixel point in the template bitmap according to the gradient type set by the user;
generating a gradient template bitmap according to the gradient angle, the gradient central point, the gradient radius of the template bitmap and the color data of each pixel point in the template bitmap, performing secondary linear interpolation processing on the generated gradient template bitmap when the scaling ratio is determined to be not 1, and generating a corresponding gradient template bitmap according to the interpolation processing result;
and calculating a matrix containing the new information of the object according to the obtained matrix containing the information of the object, and covering the bitmap of the object with the generated gradient template bitmap.
2. The method of claim 1, wherein calculating the effective area of the object based on the obtained matrix containing the object information, the size of the object envelope, and the size of the screen display area comprises:
when the matrix containing the object information contains the rotation information, multiplying a rectangular area which represents the pixel unit size of the screen display area by an inverse matrix of the matrix containing the rotation information to obtain a new rectangular area, calculating an intersection area of the obtained new rectangular area and the rectangular area which represents the pixel unit size of the object outer frame, and taking the obtained intersection area as an effective area of the object;
or,
when the matrix containing the object information contains the miscut information, multiplying a rectangular area which represents the pixel unit size of the screen display area by an inverse matrix of the matrix containing the miscut information to obtain a new rectangular area, calculating an intersection area of the obtained new rectangular area and the rectangular area which represents the pixel unit size of the object outer frame, and taking the obtained intersection area as an effective area of the object;
or,
when the matrix containing the object information contains the rotation information and the miscut information, a new rectangular area is obtained by multiplying a rectangular area representing the pixel unit size of the screen display area by an inverse matrix of the matrix containing the rotation information and the miscut information, an intersection area of the obtained new rectangular area and the rectangular area representing the pixel unit size of the object bounding box is calculated, and the obtained intersection area is used as an effective area of the object.
3. The method of claim 1, wherein the calculating color data for each pixel point in the template bitmap according to the type of gradient set by the user comprises:
determining a central point, a starting point and an end point of gradient of a template bitmap corresponding to the gradient type according to the gradient type set by a user;
and obtaining the position proportion of the gradual change color change of the corresponding position of the pixel point according to the determined central point, the starting point and the ending point of the gradual change color, obtaining the color data of the corresponding position of the pixel point according to the obtained position proportion and the gradual change color information in the system, and taking the obtained color data of the corresponding position as the color data of the pixel point.
4. The method of claim 3, wherein the fade type comprises any one of:
a linear taper type, a double linear taper type, a circular taper type, a square taper type, a diamond taper type, a conical taper type, and a double conical taper type.
5. The method of claim 1, wherein the calculating color data for each pixel point in the template bitmap according to the type of gradient set by the user comprises:
and determining the symmetry of the object according to the determined central point, the determined starting point and the determined end point of the gradient corresponding to the gradient type, and calculating the color data of each pixel point in the template bitmap according to the determined symmetry.
6. The method of claim 5, wherein computing color data for each pixel point in the template bitmap based on the determined symmetry comprises:
when the object is determined to be symmetrical about the x axis, calculating color data of 1/2 lines of pixel points of each line of object, and obtaining the color data of all pixel points of the template bitmap according to the symmetry;
or,
when the object is determined to be symmetrical about the y axis, color data of 1/2 rows of pixel points of each row of object is calculated, and color data of all pixel points of the template bitmap are obtained according to the symmetry;
or,
when it is determined that the object is symmetric about the dots, color data of each pixel point in the region of the object 1/4 is calculated, and color data of all pixel points of the template bitmap is obtained according to the symmetry.
7. The method of claim 1, wherein performing a quadratic linear interpolation process on the generated template bitmap and generating a corresponding gradient template bitmap according to a result of the quadratic linear interpolation process comprises:
calculating the effective area of the generated gradient template bitmap according to the scaling and the effective area of the object;
and zooming the effective area of the obtained gradient template bitmap according to the effective area of the object, performing secondary linear interpolation processing on the effective area of the gradient template bitmap in the zooming process, and generating a corresponding gradient template bitmap according to the result of the secondary linear interpolation processing.
8. A gradient shading realization device, characterized in that the gradient shading realization device comprises:
a matrix obtaining unit configured to obtain a matrix including object information; obtaining the size of an object outsourcing frame and the size of a screen display area;
an effective area obtaining unit, configured to calculate an effective area of the object according to the obtained matrix including the object information, the size of the object outsourcing frame, and the size of the screen display area;
the gradual change information acquisition unit is used for calculating the scaling of the effective area of the object relative to the template bitmap with the set size, and obtaining the gradual change angle, the gradual change central point and the gradual change radius of the template bitmap according to the obtained scaling and the gradual change angle, the gradual change central point and the gradual change radius which are set by a user;
the color data obtaining unit is used for calculating the color data of each pixel point in the template bitmap according to the gradient type set by the user;
the template bitmap generation unit is used for generating a gradual change template bitmap according to the gradual change angle, the gradual change central point and the gradual change radius of the template bitmap and the color data of each pixel point in the template bitmap;
the template bitmap processing unit is used for carrying out secondary linear interpolation processing on the generated gradient template bitmap when the scaling ratio is not equal to 1, and generating a corresponding gradient template bitmap according to the result of the secondary linear interpolation processing;
the covering unit is used for calculating a matrix containing the new information of the object according to the obtained matrix containing the information of the object; and covering the generated gradient template bitmap on the bitmap of the object according to the matrix containing the new information of the object and the scaling.
9. The gradation shading realization device according to claim 8, wherein the effective area obtaining unit includes:
an effective area obtaining first subunit, configured to, when the matrix including the object information includes the rotation information, multiply a rectangular area indicating a pixel unit size of the screen display area by an inverse matrix of the matrix including the rotation information to obtain a new rectangular area, and calculate an intersection area of the obtained new rectangular area and the rectangular area indicating the pixel unit size of the object bounding box, and use the obtained intersection area as an effective area of the object;
or,
the effective area obtaining second subunit is used for obtaining a new rectangular area by multiplying a rectangular area which represents the pixel unit size of the screen display area by an inverse matrix of a matrix which contains the miscut information when the matrix which contains the object information contains the miscut information, calculating an intersection area of the obtained new rectangular area and the rectangular area which represents the pixel unit size of the object outer frame, and taking the obtained intersection area as the effective area of the object;
or,
and an effective area obtaining third subunit, configured to, when the matrix including the object information includes the rotation information and the miscut information, obtain a new rectangular area by multiplying a rectangular area indicating a pixel unit size of the screen display area by an inverse matrix of the matrix including the rotation information and the miscut information, and calculate an intersection area of the obtained new rectangular area and the rectangular area indicating the pixel unit size of the object bounding box, and use the obtained intersection area as the effective area of the object.
10. The gradation shading realization apparatus according to claim 8, wherein the color data obtaining unit includes:
the gradual change color information determining subunit is used for determining a central point, a starting point and an end point of gradual change color of the template bitmap corresponding to the gradual change type according to the gradual change type set by the user;
and the color data calculation subunit is used for obtaining the position proportion of the gradual change color change of the corresponding position of the pixel point according to the determined central point, the starting point and the ending point of the gradual change color, obtaining the color data of the corresponding position of the pixel point according to the obtained position proportion and gradual change color information in the system, and taking the obtained color data of the corresponding position as the color data of the pixel point.
11. The gradation shading realization apparatus according to claim 8, wherein the color data obtaining unit includes:
and the optimization subunit is used for determining the symmetry of the object according to the determined central point, the determined starting point and the determined end point of the gradient corresponding to the gradient type, and calculating the color data of each pixel point in the template bitmap according to the determined symmetry.
12. The progressive shading realization device according to claim 11, characterized in that said optimization subunit comprises:
the first optimization module is used for calculating the color data of 1/2 rows of pixel points of each row of objects when the object is determined to be symmetrical about the x axis, and obtaining the color data of all the pixel points of the template bitmap according to the symmetry;
or,
the second optimization module is used for calculating color data of 1/2 columns of pixel points of each column of objects when the objects are determined to be symmetrical about the y axis, and obtaining the color data of all the pixel points of the template bitmap according to the symmetry;
or,
and the third optimization module is used for calculating the color data of each pixel point in the object 1/4 area when the object is determined to be symmetrical about the dots, and obtaining the color data of all the pixel points of the template bitmap according to the symmetry.
13. The gradient shading realization apparatus according to claim 8, wherein the template bitmap processing unit comprises:
an effective area obtaining subunit, configured to calculate an effective area of the generated gradient template bitmap according to the scaling and the effective area of the object;
and the template bitmap processing subunit is used for scaling the effective area of the obtained gradient template bitmap according to the effective area of the object, performing secondary linear interpolation processing on the effective area of the gradient template bitmap in the scaling process, and generating a corresponding gradient template bitmap according to the result of the secondary linear interpolation processing.
CN2008100557062A 2008-01-07 2008-01-07 A method and device for morphing shading in the process of typeset Expired - Fee Related CN101216944B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN2008100557062A CN101216944B (en) 2008-01-07 2008-01-07 A method and device for morphing shading in the process of typeset

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN2008100557062A CN101216944B (en) 2008-01-07 2008-01-07 A method and device for morphing shading in the process of typeset

Publications (2)

Publication Number Publication Date
CN101216944A CN101216944A (en) 2008-07-09
CN101216944B true CN101216944B (en) 2011-08-03

Family

ID=39623372

Family Applications (1)

Application Number Title Priority Date Filing Date
CN2008100557062A Expired - Fee Related CN101216944B (en) 2008-01-07 2008-01-07 A method and device for morphing shading in the process of typeset

Country Status (1)

Country Link
CN (1) CN101216944B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101655969B (en) * 2008-08-19 2011-12-21 方正国际软件(北京)有限公司 Method for editing color gradient attributes
CN102752545B (en) * 2011-05-11 2017-04-12 新奥特(北京)视频技术有限公司 Method for achieving special effect of cubism of subtitles
CN103862899A (en) * 2012-12-12 2014-06-18 昆山研达电脑科技有限公司 Manufacturing method of product with gradient shading
CN106569684A (en) * 2015-10-13 2017-04-19 北京国双科技有限公司 Color gradient graphic display method and device
CN106095360B (en) * 2016-05-31 2018-11-27 福州瑞芯微电子股份有限公司 Image processing method and image processing apparatus based on palette
CN106445888B (en) * 2016-09-30 2019-06-14 广州视睿电子科技有限公司 Method and device for making artistic words
CN107608671A (en) * 2017-08-22 2018-01-19 北京京东尚科信息技术有限公司 A kind of method and apparatus for realizing text color gradual change
CN111475875B (en) * 2020-02-27 2022-11-22 杭州群核信息技术有限公司 Automatic generation method and system for tile combination gradual change paving

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6597363B1 (en) * 1998-08-20 2003-07-22 Apple Computer, Inc. Graphics processor with deferred shading
US6870954B1 (en) * 2001-04-04 2005-03-22 Adobe Systems Incorporated Methods apparatus for generating shaped gradient fills

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6597363B1 (en) * 1998-08-20 2003-07-22 Apple Computer, Inc. Graphics processor with deferred shading
US6870954B1 (en) * 2001-04-04 2005-03-22 Adobe Systems Incorporated Methods apparatus for generating shaped gradient fills

Also Published As

Publication number Publication date
CN101216944A (en) 2008-07-09

Similar Documents

Publication Publication Date Title
CN101216944B (en) A method and device for morphing shading in the process of typeset
CN101685546B (en) Image editing method and image editing device
CN103310474B (en) A kind of implementation method of original handwriting and system
CN102156688B (en) Character transforming effect processing method and device
JPS63271290A (en) Character pattern generation system
CN101908216B (en) Method and device for realizing vector fonts
CN101188020A (en) Method for precisely getting pixel geometric location mapping relation between projector image and computer frame buffer image
CN102999930A (en) Method and device for drawing electronic writing lines
JP5172640B2 (en) Vector drawing equipment
DE112010005426T5 (en) Animation display device
CN103310409A (en) Quick triangle partitioning method of Tile-based rendering architecture central processing unit (CPU)
US9311896B2 (en) Glyph rendering
CN102074025A (en) Image stylized drawing method and device
JP6297169B2 (en) Drawing apparatus and drawing method
JP5111897B2 (en) Filtering method and apparatus
JP2005107602A (en) Three-dimensional image drawing device and three-dimensional image drawing method
CN101567091A (en) Method for clearing target render by three-dimension virtual reality engine
CN111462280A (en) Picture generation method and device, electronic equipment and computer storage medium
CN103839217A (en) Watermark image realization method
JP2009134762A (en) Digital content creation system, digital content creation program and digital content creation method
US20080036775A1 (en) Method for generating characters
CN111063005A (en) Handwriting processing method and device
CN106485767B (en) Method and device for drawing symbols
CN113096209B (en) Display method of vehicle-mounted image track line
US20110205241A1 (en) Figure drawing device, anti-aliasing method, and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20110803

Termination date: 20190107