Image display method, program product, electronic equipment and storage medium

By obtaining the size of images and containers, determining the scaling ratio and origin coordinates, and performing image transformation, the problem of obstructing page content when the image is enlarged or rotated, improving browsing convenience and user experience, ensuring that the image is in different devices or page spaces All displays well.

CN118916558APending Publication Date: 2024-11-08CHENGDU NEW HOPE FINANCIAL INFORMATION CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411031796.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-30
Publication Date
2024-11-08

AI Technical Summary

Technical Problem

When displaying pictures in the prior art, the picture will enlarge the page content, affecting the browsing experience, and the picture rotation will change the page layout, making it inconvenient to browse.

Method used

By obtaining the size of the image and container, determining the scaling and origin coordinates, performing image transformations, ensuring that the image is fully displayed in the container without being cropped or stretched, and adjusting the scaling according to the rotation angle to keep the page layout stable.

Benefits of technology

It realizes enlarging or rotating pictures without obstructing the content of the page, improving page browsing convenience and user experience, and ensuring that pictures can be displayed well in different devices or page spaces.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118916558A_ABST
    Figure CN118916558A_ABST
Patent Text Reader

Abstract

The invention provides an image display method, a program product, electronic equipment and a storage medium. The method comprises the steps that the image size of an image, the size of a container for displaying the image and the display mode of the image are acquired; according to the display mode of the image, based on the ratio of the container size to the image size, determining a scaling; determining an original point coordinate and a display size of the image by using the scaling; and converting the image based on the image origin coordinate and the display size, and displaying the converted image. According to the method, the converted image does not shield characters in the page, meanwhile, the problems of page layout change and inconvenience in browsing caused by image direction change can be improved, the convenience of page browsing is improved, and thus the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image processing technology, and in particular to an image display method, a program product, an electronic device and a storage medium. Background Art

[0002] With the development of Internet technology, web pages or application programs have become more and more rich in content, and pictures and videos account for a large part. On some pages, the size or direction of the picture will affect viewing. The current solution is to pop up a new window when clicking on the picture, such as a modal pop-up window, through which a large picture can be previewed, so that the picture has the effect of magnification. However, this kind of pop-up window will block part of the page content, that is, the picture and text cannot be viewed at the same time, which has a certain impact on the browsing page and is not convenient for browsing. Summary of the invention

[0003] The purpose of the embodiments of the present application is to provide an image display method, program product, electronic device and storage medium, which transform an image and display the transformed image, thereby improving the convenience of page browsing without blocking other content on the page, thereby improving the user experience.

[0004] In a first aspect, an embodiment of the present application provides an image display method, including: obtaining an image size of an image, a container size for displaying the image, and a display mode of the image; determining a scaling ratio based on a ratio of the container size to the image size according to the display mode of the image; determining the image origin coordinates and the display size using the scaling ratio; transforming the image based on the image origin coordinates and the display size, and displaying the transformed image.

[0005] In the above implementation process, the image scaling ratio is determined based on the container size, and the image origin coordinates and display size are determined according to the scaling ratio, so that the transformed image will not block the text on the page. At the same time, it can improve the problem of page layout change and inconvenience in browsing caused by the change in image direction, improve the convenience of page browsing, and thus improve user experience.

[0006] Optionally, in an embodiment of the present application, the image size includes image width and image height; the container size includes container width and container height; the display mode includes geometric display; according to the display mode of the image, the scaling ratio is determined based on the ratio of the container size to the image size, including: when the display mode is geometric display, obtaining a first ratio of the image width to the container width, and a second ratio of the image height to the container height; and determining the maximum value of the first ratio and the second ratio as the scaling ratio.

[0007] In the implementation process of the above embodiment: the maximum value of the first ratio and the second ratio is determined as the scaling ratio, and the transformed image will not cause the page content to be hidden due to an inappropriate scaling ratio, nor will the transformed image be stretched.

[0008] Optionally, in an embodiment of the present application, if the display mode is proportional display, the scaling ratio is used to determine the image origin coordinates and the display size, including: using the ratio of the image width to the scaling ratio as the display width in the display size; using the ratio of the image height to the scaling ratio as the display height in the display size; calculating a first difference between the container width and the display width, and a second difference between the container height and the display height; determining the horizontal coordinate of the image origin coordinates based on the first difference, and determining the vertical coordinate of the image origin coordinates based on the second difference.

[0009] In the implementation process of the above embodiment: in the process of determining the scaling ratio, not only the image size but also the container size needs to be considered, and the scaling ratio of the image needs to match the container size to ensure that the image is fully displayed in the container without being cropped or stretched. By considering the container size, it can be ensured that the image can be displayed in a better way on different devices or page spaces.

[0010] Optionally, in an embodiment of the present application, the display mode includes rotational display; according to the display mode of the image, the scaling ratio is determined based on the ratio of the container size to the image size, including: when the display mode is rotational display, obtaining the rotation angle of the image; based on the rotation angle, judging the quadrant parameters of the image; determining the scaling ratio according to the parity of the quadrant parameters, the ratio of the container size to the image size.

[0011] In the implementation process of the above embodiment: if the image is rotated directly, the layout of the page will change. Therefore, the embodiment of the present application first calculates the scaling ratio of the rotated display according to the rotation angle, and redetermines the size of the displayed image based on the scaling ratio. After this processing, the image rotation effect is achieved without causing changes in the layout of the page.

[0012] Optionally, in an embodiment of the present application, the image size includes image width and image height; the container size includes container width and container height; and the scaling ratio is determined according to the parity of the quadrant parameter, the ratio of the container size and the image size, including: if the quadrant parameter is an odd number, obtaining a first ratio of the image width to the container width, and a second ratio of the image height to the container height; determining the maximum value of the first ratio and the second ratio as the scaling ratio; if the quadrant parameter is an even number, obtaining a third ratio of the image width to the container height; and a fourth ratio of the image height to the container width, and determining the maximum value of the third ratio and the fourth ratio as the scaling ratio.

[0013] In the implementation process of the above embodiment: considering that different rotation angles have different quadrant parameters, the scaling ratio is determined according to the quadrant parameters, so that the image can be accurately controlled. And the algorithm for determining the scaling ratio according to the parity of the quadrant parameters improves processing efficiency and saves a lot of time.

[0014] Optionally, in an embodiment of the present application, if the display mode is a rotated display, the scaling ratio is used to determine the image origin coordinates and the display size, including: using the ratio of the image width to the scaling ratio as the display width in the display size; using the ratio of the image height to the scaling ratio as the display height in the display size; calculating a first difference between the container width and the display width, and a second difference between the container height and the display height, and determining the image origin coordinates based on the quadrant parameter using the first difference and the second difference.

[0015] In the implementation process of the above embodiment: the image origin coordinates are a reference point defined in the image coordinate system of the transformed image, that is, the starting point or reference point of image processing. The embodiment of the present application determines the image origin coordinates through quadrant parameters, so that the transformed image drawn at the determined image origin coordinates will not change or block other content of the page, nor will it change the page layout, thereby improving the convenience of page browsing.

[0016] Optionally, in an embodiment of the present application, after using the scaling ratio to determine the coordinates of the image origin and the display size, the method also includes: obtaining the coordinate point of the mouse resting point relative to the container and the mouse wheel scrolling amount by monitoring mouse events; obtaining the scaling parameters according to the mouse wheel scrolling amount; obtaining the scaled image size according to the display size and the scaling parameters; calculating the coordinate system offset based on the coordinate point of the mouse resting point relative to the container and the scaling parameters; and displaying the scaled image based on the scaled image size and the coordinate system offset.

[0017] In the implementation process of the above embodiment: by calculating the amount of mouse wheel scrolling to dynamically adjust the zoom ratio, the user can more finely control the degree of image zooming in or out to meet different viewing needs. By calculating the position of the mouse on the image and using it as the zoom origin, a zoom effect centered on the current position of the mouse can be achieved. This effect is more in line with the user's expectations and improves the practicality of the zoom operation.

[0018] In a second aspect, an embodiment of the present application also provides an image display device, including: an acquisition module, used to acquire the image size of the image, the container size for displaying the image, and the display mode of the image; a scaling ratio determination module, used to determine the scaling ratio based on the ratio of the container size to the image size according to the display mode of the image; a coordinate calculation module, used to determine the image origin coordinates and the display size using the scaling ratio; and a display module, used to transform the image based on the image origin coordinates and the display size, and display the transformed image.

[0019] In a third aspect, an embodiment of the present application further provides a computer program product, including computer program instructions, which, when executed by a processor, execute the method provided by the first aspect or any one of the implementations of the first aspect.

[0020] In a fourth aspect, an embodiment of the present application further provides an electronic device, comprising: a processor and a memory, the memory storing computer program instructions, and the computer program instructions, when executed by the processor, execute the method provided by the first aspect or any one of the implementations of the first aspect.

[0021] In a fifth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, the method provided by the first aspect or any one of the implementations of the first aspect is executed.

[0022] By using the image display method, program product, electronic device and storage medium provided by the present application, the image scaling ratio is determined based on the container size, and the image origin coordinates and display size are determined according to the scaling ratio. In this way, the transformed image will not obstruct the text on the page. At the same time, the problem of page layout change and inconvenience in browsing caused by the change in image direction can be improved, the convenience of page browsing can be improved, and the user experience can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0024] Figure 1 A schematic diagram of a flow chart of an image display method provided in an embodiment of the present application;

[0025] Figure 2 A schematic diagram of the structure of an image display device provided in an embodiment of the present application;

[0026] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0027] The following embodiments of the technical solution of the present application are described in detail in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present application, and are therefore only used as examples, and cannot be used to limit the scope of protection of the present application.

[0028] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by technicians in the technical field to which this application belongs; the terms used herein are only for the purpose of describing specific embodiments and are not intended to limit this application.

[0029] In the description of the embodiments of the present application, the technical terms "first", "second", etc. are only used to distinguish different objects, and cannot be understood as indicating or implying relative importance or implicitly indicating the number, specific order or primary and secondary relationship of the indicated technical features. In the description of the embodiments of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.

[0030] In some page contents, images and text are usually interspersed. If the size or orientation of the image is not appropriate, you may need to enlarge or rotate the image for viewing. The current solution is to pop up a new window when clicking on the image, such as a modal pop-up window, to preview the large image through the modal pop-up window, so that the image has a magnified effect. However, this type of pop-up window will block part of the page content, that is, the image and text cannot be viewed at the same time, which has a certain impact on the browsing page.

[0031] In addition, if the direction of the image needs to be changed, the existing technology usually rotates the image directly. However, after such operation, due to the unequal width and height of the image, the original page layout will be changed after direct rotation. For example, the original image layout is horizontal, occupying 5 lines on the page; after rotation, the image is vertical, occupying 10 lines on the page. Therefore, the position of the text needs to be changed after the image is rotated. Changing the layout of the original page may cause confusion of page information and inconvenience in browsing. If the layout is not changed, part of the text may be blocked, which is also inconvenient for browsing.

[0032] The embodiments of the present application provide an image display method, a program product, an electronic device, and a storage medium, which determine the scaling ratio of the image based on the container size, and determine the image origin coordinates and the display size according to the scaling ratio, so that the transformed image will not obstruct the text in the page, and at the same time can improve the layout change and the inconvenience of browsing, improve the convenience of page browsing, and thus improve the user experience.

[0033] See also Figure 1 A flow chart of an image display method provided by an embodiment of the present application is shown. The image display method provided by an embodiment of the present application can be applied to an electronic device, which may include a physical device such as a server, a PC, a tablet computer, or a smart phone, or a virtual device such as a virtual machine or a container. The electronic device may be a single device, or a combination of multiple devices or a cluster of a large number of devices. The image display method may include:

[0034] Step S110: obtaining the image size of the image, the container size for displaying the image, and the display mode of the image;

[0035] Step S120: determining a zoom ratio based on a ratio of a container size to an image size according to a display mode of the image;

[0036] Step S130: Determine the image origin coordinates and display size using the scaling ratio;

[0037] Step S140: transform the image based on the image origin coordinates and the display size, and display the transformed image.

[0038] In step S110, the image size refers to the size of the image file itself in a website page or application, which is usually measured in pixels (px). The size of an image includes two dimensions: width and height.

[0039] The container size for displaying images refers to the element used to contain or display images, text, videos, etc. on a web page (such as , The container size is also defined by the width and height dimensions, and is related to the CSS (Cascading Style Sheets) style. If the image size does not match the container size (or the reserved display area on the web page) that displays the image, the image may be incomplete or distorted.

[0040] The display modes of the image may include geometric display, rotation display, enlarged display, reduced display, etc. The geometric display of the image, i.e., proportional display, means that the image keeps its original width-to-height ratio unchanged during the display process to avoid stretching or compression deformation of the image content.

[0041] In step S120, the scaling ratio of the image refers to the proportional relationship of the size change of the image when it is enlarged or reduced. For example, the scaling ratio can represent the ratio between the display size (such as width and height) of the transformed image and the original size of the image.

[0042] When determining the scaling ratio, not only the image size needs to be considered, but also the container size. The image scaling ratio needs to match its container size to ensure that the image is fully displayed in the container without being cropped or stretched. If the scaling ratio is not appropriate, the key content of the image may be hidden or deformed, affecting the user's visual experience and understanding. And the container size will change according to different screen sizes and device types. In order to adapt to this change, the image scaling ratio also needs to be adjusted accordingly. By considering the container size, you can ensure that the image can be displayed in a better way on different devices or page spaces.

[0043] The aspect ratio can be calculated according to the container size and the image size, and the scaling ratio can be determined by the aspect ratio. It is understandable that the specific method of determining the scaling ratio may be different for different display modes, and this step will be described later.

[0044] In step S130, the image origin coordinates refer to a reference point defined in the image coordinate system of the transformed image, and its coordinate value is used as the starting point or reference point for image processing. The image origin coordinates can be based on the image pixel coordinate system or the image physical coordinate system. The image origin coordinates can be used to determine the image in its container (such as The starting position of the image in the element or any other element). This position is the basis for the layout of the image on the page and can be used to align and layout the image with surrounding elements.

[0045] The display size refers to the size of the transformed image, which can be determined by the ratio of the image size to the scaling ratio. The image origin coordinates can be determined by the display size and the container size.

[0046] In step S140, the image is transformed based on the image origin coordinates and the display size, which means that the image is transformed corresponding to the display mode based on the image origin coordinates and the display size. For example, if the display mode is geometric display, a geometric transformation is performed, and then the transformed image is displayed.

[0047] For example, in HTML <canvas>In the element, use the drawImage method to set the image origin coordinates and display size, and you can draw the transformed image on the canvas to display the transformed image.

[0048] In the above implementation process, the image scaling ratio is determined based on the container size, and the image origin coordinates and display size are determined according to the scaling ratio, so that the transformed image will not block the text on the page. At the same time, it can improve the problem of page layout change and inconvenience in browsing caused by the change in image direction, improve the convenience of page browsing, and thus improve user experience.

[0049] Optionally, in an embodiment of the present application, the image size includes image width and image height; the container size includes container width and container height; the display mode includes geometric display; according to the display mode of the image, the scaling ratio is determined based on the ratio of the container size to the image size, including: when the display mode is geometric display, obtaining a first ratio of the image width to the container width, and a second ratio of the image height to the container height; and determining the maximum value of the first ratio and the second ratio as the scaling ratio.

[0050] For example, the image width is recorded as W, the image height is recorded as H, the container width is recorded as CW, and the container height is recorded as CH. The first ratio of the image width to the container width is W / CW, and the second ratio of the image height to the container height is H / CH. The maximum value is determined from the first ratio and the second ratio by the formula Max(W / CW,H / CH), and the maximum value of the first ratio and the second ratio is determined as the scaling ratio.

[0051] In the implementation process of the above embodiment: the maximum value of the first ratio and the second ratio is determined as the scaling ratio, the transformed image will not cause the page content to be hidden due to an inappropriate scaling ratio, nor will the transformed image be stretched, the image is easy to browse, and the user experience is improved.

[0052] Optionally, in an embodiment of the present application, if the display mode is proportional display, the scaling ratio is used to determine the image origin coordinates and the display size, including: using the ratio of the image width to the scaling ratio as the display width in the display size; using the ratio of the image height to the scaling ratio as the display height in the display size.

[0053] Continuing with the above embodiment, the scaling ratio is denoted as R, the image width is W, the ratio of the image width to the scaling ratio is W / R, W / R is used as the display width in the display size, and the display width is denoted as RW.

[0054] The image height is H, and the ratio of the image height to the scaling ratio is H / R. H / R is used as the display height in the display size, and the display height is recorded as RH.

[0055] A first difference between the container width and the display width is calculated, that is, the first difference is (CW-RW); and a second difference between the container height and the display height is calculated, that is, the second difference is (CH-RH).

[0056] According to the first difference (CW-RW), the horizontal coordinate of the image origin coordinate is determined. For example, half of the first difference is used as the horizontal coordinate of the image origin coordinate, that is, the horizontal coordinate is (CW-RW) / 2. And according to the second difference (CH-RH), the vertical coordinate of the image origin coordinate is determined, for example, half of the second difference is used as the vertical coordinate of the image origin coordinate, that is, the vertical coordinate is (CH-RH) / 2. Then, the image origin coordinate can be expressed as ((CW-RW) / 2, (CH-RH) / 2).

[0057] In an optional embodiment, the preset ratio of the first difference plus or minus the preset value can be used as the horizontal coordinate, and the preset ratio of the second difference plus or minus the preset value can be used as the vertical coordinate. The preset ratio can be one-half, one-third, or two-fifths, etc., which is not limited in the embodiment of the present application.

[0058] In the implementation process of the above embodiment: in the process of determining the scaling ratio, not only the image size but also the container size needs to be considered, and the scaling ratio of the image needs to match the container size to ensure that the image is fully displayed in the container without being cropped or stretched. By considering the container size, it can be ensured that the image can be displayed in a better way on different devices or page spaces.

[0059] Optionally, in the embodiment of the present application, the display mode includes rotation display; rotation display means displaying the image after rotating it by a preset angle. According to the display mode of the image, the scaling ratio is determined based on the ratio of the container size to the image size, including:

[0060] When the display mode is a rotation display, the rotation angle of the image is obtained. For example, the preset rotation angle of the user can be obtained first. This angle can be operated on the page or analyzed through some online tools. After obtaining the preset rotation angle, the rotation angle of the image is obtained according to the preset rotation angle, and the rotation angle is recorded as D. For example, if 0°<preset rotation angle<=90°, then D=90°; if 90°<preset rotation angle<=180°, then D=180°; if 180°<preset rotation angle<=270°, then D=270°; if 270°<preset rotation angle<=360°, then D=0°. The above angle determination can be regarded as the case where the preset rotation angle is the user's clockwise rotation. If -90°<=angle<0°, then D=270°; if -180°<=preset rotation angle<-90°, then D=180°; if -180°<=preset rotation angle<-270°, then D=90°; if -360°<=preset rotation angle<-270°, then D=0°. The above angle determination can be regarded as the case where the preset rotation angle is the user's counterclockwise rotation.

[0061] Based on the rotation angle, the quadrant parameter of the image is determined, and the quadrant parameter is recorded as Z, Z = D / 90 + 1. For example, the user rotates the image 70°, then the preset rotation angle is 70°, 0° < preset rotation angle < = 90°, based on the preset rotation angle, the rotation angle is determined to be 90°, then the quadrant parameter Z = 90 / 90 + 1 = 2, indicating the second quadrant.

[0062] The scaling ratio is determined according to the parity of the quadrant parameter, the ratio of the container size and the image size. The quadrant parameters include the first quadrant, the second quadrant, the third quadrant and the fourth quadrant. If the quadrant parameter is an even number (the second quadrant or the fourth quadrant), the image may be in a flipped state. Therefore, the scaling ratio can be determined according to the parity of the quadrant parameter, the ratio of the container size and the image size, and the image can be processed based on the scaling ratio to improve the layout modification and page confusion caused by image rotation.

[0063] In the implementation process of the above embodiment: if the image is rotated directly, the layout of the page will change. Therefore, the embodiment of the present application first calculates the scaling ratio of the rotated display according to the rotation angle, and redetermines the size of the displayed image based on the scaling ratio. After this processing, the image rotation effect is achieved without causing changes in the layout of the page.

[0064] Optionally, in the embodiment of the present application, the image size includes the image width and the image height; the container size includes the container width and the container height; and the scaling ratio is determined according to the parity of the quadrant parameter, the ratio of the container size and the image size, including:

[0065] If the quadrant parameter is an odd number, that is, the quadrant parameter represents the first quadrant or the third quadrant, a first ratio of the image width to the container width is obtained, and the first ratio can be recorded as W / CW in the above embodiment. A second ratio of the image height to the container height is obtained; the second ratio can be recorded as H / CH.

[0066] The maximum value between the first ratio and the second ratio is determined as the scaling ratio. For example, the maximum value is determined from the first ratio and the second ratio by the formula Max(W / CH, H / CW), and the maximum value between the first ratio and the second ratio is determined as the scaling ratio.

[0067] If the quadrant parameter is an even number, that is, the quadrant parameter represents the second quadrant or the fourth quadrant, a third ratio of the image width to the container height and a fourth ratio of the image height to the container width are obtained. Continuing with the above embodiment, the third ratio can be recorded as W / CH, and the fourth ratio can be recorded as H / CW.

[0068] The maximum value between the third ratio and the fourth ratio is determined as the scaling ratio. For example, the maximum value is determined from the third ratio and the fourth ratio by the formula Max(W / CH, H / CW), and the maximum value between the third ratio and the fourth ratio is determined as the scaling ratio.

[0069] In the implementation process of the above embodiment: considering that different rotation angles have different quadrant parameters, the scaling ratio is determined according to the quadrant parameters, so that the image can be accurately controlled. And the algorithm for determining the scaling ratio according to the parity of the quadrant parameters improves processing efficiency and saves a lot of time.

[0070] Optionally, in the embodiment of the present application, if the display mode is a rotation display, the image origin coordinates and the display size are determined using the scaling ratio, including:

[0071] The ratio of the image width to the zoom ratio is used as the display width in the display size; continuing with the above embodiment, the zoom ratio is denoted as R, the image width is W, the ratio of the image width to the zoom ratio is W / R, W / R is used as the display width in the display size, and the display width is denoted as RW.

[0072] The ratio of the image height to the zoom ratio is used as the display height in the display size; the image height is H, the ratio of the image height to the zoom ratio is H / R, H / R is used as the display height in the display size, and the display height is recorded as RH.

[0073] A first difference between the container width and the display width is calculated, that is, the first difference is (CW-RW); and a second difference between the container height and the display height is calculated, that is, the second difference is (CH-RH).

[0074] According to the quadrant parameter, the image origin coordinates are determined using the first difference and the second difference. For example, if the quadrant parameter is the first quadrant, the abscissa of the image origin coordinates is half of the first difference, that is, (CW-RW) / 2, and the ordinate of the image origin coordinates is half of the second difference, that is, (CH-RH) / 2. Then, the image origin coordinates can be expressed as ((CW-RW) / 2, (CH-RH) / 2).

[0075] If the quadrant parameter is the second quadrant, the abscissa of the image origin coordinate is half of the second difference, that is, (CH-RH) / 2, and the ordinate of the image origin coordinate is half of the second difference minus the container width, that is, (CW-RW) / 2-CW. The image origin coordinate can be expressed as ((CH-RH) / 2, (CW-RW) / 2-CW.

[0076] If the quadrant parameter is the third quadrant, the abscissa of the image origin coordinate is half of the first difference minus the container width, that is, (CW-RW) / 2-CW, and the ordinate of the image origin coordinate is half of the second difference minus the container height, that is, (CH-RH) / 2-CH. Then, the image origin coordinate can be expressed as ((CW-RW) / 2-CW, (CH-RH) / 2-CH).

[0077] If the quadrant parameter is the fourth quadrant, the abscissa of the image origin coordinate is half of the second difference minus the container height, that is, (CH-RH) / 2-CH, and the ordinate of the image origin coordinate is half of the second difference, that is, (CW-RW) / 2. The image origin coordinate can be expressed as ((CH-RH) / 2-CH, (CW-RW) / 2.

[0078] After determining the image origin coordinates, you can use HTML5 (Hypertext Markup Language) <canvas>Elements are used to draw images, for example, call drawImage(image, startX, startY, RH, RW), where startX refers to the horizontal coordinate of the image origin, startY refers to the vertical coordinate of the image origin, RH represents the display height in the display size, and RW represents the display width in the display size. Then the image is displayed in the container.

[0079] In the implementation process of the above embodiment: the image origin coordinates are a reference point defined in the image coordinate system of the transformed image, that is, the starting point or reference point of image processing. The embodiment of the present application determines the image origin coordinates through quadrant parameters, so that the transformed image drawn at the determined image origin coordinates will not change or block other content of the page, nor will it change the page layout, thereby improving the convenience of page browsing.

[0080] Optionally, in the embodiment of the present application, after determining the image origin coordinates and the display size using the scaling ratio, the method further includes:

[0081] By listening to mouse events, you can get the coordinates of the mouse stop point relative to the container and the amount of mouse wheel rolling. For example, you can add a wheel event listener to the container where you want to listen to the wheel. This listener will be triggered when the mouse wheel rolls inside the container. In the wheel event processing function, you can use the clientX and clientY properties of the MouseEvent object to get the coordinates of the mouse relative to the viewport. Then, combined with the container's boundaries (obtained through the getBoundingClientRect() method), calculate the coordinates of the mouse relative to the container.

[0082] Get the zoom parameter based on the amount of mouse wheel scrolling; for example, you can use the deltaY property of the wheel event to calculate the zoom ratio. The deltaY value represents the distance the wheel scrolls in the vertical direction. You can define a zoom factor based on this value, such as zooming in when the wheel is scrolled up (positive value) and zooming out when it is scrolled down (negative value). Of course, it can also be the opposite, zooming out when the wheel is scrolled up (negative value) and zooming in when it is scrolled down (positive value).

[0083] The scaled image size is obtained according to the display size and the scaling parameter. For example, the display width in the display size is multiplied by the scaling parameter to obtain the width of the scaled image size; the display height in the display size is multiplied by the scaling parameter to obtain the height of the scaled image size.

[0084] Based on the coordinate point of the mouse stop point relative to the container and the scaling parameters, the coordinate system offset is calculated. The coordinate system offset may include a horizontal offset and a vertical offset.

[0085] The lateral offset is recorded as offsetX, offsetX=x*(S-1), where x is the horizontal coordinate of the coordinate point where the mouse stops relative to the container, and S is the scaling parameter.

[0086] The longitudinal offset is recorded as offsetY, offsetY=y*(S-1), where y is the longitudinal coordinate of the coordinate point where the mouse stops relative to the container, and S is the scaling parameter.

[0087] Based on the scaled image size and the coordinate system offset, the scaled image is displayed. For example, you can use HTML5 <canvas>The element draws the image drawImage(-of fsetX, -offsetY, SW, SH), where SW is the width of the scaled image size and SH is the height of the scaled image size. The image is then loaded into the container for display.

[0088] In the implementation process of the above embodiment: by calculating the amount of mouse wheel scrolling to dynamically adjust the zoom ratio, the user can more finely control the degree of image zooming in or out to meet different viewing needs. By calculating the position of the mouse on the image and using it as the zoom origin, a zoom effect centered on the current position of the mouse can be achieved. This effect is more in line with the user's expectations and improves the practicality of the zoom operation.

[0089] See also Figure 2 The structural diagram of the image display device provided in the embodiment of the present application is shown; the embodiment of the present application provides an image display device 200, including:

[0090] An acquisition module 210 is used to acquire the image size of the image, the size of the container displaying the image, and the display mode of the image;

[0091] A scaling ratio determination module 220, for determining a scaling ratio based on a ratio of a container size to an image size according to a display mode of the image;

[0092] A coordinate calculation module 230, for determining the image origin coordinates and display size using a scaling ratio;

[0093] The display module 240 is used to transform the image based on the image origin coordinates and the display size, and display the transformed image.

[0094] Optionally, in an embodiment of the present application, in an image display device, the image size includes image width and image height; the container size includes container width and container height; the display mode includes geometric display; the scaling ratio determination module 220 is further used to obtain a first ratio of the image width to the container width and a second ratio of the image height to the container height when the display mode is geometric display; and the maximum value of the first ratio and the second ratio is determined as the scaling ratio.

[0095] Optionally, in an embodiment of the present application, if the display mode of the image display device is proportional display, the coordinate calculation module 230 is also used to use the ratio of the image width to the scaling ratio as the display width in the display size; use the ratio of the image height to the scaling ratio as the display height in the display size; calculate a first difference between the container width and the display width, and a second difference between the container height and the display height; determine the horizontal coordinate of the image origin coordinate according to the first difference, and determine the vertical coordinate of the image origin coordinate according to the second difference.

[0096] Optionally, in an embodiment of the present application, the image display device includes a display mode of rotational display; the scaling ratio determination module 220 is further used to obtain the rotation angle of the image when the display mode is rotational display; based on the rotation angle, determine the quadrant parameter of the image; and determine the scaling ratio according to the parity of the quadrant parameter, the ratio of the container size and the image size.

[0097] Optionally, in an embodiment of the present application, in an image display device, the image size includes image width and image height; the container size includes container width and container height; the scaling ratio determination module 220 is further used to obtain a first ratio of the image width to the container width and a second ratio of the image height to the container height if the quadrant parameter is an odd number; determine the maximum value of the first ratio and the second ratio as the scaling ratio; if the quadrant parameter is an even number, obtain a third ratio of the image width to the container height; and a fourth ratio of the image height to the container width, and determine the maximum value of the third ratio and the fourth ratio as the scaling ratio.

[0098] Optionally, in an embodiment of the present application, if the display mode of the image display device is a rotated display, the coordinate calculation module 230 is also used to use the ratio of the image width to the zoom ratio as the display width in the display size; use the ratio of the image height to the zoom ratio as the display height in the display size; calculate the first difference between the container width and the display width, and the second difference between the container height and the display height, and determine the coordinates of the image origin using the first difference and the second difference according to the quadrant parameter.

[0099] Optionally, in an embodiment of the present application, the image display device also includes: an image zoom module, which is used to obtain the coordinate point of the mouse resting point relative to the container and the mouse wheel scrolling amount by monitoring mouse events; obtain the zoom parameter according to the mouse wheel scrolling amount; obtain the zoomed image size according to the display size and the zoom parameter; calculate the coordinate system offset based on the coordinate point of the mouse resting point relative to the container and the zoom parameter; and display the zoomed image based on the zoomed image size and the coordinate system offset.

[0100] It should be understood that the device corresponds to the above-mentioned image display method embodiment and can execute the various steps involved in the above-mentioned method embodiment. The specific functions of the device can be referred to in the above description. To avoid repetition, the detailed description is appropriately omitted here. The device includes at least one software function module that can be stored in a memory in the form of software or firmware or solidified in the operating system (OS) of the device.

[0101] See also Figure 3 The electronic device 300 provided in the embodiment of the present application includes: a processor 310 and a memory 320, wherein the memory 320 stores machine-readable instructions executable by the processor 310, and when the machine-readable instructions are executed by the processor 310, the above method is executed.

[0102] An embodiment of the present application further provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the above method is executed.

[0103] Among them, the storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Red-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic storage, flash memory, disk or optical disk.

[0104] In several embodiments provided by the embodiments of the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a part of the module, program segment or code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0105] In addition, the functional modules in each embodiment of the present application can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part.

[0106] The above description is only an optional implementation manner of the embodiments of the present application, but the protection scope of the embodiments of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or replacements within the technical scope disclosed in the embodiments of the present application, which should be covered within the protection scope of the embodiments of the present application.< / canvas> < / canvas> < / canvas>

Claims

1. An image display method, characterized in that: include: Obtaining an image size of an image, a container size for displaying the image, and a display mode of the image; Determining a scaling ratio based on a ratio of a size of the container to a size of the image according to a display mode of the image; Determine the image origin coordinates and display size using the scaling ratio; Based on the image origin coordinates and the display size, the image is transformed and the transformed image is displayed.

2. The method according to claim 1, characterized in that: The image size includes an image width and an image height; the container size includes a container width and a container height; the display mode includes proportional display; and the determining of the scaling ratio based on the ratio of the container size to the image size according to the display mode of the image includes: When the display mode is proportional display, a first ratio of the image width to the container width and a second ratio of the image height to the container height are obtained; A maximum value between the first ratio and the second ratio is determined as the scaling ratio.

3. The method according to claim 2, characterized in that If the display mode is proportional display, the image origin coordinates and display size are determined using the scaling ratio, including: using a ratio of the image width to the scaling ratio as a display width in the display size; Using the ratio of the image height to the scaling ratio as the display height in the display size; Calculating a first difference between the container width and the display width, and a second difference between the container height and the display height; The horizontal coordinate of the image origin coordinate is determined according to the first difference value, and the vertical coordinate of the image origin coordinate is determined according to the second difference value.

4. The method according to claim 1, characterized in that: The display mode includes rotation display; and the determining of the scaling ratio based on the ratio of the container size to the image size according to the display mode of the image includes: When the display mode is a rotation display, obtaining a rotation angle of the image; Based on the rotation angle, determining the quadrant parameter of the image; A scaling ratio is determined according to the parity of the quadrant parameter, the ratio of the container size and the image size.

5. The method according to claim 4, characterized in that The image size includes an image width and an image height; the container size includes a container width and a container height; and the scaling ratio is determined according to the parity of the quadrant parameter, the ratio of the container size and the image size, including: If the quadrant parameter is an odd number, obtaining a first ratio of the image width to the container width and a second ratio of the image height to the container height; and determining the maximum value of the first ratio and the second ratio as the scaling ratio; If the quadrant parameter is an even number, a third ratio of the image width to the container height and a fourth ratio of the image height to the container width are obtained, and a maximum value of the third ratio and the fourth ratio is determined as the scaling ratio.

6. The method according to claim 4, characterized in that If the display mode is a rotation display, the image origin coordinates and the display size are determined using the scaling ratio, including: using a ratio of the image width to the scaling ratio as a display width in the display size; Using the ratio of the image height to the scaling ratio as the display height in the display size; Calculating a first difference between the container width and the display width, and a second difference between the container height and the display height, The image origin coordinates are determined according to the quadrant parameter using the first difference value and the second difference value.

7. The method according to any one of claims 1 to 6, characterized in that: After determining the image origin coordinates and display size using the scaling ratio, the method further includes: By monitoring mouse events, the coordinates of the mouse stop point relative to the container and the scrolling amount of the mouse wheel are obtained; Obtaining a zoom parameter according to the scrolling amount of the mouse wheel; According to the display size and the scaling parameter, obtaining the scaled image size; Calculate the coordinate system offset based on the coordinate point of the mouse stop point relative to the container and the scaling parameter; The scaled image is displayed based on the scaled image size and the coordinate system offset.

8. A computer program product, characterized in that The method comprises computer program instructions, and when the computer program instructions are executed by a processor, the method according to any one of claims 1 to 7 is executed.

9. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores computer program instructions, and when the computer program instructions are executed by the processor, the method according to any one of claims 1 to 7 is executed.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the method according to any one of claims 1 to 7 is executed.

Citation Information

Patent Citations

  • Canvas zoom-in and zoom-out offset control method and canvas redrawing method of WEB end

    CN114706508A

  • Gravity center track drawing method and device, electronic equipment and storage medium

    CN115797499A

  • Graphic code display method and device, electronic equipment and storage medium

    CN116228533A

  • Automatic identification photo correction method

    CN117710640A