CN107481194B - Photo rotation self-adaptive scaling method in photo frame based on photo album application - Google Patents
Photo rotation self-adaptive scaling method in photo frame based on photo album application Download PDFInfo
- Publication number
- CN107481194B CN107481194B CN201710720823.5A CN201710720823A CN107481194B CN 107481194 B CN107481194 B CN 107481194B CN 201710720823 A CN201710720823 A CN 201710720823A CN 107481194 B CN107481194 B CN 107481194B
- Authority
- CN
- China
- Prior art keywords
- photo
- frame
- visible area
- points
- calculating
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
- 238000000034 method Methods 0.000 title claims abstract description 17
- 230000002159 abnormal effect Effects 0.000 claims abstract description 3
- 230000003044 adaptive effect Effects 0.000 claims description 2
- 230000000007 visual effect Effects 0.000 abstract description 2
- 230000000694 effects Effects 0.000 description 8
- 238000010586 diagram Methods 0.000 description 5
- 238000013178 mathematical model Methods 0.000 description 2
- 238000004364 calculation method Methods 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 230000002452 interceptive effect Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 238000009877 rendering Methods 0.000 description 1
- XLYOFNOQVPJJNP-UHFFFAOYSA-N water Substances O XLYOFNOQVPJJNP-UHFFFAOYSA-N 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T3/00—Geometric image transformations in the plane of the image
- G06T3/40—Scaling of whole images or parts thereof, e.g. expanding or contracting
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T3/00—Geometric image transformations in the plane of the image
- G06T3/60—Rotation of whole images or parts thereof
Landscapes
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Processing Or Creating Images (AREA)
- User Interface Of Digital Computer (AREA)
- Editing Of Facsimile Originals (AREA)
Abstract
The invention discloses a photo rotation self-adaptive zooming method in a photo frame based on photo album application, which can enable a photo to be well presented in the largest range in a visual area without abnormal display when the photo is rotated at any angle; setting a central point, setting coordinates of four corners of a visible area, calculating the coordinates of the four corners of the photo, and calculating the coordinates of the central point on the four sides of the photo; calculating the opposite side connecting line of the central points of the four sides of the photo; solving the foot hanging points from two corner points above the visible area of the photo frame to the connecting line of the opposite sides; then, the foot hanging points of the connecting line from the two left corner points to the other opposite side of the visible area of the photo frame are solved; calculating the zoom ratio, and taking a larger value as a base number of the final zoom ratio of the photo; i.e. allowing a good presentation of the photograph to the maximum extent within the visible area. By using the method, the photo can be ensured to be circumscribed in the visible area of the photo frame when the photo rotates, and the main body in the photo displays the central part of the visible area.
Description
Technical Field
The invention relates to an image zooming method, in particular to a photo rotation self-adaptive zooming method in a photo frame based on photo album application, and belongs to the technical field of image processing.
Background
Since the flash is gradually developed from an animation software, the flash is very handy to use for some rich media applications and has strong expressive force. As a piece of animation software, the flash has the concepts of 'display objects' and 'frames'. First, "frame", like the "frame rate" of a television, represents the number of film segments played per second (flash represents the number of stages rendered per second). With frames, a lot of representation and interaction can be enriched, where the adaptive rotation is also frame based. To say again, "display object": in flash, all displayed things are display objects (displayobjects). Then, there is also a display object container (DisplayObjectContainer). The display object container inherits the display objects, and one display object container may contain any other display objects. The photo frame and the photo are also display object containers. A frame is itself a Sprite (inherited from DisplayObjectContainer) that has three display objects inside it: foreground, mask, photo container. Here, the "mask" is a part of the display object below, which is just a part of the mask region. A picture graphic is placed in the picture frame, in effect placing the picture in a picture container in the picture frame. The photo container is masked and the resulting effect is shown, see figure 1.
In the attached drawing 1, the input photo is divided into two conditions of zooming and non-zooming, the photo is input according to the original size without zooming, and the part beyond the photo frame at the periphery is hidden (or cut); the picture frame is fully stretched (circumscribed) according to a certain proportion after zooming. Generally, the photos that are put in are zoomed, and the best display effect is achieved. However, it is noted that the effect achieved by zooming is to circumscribe rather than to circumscribe, with respect to both inscribe and circumscribe, that is, the edge of the picture just abuts the edge of the frame display area. See figure 2.
Referring to fig. 2, a smaller square photo is placed in a larger rectangular frame and the square photo is zoomed. If the picture frame is internally tangent, the two ends of the picture frame are left blank; if the mask is circumscribed, no blank is left, but the upper and lower parts are exceeded (the excess part is hidden by the mask). In order to leave no blank, the photo container is generally circumscribed in the actual process, and then the position of the photo container is adjusted, so that the best presentation effect is achieved. As mentioned above, no rotation has been considered. Once the photo is rotated, it is the focus of this patent on how to make the photo circumscribe in the visible area of the frame.
Disclosure of Invention
The invention aims to provide a photo rotation self-adaptive zooming method in a photo frame based on album application, which ensures that a photo is circumscribed in a visible area of the photo frame when the photo rotates.
The invention is realized by the following steps:
a photo frame internal photo rotation self-adaptive zooming method based on photo album application can enable photos to be well presented in the largest range in a visual area without abnormal display when the photos are rotated at any angle; the method comprises the following steps:
recording a coordinate PointCenter (x, y) of a central point; abbreviated as pc; the central point is used as the central point of the photo frame and the central point of the photo, and the photo rotates around the central point;
recording coordinates PhotoFramePoint1(x, y), PhotoFramePoint2(x, y), PhotoFramePoint3(x, y) and PhotoFramePoint4(x, y) of four corners of a visible area of the photo frame, wherein the sequence is left-upper, right-lower and left-lower, and is abbreviated as pf1, pf2, pf3 and pf 4;
step three, when the mouse is pressed down to drag and rotate, calculating the coordinates of the four corners of the photo according to some basic attributes of the photo; abbreviated as p1, p2, p3 and p4 according to the positions of upper left, upper right, lower right and lower left;
step four, calculating the coordinates of the central points of the four edges of the photo on the basis of the step three; abbreviated as cz1, cz2, cz3 and cz4 in terms of upper, right, lower and left positions, respectively;
step five, on the basis of the step four, calculating the opposite side connecting lines of the central points of the four sides of the photo; namely: line formed by cz1 and cz3, line13, cz2 and cz4, line 24;
step six, on the basis of the step five, solving out the vertical foot points from two corner points above the visible area of the photo frame to the line24, namely the vertical points from pf1, pf2 to the line24, which are respectively pp1 and pp 2; then, the vertical foot points from the left two corner points of the visible area of the photo frame to the line13, namely the vertical points from pf1, pf4 to the line13 are respectively pp3 and pp 4;
step seven, on the basis of the step six, calculating the distances from the pp1 and the pp2 to the center point, taking the point with the maximum distance, and then calculating the ratio by using the original height of the picture and the distance to obtain a scaling ratio scaleRate 1; then, the distances from pp3 and pp4 to the center point are solved, the point with the maximum distance is taken, then the original width of the picture is used for solving the ratio of the distance, and a scaling ratio scaleRate2 is obtained;
step eight, on the basis of the step seven, taking a larger value of the scaleRate1 and the scaleRate2 as a base number of the final zoom ratio of the photo;
step nine, the zoom ratio parameter obtained in the step eight is applied to the photo, and the visible area of the photo frame is circumscribed in each frame of the photo when the photo is dragged and rotated; good interactive experience is achieved;
step ten, after dragging and rotating to a good angle, releasing the mouse and completing the operation of rotating the picture; at this time, the corresponding zoom ratio is also calculated in the last frame, so that the angle-adjusted picture is finally well presented in the picture frame.
The further scheme is as follows:
making the photograph appear well to the maximum extent within the viewable area means ensuring that the photograph circumscribes the viewable area when rotated.
By using the method, the photo can be ensured to be circumscribed in the visible area of the photo frame when the photo rotates, and the main body in the photo displays the central part of the visible area.
Drawings
FIG. 1 is a schematic diagram of a picture frame composition distinguishing the results of zooming a picture from the results of not zooming a picture;
FIG. 2 is a schematic illustration of the endo and exo displays of the photograph;
FIG. 3 is a schematic diagram of mouse dragging a control point to rotate;
FIG. 4 is a schematic diagram of a photo rotated without zooming in and out, with blanks appearing at two corners;
FIG. 5 is a schematic diagram of a photo rotated without zooming the photo, the photo extending more beyond the visible area;
FIG. 6 is a schematic view of a visible area of a circumscribed photo frame of a photo, wherein the photo is zoomed when rotated, and no blank appears at two corners;
FIG. 7 is a schematic diagram of a photo circumscribed photo frame of a photo frame, wherein the photo is zoomed when the photo rotates, and the photo does not exceed a visible area more;
fig. 8 is a schematic view showing the main body of the photograph displayed in the center of the visible region, with the photograph being positionally adjusted.
Detailed Description
The invention is described in further detail below with reference to the figures and the specific embodiments.
The accompanying drawings are included to provide a further understanding of the invention.
According to fig. 1, in a flash album editor, the composition of a photo frame is divided into 3 parts: foreground (border), mask (visible area of photo), photo container (bitmap where photo is placed).
According to fig. 2, the picture is zoomed after being put into the picture frame, and there are two zooming ways: the visible area is inscribed in the picture and circumscribed outside the picture.
According to FIG. 3, immediately after the photo is placed in the frame, the initial zoom is such that the photo circumscribes the viewable area. Note that the scene taken by the photo itself is somewhat angularly inclined, at this time, the mouse can be pressed down on the rotation button, and the rotation button is dragged to rotate the photo.
According to fig. 4, when the photograph is not zoomed in and rotated, a situation may occur in which there is a space in the area.
According to fig. 5, the photograph is not zoomed when rotated, which may occur when the photograph is out of the viewable area.
According to fig. 6 and 7, when the photo is zoomed in and out during rotation, the photo can be ensured to circumscribe the visible area, and good rendering effect is achieved. The specific scaling mode is as follows: abstracting out a mathematical model, and dynamically calculating each frame by using a set of geometric and line segment equations to solve the zoom ratio of the picture on the current frame.
According to fig. 8, when the rotation angle of the photo is adjusted, the original inclined scenery in the photo shows a horizontal and sea surface effect in the photo frame.
As can be seen in fig. 1 and 2, the inner pictures are tilted. If one wants to adjust the tilt, one needs to rotate the picture. The rotation mode adopted in this patent is that the mouse drags a control point to rotate the picture, see fig. 3. In fig. 3, the black box is the portion of the mask within the frame, i.e., the final viewable area of the photograph. The figure has a button shaped like a water drop, namely a button for dragging and controlling the rotation; there is a white translucent ring, i.e. the running track of the rotary button. When the mouse is pressed on the drag rotate button, the mouse graphic becomes a grip and a FRAME cycle event (ENTER _ FRAME) is initiated. Thereafter, in each frame, the rotating button moves to a position of a corresponding angle around the central point on the track along with the difference of the coordinate position of the mouse, and the zoom ratio of the photo is dynamically calculated so as to make the photo circumscribed in the photo frame. To better illustrate the circumscribing, a look is first made here at the case where no zooming is performed during the dragging process, as shown in fig. 4 and 5. In fig. 4, when the rotation is performed to a certain angle, two angles are blank; in fig. 5, the photograph is again more extended beyond the visible area when rotated to another angle. Ideally, the photograph should be presented in the visible area to the maximum extent at any angle, as shown in fig. 6 and 7, while ensuring that no blank space is left in any place of the visible area.
In order to implement this method, a mathematical model is constructed, namely: there are two rectangles a and B, each with any aspect ratio, with their center points being the same, one (a) fixed and the other (B) rotating about the center point, which rotation ensures that the inside of B is at any time against the outside of a (i.e. B circumscribes a).
For this, the following initial parameters need to be prepared first.
1. Coordinates PointCenter (x, y) of the center point. Abbreviated as pc.
2. Coordinates PhotoFramePoint1(x, y), PhotoFramePoint2(x, y), PhotoFramePoint3(x, y), PhotoFramePoint4(x, y) of the four corners of the visible area of the picture frame are in the order of top left, top right, bottom left, abbreviated as pf1, pf2, pf3, pf 4.
Then, as each frame rotates, it needs to calculate:
1) coordinates of the four corners of the photograph. In flash, any display object has some basic attribute values, such as coordinates (X, Y), angle (rotation), scaleX (scaling on the X coordinate axis), scaleY (scaling on the Y coordinate axis). From these basic attribute values, the coordinate positions of the four corners of the photograph can be calculated. Also, the positions of upper left, upper right, lower right, and lower left are abbreviated as p1, p2, p3, and p4, respectively.
2) Coordinates of the center point on the four sides of the photograph. In terms of the upper, right, lower, and left positions, these are abbreviated as cz1, cz2, cz3, and cz4, respectively.
3) The opposite sides of the center point on the four sides of the picture are connected. Namely: line formed by cz1 and cz3 (line13), and line formed by cz2 and cz4 (line 24).
4) The vertical foot points from the upper two corner points of the visible area of the picture frame to the line24 (namely the vertical points from pf1, pf2 to the line24) are respectively pp1 and pp 2.
5) The vertical foot points from the left two corner points of the visible area of the picture frame to the line13 (namely the vertical points from pf1, pf4 to the line13) are respectively pp3 and pp 4.
6) The distances from pp1 and pp2 to the center point are calculated, the point with the maximum distance is taken, and then the original height of the picture is used to calculate the ratio of the distances, and a scaling ratio scaleRate1 is obtained.
7) The distances from pp3 and pp4 to the center point are calculated, the point with the maximum distance is taken, and then the original width of the picture is used to compare the distances to obtain a scaling ratio scaleRate 2.
8) The larger of scalenate 1 and scalenate 2 is taken as the base of the final zoom ratio of the photograph.
According to the method, the zoom ratio of each frame of photo can be obtained so as to meet the requirement of the visible area of the circumscribed photo frame of the photo. Of course, in addition to the zoom ratio, the coordinates of the photograph need to be calculated for each frame (since the coordinates of the display object are not the center point, but the upper left corner of the display object), although this calculation is relatively simple and will be apparent to those skilled in the art and is not set forth herein.
After the final adjustment, the effect in fig. 8 is obtained. As shown, when the position of the photo is adjusted and the position is moved, the subject in the photo is displayed in the center of the visible area.
Although the present invention has been described herein with reference to the illustrated embodiments thereof, which are intended to be preferred embodiments of the present invention, it is to be understood that the invention is not limited thereto, and that numerous other modifications and embodiments can be devised by those skilled in the art that will fall within the spirit and scope of the principles of this disclosure.
Claims (2)
1. A photo rotation self-adaptive zooming method in a photo frame based on photo album application is characterized in that: when the photo is rotated at any angle, the photo can be well presented in the largest range in the visible area, and the abnormal display condition is avoided; the method comprises the following steps:
recording a coordinate PointCenter (x, y) of a central point; abbreviated as pc; the central point is used as the central point of the photo frame and the central point of the photo, and the photo rotates around the central point;
recording coordinates PhotoFramePoint1(x, y), PhotoFramePoint2(x, y), PhotoFramePoint3(x, y) and PhotoFramePoint4(x, y) of four corners of a visible area of the photo frame, wherein the sequence is left-upper, right-lower and left-lower, and is abbreviated as pf1, pf2, pf3 and pf 4;
step three, when the mouse is pressed down to drag and rotate, calculating the coordinates of the four corners of the photo according to some basic attributes of the photo; abbreviated as p1, p2, p3 and p4 according to the positions of upper left, upper right, lower right and lower left; the basic attributes comprise coordinates, angles, scaling on an X coordinate axis and scaling on a Y coordinate axis;
step four, calculating the coordinates of the central points of the four edges of the photo on the basis of the step three; abbreviated as cz1, cz2, cz3 and cz4 in terms of upper, right, lower and left positions, respectively;
step five, on the basis of the step four, calculating the opposite side connecting lines of the central points of the four sides of the photo; namely: line formed by cz1 and cz3, line13, cz2 and cz4, line 24;
step six, on the basis of the step five, solving out the vertical foot points from two corner points above the visible area of the photo frame to the line24, namely the vertical points from pf1, pf2 to the line24, which are respectively pp1 and pp 2; then, the vertical foot points from the left two corner points of the visible area of the photo frame to the line13, namely the vertical points from pf1, pf4 to the line13 are respectively pp3 and pp 4;
step seven, on the basis of the step six, calculating the distances from the pp1 and the pp2 to the center point, taking the point with the maximum distance, and then calculating the ratio by using the original height of the picture and the distance to obtain a scaling ratio scaleRate 1; then, the distances from pp3 and pp4 to the center point are solved, the point with the maximum distance is taken, then the original width of the picture is used for solving the ratio of the distance, and a scaling ratio scaleRate2 is obtained;
step eight, on the basis of the step seven, taking a larger value of the scaleRate1 and the scaleRate2 as a base number of the final zoom ratio of the photo;
step nine, the zoom ratio parameter obtained in the step eight is applied to the photo, and the visible area of the photo frame is circumscribed in each frame of the photo when the photo is dragged and rotated;
step ten, after dragging and rotating to a good angle, releasing the mouse and completing the operation of rotating the picture; at this time, the corresponding zoom ratio is also calculated in the last frame, so that the angle-adjusted picture is finally well presented in the picture frame.
2. The photo album application-based photo frame photo rotation adaptive scaling method according to claim 1, characterized in that:
making the photograph appear well to the maximum extent within the viewable area means ensuring that the photograph circumscribes the viewable area when rotated.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710720823.5A CN107481194B (en) | 2017-08-22 | 2017-08-22 | Photo rotation self-adaptive scaling method in photo frame based on photo album application |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710720823.5A CN107481194B (en) | 2017-08-22 | 2017-08-22 | Photo rotation self-adaptive scaling method in photo frame based on photo album application |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107481194A CN107481194A (en) | 2017-12-15 |
CN107481194B true CN107481194B (en) | 2020-06-30 |
Family
ID=60601175
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710720823.5A Active CN107481194B (en) | 2017-08-22 | 2017-08-22 | Photo rotation self-adaptive scaling method in photo frame based on photo album application |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107481194B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110316084B (en) * | 2018-03-30 | 2021-09-21 | 比亚迪股份有限公司 | Navigation display system and method based on vehicle-mounted display terminal and vehicle |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101184142A (en) * | 2007-12-21 | 2008-05-21 | 北京海尔集成电路设计有限公司 | Image processing method and image rotatable digital photo frame of implementing the same |
CN101415103A (en) * | 2007-10-19 | 2009-04-22 | 英华达(南京)科技有限公司 | Method for regulating video signal picture |
CN103700099A (en) * | 2013-12-18 | 2014-04-02 | 同济大学 | Rotation and dimension unchanged wide baseline stereo matching method |
CN104881263A (en) * | 2015-05-27 | 2015-09-02 | 天津三星电子有限公司 | Display control method and display equipment |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7734572B2 (en) * | 2006-04-04 | 2010-06-08 | Panduit Corp. | Building automation system controller |
-
2017
- 2017-08-22 CN CN201710720823.5A patent/CN107481194B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101415103A (en) * | 2007-10-19 | 2009-04-22 | 英华达(南京)科技有限公司 | Method for regulating video signal picture |
CN101184142A (en) * | 2007-12-21 | 2008-05-21 | 北京海尔集成电路设计有限公司 | Image processing method and image rotatable digital photo frame of implementing the same |
CN103700099A (en) * | 2013-12-18 | 2014-04-02 | 同济大学 | Rotation and dimension unchanged wide baseline stereo matching method |
CN104881263A (en) * | 2015-05-27 | 2015-09-02 | 天津三星电子有限公司 | Display control method and display equipment |
Non-Patent Citations (1)
Title |
---|
自适应旋转投影分解法;殷勤业等;《电子学报》;19970430;第25卷(第4期);全文 * |
Also Published As
Publication number | Publication date |
---|---|
CN107481194A (en) | 2017-12-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110287368B (en) | Short video template design drawing generation device and short video template generation method | |
US6515659B1 (en) | Method and system for creating realistic smooth three-dimensional depth contours from two-dimensional images | |
US6529206B1 (en) | Image processing apparatus and method, and medium therefor | |
CN106971165B (en) | A kind of implementation method and device of filter | |
Horry et al. | Tour into the picture: using a spidery mesh interface to make animation from a single image | |
CN109410298B (en) | Virtual model manufacturing method and expression changing method | |
CN111325824A (en) | Image data display method and device, electronic equipment and storage medium | |
US8666146B1 (en) | Discontinuous warping for 2D-to-3D conversions | |
CN106447604B (en) | Method and device for transforming face picture in video | |
US20110050685A1 (en) | Image processing apparatus, image processing method, and program | |
CN109660783A (en) | Virtual reality parallax correction | |
CN110049351A (en) | The method and apparatus of Facial metamorphosis, electronic equipment, computer-readable medium in video flowing | |
US20100201681A1 (en) | Image Editing Consistent with Scene Geometry | |
CN109523622B (en) | Unstructured light field rendering method | |
CN105760073B (en) | A method of realizing graphical perspectives in interactive electric whiteboard software | |
JP2008276410A (en) | Image processor and method | |
CN107146197A (en) | A kind of reduced graph generating method and device | |
CN103914862A (en) | Pencil sketch simulating method based on edge tangent stream | |
CN107481194B (en) | Photo rotation self-adaptive scaling method in photo frame based on photo album application | |
CN109461197B (en) | Cloud real-time drawing optimization method based on spherical UV and re-projection | |
JP4188487B2 (en) | Eye makeup simulation system | |
WO2022003066A1 (en) | User interface | |
JPH10507858A (en) | Method and apparatus for automatically and quickly drawing on a photographic real surface on a three-dimensional wireframe | |
WO2023143120A1 (en) | Material display method and apparatus, electronic device, storage medium, and program product | |
WO2022105737A1 (en) | Rendering method and system for map area boundary in game map, and computer readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |