Background technology
When literal or graph image are shown, based on different space of a whole page demands, usually can only display text or the part of graph image, therefore, need carry out cutting to literal or graph image.
Literal is carried out cutting, according to the part of the demand display text of the space of a whole page, when literal is carried out cutting, is that the irregular polygon that the profile of literal is formed is carried out cutting in fact just.Fig. 1 is " mouth " figure that glyph constituted, and is as shown in Figure 1, when " mouth " word is carried out cutting, is that the figure that the shadow part branch constitutes is carried out cutting in fact, therefore, the cutting of literal also just can be regarded as the cutting to figure; Image is carried out cutting, according to the part of the demand display image of the space of a whole page, when image is carried out cutting, is that the polygon that the image sideline is formed is carried out cutting in fact just, therefore, the cutting of image also is appreciated that be the cutting to figure.That is to say, existing literal or graph image are carried out cutting all realize in fact through figure is carried out cutting.
To different patterns, different trimming algorithms is arranged again, trimming algorithm commonly used at present has to the straight-line segment trimming algorithm of straight-line segment with to polygonal algorithm for polygon clipping.Wherein, concrete straight-line segment trimming algorithm has vector trimming algorithm, coding trimming algorithm, mid point to cut apart trimming algorithm, Koln-Sutherland (Cohen-Sutherland) trimming algorithm and Liang Youdong-Bath base (Barskey) trimming algorithm etc. again; Concrete algorithm for polygon clipping has by the sideline judge cuts algorithm, border trimming algorithm, Sutherland-Huo Zhiman (Sutherland-Hodegman) trimming algorithm etc.Though the concrete cutting mode of above-mentioned various algorithms is different; But their basic thought all is consistent: at first; The straight line at each place, bar limit that the cutting object is decomposed into the cutting object to the cutting of figure is to the cutting of figure, and the straight line with each place, bar limit of cutting object is called cutting wires here; Secondly, each bar cutting wires is decomposed into the cutting of each bar cutting wires to each bar limit of figure to the cutting of figure.Be the concrete implementation procedure that example is explained cutting with the Sutherland-Hodegman trimming algorithm below.
Fig. 2 is the process synoptic diagram that polygon is carried out cutting with rectangle in the existing Sutherland-Hodegman trimming algorithm.As scheme shown in a, rectangle ABCD is the cutting object, the zone that also promptly finally can on the space of a whole page, show, polygon V
0V
1V
2V
3Be object to be cut, P
1, P
2, P
3, P
4, P
5And P
6Be respectively rectangle ABCD and polygon V
0V
1V
2V
3Intersection point.When carrying out cutting, need be with rectangle ABCD to polygon V
0V
1V
2V
3Cutting be decomposed into rectangle the cutting wires at place, each bar limit to polygonal cutting, each bar cutting wires here all carries out cutting to polygonal each bar limit through cutting wires in regular turn to polygonal cutting to be realized.
Fig. 3 has provided cutting wires carries out cutting to a polygon a process synoptic diagram.As shown in Figure 3; A ' B ' C ' D ' is need be by the polygon of cutting, and 1 ' is cutting wires, and it has been divided into two parts with the plane at A ' B ' C ' D ' place; 1 ' right side is the part that needs demonstration on the space of a whole page; So be called as a visible side, the 1 ' part of left side for being cropped is called as an invisible side.Be successively cutting to be carried out on each bar limit of A ' B ' C ' D ' according to CW during cutting: when opposite side D ' A ' carried out cutting, all points on this edge had all been dismissed; When opposite side A ' B ' carried out cutting, the intersection point of supposing cutting wires 1 ' and A ' B ' was P ', and the part of then being dismissed is all points on A ' and A ' and the P ' line, and the part that can show is P ' and 2 definite line segments of B '; When opposite side B ' C ' carried out cutting, points all on this edge can both show; When opposite side C ' D ' carried out cutting, the intersection point of supposing cutting wires 1 ' and C ' D ' was Q ', and the part of then being dismissed is all points on D ' and Q ' and the D ' line, and the part that can show is C ' and 2 definite line segments of Q '.
Total l in Fig. 2
1, l
2, l
3And l
4Article 4, cutting wires, the cutting process of every cutting wires all is to carry out according to the described cutting process of Fig. 3: the P among the figure (b)
1P
6V
1V
2V
3For using cutting wires l
1To polygon V
0V
1V
2V
3Carry out the polygon after the cutting; P among the figure (c)
1P
6V
1V
2V '
3P
2For using cutting wires l
2To the P among the figure (b)
1P
6V
1V
2V
3Carry out the polygon after the cutting; P among the figure (d)
1P
6V '
1P
4V
2P
3DP
2For using cutting wires l
3To the P among the figure (c)
1P
6V
1V
2V '
3P
2Carry out the polygon after the cutting; P among the figure (e)
1P
6P
5CP
4V
2P
3DP
2For using cutting wires l
4To the P among the figure (d)
1P
6V '
1P
4V
2P
3DP
2Carry out the polygon after the cutting, i.e. ultimate demand by the figure after the cutting.From figure (e), can find out that what finally can show only is the part of polygon in rectangle, just scheme in (e) by P
1P
6P
5CP
4V
2P
3DP
2The polygon of forming.
Need to prove that the cutting object that existing trimming algorithm is used all is an enclosed region, this enclosed region also is the zone that finally can show on the space of a whole page, and the above-mentioned enclosed region of using during the Sutherland-Hodegman trimming algorithm is described is a rectangle.
Can find out that from above-mentioned cutting process the cutting wires that existing Sutherland-Hodegman trimming algorithm need belong to each bar limit of enclosed region carries out cutting to figure respectively, the basic thought of existing other trimming algorithm also is the same.Therefore, the computation process of existing algorithm can more complicated, be that the situation of circle is all the more so for enclosed region.
Embodiment
For solving the problem that exists in the prior art; The present invention proposes a kind of brand-new page method of cutting out; Promptly through the interim page and object to be cut and the mutual raster manipulation (ROP of target pages according to the target pages generation; Raster Operations), thus obtain final required by the page after the cutting.This method only needs just can to realize object to be cut is carried out cutting exactly through generating the interim page, has avoided complicated loaded down with trivial details computation process, makes whole process simple and fast, also more convenient to achieve.
Need to prove that all pages in fact all are to store with the form of image in the present embodiment, and image is that wherein each pixel is stored in the calculator memory with binary mode.Therefore, the page just is stored in the internal memory of computing machine with binary mode.
For making the object of the invention, technical scheme and advantage clearer, below with reference to the accompanying drawing embodiment that develops simultaneously, to further explain of the present invention.In following examples of the present invention, be that example describes with the black and white model, it will be understood by those skilled in the art that in fact technical scheme of the present invention can be applied to color model equally, like rgb color model and GMYK colour model.
In the present invention, the Crop Area is meant the fill area that is made up of at least one closing line, and in theory, the Crop Area initially can be filled to white or black.Usually, the user also can specify the position of Crop Area on the page except the shape of specifying the Crop Area.At embodiments of the invention, be the example explanation with two rectangle fill areas as the Crop Area, in practice, the clipping region can be an arbitrary form.In addition, in embodiments of the present invention, need final page displayed to be called target pages object to be cut.
The process flow diagram of the page method of cutting out that Fig. 4 provides for the embodiment of the invention one.As shown in Figure 4, this method may further comprise the steps:
Step 401: generate the interim page.In embodiments of the present invention, suppose that the interim page initially is filled to white.In addition, in embodiments of the present invention, can suppose that correspondence is filled to white when the binary mode of each pixel is set to 1.
The size of the interim page does not generally limit, more excellent scheme, and the interim page is greater than the Crop Area.
Step 402: in this interim page, object to be cut and Crop Area are carried out ROP, in the interim page after this carries out ROP, what show in the Crop Area is object to be cut, and all the other zones are white.
At this moment, can be in the interim page, to draw object to be cut earlier, and then to specify the ROP pattern to draw the Crop Area; Also can in the interim page, draw the Crop Area earlier, and then, adopt a kind of mode in back in embodiments of the present invention to specify the ROP pattern to draw object to be cut.Here, suppose that the Crop Area initially is filled to black.Step 402 is specially: in the interim page, draw the Crop Area, each pixel binary numeral of zone, Crop Area is 0 in interim page this moment so, and other each pixel binary numerals of zone are 1, and this moment, this ROP was operating as step-by-step OR operation.To specify the ROP pattern to draw be again: the numerical value of the binary mode of pixel on the numerical value of the binary mode on each pixel in the object to be cut and the interim page respective pixel position is carried out the OR computing by reducing object.
It will be appreciated by those skilled in the art that: when object to be cut during less than the Crop Area, in the interim page after this carries out ROP, the part greater than object to be cut in the Crop Area also is a black so.
Step 403: in target pages; The interim page that obtains after the execution of step 402 and target pages are carried out ROP; Then in the target pages after carrying out ROP, stack has shown object to be cut on the Crop Area, and what show in all the other zones is the original image in the target pages.
Equally; Here ROP is step-by-step ROP and operation, the numerical value of the binary mode in the interim page that is about to obtain after the execution of step 402 on each pixel respectively with target pages in the numerical value of the locational binary mode of respective pixel carry out step-by-step ROP and operation.
In another embodiment of the present invention, can suppose that also correspondence is filled to white when the binary mode of each pixel is set to 0, in the said process, ROP is step-by-step AND operation so.
In the above description, object to be cut can be the literal page or the graph image page.In the above-described embodiments, on the final objective page in, stack has simultaneously shown the original background image of target pages and the image of object to be cut on the Crop Area.And in fact, when the page is carried out cutting, need in the Crop Area, cover the background image in the target pages.Following embodiment will be described in detail cutting process in this case.
Fig. 5 is the process flow diagram of the page method of cutting out that the embodiment of the invention two provides.As shown in Figure 5, this method may further comprise the steps:
Step 501: generate the interim page.Equally, suppose that the interim page initially is filled to white, the binary mode of each corresponding pixel is set to 1.
Step 502: in this interim page, object to be cut and Crop Area are carried out ROP, in the interim page after this carries out ROP, what show in the Crop Area is object to be cut, and all the other zones are white.Here, suppose that equally the Crop Area initially is filled to black.
Step 503: in target pages, target pages and Crop Area are carried out ROP, carry out like this in the target pages behind the ROP, what show in the Crop Area is white, and all the other zones still be the original background image of target pages, and this moment, ROP was that NOT OR operates.Specifically, at first the numerical value with the binary mode on each pixel in the Crop Area carries out the NOT computing, yet carries out the OR computing at the numerical value with the binary mode of the locational pixel of target pages respective pixel.Certainly, the process of this step also can be: on target pages, draw the Crop Area, be filled to this Crop Area white then.
Step 504: in the target pages that step 503 obtains; The target pages that obtains after the interim page that obtains after the execution in step 502 and the execution in step 503 is carried out ROP; Then in the final objective page; Stack has shown object to be cut on the Crop Area, and what show in all the other zones is the original background image in the target pages.Equally, here, raster manipulation is step-by-step ROPAND operation.
In these two embodiment, only adopt an interim page just can realize cutting to the page, saved the internal memory in the concrete implementation procedure, implementation process is convenient.
Fig. 6 is the process flow diagram of the page method of cutting out that the embodiment of the invention three provides.In this embodiment, reducing object with quilt is that the graph image page is that example describes.As shown in Figure 6, this method may further comprise the steps:
Step 601: generate the interim page, in this interim page, the Crop Area is distinguished with other zones and is filled.Here, concrete process can be: on the interim page, directly draw a Crop Area.In the present embodiment, suppose that still the Crop Area is filled to black, the interim page initially is filled to white, and then after this step, the Crop Area is a black, and all the other zones are white.
Step 602: in this interim page, the graph image page and the interim page are carried out ROP.
If each pixel binary numeral is 1 to correspond to white, ROP is operating as step-by-step OR operation in this step so.After carrying out this step, in the interim page after carrying out ROP, what show on the Crop Area is graph image, and all the other zones are white.
Step 603: in target pages, the interim page and target pages that execution in step 602 is obtained carry out ROP.Like this, what in the final objective page, show is the graph image page that meets space of a whole page demand, and specifically, stack shows object to be cut on the Crop Area, and what show in all the other zones is the original background image of target pages.Here, the ROP operation can be step-by-step AND operation.
Fig. 7 is the process flow diagram of the page method of cutting out that the embodiment of the invention four provides.。In this embodiment, reducing object with quilt is that the graph image page is that example describes.As shown in Figure 7, this method may further comprise the steps:
Step 701: generate the interim page, in this interim page, the Crop Area is distinguished with other zones and is filled.
Step 702: in this interim page, the graph image page and the interim page are carried out ROP.Suppose step 701-702 with step 601-602, in the interim page after carrying out ROP, what show on the Crop Area is graph image so, and all the other zones are white.
Step 703: generate an interim page once more.Equally, filling is distinguished in Crop Area and other zones.After this step, the Crop Area is a black, and all the other zones are white.
Step 704: in target pages, the interim page in target pages and the step 703 is carried out ROP.This moment, ROP was operating as step-by-step NOT OR operation, then in the target pages after carrying out ROP, was shown as white on the Crop Area, and other zones are the original background image of target pages.Specifically, the numerical value of the binary mode on each pixel of the interim page that at first step 703 is obtained carries out the NOT computing, yet carries out the OR computing at the numerical value with the binary mode of the locational pixel of target pages respective pixel.
Step 705: in the target pages that in step 704, obtains; The target pages that the interim page that step 702 is obtained and step 704 obtain carries out ROP; Like this; In the final objective page, promptly obtain meeting space of a whole page demand by the graph image page after reducing, show object to be cut in the Crop Area, what show in all the other zones is original background image in the target pages.
Those skilled in the art can understand: the step 602 in the foregoing description two can mutual alternative with the step 703-704 among the embodiment four.
In an embodiment of the present invention; By reducing object also can be a plurality of objects; Can utilize this moment an interim page with a plurality of reduced object convert into as embodiment three with four described by the reduction page--the graph image page; Specifically, in this interim page, draw and a plurality ofly to be got final product by the reduction object.
It will be appreciated by those skilled in the art that; The Crop Area can be black or white with the interim initial filling of the page, in addition, and in embodiment three and four; When in the interim page, Crop Area and other zones being filled respectively, other multiple array mode all is fine; Each pixel binary numeral that white portion equally, also can be set is 0.It will be understood by those skilled in the art that under the above cited certain situation, only need the logical operation rule of modify ROP operation can realize the present invention.
Based on said method, the embodiment of the invention also provides a kind of page Scissoring device, and this device comprises:
Interim page generation unit is used to generate an interim page;
The ROP unit is used at this interim page object to be cut and Crop Area being carried out a ROP; And in target pages, this interim page and target pages that carries out behind the ROP is carried out the 2nd ROP on target pages.
In another embodiment, this device comprises:
Interim page generation unit is used to generate an interim page;
Filler cells is used for the interim page in interim page generation unit generation, and Crop Area and other zones are filled respectively;
The ROP unit is used at the said interim page, will be reduced object and carry out first raster manipulation with the interim page; In target pages, the said interim page and the target pages that carries out obtaining behind the raster manipulation carried out second raster manipulation.
More than the concrete workflow of device repeats no more please with reference to the respective description among Fig. 5-method embodiment shown in Figure 7 here.
What also need further specify is that the embodiment of the invention is not only applicable to the rgb color model, equally is applicable to other colour models such as GMYK colour model yet, is as the criterion with the realization that does not influence the embodiment of the invention in the reality.
In a word; Page method of cutting out and device that the embodiment of the invention adopted only need to generate an interim page, through the interim page, reduced the ROP of object, Crop Area and target pages; Realization is carried out cutting exactly to object to be cut; Thereby obtain final requiredly, avoided complicated loaded down with trivial details computation process, make whole process simple and fast, also more convenient to achieve by the page after the cutting.
Based on above technical scheme, adopt interim page instruction, can design a kind of PDL that does not have the cutting instruction, its descriptive power is identical with the PDL that the cutting instruction is arranged, and but more is prone to realize.This PDL can comprise interim page sign on and interim end-of-page instruction, and the page-describing instruction after the interim page sign on all is to be directed against this interim page, till corresponding interim end-of-page instruction.Such as comprising TEMPPAGEBEG instruction and TEMPPAGEEND instruction; After running into the TEMPPAGEBEG instruction in the page-describing instruction sequence; Promptly represent a newly-generated interim page; Instruction in all page-describing instruction sequences afterwards all is on this interim page, to accomplish, and runs into to show this interim page of end after TEMPPAGEEND instructs, and this interim page and original page are done a ROP operation.Instruction in all page-describing instruction sequences afterwards returns to again on the original operation pages.These two instructions of TEMPPAGEBEG and TEMPPAGEEND should be to occur in pairs; Promptly there is a TEMPPAGEBEG instruction then must have a TEMPPAGEEND instruction corresponding with it; And the interim page can be nested; Promptly can occur two TEMPPAGEBEG instructions continuously, have 2 TEMPPAGEEND to finish the interim page afterwards continuously.So just can cutting object and Crop Area be placed on the different interim pages, in interim end-of-page, realize the function of cutting then through mutual ROP.
In addition, can also the PDL of Traditional use cutting instruction be converted to this PDL that the interim page is arranged but do not have cutting to instruct.In the PDL of Traditional use cutting instruction, normally define the Crop Area through the instruction that is similar to SetClipPath and so on, all objects after this instruction all are objects to be cut, till finishing cutting.Therefore; When the PDL with Traditional use cutting instruction converts the interim page to but does not have the PDL of cutting instruction; Need be when running into the instruction of definition Crop Area; Get access to the Crop Area, generate corresponding interim page instruction, when finishing the Crop Area subsequently, finish the corresponding interim page.Concrete grammar is from article one instruction beginning, each bar instruction carrying out the following step to be realized:
A. judge whether this instruction is the instruction of definition Crop Area, if, execution in step B, otherwise judge whether this instruction is the instruction that finishes the Crop Area, if, execution in step C, otherwise execution in step D;
B. obtain the Crop Area; Generate interim page sign on; Generate the instruction (Crop Area will be plotted on the interim page) of drawing the Crop Area, but do not finish this interim page, but generate an interim page that is used for drawing object to be cut with interim page sign on again; Continue next bar instruction, carry out A;
C. generate two interim end-of-page instructions; Two interim pages that end step B generates; Make that the interim page of drawing the Crop Area and the interim page of drawing object to be cut carry out carrying out the ROP operation with parent page again after the ROP operation, continue next bar instruction, carry out A;
D. generate with the PDL that adopts the cutting instruction in identical instruction, as drawing the object to be cut instruction, this instruction is present in equally to be adopted in the PDL that reduction instructs.Continue next bar instruction, carry out A.
Wherein, in step C, the interim page of so-called end is meant no longer draws any instruction in this interim page, and does not mean that and must this interim page be removed.In addition, the ROP of interim page operation can be an attribute of interim end-of-page instruction, also can be an attribute of interim page sign on, or an independent instruction.When the ROP operation was attribute of interim page sign on, obviously after the ROP operation, the interim page just finished.And when ROP operation is independent instruction; The operated interim page does not temporarily finish; As, when the interim page of drawing the Crop Area and the interim page of drawing object to be cut carry out the ROP operation, because the ROP operation finally is plotted in the interim page of drawing object to be cut; So the interim page of this drafting object to be cut does not temporarily finish, treat to finish this interim page again after the ROP operation.
Like this; Just can " in a Crop Area, a plurality of objects to be cut being carried out cutting " in the PDL that cutting instruction is arranged be converted in the PDL of interim page instruction " the definition one interim page is drawn the Crop Area in an interim page; Define another interim page, on this another interim page, draw these a plurality of objects to be cut successively; Two interim pages are carried out the ROP operation; The cutting result (ROP result) who generates is carried out the ROP operation once more with target pages ".
In sum, more than being merely preferred embodiment of the present invention, is not to be used to limit protection scope of the present invention.All within spirit of the present invention and principle, any modification of being done, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.