Embodiment
For solving problems of the prior art, propose among the present invention a kind of brand-new on picture the scheme of synthesizing photo frame: at first, according to the size of original image, to original photo frame picture, promptly the photo frame picture that synthesizes on described original image of the needs selected of user is dynamically adjusted; Then, will carry out dynamic adjusted original photo frame picture and original image and merge, the picture after obtaining synthesizing.
That is mentioned here dynamically adjusts original photo frame picture, can be meant size according to original image, original photo frame picture is carried out convergent-divergent in proportion, also can be meant size according to original image, the size of the required photo frame picture of dynamic calculation each several part, and the each several part that calculates made up, to obtain being fit to the photo frame picture of original image.
For making purpose of the present invention, technical scheme and advantage clearer, below with reference to the accompanying drawing embodiment that develops simultaneously, the present invention is described in further detail.
Fig. 1 is the process flow diagram of method first embodiment of the present invention's synthesizing photo frame on picture.As shown in Figure 1, may further comprise the steps:
Step 101: the ratio A of the width W 0 of the picture viewing area in the width W 1 of calculating original image and the original photo frame picture, and the ratio B of the height H 0 of the picture viewing area in the height H 1 of original image and the original photo frame picture.
When the user need add photo frame for a certain picture, at first need to select the phase frame template that will add, promptly selected original photo frame picture, and can be selected, illustrate that then the photo frame picture must be existing, so correspondingly, the relevant information of this photo frame picture, as the width of photo frame picture itself, highly, the width and the height of the picture viewing area in the photo frame picture, and the information such as demonstration reference position of picture viewing area can get access to from the pairing configuration file of this photo frame picture at an easy rate.
Fig. 2 is the synoptic diagram of existing a kind of photo frame picture.As shown in Figure 2, oval The corresponding area wherein is the picture viewing area; The width of supposing this photo frame picture is W, highly is H; The width of picture viewing area is W0, highly is H0.Need to prove that in actual applications, the picture viewing area can show as various irregular shapes, so, the width of picture viewing area and highly typically refer to the minimum rectangle that comprises the picture viewing area width and the height; And the upper left end points position of this minimum rectangle promptly is called the demonstration reference position, i.e. (X0, Y0) the pairing position of coordinate shown in Fig. 2.
In the present embodiment, the width of supposing original image is W1, is H1 highly, and supposes that photo frame picture shown in Figure 2 is user-selected fixed original photo frame picture, then has:
A=W1/W0; (1)
B=H1/H0。(2)
Step 102: calculate the width W of original photo frame picture and the product width of A, and the product height of the height H of original photo frame picture and B, obtain the width and the height of adjusted original photo frame picture.
Promptly have:
width=W*A=W*(W1/W0); (3)
height=H*B=H*(H1/H0)。(4)
Step 103: the width W of original photo frame picture is adjusted into width, height H is adjusted into height.
Here the adjustment of being mentioned promptly refers to stretching/scaling, how to be embodied as prior art, repeats no more.
Step 104: creating a fabric width degree is width, highly is that height and content are the first empty interim picture.
Step 105: the correspondence position of demonstration reference position in the first interim picture that calculates the picture viewing area in the original photo frame picture.
Concrete account form is:
X1=X0*A=X0*(W1/W0); (5)
Y1=Y0*B=Y0*(H1/H0); (6)
Wherein, X0 and Y0 represent the horizontal ordinate of the demonstration reference position of the picture viewing area in the original photo frame picture respectively; X1 and Y1 represent the horizontal ordinate of the correspondence position of demonstration reference position in the first interim picture of the picture viewing area in the original photo frame picture respectively.
Step 106: original image is copied in the first interim picture, obtain the second interim picture, the correspondence position of demonstration reference position in the first interim picture of the picture viewing area in the position of first pixel of described original image and the original photo frame picture that calculated coincides.
After the processing by this step, original image in interim picture, will occupy four apex coordinates be respectively (X1, Y1), (X1+W1, Y1), (X1, Y1+H1), (X1+W1, zone Y1+H1).
Step 107: the adjusted original photo frame picture and the second interim picture are merged the picture after obtaining synthesizing, process ends.
Soon the second interim picture that obtains in photo frame picture that obtains in the step 103 and the step 106 merges, the picture after obtaining synthesizing, promptly final required picture.
In the present embodiment, can merge the adjusted original photo frame picture and the second interim picture according to mixed (blend) mode, because photo frame pictures etc. all are to preserve in the mode of alpha data usually, and the blend mode can merge these class data preferably.Specific implementation is a prior art, repeats no more.
Need to prove that the execution sequence of each step shown in Figure 1 is not limited to technical scheme of the present invention only for illustrating.Such as, step 103 is carried out after also can being placed on step 106.
In addition, for original image and original photo frame picture can be combined better, can also be before execution in step 101, further comprise a deterministic process: judge promptly whether picture viewing area in the original photo frame picture and original image are width greater than height or be height greater than width, whether be W0 promptly〉H0 and W1〉H1, or W0<H0 and W1<H1, if not, then original image is carried out in the clockwise direction the rotation of 90 degree, make the width of original image and height value exchange.Correspondingly, after execution of step 107, also need the picture after synthetic is carried out the rotation of 90 degree in the counterclockwise direction.
By above-mentioned introduction as can be seen, embodiment illustrated in fig. 1 in, according to the size of original image,, realize dynamic adjustment to original photo frame picture by original photo frame picture is carried out convergent-divergent in proportion; This dynamic adjustment mode is applicable to the exquisite photo frame of having made.To introduce another kind of dynamically adjustment mode below, promptly according to original picture size, dynamic calculation goes out the size of the each several part of required photo frame picture, and the each several part that calculates is made up, to obtain being fit to the photo frame picture of original image; This dynamic adjustment mode is applicable to the photo frame of the comparatively simple and shape comparison rule that user oneself makes.
Fig. 3 is the process flow diagram of method second embodiment of the present invention's synthesizing photo frame on picture.As shown in Figure 3, may further comprise the steps:
Step 301: the width src_Width and the width frame_Width of smaller value among the height src_Height and original photo frame picture and the ratio N of the smaller value among the height frame_Height that calculate original image.
In the present embodiment, suppose that src represents original image, frame represents original photo frame picture; Src_Width and src_Height represent the width and the height of original image respectively, and frame_Width and frame_Height represent the width and the height of original photo frame picture respectively; Then have:
srcSize=Min(src_Width,src_Height); (7)
frameSize=Min(frame_Width,frame_Height); (8)
N=srcSize/frameSize。(9)
Step 302: determine the scaling COEFFICIENT K according to the N value that calculates.
K=Min(10,Max(1,N))=Min(10,Max(1,srcSize/frameSize));
(10)
Wherein, Min represents to get smaller value, and Max represents to get higher value.As can be seen, the value of the scaling COEFFICIENT K of determining according to formula (10) will be between 1~10.
Step 303: calculate the width frame_Width of original photo frame picture and the product temp1 of scaling COEFFICIENT K, and the product temp2 of the height frame_Height of original photo frame picture and scaling COEFFICIENT K; And the width frame_Width of original photo frame picture is adjusted into temp1, the height frame_Height of original photo frame picture is adjusted into temp2.
In this step, promptly original photo frame picture is carried out scaling/stretching according to the scaling COEFFICIENT K of determining.
Step 304: four corner rectangles and the peripheral rectangular information of obtaining adjusted original photo frame picture.
Here the information of being mentioned is meant each rectangular width and elevation information.These information can obtain from the pairing configuration file of original photo frame picture.
As shown in Figure 4, Fig. 4 is the synoptic diagram of existing another kind of photo frame picture.Ra wherein, rb, rc and rd are four corner rectangles of this photo frame picture; Re, rf, rg and rh are the peripheral rectangle of this photo frame picture.The number of periphery rectangle re, rf, rg and rh and area etc. all not necessarily equate, decide on the concrete production method of photo frame; But it is normally the same to be positioned at each peripheral rectangular area on same the frame.
Step 305: create a content and be the 3rd empty interim picture.
The width width of the 3rd interim picture and height height are respectively:
width=src_Width+(extraspaceX*K); (11)
height=src_Height+(extraspaceY*K); (12)
Wherein, extraspaceX represents width poor of original photo frame picture and original image, and extraspaceY represents height poor of original photo frame picture and original image.
Step 306: the correspondence position of demonstration reference position in the 3rd interim picture that calculates the picture viewing area in the original photo frame picture.
Concrete account form is:
X1=X0*K; (13)
Y1=Y0*K; (14)
Wherein, show that reference position is the upper left end points position that comprises the minimum rectangle of picture viewing area; X0 and Y0 represent the horizontal ordinate and the ordinate of the demonstration reference position of the picture viewing area in the original photo frame picture respectively; The horizontal ordinate and the ordinate of the correspondence position of the demonstration reference position of the picture viewing area in the original photo frame picture that X1 and Y1 represent respectively to calculate in the 3rd interim picture.
Step 307: original image is copied in the 3rd interim picture, obtain the 4th interim picture; The correspondence position of demonstration reference position in the 3rd interim picture of the picture viewing area in the position of first pixel of described original image and the original photo frame picture that calculated coincides.
Step 308:, in the 4th interim picture, dynamically build photo frame for original image, process ends according to four the corner rectangles and the peripheral rectangle information of the adjusted original photo frame picture that gets access to.
Concrete dynamic build process is as follows:
For each the bar frame in the adjusted original photo frame picture, handle according to mode shown in Figure 5 respectively:
Step 501: four apex coordinates of region duplication to the four interim pictures that are arranged in the corner rectangle r1 correspondence in left side in this frame are respectively (0,0), (r1_Width, 0), (0, r1_Height) and (r1_Width, zone r1_Height).
Wherein, r1_Width represents the width of corner rectangle r1, and r1_Height represents the height of corner rectangle r1.
In the present embodiment,, mark a zone with four apex coordinates for ease of describing, wherein, corresponding different frames, the mode of choosing of true origin also can be different.Such as, when building upper side frame, can be with the upper left end points of the 4th interim picture as true origin.The operation of this step is the equal of the upper left corner that the corner rectangle that will be arranged in the upper left corner in the adjusted original photo frame picture copies to the 4th interim picture, so, four apex coordinates that duplicate the zone in the 4th shared interim picture of back will be respectively (0,0), (r1_Width, 0), (0, r1_Height) and (r1_Width, r1_Height).
Correspondingly, for guaranteeing when building other frame, the form of presentation of this step is still suitable, can be when building left frame, with the lower-left end points of the 4th interim picture as true origin, when building lower frame, with the bottom right end points of the 4th interim picture as true origin, when building left frame, with the upper right end points of the 4th interim picture as true origin.
Step 502: make i=r1_Width, j=width-r2_Width.
Wherein, r2_Width represents to be positioned at the width of the corner rectangle r2 on frame right side.
Step 503: whether judge i less than j, if then execution in step 504; Otherwise, execution in step 508.
Step 504: whether judge i+r5_Width less than j, if then execution in step 505; Otherwise, execution in step 506.
R5_Width represents to be positioned at the width of the peripheral rectangle r5 on the frame.
Step 505: four apex coordinates in region duplication to the four interim pictures of peripheral rectangle r5 correspondence are respectively (i, 0), (i+r5_Width, 0), (i, r5_Height) and (i+r5_Width, r5_Height) zone, execution in step 507 then.
Step 506: four apex coordinates that the subregion of peripheral rectangle r5 correspondence is copied in the 4th interim picture are respectively (i, 0), (j, 0), (i, r5_Height) and (j, zone r5_Height).
If i+r5_Width more than or equal to j, then illustrates the peripheral rectangle r5 situation of (corresponding " equaling ") can only be set between corner rectangle r1 and the r2, perhaps can only be provided with peripheral rectangle r5 a part (corresponding " and greater than " situation).At this moment, the right side that copies to the peripheral rectangle r5 in the 4th interim picture up and down the coordinate of two end points will be respectively (j, 0) and (j, r5_Height).
Step 507: make i=i+r5_Width, return execution in step 503 then.
Step 508: four apex coordinates in region duplication the 4th interim picture of corner rectangle r2 correspondence are respectively (width-r2_Width, 0), (width, 0), (width-r2_Width, r2_Height) and (width, r2_Height) zone, process ends.
So far, promptly finished building of a frame.The mode of building and the process shown in Figure 5 of other frame are similar, repeat no more.
Need to prove, in actual applications, be not that each bar frame all must be built in strict accordance with mode shown in Figure 5.Because with Fig. 4 is example, after having built upper side frame, corner rectangle ra and rb and peripheral rectangle re just have been copied in the 4th interim picture; So, when building left frame subsequently, because corner rectangle ra is that upper side frame and left frame are total, so, need not to duplicate corner rectangle ra in building the process of left frame, a need duplicates corner rectangle rd according to mode shown in Figure 5 and peripheral rectangle rh gets final product again.In a word, shown in Figure 5 is the explanation of principle only, can be based on the implementation procedure of this principle flexible design reality in application.
In addition, duplicating of being mentioned in the present embodiment promptly refers to a kind of fusion process, and be same, also can adopt the amalgamation mode of blend in the present embodiment.
Based on said method, Fig. 6 is the composition structural representation of the present invention device embodiment of synthesizing photo frame on picture.As shown in Figure 6, this device comprises:
Adjustment unit 61 is used for the size according to original image, and the selected original photo frame picture that need synthesize on described original image is dynamically adjusted;
Synthesis unit 62 is used for merging with carrying out dynamic adjusted original photo frame picture and original image with the picture after obtaining synthesizing.
Wherein, can further comprise different subelements respectively again in adjustment unit 61 and the synthesis unit 62, shown in Fig. 7 and 8:
Fig. 7 is the composition structural representation of device first preferred embodiment of the present invention's synthesizing photo frame on picture.As shown in Figure 7, can specifically comprise in the adjustment unit 61:
First computation subunit 71 is used for calculating the ratio A of width W 1 with the width W 0 of the picture viewing area of original photo frame picture of original image, and the ratio B of the height H 0 of the picture viewing area in the height H 1 of original image and the original photo frame picture; The width of described picture viewing area and highly be respectively the minimum rectangle that comprises the picture viewing area width and the height;
Second computation subunit 72 is used to calculate the width W of original photo frame picture and the product width of A, and the product height of the height H of original photo frame picture and B;
First adjusts subelement 73, is used for the width W of original photo frame picture is adjusted into width, and the height H of original photo frame picture is adjusted into height.
Can specifically comprise in the synthesis unit 62:
First creates subelement 74, is used to create a width and is width, highly is height and the content first interim picture for sky;
The 3rd computation subunit 75 is used for calculating the correspondence position of demonstration reference position in the first interim picture of the picture viewing area of original photo frame picture: X1=X0*A; Y1=Y0*B; Wherein, show that reference position is the upper left end points position that comprises the minimum rectangle of picture viewing area; X0 and Y0 represent the horizontal ordinate and the ordinate of the demonstration reference position of the picture viewing area in the original photo frame picture respectively; The horizontal ordinate and the ordinate of the correspondence position of the demonstration reference position of the picture viewing area in the original photo frame picture that X1 and Y1 represent respectively to calculate in the first interim picture;
The first replicon unit 76, be used for original image is copied to the first interim picture, obtain the second interim picture, the correspondence position of demonstration reference position in the first interim picture of the picture viewing area in the position of first pixel of described original image and the original photo frame picture that calculated coincides;
The first synthon unit 77 is used for the adjusted original photo frame picture and the second interim picture are merged, the picture after obtaining synthesizing.
In addition, also can further comprise in the device shown in Figure 7: rotary unit 63, be used for determining whether the picture viewing area of original photo frame picture and original image are width greater than height or be height greater than width, if not, then original image is carried out in the clockwise direction the rotation of 90 degree, make the width and the height value of original image exchange, and notice adjustment unit 61 is carried out self function according to postrotational original image; And be further used for, receive from the picture behind synthesis unit 62 synthetic, the picture after synthetic is carried out the rotations of 90 degree in the counterclockwise direction.
Fig. 8 is the composition structural representation of device second preferred embodiment of the present invention's synthesizing photo frame on picture.As shown in Figure 8, can specifically comprise in the adjustment unit 61:
The 4th computation subunit 81, be used for calculating the width src_Width of original image and smaller value and the width frame_Width of original photo frame picture and the ratio N of the smaller value among the height frame_Height of height src_Height, and according to definite scaling COEFFICIENT K: the K=Min (10 of the N value that calculates, Max (1, N)), wherein, Min represents to get smaller value, and Max represents to get higher value;
The 5th computation subunit 82 is used to calculate the width frame_Width of original photo frame picture and the product temp1 of scaling COEFFICIENT K, and the product temp2 of the height frame_Height of original photo frame picture and scaling COEFFICIENT K;
Second adjusts subelement 83, is used for the width frame_Width of original photo frame picture is adjusted into temp1, and the height frame_Height of original photo frame picture is adjusted into temp2.
Can specifically comprise in the synthesis unit 62:
Obtain subelement 84, be used to obtain four the corner rectangles and the peripheral rectangular information of adjusted original photo frame picture, described information is each rectangular width and elevation information;
Second creates subelement 85, is used to create a content and is the 3rd empty interim picture, the width width=src_Width+ (extraspaceX*K) of the 3rd interim picture, height height=src_Height+ (extraspaceY*K); Wherein, extraspaceX represents width poor of original photo frame picture and original image, and extraspaceY represents height poor of original photo frame picture and original image;
The 6th computation subunit 86 is used for calculating the correspondence position of demonstration reference position in the 3rd interim picture of the picture viewing area of original photo frame picture: X1=X0*K; Y1=Y0*K; Wherein, show that reference position is the upper left end points position that comprises the minimum rectangle of picture viewing area; X0 and Y0 represent the horizontal ordinate and the ordinate of the demonstration reference position of the picture viewing area in the original photo frame picture respectively; The horizontal ordinate and the ordinate of the correspondence position of the demonstration reference position of the picture viewing area in the original photo frame picture that X1 and Y1 represent respectively to calculate in the 3rd interim picture;
The second replicon unit 87, be used for original image is copied to the 3rd interim picture, obtain the 4th interim picture, the correspondence position of demonstration reference position in the 3rd interim picture of the picture viewing area in the position of first pixel of described original image and the original photo frame picture that calculated coincides;
The second synthon unit 88 is used for four corner rectangles and peripheral rectangle information according to the adjusted original photo frame picture that gets access to, dynamically builds photo frame for original image in the 4th interim picture, with the picture after obtaining synthesizing.
In addition, can comprise again in the second synthon unit 88: build subelement (not shown) for four, wherein, each builds subelement, be respectively applied for according to corner rectangle information and peripheral rectangle information in the frame in the adjusted original photo frame picture that gets access to, in the 4th interim picture, dynamically build a frame for original image; Building subelement for four is respectively applied for and builds four different frames.
Fig. 9 builds the composition structural representation of subelement for each.As shown in Figure 9, comprising:
The 3rd replicon unit 91, four apex coordinates of region duplication to the four interim pictures that are used for frame is arranged in the corner rectangle r1 correspondence in left side are respectively (0,0), (r1_Width, 0), (0, r1_Height) and (r1_Width, zone r1_Height);
Wherein, r1_Width represents the width of corner rectangle r1, and r1_Height represents the height of corner rectangle r1; When frame is upper side frame, with the upper left end points of the 4th interim picture as true origin; When frame is left frame, with the lower-left end points of the 4th interim picture as true origin; When frame is lower frame, with the bottom right end points of the 4th interim picture as true origin; When frame is left frame, with the upper right end points of the 4th interim picture as true origin;
The first assignment subelement 92 is used for giving i with the r1_Width assignment, and the assignment as a result that width and r2_Width are subtracted each other is to j, and r2_Width represents to be positioned at the width of the corner rectangle r2 on frame right side;
Whether first judgment sub-unit 93 is used to judge i less than j, if, then notify second judgment sub-unit 94 to carry out self function, otherwise, notify the 4th replicon unit 95 to carry out self function;
Second judgment sub-unit 94, whether the sum that is used to judge i and r5_Width is less than j, and r5_Width represents to be positioned at the width of the peripheral rectangle r5 on the frame; If, then four apex coordinates in region duplication to the four interim pictures of peripheral rectangle r5 correspondence are respectively (i, 0), (i+r5_Width, 0), (i, r5_Height) and (i+r5_Width, r5_Height) zone, otherwise four apex coordinates that the subregion of peripheral rectangle r5 correspondence is copied in the 4th interim picture are respectively (i, 0), (j, 0), (i, r5_Height) and (j, zone r5_Height); And the sum of i and r5_Width sent to first judgment sub-unit 93 as new i value;
The 4th replicon unit 95, be used for four apex coordinates of region duplication the 4th interim picture of corner rectangle r2 correspondence are respectively (width-r2_Width, 0), (width, 0), (width-r2_Width, r2_Height) and (width, zone r2_Height).
The concrete workflow of Fig. 6~9 shown device embodiment please refer to the respective description among the method embodiment, repeats no more herein.
In a word, adopt technical scheme of the present invention,, original photo frame picture to be synthesized is dynamically adjusted according to the size of original image, and then merge, thereby obtain final required picture after synthetic to carrying out dynamically adjusted original photo frame picture and original image.Compared with prior art, scheme of the present invention can combine picture and photo frame better, thereby makes the picture after synthesizing have more aesthetic property and recreational.
In sum, more than be preferred embodiment of the present invention only, be not to be used to limit protection scope of the present invention.Within the spirit and principles in the present invention all, any modification of being done, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.