CN117991962A - Limiting image zooming and dragging method based on cloud platform - Google Patents

Limiting image zooming and dragging method based on cloud platform Download PDF

Info

Publication number
CN117991962A
CN117991962A CN202410396078.3A CN202410396078A CN117991962A CN 117991962 A CN117991962 A CN 117991962A CN 202410396078 A CN202410396078 A CN 202410396078A CN 117991962 A CN117991962 A CN 117991962A
Authority
CN
China
Prior art keywords
picture
height
width
view port
mouse
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.)
Pending
Application number
CN202410396078.3A
Other languages
Chinese (zh)
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.)
Shandong Jerei Digital Technology Co Ltd
Original Assignee
Shandong Jerei Digital Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shandong Jerei Digital Technology Co Ltd filed Critical Shandong Jerei Digital Technology Co Ltd
Priority to CN202410396078.3A priority Critical patent/CN117991962A/en
Publication of CN117991962A publication Critical patent/CN117991962A/en
Pending legal-status Critical Current

Links

Landscapes

  • Processing Or Creating Images (AREA)

Abstract

The invention relates to a method for limiting image scaling and dragging based on a cloud platform, and belongs to the technical field of computer visual operation. The method comprises the following steps: s1, positioning an origin of a picture; s2, enabling the picture to be self-adaptive to the width and height of the view port, and taking the view port height value as a minimum zooming limiting value of the picture; s3, positioning the picture in the center of the view port; s4, triggering a mouse wheel event to execute limited zooming operation on the picture; s5, acquiring a coordinate point pressed by a mouse and a coordinate point after the mouse moves; s6, performing difference processing on the coordinate points after the mouse moves and the coordinate points when the mouse is pressed, obtaining the difference value of the two coordinate points and giving left and top attributes of the picture patterns; s7, calculating a width difference value and a height difference value of the pictures before and after zooming; s8, drag limiting is carried out based on the difference value of the two coordinate points acquired in the S6. According to the invention, through setting the limitation of positioning and zooming on the picture, the convenience and experience of picture operation are improved.

Description

Limiting image zooming and dragging method based on cloud platform
Technical Field
The invention relates to a method for limiting image scaling and dragging based on a cloud platform, and belongs to the technical field of computer visual operation.
Background
At present, informatization, intelligence and networking have become the signs of time development, and people have higher and higher aesthetic level and requirements while pursuing convenience of life. Based on this, the picture display function of the platform should be more comprehensive, convenient and beautiful to meet the needs and aesthetic requirements of the public.
At present, although the existing plug-in provided based on jQuery can realize the zooming and dragging functions of pictures, the zooming and dragging of the pictures are not provided with a limiting function, and in practice, the plug-in mainly has the following two defects:
1. When the picture is reduced to break through the minimum value, the picture can be inversely amplified due to lack of scaling limitation;
2. Since the drag restriction is not set for the picture in the viewport, when the picture is dragged, a problem often occurs that the picture is dragged out of the viewport, and the position where the picture is located cannot be determined.
In view of the above, the present invention proposes a method for limiting image scaling and dragging based on a cloud platform.
Disclosure of Invention
In order to solve the problems, the invention provides a method for limiting image scaling and dragging based on a cloud platform.
A method for limiting image scaling and dragging based on a cloud platform comprises the following steps:
S1, positioning an operation origin of a picture at the upper left corner of the picture;
s2, enabling the picture to be self-adaptive to the width and the height of the view port, taking the width and the height of the view port as minimum zoom limiting values of the picture, and obtaining the width w1 and the height h1 of the view port, wherein the width w1 and the height h1 of the view port are the width and the height of the picture before zooming;
S3, positioning the picture at the most center of the view port;
S4, responding to the sliding operation of the mouse wheel on the picture in the view port, and executing limited zooming operation on the picture by triggering a mouse wheel event;
s5, responding to the dragging operation of the mouse on the picture in the view port, and respectively acquiring coordinate points (xa, ya) of the pressed mouse and coordinate points (xb, xb) of the moved mouse;
S6, carrying out difference processing on coordinate points (xb, xb) after the mouse is moved and coordinate points (xa, ya) when the mouse is pressed, obtaining difference values (xc, yc) of the two coordinate points, and respectively giving the difference values (xc, yc) to left and top attributes of a picture pattern through setting $ (') css ({ "left": xc, "top": yc }), so as to position the picture;
S7, subtracting the width w2 of the zoomed picture from the width w1 of the picture before zooming, namely the width w1 of the viewport, so as to obtain a width difference value w3=w1-w 2 of the picture before zooming and the picture after zooming; subtracting the height h2 of the zoomed picture from the height h1 of the zoomed picture, namely the view port height, so as to obtain a height difference value h3=h1-h 2 of the zoomed picture;
S8, based on xc and yc obtained in the S6, the following judgment is made:
When xc < = 0 and xc > w3, positioning the picture at a position distant from the left frame xc pixel of the view port based on the operation origin point of the picture, so as to limit the dragging of the picture in the left-right direction of the view port, and prevent the picture from leaving the left-right frame boundary of the view port;
When yc < = 0 and yc > h3, the picture is positioned at a position away from the yc pixel of the upper frame of the view port based on the operation origin point of the picture, so that the dragging of the picture in the up-down direction of the view port is limited, and the picture cannot leave the upper and lower frame boundaries of the view port.
Further, in the step S2, by setting in css of the picture
Img { width:100%, min-height:100%, object-fit: contact }, adapting the picture to the width and height of the viewport, and taking the height value of the viewport as the minimum zoom limit value of the picture.
Further, the specific step of S4 includes:
S41, acquiring a receiving value "e" of an event return result object through a mouse wheel event $ (') on (mousewheel, function (e));
s42, based on the step value e.originalevent.wheel delta in the receiving value "e", a corresponding scaling multiple currentScale is calculated;
S43, assigning the obtained scaling multiple currentScale to transfrom attribute in the picture css, namely transfrom: scale (currentScale), realizing a zooming function of the picture, and obtaining a zoomed picture width w2 and a zoomed picture height h2;
And S44, when the picture is reduced to the minimum, namely, the picture is consistent with the width and height dimensions of the video port, no reduction event is executed.
According to the cloud platform-based image scaling and dragging limiting method, based on the image function of jQuery, the image cannot be dragged to a position away from the boundary of the viewport and cannot be infinitely reduced by setting positioning and scaling limits on the image. The picture is kept in the center of the view port all the time, the picture can be prevented from being infinitely reduced, lost, the convenience of watching the picture is improved, and the picture viewing device has a good impression experience effect.
Drawings
Fig. 1 is a schematic flow chart of a method for limiting image scaling and dragging based on a cloud platform according to the first embodiment.
Detailed Description
In order to clearly illustrate the technical features of the present solution, the present invention will be described in detail below with reference to the following detailed description and the accompanying drawings. The following disclosure provides many different embodiments for implementing different configurations of the invention. In order to simplify the present disclosure, components and arrangements of specific examples are described below. Furthermore, the present invention may repeat reference numerals and/or letters in the various examples. This repetition is for the purpose of simplicity and clarity and does not in itself dictate a relationship between the various embodiments and/or configurations discussed. It should be noted that the components illustrated in the figures are not necessarily drawn to scale. Descriptions of well-known components and processing techniques and processes are omitted so as to not unnecessarily obscure the present invention.
Example 1
A method for limiting image scaling and dragging based on a cloud platform comprises the following steps:
S1, origin positioning
Transfrom-origin is added to css (cascading style sheet) of the picture: 00 attribute, positioning the operation origin of the picture at the upper left corner of the picture, so that the mouse can zoom based on the upper left corner of the picture when zooming.
S2, initializing a minimum value of the picture
Set in css (cascading style sheet) of picture
Img { width:100%, min-height:100%, object-fit: contact } making the picture self-adapt to the width and height of the viewport, and taking the viewport height and viewport width as limiting values for picture shrinkage; and obtaining the width w1 and the height h1 of the viewport through parseInt ($ (', ') css (' width ')), parseInt ($ (') css (' width ')), wherein the width w1 and the height h1 of the viewport are the width and the height of the picture before zooming.
S3, initializing picture positioning
The picture is positioned in the most center of the viewport by setting $ (') css ({ "left": "0", "top": "0").
S4, scaling operation
When the mouse performs zooming operation on the picture in the view port, responding to the sliding of the mouse wheel on the picture in the view port, and executing the zooming operation with limitation on the picture by triggering a mouse wheel event:
S41, a mouse-over wheel event $ (') on (mousewheel, function (e) { }) acquires a receiving value "e" of an object of a return result of the event;
s42, based on the step value e.originalevent.wheel delta in the receiving value "e", a corresponding scaling multiple currentScale is calculated;
S43, assigning the obtained scaling multiple currentScale to transfrom attribute in the picture css, namely transfrom: scale (currentScale), realizing a zooming function of the picture, and obtaining a zoomed picture width w2 and a zoomed picture height h2;
s44, limiting the zooming of the picture when the picture is reduced to the minimum, namely, the picture is consistent with the width and the height of the video port, and not executing the reduction event.
S5, acquiring coordinate points before and after dragging
When the mouse performs drag operation on the picture in the view port, the system will obtain a coordinate point (xa, ya) of pressing the mouse by pressing the mouse event $ (') mousedown (); the coordinate point (xb, xb) after the mouse movement is obtained by the mouse movement event $ (') mousemove ().
S6, drawing and positioning
And performing difference processing on the coordinate points (xb, xb) after the mouse moves and the coordinate points (xa, ya) when the mouse is pressed to obtain difference values (xc, yc) of the two coordinate points, and respectively assigning the difference values (xc, yc) to the left and top attributes of the picture patterns by setting $ ('.+ -.)') css ({ left ": xc top": yc }), so as to position the picture.
S7, obtaining the difference before and after zooming
Subtracting the width w2 of the zoomed picture from the width w1 of the zoomed picture, namely the width of the viewport, so as to obtain a width difference value w3=w1-w 2 of the zoomed picture; subtracting the height h2 of the zoomed picture from the height h1 of the zoomed picture, namely the view port height, to obtain a height difference value h3=h1-h 2 of the zoomed picture.
S8, limiting drawing
Based on xc and yc acquired in S6, the following determination is made:
When xc < = 0 and xc > w3, positioning the picture at a position distant from the left frame xc pixel of the view port based on the operation origin point of the picture, so as to limit the dragging of the picture in the left-right direction of the view port, and prevent the picture from leaving the left-right frame boundary of the view port;
When yc < = 0 and yc > h3, the picture is positioned at a position away from the yc pixel of the upper frame of the view port based on the operation origin point of the picture, so that the dragging of the picture in the up-down direction of the view port is limited, and the picture cannot leave the upper and lower frame boundaries of the view port.
The specific operation code of S8 is as follows:
if(xc<= 0&&xc>w3){
$(‘...’).css(‘left’,xc+’px’)
}else(yc<= 0&&yc>h3){
$(‘...’).css(‘top’,yc+’px’)
} 。
Finally, it should be noted that: the above embodiments are only for illustrating the technical aspects of the present invention and not for limiting the same, and although the present invention has been described in detail with reference to the above embodiments, it should be understood by those of ordinary skill in the art that: modifications and equivalents may be made to the specific embodiments of the invention without departing from the spirit and scope of the invention, which is intended to be covered by the claims.

Claims (3)

1. A method for limiting image scaling and dragging based on a cloud platform is characterized by comprising the following steps:
S1, positioning an operation origin of a picture at the upper left corner of the picture;
s2, enabling the picture to be self-adaptive to the width and the height of the view port, taking the width and the height of the view port as minimum zoom limiting values of the picture, and obtaining the width w1 and the height h1 of the view port, wherein the width w1 and the height h1 of the view port are the width and the height of the picture before zooming;
S3, positioning the picture at the most center of the view port;
S4, responding to the sliding operation of the mouse wheel on the picture in the view port, and executing limited zooming operation on the picture by triggering a mouse wheel event;
s5, responding to the dragging operation of the mouse on the picture in the view port, and respectively acquiring coordinate points (xa, ya) of the pressed mouse and coordinate points (xb, xb) of the moved mouse;
S6, carrying out difference processing on coordinate points (xb, xb) after the mouse is moved and coordinate points (xa, ya) when the mouse is pressed, obtaining difference values (xc, yc) of the two coordinate points, and respectively giving the difference values (xc, yc) to left and top attributes of a picture pattern through setting $ (') css ({ "left": xc, "top": yc }), so as to position the picture;
S7, subtracting the width w2 of the zoomed picture from the width w1 of the picture before zooming, namely the width w1 of the viewport, so as to obtain a width difference value w3=w1-w 2 of the picture before zooming and the picture after zooming; subtracting the height h2 of the zoomed picture from the height h1 of the zoomed picture, namely the view port height, so as to obtain a height difference value h3=h1-h 2 of the zoomed picture;
S8, based on xc and yc obtained in the S6, the following judgment is made:
when xc < = 0 and xc > w3, positioning the picture at a position distant from the left frame xc pixel of the view port based on the operation origin point of the picture, so as to limit the dragging of the picture in the left-right direction of the view port, and prevent the picture from leaving the left-right frame boundary of the view port;
when yc < = 0 and yc > h3, the picture is positioned at a position away from the yc pixel of the upper frame of the view port based on the operation origin point of the picture, so that the dragging of the picture in the up-down direction of the view port is limited, and the picture cannot leave the upper and lower frame boundaries of the view port.
2. The method for restricting image zooming and dragging based on a cloud platform as claimed in claim 1, wherein in S2, by setting in css of a picture
Img { width:100%, min-height:100%, object-fit: contact }, adapting the picture to the width and height of the viewport, and taking the height value of the viewport as the minimum zoom limit value of the picture.
3. The method for restricting image zooming and dragging based on the cloud platform as claimed in claim 1, wherein the specific step of S4 includes:
S41, acquiring a receiving value "e" of an event return result object through a mouse wheel event $ (') on (mousewheel, function (e));
s42, based on the step value e.originalevent.wheel delta in the receiving value "e", a corresponding scaling multiple currentScale is calculated;
S43, assigning the obtained scaling multiple currentScale to transfrom attribute in the picture css, namely transfrom: scale (currentScale), realizing a zooming function of the picture, and obtaining a zoomed picture width w2 and a zoomed picture height h2;
And S44, when the picture is reduced to the minimum, namely, the picture is consistent with the width and height dimensions of the video port, no reduction event is executed.
CN202410396078.3A 2024-04-03 2024-04-03 Limiting image zooming and dragging method based on cloud platform Pending CN117991962A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410396078.3A CN117991962A (en) 2024-04-03 2024-04-03 Limiting image zooming and dragging method based on cloud platform

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410396078.3A CN117991962A (en) 2024-04-03 2024-04-03 Limiting image zooming and dragging method based on cloud platform

Publications (1)

Publication Number Publication Date
CN117991962A true CN117991962A (en) 2024-05-07

Family

ID=90893664

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410396078.3A Pending CN117991962A (en) 2024-04-03 2024-04-03 Limiting image zooming and dragging method based on cloud platform

Country Status (1)

Country Link
CN (1) CN117991962A (en)

Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6407749B1 (en) * 1999-08-04 2002-06-18 John H. Duke Combined scroll and zoom method and apparatus
KR101017935B1 (en) * 2010-10-13 2011-03-04 (주)네오시드넷 Deep zoom system of high resolution image on web using unit image tile
US20130088519A1 (en) * 2010-06-30 2013-04-11 Koninklijke Philips Electronics N.V. Zooming a displayed image
US8937617B1 (en) * 2011-04-20 2015-01-20 Google Inc. Matching views between a three-dimensional geographical image and a two-dimensional geographical image
CN109358797A (en) * 2018-12-22 2019-02-19 武汉兴图新科电子股份有限公司 A kind of method of D mouse scaling translation bitmap
WO2019043025A1 (en) * 2017-08-29 2019-03-07 Koninklijke Kpn N.V. Zooming an omnidirectional image or video
KR20200094309A (en) * 2019-01-30 2020-08-07 한화테크윈 주식회사 Apparatus for capturing images with Area Zoom, and Method thereof
CN111611989A (en) * 2020-05-22 2020-09-01 四川智动木牛智能科技有限公司 Multi-target accurate positioning identification method based on autonomous robot
CN114706508A (en) * 2022-04-28 2022-07-05 山东亿云信息技术有限公司 Canvas amplification and reduction offset control method and canvas redrawing method for WEB side

Patent Citations (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6407749B1 (en) * 1999-08-04 2002-06-18 John H. Duke Combined scroll and zoom method and apparatus
US20130088519A1 (en) * 2010-06-30 2013-04-11 Koninklijke Philips Electronics N.V. Zooming a displayed image
KR101017935B1 (en) * 2010-10-13 2011-03-04 (주)네오시드넷 Deep zoom system of high resolution image on web using unit image tile
US8937617B1 (en) * 2011-04-20 2015-01-20 Google Inc. Matching views between a three-dimensional geographical image and a two-dimensional geographical image
WO2019043025A1 (en) * 2017-08-29 2019-03-07 Koninklijke Kpn N.V. Zooming an omnidirectional image or video
CN109358797A (en) * 2018-12-22 2019-02-19 武汉兴图新科电子股份有限公司 A kind of method of D mouse scaling translation bitmap
KR20200094309A (en) * 2019-01-30 2020-08-07 한화테크윈 주식회사 Apparatus for capturing images with Area Zoom, and Method thereof
CN111611989A (en) * 2020-05-22 2020-09-01 四川智动木牛智能科技有限公司 Multi-target accurate positioning identification method based on autonomous robot
CN114706508A (en) * 2022-04-28 2022-07-05 山东亿云信息技术有限公司 Canvas amplification and reduction offset control method and canvas redrawing method for WEB side

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
张晏: ""OpenStack的拓扑可视化监控技术研究与实现"", 《中国优秀硕士学位论文全文数据库•信息科技辑》, vol. 2016, no. 3, 15 March 2016 (2016-03-15), pages 1 - 90 *
李卫国等: ""点云模型表面物体自由拖拽定位"", 《计算机工程与应用》, vol. 47, no. 15, 21 May 2011 (2011-05-21), pages 187 - 190 *

Similar Documents

Publication Publication Date Title
CN108446698B (en) Method, device, medium and electronic equipment for detecting text in image
JP2022528294A (en) Video background subtraction method using depth
CN110100251B (en) Apparatus, method, and computer-readable storage medium for processing document
JP6421754B2 (en) Information processing apparatus, information processing method, and program
US20150178992A1 (en) Method, system and apparatus for removing a marker projected in a scene
KR101598159B1 (en) Image providing method and image providing device
CN111078035B (en) Drawing method based on HTML5Canvas
US20130279763A1 (en) Method and apparatus for providing a mechanism for gesture recognition
US20200304713A1 (en) Intelligent Video Presentation System
CN109121000A (en) A kind of method for processing video frequency and client
CN110796664A (en) Image processing method, image processing device, electronic equipment and computer readable storage medium
WO2020108060A1 (en) Video processing method and apparatus, and electronic device and storage medium
CN113342248A (en) Live broadcast display method and device, storage medium and electronic equipment
WO2023160617A9 (en) Video frame interpolation processing method, video frame interpolation processing device, and readable storage medium
JP7140773B2 (en) Live ink presence for real-time collaboration
JP2015165346A (en) Image processing apparatus, image processing method, image processing system, and program
CN113655975B (en) Image display method, image display device, electronic apparatus, and medium
CN113411637B (en) Picture processing method and device
CN117991962A (en) Limiting image zooming and dragging method based on cloud platform
CN109859328B (en) Scene switching method, device, equipment and medium
US9483171B1 (en) Low latency touch input rendering
CN112004065B (en) Video display method, display device and storage medium
KR101719291B1 (en) Image providing method and image providing device
CN113157152B (en) Data processing method, device, playing terminal and computer storage medium
CN114663314A (en) Image noise reduction method and device, computer equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination