CN101764946A - Method for discretization of vector outline of subtitle object into straight-line segment - Google Patents

Method for discretization of vector outline of subtitle object into straight-line segment Download PDF

Info

Publication number
CN101764946A
CN101764946A CN 200810225870 CN200810225870A CN101764946A CN 101764946 A CN101764946 A CN 101764946A CN 200810225870 CN200810225870 CN 200810225870 CN 200810225870 A CN200810225870 A CN 200810225870A CN 101764946 A CN101764946 A CN 101764946A
Authority
CN
China
Prior art keywords
point
line segment
bezier
secondary bezier
straightway
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.)
Granted
Application number
CN 200810225870
Other languages
Chinese (zh)
Other versions
CN101764946B (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.)
Beijing culture science and technology finance leasing Limited by Share Ltd
Original Assignee
China Digital Video Beijing 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 China Digital Video Beijing Ltd filed Critical China Digital Video Beijing Ltd
Priority to CN 200810225870 priority Critical patent/CN101764946B/en
Publication of CN101764946A publication Critical patent/CN101764946A/en
Application granted granted Critical
Publication of CN101764946B publication Critical patent/CN101764946B/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Image Generation (AREA)
  • Controls And Circuits For Display Device (AREA)

Abstract

The invention discloses a method for discretization of the vector outline of a subtitle object into straight-line segments, which belongs to the technical field of subtitle editing and broadcasting of the television program production and broadcasting mechanism in radio, television and film industries. In the method, a numerical value from 0 to 1 is set for t in each step according to the parametric equation of the quadratic Bezier curve, corresponding points on the quadratic Bezier curve are then calculated according to the value of t, and Q0 and Q1 are supposed to be points calculated according to two adjacent values of t. If the spatial straight distance of Q0 and Q1 is more than the two adjacent values, a value for t is selected between the value of t corresponding to Q0 and the value of t corresponding to Q1, and the step is repeated until the spatial straight distance of Q0 and Q1 on the quadratic Bezier curve corresponding to every two values of t is less than or equal to the two adjacent values. The straight line formed by Q0 and Q1 is a first straight-line segment after discretization. Then one Bezier segment can be discretized into straight-line segments accordingly. The method of the invention can improve the subtitle rendering efficiency and enhance the subtitle rendering effect.

Description

The discrete method that turns to straightway of a kind of vector outline with caption object
Technical field
The invention belongs to the subtitle editing and playing technical field of radio, TV and film industries TV programme record and broadcast mechanism, be specifically related to the discrete method that turns to straightway of a kind of vector outline caption object.
Background technology
In the subtitle editing and playing field, caption object can be divided into literal and two parts of figure.Literal comprises the literal of various languages in the world, compound pattern that figure comprises the figure of various regular shapes, be made up of primary graphic element and irregular figure arbitrarily.From the angle of computer graphics, all types of caption object can be considered as the figure of forming by a series of straight lines and curve.Figure is made up of non-geometric attributes such as geometric elements such as point, line, surface, body and gray scale, color, line style, live widths usually.From treatment technology, figure mainly is divided into two classes: a class is based on that line information represents, as line frame graph of engineering drawing, contour map, curved surface etc.; Another kind of is continuous-tone image, just usually said photo realism graphic.
Caption rendering is that computer graphics, computer digital image are handled the technology that combines with the program making business of TV station.Angle from the computer digital image processing, playing up of caption object comprised two aspects: first, based on a series of static treatment of pixel or sub-pixel, as image intensification, binary conversion treatment, rim detection, Fuzzy Processing, embossment, the edge is anti-aliasing, the brightness pinup picture, texturing, anti-shake, ovalizing deflection, the polygon distortion, crisperding, blast, sharpening, softening, projection, colored pencil, the oil painting be full of cracks, crosshatch, sample cutting, glass, the edge blast, ink outline is drawn, ceramic tile, letter paper, patchwork, plastics package, the ripples line, sponge, the spraying pen, coloured glass, special efficacys such as Gaussian Blur; Second, based on a series of dynamic process of key frame, comprise that ripples, flag waft, spiral, distortion, tripleplane, flame, ball change, three-dimensional deformation, bending, phantom, scrolling, folding, fireworks display, shutter, cracked, ripples, fluctuation, draw picture, change ball, spiral, flag waft, fluctuate diplopia, butterfly change, time, convex lens, kaleidoscope, laser, fly light, magic spiral, motion blur, radial blur, wave, wave inverted image, special efficacy such as circle round.
The rendering effect of captions is to weigh the important indicator of a caption system, particularly at the aspects such as processing of the processing on the treatment of details of anti-aliasing processing, small character, three-dimensional limit, empty limit, diplopia, true three-dimension visual impression, three-dimensional word chamfering, texture, illumination.
In existing caption system, caption rendering exists following problem:
The first, the difference of playing up of text subtitle and graphic subtitle is come, and different graphic elements also uses geometric vector of different nature to describe.This problem realize and use aspect two brought to caption system a lot of unfavorable.From the angle that realizes, can cause existing in the caption system a plurality of diverse render engines and play up flow process, and if support a kind of new caption object, then need to define and realize new render engine, thereby cause the function expansibility of caption system to have significant limitation.From application point of view, bring the fatal problem in two aspects: on the one hand, the effect that dissimilar caption object finally represents is inconsistent, for example two dissimilar caption object are the full limit that has added 2 pixels equally, but owing to passed through different render engines, final result may be different, has brought inconvenience to the user when carrying out the captions creation; On the other hand, in caption system, have to carry out specific restriction at the operation of caption object, for example, the caption object that has is supported how much rotations, how much convergent-divergents, what have does not then support, the caption object that has is supported at any angle edged, is added shadow, the edged of then only supporting fixed angle that has, adds shadow, the not even support that has.All these problems all can influence the general applicability and the functional completeness of caption system.
The second, the core algorithm of caption rendering engine all is based on floating-point operation, for example trigonometric function operation, antitrigonometric function computing, division arithmetic, power operation, extracting operation etc.This can cause the problem of two aspects: on the one hand, because what final process result required is the pixel value of integer type, therefore can carry out rounding operation in the different phase of render engine algorithm, this will cause the cumulative errors in the calculating, cause final captions effect on local detail, to have defective, for example smudgy clear, the stroke adhesion of the literal that stroke is many etc.; On the other hand, these floating-point operations all are the mathematical operations that takies a large amount of machine instructions, greatly reduce the operating efficiency of whole caption system, have influence on the ageing of captions making and broadcast, particularly in the making of high definition TV captions, because its data volume is 5 times of SD, it is more obvious that this point shows.
The 3rd, not satisfactory as the effect that the edge of one of caption rendering important indicator is anti-aliasing, even can't reach practical degree.This is because existing caption system is when carrying out anti-aliasing processing, rely on the image processing method in current pixel space fully, there is not the participation of captions geometric vector information, also just can't realize processing based on sub-pixel, make the final rendering effect of existing caption system apparent in view edge sawtooth effect occur, influence the effect that captions represent.
Because above-mentioned same, when the image processing of caption object being carried out based on the filter pipeline, also can influence the final effect of captions.Existing caption system play up the pinup picture that flow process is normally carried out face limit shadow earlier, obtain an image, then this image is put into the filter pipeline, carry out a series of image processing again.But owing to there is not the participation of captions geometric vector information, the processing of filter pipeline can destroy the former effect after anti-aliasing.That is to say, on originally with regard to unfavorable edge treated, accumulated new edge sawtooth effect.
Because above-mentioned same, for more complicated a little the caption object of graphic element, oscillation effect appears in the place in the figure flex point, causes graph outline unsmooth.Chang Yong round rectangle object for example, by circular arc and four rectilinear(-al)s at four angles, scraggly phenomenon will appear in the place in that circular arc and straight line join.
The 4th, caption object is being carried out the gradual change look when playing up, should be that the gradual change color that the vector outline according to this object carries out is radially handled, but in existing caption system, it is that the gradual change look is put in the memory block that playing up of gradual change look handled, when playing up, still taked the method for respective pixel pinup picture.This just makes existing caption system can't realize the rendering effect of gradual change look truly.
The 5th, existing caption system can't realize increasing a plurality of outsides, a plurality of inner edge, three-dimensional limit, a plurality of side, a plurality of shadow.The captions of the stack of simple face, limit, shadow represent can't satisfy the requirement of television program designing to caption system.
The 6th, playing up of existing caption system is not based on the Bezier curved profile, but because the type matrix in the TrueType character library all is to use the Bezier curve to describe, so just the Bezier curve that need will extract from character library converts the vector of another form to, because the information asymmetry between the different vector expressions loss of information can occur in transfer process, thereby make the warpage of stroke, cause stroke weight inhomogeneous, influence attractive in appearance that font represents.
The 7th, existing caption system can't be converted to the text subtile object graphic subtitle object, thereby can't realize functions such as character distortion, character inverted image, character counter-rotating, curve are put, characters in a fancy style, can't satisfy senior captions application demand.
The 8th, existing caption system can't be realized the edged mode of number of different types, and as wedge angle limit, round edge, corner limit etc., this has influenced the popularity that captions are used to a certain extent.
The 9th, existing caption system can't be realized the support to the arbitrary shape irregular figure, thereby the captions that can't tackle types such as the geography information description that becomes more and more important, weather forecast, Comprehensive Data are made.
Bezier (Bezier) curve is a kind of important polynomial parameters curve in the computer graphics.The individual point of any N in the plane (N>=2) can constitute a Bezier curve, and this N point is called the control point of Bezier curve, and the polygon of N some composition is called the control polygon of Bezier curve.The parametric equation of N Bezier curve is as follows:
B ( t ) = Σ i = 0 n n i P i ( 1 - t ) n - i t i = P 0 ( 1 - t ) n + n 1 P 1 ( 1 - t ) n - 1 t + . . . + P n t n , t∈[0,1]
Wherein, P 0, P 1..., P nIt is the control point of Bezier curve.
Thus, the parameter expression of a Bezier curve is:
B(t)=P 0+(P 1-P 0)t=(1-t)P 0+tP 1,t∈[0,1]
One time the Bezier curve is exactly linear Bezier curve, is actually two control point P 0And P 1Between straightway.
The parameter expression of quadratic bezier curve is:
B(t)=(1-t) 2P 0+2t(1-t)P 1+t 2P 2,t∈[0,1]
The parameter expression of three bezier curve is:
B(t)=P 0(1-t) 3+3P 1t(1-t) 2+3P 2t 2(1-t)+P 3t 3,t∈[0,1]
P 0, P 1, P 2, P 3Four points have defined three bezier curve on the plane or in three dimensions.Curve originates in P 0Move towards P 1, and from P 2Direction come P 3Generally can not pass through P 1Or P 2, these two points only provide directional information.P 0And P 1Between spacing, determined curve then the into P that becomes 3Before, move towards P 2The length of direction.
The Bezier curve has following characteristic.
(1) limitlessly detachable: a Bezier curve can cut into two or any many strips curve in the arbitrfary point, and each strip curve is still the Bezier curve.
(2) symmetry: keep the coordinate position of the whole control point Pi of Bezier curve constant, just the ordering of control point Pi is put upside down, curve shape remains unchanged.This character explanation Bezier curve has any geometric properties at the starting point place, at destination county identical geometric properties is arranged also.
(3) convex closure: the Bezier curve is positioned within the convex closure at its control point.
(4) geometric invariance: the Bezier curve location is relevant with the position of its feature polygon vertex with shape, and it does not rely on the selection of coordinate system.
(5) variation reduction property: no more than this straight line of the intersection point number of arbitrary line and curve and the polygonal intersection point number of its feature in the plane.
(6) end points tangent vector: the starting point of Bezier curve, terminal point overlap with the corresponding polygonal starting point of feature, terminal point.The tangential direction of its starting point and destination county is consistent with the trend on feature polygonal article one limit and the last item limit.
In view of the characteristic of above-mentioned Bezier curve, if dissimilar caption object all is converted to quadratic bezier curve, then help improving the rendering effect of captions, satisfy the senior application of captions and solve the problem that existing caption rendering method exists.After dissimilar caption object is converted to the vector outline of being made up of quadratic bezier curve, also need following several situations are handled:
The first, when there is the self intersection situation in a sealing quadratic bezier curve inside, needs deletion or cut apart the closed circuit that sealing quadratic bezier curve inside comprises;
Second, when having the situation of intersecting between a plurality of sealing quadratic bezier curves that comprise in the vector outline of a caption object, need a quadratic B ezier line segment be divided into multistage quadratic B ezier line segment at the intersection point place, identify the inside and outside side attribute of every quadratic B ezier line segment, with attribute is the quadratic B ezier line segment deletion of inner edge, and remaining quadratic B ezier line segment is made up new closed outline according to intersection point.
After the vector outline of caption object carried out above-mentioned processing, there was not the closed outline of self intersection in the vector outline of caption object, is not existed the closed outline that intersects with other closed outlines to constitute yet by several.At this moment, if directly will carry out inner edge, add the outside, add side and add shadow etc. and play up, will there be following problems through the caption object after the above-mentioned processing.
Play up the vector outline that all is based on caption object because caption object adds inner edge, add the outside, add side, add shadow etc.When adding a plurality of outside, need along vector outline to around an equidistant expansion X1 pixel (X1 is the thickness on article one limit), then again along the vector outline that after aforesaid operations, forms, again to around an equidistant expansion X2 pixel (X2 is the thickness on second limit); When adding side, need along a vector outline (this vector outline be add the outside after vector outline) X pixel of Y angle spread (Y is the direction of side, and X is the thickness of side).If handle according to quadratic bezier curve, the vector outline after a quadratic bezier curve outwards or is inwardly expanded so has been not a quadratic bezier curve just, but the Bezier curve of a high price.That is to say, spatially can't represent with the quadratic bezier curve equation accurately with the equidistant curve of quadratic bezier curve.If use the Bezier curve of high-order to carry out follow-up playing up, for example add a plurality of inner edges, a plurality of outside, a plurality of sides etc., at first the Bezier curve of high-order is carried out the depression of order processing with regard to needs, the amount of calculation of this depression of order processing procedure is very huge, needed memory space is also very huge, is infeasible in actual applications.
Summary of the invention
At the defective that exists in the prior art, the purpose of this invention is to provide the discrete method that turns to straightway of a kind of vector outline with caption object, this method can improve the rendering efficiency of caption object, strengthens the rendering effect of caption object.
For reaching above purpose, the technical solution used in the present invention is: the discrete method that turns to straightway of a kind of vector outline with caption object may further comprise the steps:
(1) vector outline of traversal caption object, takes out one with get different sealing secondary Bezier G[i], the vector outline of supposing caption object comprises that N is sealed the secondary Bezier, i ∈ [0, N-1] then, N and i are positive integer;
(2) traversal sealing secondary Bezier G[i], take out one with get different secondary Bezier line segment B[j], suppose G[i] in comprise M secondary Bezier line segment, j ∈ [0, M-1] then, j is a positive integer;
(3) with B[j] dispersing turns to straightway, and concrete implementation procedure is as follows:
Suppose B[j] three control points be respectively P[0], P[1] and P[2]; P[0] be initial control point, P[1] be the intermediate controlled point, P[2] for stopping the control point;
At first, with P[0] point be starting point, calculating B[j] article one straightway L[j after the discretization] [0];
1. the initial value of t is set, t=P[0] .t+L; Wherein, L is a constant, 0<L<1; P[0] .t is P[0] t value in the corresponding secondary Bezier equation of point;
2. according to putting Q[0 on the corresponding secondary Bezier of secondary Bezier Equation for Calculating t value] coordinate;
3. calculate P[0] point and Q[0] point between air line distance d, Wherein, x0, y0 are P[0] coordinate, x1, y1 are Q[0] coordinate;
4. judge
Figure G2008102258703D0000062
Whether set up,, then make t=(P[0] .t+Q[0] .t)/2, wherein, Q[0 if set up] .t is Q[0] t value in the corresponding secondary Bezier equation of point; Repeating step 2. to step 4., up to
Figure G2008102258703D0000063
Final Q[0] point and P[0] straight line that constitutes of point is the straight line L[j after article one discretization] [0];
Then, with Q[0] point be starting point, adopt and calculating B[j] the identical method calculating second straightway L[j of article one straightway after the discretization] [1];
By that analogy, up to handling B[j] finishing control point P[2] till, obtain K bar straightway L[j] [0] to L[j] [K-1];
(4) repeating step (2) is to step (3), up to G[i] in all secondary Bezier line segments dispose;
(5) repeating step (1) to step (4) all closed curves in the vector outline of caption object dispose.
The discrete method that turns to straightway of aforesaid a kind of vector outline with caption object, wherein, described L value is 0.0625.
The discrete method that turns to straightway of aforesaid a kind of vector outline with caption object, in the step (3) with secondary Bezier line segment is discrete turn to straightway after, comprise that also the end points coordinate with every straightway amplifies M operation doubly, making original floating number coordinate transform is the integer type coordinate.Described M equals 512.
Method of the present invention turns to straightway by the quadratic B ezier line segment of will be in the caption object forming closed outline is discrete, and closed outline is converted to polygonal mode, has improved the rendering efficiency of caption object, has strengthened the rendering effect of caption object.
Description of drawings
Fig. 1 in the embodiment converts oval pel to the closed outline schematic diagram of being made up of the cubic Bezier line segment;
Fig. 2 is that the pel that in the embodiment wave flag waftd converts the closed outline schematic diagram of being made up of the cubic Bezier line segment to;
Fig. 3 is the closed outline schematic diagram that in the embodiment heart-shaped pel is converted to cubic Bezier line segment composition;
Bezier line segment of Fig. 4 converts secondary Bezier line segment schematic diagram to, and 4a is a preceding Bezier line segment schematic diagram of conversion, and 4b is the quadratic B ezier line segment schematic diagram after changing;
Fig. 5 cubic Bezier line segment converts two quadratic B ezier line segment schematic diagrames to, and the contrast schematic diagram before and after 5a cubic Bezier line segment conversion, 5b are the contrast schematic diagrames before and after the another kind of cubic Bezier line segment conversion;
Fig. 6 exists the closed outline of adjacent secondary Bezier line segment self intersection situation to handle front and back effect schematic diagram in the embodiment;
Fig. 7 exists the closed outline of non-adjacent secondary Bezier line segment self intersection situation to handle front and back effect schematic diagram in the embodiment;
Fig. 8 is the boundary rectangle schematic diagram of secondary Bezier line segment in the embodiment;
Fig. 9 is a secondary Bezier line segment mid point schematic diagram in the embodiment;
Figure 10 is twice processing of the closed outline front and back effect schematic diagram that has non-adjacent secondary Bezier line segment self intersection situation in the embodiment;
Figure 11 is a method flow diagram of cutting apart secondary Bezier in the caption object vector outline in the embodiment according to intersection point;
Figure 12 is the method flow diagram that calculates the intersection point of secondary Bezier line segments all in the caption object vector outline and other secondary Bezier line segments in the embodiment;
Figure 13 is a method flow diagram of the present invention;
Figure 14 determines the inside and outside side attribute schematic diagram of a secondary Bezier line segment in the embodiment;
Figure 15 is a method flow diagram of the present invention;
Figure 16 is the discrete schematic diagram of according to the t value in the secondary Bezier parametric equation secondary Bezier line segment being formed in the embodiment that turns to straightway of closed outline.
Embodiment
Describe the present invention below in conjunction with embodiment and accompanying drawing.
Method of the present invention be mainly used in dissimilar caption object is converted to by quadratic B ezier line segment form comprise the vector outline information of one or more closed outlines the time, closed outline is converted in the polygonal caption rendering.
Dissimilar caption object is converted to the vector outline information of being made up of quadratic B ezier line segment that comprises one or more closed outlines can adopts following method.
Because the type of caption object comprises text subtile, fundamental figure captions and compound captions (captions that comprise literal and fundamental figure), therefore need carry out different processing at dissimilar caption object.
If the type of caption object is a text subtile, then can directly use the TrueType character library of operating system, need not conversion.Its method mainly may further comprise the steps:
1. according to the font name of text subtile object, the API (CreateFont) that uses operating system to provide creates logical font object F;
2. the API (SelectObject) that uses operating system to provide is set to logical font object F in the resource description table of operating system, and preserves the original logical font of operating system;
3. according to the Unicode of current character coding, the API (GetG1yphOutline) that uses operating system to provide obtains the internal memory byte number B that the vector outline information of current character takies in the TrueType character library from the current resource description table of operating system;
4. the internal memory byte number B that takies according to current character, storage allocation P;
5. according to the Unicode coding of current character and the internal memory P that takies, reuse the API (GetGlyphOutline) that operating system provides, from the current resource description table of operating system, obtain the vector outline information G of current character, and the original logical font of recovery operation system.
If the type of caption object is the fundamental figure captions, then convert thereof into the vector outline information of the closed outline of forming by some three Bezier line segments, mainly be to determine every control point coordinate on the Bezier line segment, specifically may further comprise the steps according to the geometric parameter of fundamental figure:
1. according to the geometry of fundamental figure captions, the fundamental figure captions are divided into many curved sections, described curved section comprises straightway, just profound or surplus profound curved section, arc section and oval segmental arc;
2. according to the parametric equation of the boundary rectangle of fundamental figure captions, every curved section calculate every curved section convert to three times behind the Bezier line segment initial control point and the coordinate of finishing control point;
3. to every three Bezier line segments, coordinate and three Bezier parametric equations according to initial control point and finishing control point calculate the coordinate at two other control point at t=1/3 and t=2/3 place respectively.
Geometry with the fundamental figure captions is that ellipse is an example, as shown in Figure 1.At first, be divided into four Bezier line segments, be respectively from P100 to P103, from P103 to P106, from P106 to P109 and from P109 to P100 according to oval four intersection point P100, P103, P106 and P109 with its boundary rectangle.Four control points of the three bezier curve from P100 to P103 are respectively P100, P101, P102 and P103, four control points of the three bezier curve from P103 to P106 are respectively P103, P104, P105 and P106, four control points of the three bezier curve from P106 to P109 are respectively P106, P107, P108 and P109, and four control points of the three bezier curve from P109 to P100 are respectively P109, P110, P111 and P100.
Then, according to four apex coordinates of the boundary rectangle of oval pel calculate elliptical center point coordinate (a, b), transverse axis radius r a and longitudinal axis radius r b.Each control point Coordinate Calculation formula of every three Bezier line segments is as follows:
Make PinA=ra*0.55179445, PinB=rb*0.55179445.
P100.x=a, P100.y=b+rb;
P101.x=a+PinA; P101.y=b+rb;
P102.x=a+ra; P102.y=b+PinB;
P103.x=a+ra; P103.y=b;
P104.x=a+ra; P104.y=b-PinB;
P105.x=a+PinA; P105.y=b-rb;
P106.x=a; P106.y=b-rb;
P107.x=a-PinA; P107.y=b-rb;
P108.x=a-ra; P108.y=b-PinB;
P109.x=a-ra; P109.y=b;
P110.x=a-ra; P110.y=b+PinB;
P111.x=a-PinA; P111.y=b+rb。
Wherein, P100.x represents the abscissa that P100 is ordered, and P100.y represents the ordinate that P100 is ordered.In the present embodiment, other represent that similarly the implication of mode is identical with P100.
With the geometry of fundamental figure captions is that the wave flag shape of wafing is an example, as shown in Figure 2.At first, be divided into four curved sections, be respectively from P200 to P203, from P203 to P206, from P206 to P209 and from P209 to P200 according to four intersection point P200, P203, P206 and P209 of two curved sections and two straightways.After converting every curved section to three Beziers, four control points of the cubic Bezier line segment from P200 to P203 are respectively P200, P201, P202 and P203, four control points of the cubic Bezier line segment from P203 to P206 are respectively P203, P204, P205 and P206, four control points of the cubic Bezier line segment from P206 to P209 are respectively P206, P207, P208 and P209, and four control points of the cubic Bezier line segment from P209 to P200 are respectively P209, P210, P211 and P200.
Waft four point coordinates of boundary rectangle of shape pel of known wave flag can calculate the width and the height of this pel boundary rectangle, are respectively W2 and H2.In addition, according to known adjusting wave flag the waft level of pel and the parameter f x and the fy of field amplitude, can calculate coordinate that P200 orders for (a, b), a=fx*W, b=fy*H.
Control point Coordinate Calculation process may further comprise the steps on every three Bezier line segments.
1. based on just profound curvilinear equation, calculate the P203 point coordinates according to the P200 point coordinates.
P203.x=W2;
P203.y=b+b*0.9*sin((W2-a)*2*PI/W2)。
2. being starting point with the P200 point, is terminal point with the P203 point, according to the three bezier curve equation, calculates the P201 point at t=1/3 and t=2/3 place and the coordinate that P202 is ordered respectively.
P201.x=((m 1*c 2-m 2*c 1)-(a 1*c 2-a 2*c 1)*P200.x-(d 1*c 2-c 1*d 2)*P203.x)/(b 1*c 2-b 2*c 1)。
P202.x=((m 1*b 2-m 2*b 1)-(a 1*b 2-a 2*b 1)*P200.x-(d 1*b 2-d 2*b 1)*P203.x)/(c 1*b 2-c 2*b 1)。
Wherein, m 1=a+ (W2-a)/3, m 2=a+ (W2-a) * 2/3; t 1=1.0/3, t 2=2.0/3;
a 1=(1-t 1)*(1-t 1)*(1-t 1);
b 1=3*t 1*(1-t 1)*(1-t 1);
c 1=3*t 1*t 1*(1-t 1);
d 1=t 1*t 1*t 1
a 2=(1-t 2)*(1-t 2)*(1-t 2);
b 2=3*t 2*(1-t 2)*(1-t 2);
c 2=3*t 2*t 2*(1-t 2);
d 2=t 2*t 2*t 2
P201.y=((n 1*c 2-n 2*c 1)-(a 1*c 2-a 2*c 1)*P200.y-(d 1*c 2-c 1*d 2)*P203.y)/(b 1*c 2-b 2*c 1)。
P202.y=((n 1*b 2-n 2*b 1)-(a 1*b 2-a 2*b 1)*P200.y-(d 1*b 2-d 2*b 1)*P203.y)/(c 1*b 2-c 2*b 1)。
Wherein, n 1=b-b*0.9*sin ((W2-a) * 2*PI/ (3*W2)),
n 2=b-b*0.9*sin((W2-a)*2*PI*2/(3*W2))。
3. based on just profound curvilinear equation, calculate the P206 point coordinates according to the P200 point coordinates.
P206.x=W2-a;
P206.y=H2-b-b*0.9*sin((W2-a)*2*PI/W2)
4. calculate the P209 point coordinates.
P209.x=0;
P209.y=H2-b
5. being starting point with the P206 point, is terminal point with the P209 point, according to the three bezier curve equation, calculates the P207 point and the P208 point coordinates at t=1/3 and t=2/3 place respectively, and computational methods are identical with the coordinate that calculating P201 point, P202 are ordered.
6. the P204 point coordinates equals the P203 point coordinates, and the P205 point coordinates equals the P206 point coordinates, and the P210 point coordinates equals the P209 point coordinates, and the P211 point coordinates equals the P200 point coordinates.Why will repeat this several points, be in order to make that every Bezier line segment in the sealing vector outline information of this caption object all is a three bezier curve.In fact, the three bezier curve that forms by control point P203, P204, P205, P206, and be the straight line section by the three bezier curve that control point P209, P210, P211, P200 form.
Geometry with the fundamental figure captions is that heart is an example, as shown in Figure 3.Four point coordinates of the boundary rectangle of known heart-shaped pel, can calculate this pel width and the height, be respectively W3 and H3.At first this pel is divided into 8 curved sections, is respectively from P300 to P303, from P303 to P306, from P306 to P309, from P309 to P312, from P312 to P315, from P315 to P318, P318 is to P320, from P320 to P300.Each control point Coordinate Calculation process may further comprise the steps after converting every curved section to three Bezier line segments.
1. at first according to the features of shape of heart-shaped pel, the coordinate of calculation level P300, P303, P306 and P309.
P300.x=0.73*W3+0.27*W3*cos(A),
P300.y=0.25*H3-0.25*H3*sin(A);
P303.x=0.73*W3+0.27*W3*cos(PI/3+A),
P303.y=0.25*H3-0.25*H3*sin(PI/3+A);
P306.x=0.73*W3+0.27*W3*cos(2*PI/3+A),
P306.y=0.25*H3-0.25*H3*sin(2*PI/3+A);
P309.x=0.73*W3+0.27*W3*cos(PI+A),
P309.y=0.25*H3-0.25*H3*sin(PI+A)。
Wherein PI and A are constant, PI=3.1415926, A=-0.5535442.
2. utilizing the cubic Bezier parametric equation, is starting point with the P300 point, is terminal point with the P303 point, calculates the P301 point at t=1/3 and t=2/3 place and the coordinate that P302 is ordered respectively.The matrix form of three bezier curve is as follows:
P ( t ) = t 3 t 2 t 1 2 - 2 1 1 - 3 3 - 2 - 1 0 0 1 0 1 0 0 0 P 600 P 601 P 602 P 603 t∈[0,1]
X ( t ) = t 3 t 2 t 1 2 - 2 1 1 - 3 3 - 2 - 1 0 0 1 0 1 0 0 0 X 0 X 1 X 2 X 3 t∈[0,1]
Y ( t ) = t 3 t 2 t 1 2 - 2 1 1 - 3 3 - 2 - 1 0 0 1 0 1 0 0 0 Y 0 Y 1 Y 2 Y 3 t∈[0,1]
After top matrix expansion, obtain:
X(t)=A 0+A 1*t+A 2*t 2+A 3*t 3
Y(t)=B 0+B 1*t+B 2*t 2+B 3*t 3
Wherein, A 0=X 0A 1=-3X 0+ 3X 1A 2=3X 0-6X 1+ 3X 2A 3=-X 0+ 3X 1-3X 2+ X 3B 0=Y 0B 1=-3Y 0+ 3Y 1B 2=3Y 0-6Y 1+ 3Y 2B 3=-Y 0+ 3Y 1-3Y 2+ Y 3
Because the coordinate X that P300 point and P303 are ordered 0, X 3, Y 0, Y 3Known, the t value that P301 is ordered is 1/3, and the t value that P302 is ordered is 2/3, therefore can list a following quaternary linear function group:
X 1=A 0+A 1*(1/3)+A 2*(1/3) 2+A 3*(1/3) 3
Y 1=B 0+B 1*(1/3)+B 2*(1/3) 2+B 3*(1/3) 3
X 2=A 0+A 1*(2/3)+A 2*(2/3) 2+A 3*(2/3) 3
Y 2=B 0+B 1*(2/3)+B 2*(2/3) 2+B 3*(2/3) 3
Separate this equation group, can obtain the coordinate X that P301 and P302 are ordered 1, X 2, Y 1, Y 2Value.
3. utilizing the cubic Bezier parametric equation, is starting point with the P303 point, is terminal point with the P306 point, calculates the P304 point at t=1/3 and t=2/3 place and the coordinate that P305 is ordered respectively.3. method asks the coordinate of P301, P302 identical in the step with the, repeats no more.
4. utilizing the cubic Bezier parametric equation, is starting point with the P306 point, is terminal point with the P309 point, calculates the P307 point at t=1/3 and t=2/3 place and the coordinate that P308 is ordered respectively.3. method asks the coordinate of P301, P302 identical in the step with the, repeats no more.
5. according to the left-right symmetric of heart-shaped pel, can obtain the coordinate of P311, P312, P313, P314, P315, P316, P317 and P318.
6. the P320 coordinate of ordering be (W/2, H).
7. P323, the P324 coordinate of ordering equals the P300 point, and the coordinate that P319 is ordered equals the P318 point, and the coordinate that P321, P322 are ordered equals the P320 point.
At last, obtain the vector outline information that 8 three Bezier line segments are formed.These 8 three Bezier line segments are as follows:
Article one, three Bezier line segments forming by control point (P300, P301, P302, P303) of line segment;
Three Bezier line segments that the second line segment is formed by control point (P303, P304, P305, P306);
Article three, three Bezier line segments forming by control point (P306, P307, P308, P309) of line segment;
Article four, three Bezier line segments forming by control point (P309, P310, P311, P312) of line segment;
Article five, three Bezier line segments forming by control point (P312, P313, P314, P315) of line segment;
Article six, three Bezier line segments forming by control point (P315, P316, P317, P318) of line segment;
Article seven, three Bezier line segments forming by control point (P318, P319, P320, P321) of line segment (because the coordinate of P318, P319 is identical, the coordinate of P320, P321 is identical, so this line segment is actually the straight line section);
Article eight, three Bezier line segments forming by control point (P321, P322, P323, P324) of line segment (because the coordinate of P321, P322 is identical, the coordinate of P323, P324 is identical, so this line segment is actually the straight line section).
For the fundamental figure caption object of other types, can be according to same thought, be converted into by once, the closed outline formed of secondary or cubic Bezier line segment.
When the type of caption object was compound captions, the method that converts thereof into vector outline information may further comprise the steps:
1. according to the data structure of compound caption object, it is split as the individual basic caption object of M (M is a positive integer).Basic caption object just is meant text subtile object or fundamental figure caption object.
2. use the processing method of above-mentioned " text subtile object " and " fundamental figure caption object " to obtain this M the vector outline information of caption object substantially respectively.
3. according to the space coordinate of the basic caption object of M, M the vector outline information combination that step is obtained in 2. forms the final vector outline information of this compound caption object together.
Caption object through after the above-mentioned conversion, is also needed rotation, deformation parameter according to caption object, the vector outline information after the conversion is carried out the space geometry conversion.
The anglec of rotation of supposing caption object is A, and the control point number of basic caption object is n (n is a positive integer), is respectively P[0] to P[n-1], then the process that a basic caption object is carried out the space geometry conversion may further comprise the steps.
A. four apex coordinates of the boundary rectangle of the basic caption object of basis calculate the coordinate of the central point Q of basic caption object.
B. according to the postrotational P[i of following formula correction] coordinate of (0≤i≤n, i are positive integer):
x=P[i].x-Q.x,
y=P[i].y-Q.y,
P[i].x=Q.x+x*cos(A)-y*sin(A),
P[i].y=Q.y+x*sin(A)+y*cos(A);
Wherein, P[i] .x and P[i] .y is respectively P[i] point is horizontal, ordinate, Q.x and Q.y are respectively horizontal stroke, the ordinate that Q is ordered.
Dissimilar caption object is converted to by once, behind the closed outline formed of secondary or three bezier curve, in order to make the consistency of render engine on algorithm process, reduce the complexity of algorithm, the efficient of optimized Algorithm also needs the Bezier line segment unification of different number of times is converted to quadratic B ezier line segment.
The principle that Bezier line segment is converted to quadratic B ezier line segment is: with former and later two control points R0 of a Bezier line segment and R1 first and the 3rd control point as quadratic B ezier line segment, the mid point of R0 and R1 is as second control point of quadratic B ezier line segment.
Fig. 4 is that a Bezier line segment is converted to secondary Bezier line segment schematic diagram, and 4a is a preceding Bezier line segment of conversion, and 4b is the quadratic B ezier line segment after changing.Wherein, P40=R40, P42=R41, P41=(mid point of R40 and R41), i.e. P41.x=(R40.x+R41.x)/2; P41.y=(R40.y+R41.y)/2.
The principle that the cubic Bezier line segment is converted to quadratic B ezier line segment is: convert a cubic Bezier line segment to two quadratic B ezier line segments.
5a among Fig. 5 and 5b are respectively two kinds of situation schematic diagrames that the cubic Bezier line segment are converted to two quadratic B ezier line segments.The control point of supposing a cubic Bezier line segment is respectively R50, R51, R52, R53.Q1 is the mid point of R50 and R51, Q2 is the mid point of R52 and R53, Q3 is the mid point of R51 and R52, Q4 is the mid point of Q1 and Q3, Q5 is the mid point of Q2 and Q3, Q6 is the mid point of Q4 and Q5, and Q7 is the straight line of Q4 and Q5 formation and the intersection point of R0 and R1 formation straight line, and Q8 is the straight line of Q4 and Q5 formation and the intersection point of R52 and R53 formation straight line.
As follows according to the coordinate that coordinate and the Bezier parametric equation of 4 of R50, R51, R52, R53 calculates Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8:
Q1.x=(R50.x+R51.x)/2,Q1.y=(R50.y+R51.y)/2;
Q2.x=(R52.x+R53.x)/2,Q2.y=(R52.y+R53.y)/2;
Q3.x=(R51.x+R52.x)/2,Q3.y=(R51.y+R52.y)/2;
Q4.x=(Q1.x+Q3.x)/2,Q4.y=(Q1.y+Q3.y)/2;
Q5.x=(Q2.x+Q3.x)/2,Q5.y=(Q2.y+Q3.y)/2;
Q6.x=(Q4.x+Q5.x)/2,Q6.y=(Q4.y+Q5.y)/2;
Q7.x=(3*Q1.x+3*Q4.x-R0.x-Q6.x)/4,
Q7.y=(3*Q1.y+3*Q4.y-R0.y-Q6.y)/4;
Q8.x=(3*Q2.x+3*Q5.x-R3.x-Q6.x)/4,
Q8.y=(3*Q2.y+3*Q5.y-R3.y-Q6.y)/4。
Original cubic Bezier line segment is punished into two quadratic B ezier line segments at the Q6 point, and three control points of a Bezier line segment are respectively R50, Q7, and Q6, three control points of another Bezier line segment are respectively Q6, Q8, R53.
In the vector outline information of the closed outline of forming by quadratic bezier curve, may there be the quadratic B ezier line segment of self intersection, promptly closed outline includes one or more closed circuits, as Fig. 6, Fig. 7 and shown in Figure 10.In order to strengthen the rendering effect of captions, improve rendering efficiency, need handle this situation, delete or cut apart closed circuit.
The method of handling the secondary Bezier of self intersection is: at first judge the situation that whether has secondary Bezier line segment self intersection among the closed outline G, if exist, then continue to judge it is adjacent secondary Bezier line segment self intersection or non-adjacent secondary Bezier line segment self intersection, if adjacent secondary Bezier line segment self intersection, then with the closed circuit deletion that comprises adjacent secondary Bezier line segment self intersection that includes among the closed outline G; If non-adjacent secondary Bezier line segment self intersection then is divided into a plurality of closed outlines with closed outline G and its closed circuit that comprises non-adjacent secondary Bezier line segment self intersection that includes.
Judge whether exist the method for secondary Bezier line segment self intersection to be among the closed outline G: supposing to have among the G M secondary Bezier line segment, is respectively B[0], B[1], B[2] to B[M-1]; Take out each secondary Bezier line segment B[j among the G successively], judge B[j] whether crossing with other secondary Bezier line segment among the G, if intersect, then there is the self intersection situation in G; Otherwise, do not have the self intersection situation.
Judge that the method whether two secondary Bezier line segments intersect is: the boundary rectangle that at first calculates two secondary Bezier line segments; Whether the boundary rectangle of judging two secondary Bezier line segments then exists common factor, if exist, and these two secondary Bezier line segment intersections then, if there is no, then these two secondary Bezier line segments are non-intersect.
With reference to Fig. 8, the method for calculating the boundary rectangle of a secondary Bezier line segment is: three control points supposing secondary Bezier line segment are respectively P0, P1 and P2, and the abscissa that P0 is ordered is P0.x, and ordinate is P0.y; The abscissa that P1 is ordered is P1.x, and ordinate is P1.y; The abscissa that P2 is ordered is P2.x, and ordinate is P2.y; The leg-of-mutton boundary rectangle T that calculating is made of P0, P1 and P2, T is the boundary rectangle of this secondary Bezier line segment, and formula is as follows:
T.left=min(P0.x,P1.x,P2.x),
T.right=max(P0.x,P1.x,P2.x),
T.top=min(P0.y,P1.y,P2.y),
T.bottom=max(P0.y,P1.y,P2.y);
Wherein, T.left represents the abscissa of boundary rectangle left frame, and T.right represents the abscissa of boundary rectangle left frame, and T.top represents the ordinate of boundary rectangle upper side frame, and T.bottom represents the ordinate of boundary rectangle lower frame; The min function representation is got the minimum value in all parameters, and the max function representation is got the maximum in all parameters.
If there is the situation of secondary Bezier line segment self intersection among the closed outline G, then judge it is that the adjacent secondary Bezier line segment self intersection or the method for non-adjacent secondary Bezier line segment self intersection are: if B[j] and adjacent segments B[j+1] intersect, then be adjacent secondary Bezier line segment self intersection, otherwise be non-adjacent secondary Bezier line segment self intersection.
With reference to Fig. 6, if adjacent secondary Bezier line segment self intersection, then the method with the closed circuit deletion of the adjacent secondary Bezier line segment that comprises self intersection that includes among the closed outline G is:
Supposing to have among the G M secondary Bezier line segment, is respectively B[0], B[1], B[2] to B[M-1], the adjacent secondary Bezier line segment of two self intersections is respectively B[j] and B[j+1]; At first calculate B[j] and B[j+1] point of intersection S; Then with B[j] initial control point link to each other with S constitute a new secondary Bezier line segment B[j '], with S and B[j+1] finishing control point link to each other constitute a new secondary Bezier line segment B[j+1 '], B[j '], B[j+1 '] with closed outline G in original secondary Bezier line segment B[0] to B[j-1], B[j+2] to B[M-1] constituted a new closed outline G ', make G=G '; Delete S and B[j at last] the closed outline that constitutes of finishing control point.(6a) is the preceding closed outline G of processing among Fig. 6, (6b) is the closed outline G after handling, (6c) closed outline for deleting.
With reference to Fig. 7, if non-adjacent secondary Bezier line segment self intersection, the method that then closed circuit of closed outline G and its non-adjacent secondary Bezier line segment that comprises self intersection that includes is divided into a plurality of closed outlines is:
The non-adjacent secondary Bezier line segment of supposing two self intersections is respectively B[j] and B[k], j<k; At first calculate B[j] and B[k] point of intersection S; Then with B[j] initial control point link to each other with S constitute a new secondary Bezier line segment B[j '], and with S and B[k] finishing control point link to each other constitute a new secondary Bezier line segment B[k '], B[j '], B[k '] with closed outline G in original line segment B[0] to B[j-1], B[k+1] to B[M-1] constituted a new closed outline G ', make G=G '; At last with S and B[j] finishing control point and B[k] initial control point link to each other, two new secondary Bezier line segments have been formed, with these two new secondary Bezier line segment and B[j+1] to B[k-1] in all secondary Bezier line segments constituted a new closed outline G ", G " is joined caption object vector outline information table.
Calculate the method for two quadratic bezier curve intersection points in the caption object vector outline information, in theory, can be according to the combined parameters Equation for Calculating of two quadratic bezier curves.But this method is worthless, because not only amount of calculation is huge, and all is based on the computing of floating number, and the efficient of algorithm can be lower.Therefore, present embodiment adopts " two fens iterative methods ".The core concept of this method is: if two quadratic B ezier line segment intersections, these two quadratic B ezier line segments of naming a person for a particular job in the basis so are divided into two quadratic B ezier line segments respectively, obtain 4 quadratic B ezier line segments; And then after the same method, handle this 4 line segments, (generally, this value is less than some values up to the initial control point of final every line segment and the air line distance of finishing control point
Figure G2008102258703D0000191
), finally can be summed up as the intersection point that calculates two straightways.This method specifically may further comprise the steps:
(I) suppose that two crossing secondary Bezier line segments are respectively B[j] and B[k], with B[j] and B[k] carry out following processing respectively:
1. calculate the initial control point of secondary Bezier line segment and the air line distance L between the finishing control point,
Figure G2008102258703D0000192
Wherein, x0, y0 are initial control point horizontal stroke, ordinate, and x1 and y1 are that finishing control point is horizontal, ordinate;
2. whether judge L greater than M, if greater than, then calculate the mid point of secondary Bezier line segment, secondary Bezier line segment is divided into two secondary Bezier line segments in midpoint, described
Figure G2008102258703D0000193
3. repeating step 1. to step 2., the initial control point of every secondary Bezier line segment after dividing and the air line distance L between the finishing control point are less than or equal to M;
(II) with B[j] and B[k] through after step (I) processing, suppose that final two secondary Bezier line segments that intersect are respectively B[j '] and B[k '], calculate B[j '] initial control point and the straight line and the B[k ' of finishing control point formation] initial control point and the intersection point of the straight line of finishing control point formation.
In the present embodiment, the method for calculating the mid point of secondary Bezier line segment is: three control points supposing secondary Bezier line segment are respectively P0, P1 and P2, and function expression is
B(t)=(1-t) 2P 0+2t(1-t) 2P 1+t 2P 2 t∈[0,1];
Make t=0.5, calculate on the secondary Bezier equation a bit, this point is the mid point of secondary Bezier line segment, and its Coordinate Calculation formula is B=(P0+2*P1+P2)/4.
As shown in Figure 9, R1 is that (P0, mid point P1), R2 are that (P1, mid point P2), R3 are that (P2, mid point P0), Q are that (R1 is R2) with straight line (R3, intersection point P1) for straight line to straight line to straight line to straight line.The Q point is quadratic bezier curve (P0, P1, mid point P2).
R1 point abscissa R1.x=(P0.x+P1.x)/2, R1 point ordinate R1.y=(P0.y+P1.y)/2; R2 point abscissa R2.x=(P1.x+P2.x)/2, R2 point ordinate R2.y=(P1.y+P2.y)/2.Wherein, P0.x, P0.y are that the P0 point is horizontal, ordinate; P1.x, P1.y are that the P1 point is horizontal, ordinate; P2.x, P2.y are that the P2 point is horizontal, ordinate.
The ordinate Q.y=(R1.y+R2.y) that the abscissa Q.x=(R1.x+R2.x) that Q is ordered/2=(P0.x+2*P1.x+P2.x)/4, Q are ordered/2=(P0.y+2*P1.y+P2.y)/4.
After the situation of non-adjacent secondary Bezier line segment self intersection among the closed outline G was handled, still might there be the situation of self intersection in the closed outline after cutting apart.As shown in figure 10, closed outline (10a) after treatment, be divided into (10b), (10c) and (10d) shown in closed outline, wherein still there is the situation of self intersection in the closed outline shown in (10c), therefore need to repeat above-mentioned steps the closed outline shown in (10c) is handled again, do not have the situation of self intersection to take place in all closed outlines after cutting apart.Closed outline (10c) is through after handling again, is divided into (10c1) and (10c2) two closed outlines.
In the vector outline information of caption object, may there be crossing situation between the different closed outlines, in order to help the follow-up rendering of caption object, strengthen the final rendering effect of caption object, need handle this situation, a quadratic B ezier line segment is divided into many quadratic B ezier line segments at the intersection point place.
Figure 11 has shown of the present inventionly cuts apart the method for secondary Bezier in the caption object vector outline according to intersection point, may further comprise the steps:
(1) calculates the secondary Bezier line segments all in the caption object vector outline and the intersection point of other secondary Bezier line segments;
(2), this secondary Bezier line segment is cut apart at the intersection point place of every secondary Bezier line segment;
Three control points supposing a secondary Bezier line segment B are respectively P[0], P[1], P[2], n intersection point arranged, be respectively S[0 on B] to S[n-1], the t value in the Bezier parametric equation of each intersection point correspondence is respectively S[0] .t is to S[n-1] .t;
At first at S[0] the some place is divided into two line segment B1 and B1 ' with line segment B;
Three control points of B1 are respectively P[0], Q[0], S[0], P[0] and S[0] coordinate known, Q[0] coordinate be:
Q[0].x=(1-t)*P[0].x+t*P[1].x,
Q[0].y=(1-t)*P[0].y+t*P[1].y;
Three control points of B1 ' are respectively S[0], R[0], P[2], S[0] and P[2] coordinate known, R[0] coordinate be:
R[0].x=(1-t)*P[1].x+t*P[2].x,
R[0].y=(1-t)*P[1].y+t*P[2].y;
Wherein, Q[0] .x represents Q[0] abscissa of point, Q[0] .y represents Q[0] and the ordinate of point, R[0] .x represents R[0] and the some abscissa, R[0] .y represents R[0] the some ordinate; T=(S[0] .t-P[0] .t)/(P[2] .t-P[0] .t), P[0] .t is P[0] t value in the corresponding Bezier parametric equation of point, P[2] .t is P[2] t value in the Bessel equation of some correspondence;
Then at S[1] the some place is divided into two line segment B2 and B2 ' with line segment B1 ', and method is 1. identical with step;
By that analogy, at last at S[n-1] the some place is divided into two line segment Bn and Bn ' with line segment Bn-1 '; Finally obtain the line segment after the N+1 bar is cut apart.
Figure 12 has shown the method flow that calculates the intersection point of secondary Bezier line segments all in the caption object vector outline and other secondaries Bei Jier line segment, may further comprise the steps:
1. travel through closed outlines all in the caption object vector outline, take out one with get different closed outline G[i];
2. travel through G[i] in all quadratic B ezier line segments, take out one with get different secondary Bezier line segment B[j];
3. travel through in this caption object vector outline except that B[j] all secondary Bezier line segments, take out one with get different secondary Bezier line segment B[k];
4. judge B[j] and B[k] boundary rectangle whether have common factor, if there is no, then go to step 3.; If exist, then calculate B[j] and B[k] between intersection point.
Calculate B[j] with B[k] between the intersection point and the principle of the intersection point of the secondary Bezier line segment of aforementioned calculation self intersection identical, repeat no more herein.
Figure 13 has shown the method flow of the caption object vector outline being advised and being put in order according to the inside and outside side attribute of secondary Bezier line segment, mainly may further comprise the steps.
(1) determines the inside and outside side attribute of every secondary Bezier line segment in all closed outlines of caption object.
Determine the inner edge/outer side attribute of a secondary Bezier line segment, only need to determine that any one point on this secondary Bezier line segment is an interior point or exterior point gets final product in the vector outline information of whole caption object, generally can use the mid point of this line segment.If the mid point of this line segment is interior point, then this line segment is an inner edge; If exterior point, then this line segment is the outside.
The mid point of judging secondary Bezier line segment is interior point or the method for exterior point may further comprise the steps in all closed outlines of caption object.
Suppose that secondary Bezier line segment is B, three control points of B are respectively P[0], P[1], P[2], mid point is Q.
1. determine the direction value d of B: if P[2] .y>P[0] .y, then d=1; If P[2] .y<P[0] .y, then d=-1; If P[2] .y=P[0] .y, then d=0.Wherein, P[0] .y and P[2] .y represents P[0 respectively] and P[2] ordinate.
2. calculate the mid point Q coordinate of B.
3. judge that abs (P[2] .y-P[0] .y) whether greater than abs (P[2] .x-P[0] .x), in this way, is a starting point with the Q point then, along continuous straight runs is made a ray H to the right; As not, be that starting point is vertically upwards made a ray H then with the Q point.In the present embodiment, suppose that along continuous straight runs makes a ray H to the right, as shown in figure 14.Calculate all the secondary Bezier line segments except that B that intersect with H in all closed outlines of caption object, suppose to have M bar secondary Bezier line segment and H crossing, be respectively B[0], B[1] to B[M-1].Wherein, P[0] .x and P[2] .x represents P[0 respectively] and P[2] abscissa, the abs function is the function that takes absolute value.
4. calculate B[i respectively] direction value d[i], the method that method and step are calculated the d value in 1. is identical.Wherein, i=0,1 ..., M-1.
5. calculate d[i] with value d ': d '=d[0]+d[1]+...+d[M-1].
6. according to the inside and outside side attribute value a of d and d ' calculating B:
a=1-abs(SIGN(d+d′)*SIGN(d′))。Wherein, is SIGN (x) defined as (x==0)? 0:((x>0)? 1:-1)), if i.e. x=0, then SIGN (x)=0; If x>0, then SIGN (x)=1; If x<0, then SIGN (x)=-1.
If a=0, then B is an inner edge; If a=1, then B is the outside.
Behind the inside and outside side attribute of a secondary Bezier line segment in having determined a closed outline, then the inside and outside side attribute of the secondary Bezier line segment after this closed outline this secondary Bezier line segment is identical with it, till running into an intersection point.
Utilize said method can determine the inside and outside side attribute of every secondary Bezier line segment comprising in all closed outlines.
(2) with attribute be the secondary Bezier line segment deletion of inner edge.
Behind the inside and outside side attribute of every the secondary Bezier line segment that in having determined vector outline information, has comprised in all closed outline, deleting all methods that are labeled as the secondary Bezier line segment of inner edge is: in every secondary Bezier line segment, all there is a border attribute variable to represent inner edge/outer side attribute, all secondary Bezier line segments in the traversal vector outline information are that the secondary Bezier line segment of inner edge is deleted from closed outline and got final product with the border attribute.
(3) according to the closed outline of intersection point reconstruct caption object.
Delete property need be advised also again to all closed outlines after being the secondary Bezier line segment of inner edge, promptly according to intersection point secondary Bezier line segment is coupled together, and rebuilds each closed outline.The closed outline that rebuilds must be disjoint each other closed outline.
The concrete grammar of rule and a caption object may further comprise the steps:
A. from all closed outlines, take out one with get different closed outline G1;
Whether the difference of starting point coordinate of b. judging the end point coordinate of the last item secondary Bezier line segment of G1 and article one secondary Bezier line segment is smaller or equal to threshold values T, usually T gets 0.00001, in this way, then G1 does not need to handle, repeating step a is to step b, finishes up to all closed outlines are processed;
C. take out the next closed outline G2 adjacent with G1;
Whether the curve tail of d. judging G1 overlaps with the curve tail of G2 with the curve head of G2 or the curve head of G1, whether the difference of end point coordinate of the last item secondary Bezier line segment of promptly judging the starting point coordinate of article one secondary Bezier line segment of the difference of starting point coordinate of article one secondary Bezier line segment of the end point coordinate of the last item secondary Bezier line segment of G1 and G2 or G1 and G2 is smaller or equal to threshold values T, in this way, then G1, G2 are merged, and from vector outline, delete G2;
E. take out the next closed outline G2 ' adjacent with G2, make G2=G2 ', repeating step d is that last closed outline or G2 equate with G1 up to G2;
F. repeating step a is to step e, finishes up to all closed outlines are processed.
Said process is described below with false code:
First closed outline in the G1=vector outline;
While (G1!=NULL) // traversal vector outline in all closed outlines
{
While (G1 needs to handle again)
{
G2=G1.Next; //G2 is the next closed outline adjacent with G1
while(G2!=NULL&&G2!=G1)
{
If (G2 needs to handle again)
{
If (nose heave the closing of curve of the curve tail of G1 and G2)
{
// G1 and G2 are joined end to end
G1.Tail.Next=G2.Head;
G1.Head.Prev=G2.Tail;
G2.Tail.Next=G1.Head;
G2.Head.Prev=G1.Tail;
G1.Tail=G2.Tail;
G′=G2;
G2=G2.Prev;
From the closed outline chained list, delete G ';
}
Else if (the curve head of G1 and the curve cabrage of G2 are closed)
{
// G1 and G2 are joined end to end
G2.Tail.Next=G1.Head;
G2.Head.Prev=G1.Tail;
G1.Tail.Next=G2.Head;
G1.Head.Prev=G2.Tail;
G1.Head=G2.Head;
G′=G2;
G2=G2.Prev;
From the closed outline chained list, delete G ';
}
}
G2=G2.Next;
}
}
G1=G1.Next;
}
(4) boundary rectangle of every secondary Bezier line segment in all closed outlines that obtain in the calculation procedure (3) and all closed outlines, method is the same, repeats no more herein.
(5) direction of all closed outlines that obtain in the markers step (3) comprises clockwise direction and counter clockwise direction.Clockwise direction is labeled as 1, is labeled as-1 counterclockwise.Judge the direction of a closed curve G, only need to take out any secondary Bezier line segment among the G, judge that its direction gets final product.Concrete treatment step is as follows:
1. appoint from closed outline G that to get a secondary Bezier line segment be B, suppose that three control points of B are respectively P[0], P[1], P[2], mid point is Q;
2. determine the direction value d of B: if P[2] .y>P[0] .y, then d=1; If P[2] .y<P[0] .y, then d=-1; If P[2] .y=P[0] .y, then d=0;
3. calculate the mid point Q of B;
4. judge that abs (P[2] .y-P[0] .y) whether greater than abs (P[2] .x-P[0] .x), in this way, is a starting point with the Q point then, along continuous straight runs is made a ray H; As not, be that starting point is vertically made a ray H then with the Q point; Calculate all the secondary Bezier line segments except that B that intersect with H in all closed outlines of caption object, suppose to have M bar secondary Bezier line segment and H crossing, be respectively B[0], B[1] to B[M-1];
5. calculate B[i respectively] direction value d[i], the method that method and step are calculated the d value in 1. is identical; Wherein, i=0,1 ..., M-1;
6. calculate d[i] with value d ': d '=d[0]+d[1]+...+d[M-1];
7. calculate the value of the direction attribute b of B, b=d* (1-2*abs (d ')); If b>0, then closed outline G is a clockwise direction, otherwise is counterclockwise.
After the above-mentioned conversion of vector outline information via of caption object, the closed outline that also needs to be made up of secondary Bezier line segment converts polygon to, is about to the discrete straightway that turns to of every secondary Bezier line segment.Its core concept has comprised " adaptive step of t value is chosen ", " dispersing ", " changing straight " and " floating-point coordinate integer " four aspects.
According to secondary Bezier parametric equation, to numerical value of t value from 0 to 1 each stepping, calculate point on the corresponding secondary Bezier according to the t value, suppose that the point that adjacent two t values are calculated is Q0 and Q1, if the air line distance of Q0 and Q1 greater than
Figure G2008102258703D0000261
Then between the t of the t of Q0 value and Q1 value, select a t value once more, some Q0 on the corresponding secondary Bezier of per two t values and the air line distance of Q1 smaller or equal to
Figure G2008102258703D0000262
Till.At this moment the straight line of Q0 and Q1 formation is exactly the straight line section after the discretization.Coordinate with each point amplifies M doubly at last, and making original floating number coordinate transform is the integer type coordinate.
Why the space length with every after discretization straightway is limited in
Figure G2008102258703D0000263
Main thought be make the horizontal range of the starting point of every straightway after the discretization and terminal point and vertical range all smaller or equal to
Figure G2008102258703D0000264
The straight line section is passed through at most
Figure G2008102258703D0000265
Individual pixel.So just can guarantee the precision of caption rendering.
Figure 15 has shown of the present invention with the discrete method flow that turns to straightway of caption object vector outline, mainly may further comprise the steps.
(1) vector outline of traversal caption object, takes out one with get different sealing secondary Bezier G[i], the vector outline of supposing caption object comprises that N is sealed the secondary Bezier, i ∈ [0, N-1] then, N and i are positive integer.
(2) traversal sealing secondary Bezier G[i], take out one with get different secondary Bezier line segment B[j], suppose G[i] in comprise M secondary Bezier line segment, j ∈ [0, M-1] then, j is a positive integer.
(3) with B[j] dispersing turns to straightway, and with reference to Figure 16, concrete implementation procedure is as follows:
Suppose B[j] three control points be respectively P[0], P[1] and P[2]; P[0] be initial control point, P[1] be the intermediate controlled point, P[2] for stopping the control point.
At first, with P[0] point be starting point, calculating B[j] article one straightway L[j after the discretization] [0].
1. the initial value of t is set, t=P[0] .t+L; Wherein, L is a constant, 0<L<1 (L=0.0625 in the present embodiment); P[0] .t is P[0] t value in the corresponding secondary Bezier equation of point, P[0] .t=0.
2. according to putting Q[0 on the corresponding secondary Bezier of secondary Bezier Equation for Calculating t value] coordinate.
3. calculate P[0] point and Q[0] point between air line distance d,
Figure G2008102258703D0000271
Wherein, x0, y0 are P[0] coordinate, x1, y1 are Q[0] coordinate.
4. judge
Figure G2008102258703D0000272
Whether set up,, then make t=(P[0] .t+Q[0] .t)/2, wherein, Q[0 if set up] .t is Q[0] t value in the corresponding secondary Bezier equation of point; Repeating step 2. to step 4., up to Final Q[0] point and P[0] straight line that constitutes of point is the straight line L[j after article one discretization] [0].At last with Q[0] point and P[0] coordinate of point amplifies M doubly, and making original floating number coordinate transform is the integer type coordinate.In the present embodiment, M equals 512.
Then, with Q[0] point be starting point, adopt and calculating B[j] the identical method calculating second straightway L[j of article one straightway after the discretization] [1];
By that analogy, up to handling B[j] finishing control point P[2] till, obtain K bar straightway L[j] [0] to L[j] [K-1];
(4) repeating step (2) is to step (3), up to G[i] in all secondary Bezier line segments dispose;
(5) repeating step (1) to step (4) all closed curves in the vector outline of caption object dispose.
Method of the present invention is not limited to above-mentioned embodiment, and those skilled in the art's technical scheme according to the present invention draws other execution mode, belongs to technological innovation scope of the present invention equally.

Claims (4)

1. the vector outline with caption object disperses and turns to the method for straightway, may further comprise the steps:
(1) vector outline of traversal caption object, takes out one with get different sealing secondary Bezier G[i], the vector outline of supposing caption object comprises that N is sealed the secondary Bezier, i ∈ [0, N-1] then, N and i are positive integer;
(2) traversal sealing secondary Bezier G[i], take out one with get different secondary Bezier line segment B[j], suppose G[i] in comprise M secondary Bezier line segment, j ∈ [0, M-1] then, j is a positive integer;
(3) with B[j] dispersing turns to straightway, and concrete implementation procedure is as follows:
Suppose B[j] three control points be respectively P[0], P[1] and P[2]; P[0] be initial control point, P[1] be the intermediate controlled point, P[2] for stopping the control point;
At first, with P[0] point be starting point, calculating B[j] article one straightway L[j after the discretization] [0];
1. the initial value of t is set, t=P[0] .t+L; Wherein, L is a constant, 0<L<1; P[0] .t is P[0] t value in the corresponding secondary Bezier equation of point;
2. according to putting Q[0 on the corresponding secondary Bezier of secondary Bezier Equation for Calculating t value] coordinate;
3. calculate P[0] point and Q[0] point between air line distance d,
d = ( x 1 - x 0 ) 2 + ( y 1 - y 0 ) 2 , Wherein, x0, y0 are P[0] coordinate, x1, y1 are Q[0] coordinate;
4. judge
Figure F2008102258703C0000012
Whether set up,, then make t=(P[0] .t+Q[0] .t)/2, wherein, Q[0 if set up] .t is Q[0] t value in the corresponding secondary Bezier equation of point; Repeating step 2. to step 4., up to
Figure F2008102258703C0000013
Final Q[0] point and P[0] straight line that constitutes of point is the straight line L[j after article one discretization] [0];
Then, with Q[0] point be starting point, adopt and calculating B[j] the identical method calculating second straightway L[j of article one straightway after the discretization] [1];
By that analogy, up to handling B[j] finishing control point P[2] till, obtain K bar straightway L[j] [0] to L[j] [K-1];
(4) repeating step (2) is to step (3), up to G[i] in all secondary Bezier line segments dispose;
(5) repeating step (1) to step (4) all closed curves in the vector outline of caption object dispose.
2. the discrete method that turns to straightway of a kind of vector outline with caption object as claimed in claim 1, it is characterized in that: described L value is 0.0625.
3. the discrete method that turns to straightway of a kind of vector outline as claimed in claim 1 or 2 with caption object, it is characterized in that: in the step (3) with secondary Bezier line segment is discrete turn to straightway after, comprise that also the end points coordinate with every straightway amplifies M operation doubly, making original floating number coordinate transform is the integer type coordinate.
4. the discrete method that turns to straightway of a kind of vector outline with caption object as claimed in claim 3, it is characterized in that: described M equals 512.
CN 200810225870 2008-11-04 2008-11-04 Method for discretization of vector outline of subtitle object into straight-line segment Expired - Fee Related CN101764946B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 200810225870 CN101764946B (en) 2008-11-04 2008-11-04 Method for discretization of vector outline of subtitle object into straight-line segment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 200810225870 CN101764946B (en) 2008-11-04 2008-11-04 Method for discretization of vector outline of subtitle object into straight-line segment

Publications (2)

Publication Number Publication Date
CN101764946A true CN101764946A (en) 2010-06-30
CN101764946B CN101764946B (en) 2013-06-05

Family

ID=42495918

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 200810225870 Expired - Fee Related CN101764946B (en) 2008-11-04 2008-11-04 Method for discretization of vector outline of subtitle object into straight-line segment

Country Status (1)

Country Link
CN (1) CN101764946B (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103390283A (en) * 2012-05-09 2013-11-13 腾讯科技(深圳)有限公司 Method and device for drawing parallel curves
CN110377865A (en) * 2019-09-07 2019-10-25 上海飞来飞去新媒体展示设计有限公司 A kind of ball curtain combination of edge weight computation method merging Bezier
CN110598550A (en) * 2019-08-08 2019-12-20 横琴善泊投资管理有限公司 Vehicle networking identification system based on multilayer information intelligent analysis
CN113626903A (en) * 2021-08-18 2021-11-09 北京赛目科技有限公司 Road curve setting method and device, electronic equipment and storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1069584A (en) * 1991-08-15 1993-03-03 中国长城计算机集团公司 The generation method and system of Chinese character pattern
US6448968B1 (en) * 1999-01-29 2002-09-10 Mitsubishi Electric Research Laboratories, Inc. Method for rendering graphical objects represented as surface elements
CN1302440C (en) * 2004-04-13 2007-02-28 复旦大学 Three-D texture chartlet method based on master drawing covering and separating
CN1975712A (en) * 2006-12-15 2007-06-06 北京北大方正电子有限公司 Method for changing literal to curved line

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103390283A (en) * 2012-05-09 2013-11-13 腾讯科技(深圳)有限公司 Method and device for drawing parallel curves
CN103390283B (en) * 2012-05-09 2017-10-31 腾讯科技(深圳)有限公司 The method and apparatus for drawing parallel curves
CN110598550A (en) * 2019-08-08 2019-12-20 横琴善泊投资管理有限公司 Vehicle networking identification system based on multilayer information intelligent analysis
CN110598550B (en) * 2019-08-08 2021-02-26 善泊科技(珠海)有限公司 Vehicle networking identification system based on multilayer information intelligent analysis
CN110377865A (en) * 2019-09-07 2019-10-25 上海飞来飞去新媒体展示设计有限公司 A kind of ball curtain combination of edge weight computation method merging Bezier
CN113626903A (en) * 2021-08-18 2021-11-09 北京赛目科技有限公司 Road curve setting method and device, electronic equipment and storage medium
CN113626903B (en) * 2021-08-18 2024-03-12 北京赛目科技股份有限公司 Road curve setting method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN101764946B (en) 2013-06-05

Similar Documents

Publication Publication Date Title
CN101465973B (en) Method for rendering subtitling based on curved profile closed loop domain and pixel mask matrix
CN101764945B (en) Subtitle dramatizing method based on closed outline of Bezier
CN101415079B (en) Method for transforming subtitling object into Bessel curve
CN101764943B (en) Method for dividing quadratic Bezier curve in subtitle object vector outline by intersection points
CN101764946B (en) Method for discretization of vector outline of subtitle object into straight-line segment
Eck Introduction to Computer Graphics
CN101764948B (en) Segmenting method of self-intersection closed outline in caption object vector outline
CN101764944B (en) Method for merging and classifying subtitle object vector outline according to inner and outer side attribute
CN101764947B (en) Method for bordering inner edge and outer edge to polygon of vector outline of subtitle object
CN101764939B (en) Texture mapping method based on pixel space mask matrix
CN101394489B (en) Subtitle rendering efficiency bottle neck automatically positioning method based on template and parameter step length
US9064340B2 (en) Drawing apparatus, drawing method, and drawing program
CN101764938B (en) Edge anti-aliasing processing method based on contour line distance of adjacent four pixels
CN101764935B (en) Form gradient radial color filling method based on pixel space mask matrix
Haeberling Cartographic design principles for 3D maps–A contribution to cartographic theory
CN100380438C (en) Display apparatus, information display method, information display program, readable recording medium, and information apparatus
CN111666739A (en) Chinese vector word stock generation method based on Potrace algorithm
CN110570504B (en) Closed symbol drawing method and device, electronic equipment and storage medium
CN101764942B (en) Method for defining pixel area of pixel space mask matrix
CN101764937B (en) Method for confirming distance of pixel space mask code matrix from pixel to outermost side
Hussain et al. Intelligent digitisation of Arabic characters
CN111028353A (en) Vector map line symbol dovetail arrow drawing method considering line width consistency
CN111145303A (en) Vector map line symbol sharp arrow drawing method considering line width consistency
Agui et al. Animating planar folds by computer
Cao et al. Reversible visible watermarking algorithm for 3D models

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
ASS Succession or assignment of patent right

Owner name: BEIJING CULTURAL AND SCIENTIFIC FINANCING LEASE CO

Free format text: FORMER OWNER: XIN'AOTE(BEIJING) VIDEO TECHNOLOGY CO., LTD.

Effective date: 20150319

C41 Transfer of patent application or patent right or utility model
COR Change of bibliographic data

Free format text: CORRECT: ADDRESS; FROM: 100080 HAIDIAN, BEIJING TO: 100044 SHUNYI, BEIJING

TR01 Transfer of patent right

Effective date of registration: 20150319

Address after: 100044, room 2, building 1, No. 401, Golden Sail Road, Beijing, Shunyi District

Patentee after: Beijing culture science and technology finance leasing Limited by Share Ltd

Address before: 100080 Beijing city Haidian District xicaochang No. 1 Beijing Silicon Valley computer city 15 1501-1506 room

Patentee before: China Digital Video (Beijing) Limited

CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20130605

Termination date: 20161104

CF01 Termination of patent right due to non-payment of annual fee