Screenshot method, device, electronic device and computer program product
By obtaining the pixel coordinate information of the map overlay and dividing it into rectangular sub-regions, the problem of incomplete screenshots when the map overlay is large is solved, and the effect of obtaining a complete image on a map of any zoom level and size is achieved.
Patent Information
- Application Number
- CN202210399737.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-15
- Publication Date
- 2025-01-03
- Estimated Expiration
- 2042-04-15
AI Technical Summary
The existing screenshot method cannot obtain the complete image of the map overlay when the map overlay is large. The map zoom level needs to be adjusted to load the undisplayed part, resulting in the inability to obtain the complete image in one screenshot.
By obtaining the pixel coordinate information of the target rectangular area in the target map, it is divided into a set of rectangular sub-regions, and the images of each rectangular sub-regions are obtained separately for stitching to form a complete image.
It realizes the acquisition of a complete image of the rectangular area of the map covering on a map of any zoom level and size, avoiding map performance problems and incomplete screenshots.
Smart Images

Figure CN114841857B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a screenshot method, device and computer program product. Background Art
[0002] In order to enrich the displayed content of the map, various map overlays can be added to the map, such as polygons, point markers, text markers, image markers, etc. When the user needs to save or share the map overlay and the map base map background with other users, the image of the area where the map overlay is located can be obtained by taking a screenshot.
[0003] However, the existing screenshot method can only take a screenshot of the content currently displayed on the map. When the rectangular area covered by the map overlay is large, in order to fully display the map content within the rectangular area, the zoom level of the map needs to be adjusted. At this time, the undisplayed part of the map overlay needs to be loaded. Otherwise, the map overlay cannot be fully displayed within the map field of view, and the complete image of the map overlay cannot be obtained through a single screenshot operation. Summary of the invention
[0004] The object of the present invention is to provide a screenshot method, device and computer program product for solving the problem that when the map overlay is large, it is impossible to obtain a complete image of the map overlay.
[0005] The present invention provides a screenshot method, comprising:
[0006] Obtain first pixel coordinate information of a target rectangular area in a target map, wherein the first pixel coordinate information is used to indicate a relative position and a coverage range of a target overlay on the target map; divide the target rectangular area into regions based on the viewport information of the target map and the first pixel coordinate information to obtain a set of rectangular sub-regions; obtain a first image of each rectangular sub-region in the set of rectangular sub-regions, and stitch the first image of each rectangular sub-region into a second image; wherein the area displayed by the viewport of the target map is smaller than the coverage range of the target overlay; and the second image includes the display content of the target rectangular area.
[0007] Optionally, before obtaining the first pixel coordinate information of the target rectangular area in the target map, the method further includes: drawing the target overlay on the target map, and adjusting the zoom level of the target overlay based on the target information; wherein the target information includes at least one of the following: the content contained in the target overlay, and the zoom level of the target map.
[0008] Optionally, after obtaining the first pixel coordinate information of the target rectangular area in the target map, the method further includes: determining the second pixel coordinate information of the target feature point based on the first pixel coordinate information, the target feature point being any vertex of the target rectangular area; obtaining the size information of the target map, and adjusting the center point of the target map based on the size information of the target map and the second pixel coordinate information; wherein the adjusted target map has the target feature point as a rectangular vertex.
[0009] Optionally, after obtaining the size information of the target map and adjusting the center point of the target map based on the size information of the target map and the second pixel coordinate information, the method further includes: updating the first pixel coordinate information based on the adjusted target map; dividing the target rectangular area based on the viewport information of the target map and the first pixel coordinate information to obtain a set of rectangular sub-areas, including: dividing the target rectangular area based on the viewport information of the target map and the updated first pixel coordinate information to obtain a set of rectangular sub-areas.
[0010] Optionally, obtaining the first image of each rectangular sub-region in the set of rectangular sub-regions includes: taking the target feature point as the starting point and the rectangular side length of the rectangular sub-region as the offset, adjusting the viewport of the target map, and obtaining the display content of the viewport of the target map after each adjustment; wherein the size of each rectangular sub-region in the set of rectangular sub-regions is less than or equal to the size of the rectangular area that can be displayed by the viewport of the target map.
[0011] The present invention also provides a screenshot device, comprising:
[0012] An acquisition module is used to acquire first pixel coordinate information of a target rectangular area in a target map, wherein the first pixel coordinate information is used to indicate a relative position and coverage of a target cover on the target map; a division module is used to divide the target rectangular area into regions based on viewport information of the target map and the first pixel coordinate information to obtain a set of rectangular sub-regions; an image processing module is used to acquire a first image of each rectangular sub-region in the set of rectangular sub-regions, and to stitch the first image of each rectangular sub-region into a second image; wherein the area displayed by the viewport of the target map is smaller than the coverage of the target cover; and the second image includes the display content of the target rectangular area.
[0013] Optionally, the device further includes: an adjustment module; the adjustment module is used to draw the target overlay on the target map and adjust the zoom level of the target overlay based on target information; wherein the target information includes at least one of the following: content contained in the target overlay, and the zoom level of the target map.
[0014] Optionally, the device also includes: a determination module and an adjustment module; the determination module is used to determine the second pixel coordinate information of the target feature point based on the first pixel coordinate information, wherein the target feature point is any vertex of the target rectangular area; the adjustment module is used to obtain the size information of the target map, and adjust the center point of the target map based on the size information of the target map and the second pixel coordinate information; wherein the adjusted target map uses the target feature point as a rectangular vertex.
[0015] Optionally, the adjustment module is also used to update the first pixel coordinate information based on the adjusted target map; the division module is specifically used to divide the target rectangular area into regions based on the viewport information of the target map and the updated first pixel coordinate information to obtain a set of rectangular sub-regions.
[0016] Optionally, the image processing module is specifically used to adjust the viewport of the target map with the target feature point as the starting point and the rectangular side length of the rectangular sub-area as the offset, and obtain the display content of the viewport of the target map after each adjustment as the first image; wherein the size of each rectangular sub-area in the rectangular area set is less than or equal to the size of the rectangular area that can be displayed by the viewport of the target map.
[0017] The present invention also provides a computer program product, comprising a computer program / instruction, which implements the steps of any of the above-mentioned screenshot methods when executed by a processor.
[0018] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any of the above-mentioned screenshot methods are implemented.
[0019] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above-mentioned screenshot methods are implemented.
[0020] The screenshot method and device provided by the present invention, after obtaining the first pixel coordinate information of the target rectangular area in the target map, divides the target rectangular area into a set of rectangular sub-areas based on the viewport information of the target map and the first pixel coordinate information. Afterwards, the first image of each rectangular sub-area is obtained, and the obtained multiple first images are image stitched to obtain a second image containing the display content of the target rectangular area, so that a complete image of the rectangular area covered by a map overlay of any size on a map of any zoom level can be obtained. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0022] Figure 1 (A) and Figure 1 (B) is a rendering of a captured map overlay provided by the present invention;
[0023] Figure 2 This is one of the flowcharts of the screenshot method provided by the present invention;
[0024] Figure 3 This is the second flow chart of the screenshot method provided by the present invention;
[0025] Figure 4 It is a structural schematic diagram of the screenshot device provided by the present invention;
[0026] Figure 5 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0027] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0028] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0029] In the scenario of obtaining an image of a map overlay, in the related art, an image of the area where the map overlay is located can be obtained by using a screenshot tool or a webpage screenshot. Figure 1 As shown in (A), the screenshot tool can obtain an image of the currently displayed content, such as Figure 1 As shown in (B), if the coverage of the map overlay (the area shown by the black box in the figure is the map overlay) is large and exceeds the viewport (current visible area of the map), the screenshot tool cannot take screenshots of the content outside the display range of the map viewport. For webpage screenshots, although the currently loaded content of the entire webpage can be obtained, the content displayed on the map at different zoom levels is different (the larger the zoom level, the more detailed the content displayed). When the map overlay is large, in order to obtain the image of the map overlay and the detailed content of the map in the rectangular area covered by the map overlay at the same time, the map size needs to be set very large. At this time, performance problems will occur when loading the map, and it cannot be displayed correctly, and thus the complete image of the rectangular area covered by the map overlay cannot be obtained.
[0030] In order to solve the above problem, in the technical solution provided by the embodiment of the present invention, the rectangular area covered by the map overlay can be divided into multiple smaller areas, the map content of each small area is loaded separately, and each loaded area is screenshotted, and then the images of the multiple different areas are spliced to obtain a complete image of the rectangular area. The technical solution provided by the embodiment of the present invention can cope with map overlays of various sizes and different zoom levels of the map.
[0031] The screenshot method provided by the embodiment of the present invention is described in detail below through specific embodiments and application scenarios in conjunction with the accompanying drawings.
[0032] like Figure 2 As shown, an embodiment of the present invention provides a screenshot sharing method, which may include the following steps 201 to 203:
[0033] Step 201: Obtain first pixel coordinate information of a target rectangular area in a target map.
[0034] The first pixel coordinate information is used to indicate the relative position and coverage of the target coverage on the target map.
[0035] Exemplarily, the target map is a map loaded by an electronic device, which may be map content loaded by a browser or map content loaded by a map interface called by a third-party application.
[0036] It is understandable that, when the target overlay is displayed on the map, the pixel information of each pixel of the target rectangular area covered by the target overlay can be obtained by converting the longitude and latitude coordinates of the pixel point on the target map. That is, any content displayed on the map includes pixel coordinates and longitude and latitude coordinates, and pixel coordinates and longitude and latitude coordinates can be converted to each other.
[0037] Exemplarily, the first pixel coordinate information of the target rectangular area may be obtained from the latitude and longitude coordinate information of the target rectangular area on the target map.
[0038] Exemplarily, the first pixel coordinate information may include pixel coordinates of rectangular vertices of the target rectangular area. The coverage range of the target rectangular area and relative position information on the map may be obtained through the pixel coordinates of the four rectangular vertices.
[0039] Step 202: Based on the viewport information and the first pixel coordinate information of the target map, the target rectangular area is divided into regions to obtain a set of rectangular sub-regions.
[0040] The area displayed by the viewport of the target map is smaller than the coverage of the target covering.
[0041] It should be noted that the viewport of the target map can be understood as the current display area of the target map on the electronic device. It is understandable that, since only the image displayed by the current viewport of the target map is captured when taking a screenshot, when the size of the target rectangular area is larger than the viewport size of the target map, the target rectangular area needs to be divided into logical areas according to the viewport size of the target map, and each screenshot only captures the image of one of the areas.
[0042] For example, the size of the current visible area of the target map and the size of the target rectangular area can be obtained according to the viewport information and the first pixel coordinate information of the target map. Afterwards, the target rectangular area can be divided into regions according to the sizes of the above two regions, and the divided regions can be screenshotted respectively, thereby obtaining a complete screenshot of the target rectangular area.
[0043] It should be noted that, in the embodiment of the present invention, the sizes of various regions are pixel sizes, that is, the number of pixels occupied by the length and width of the region.
[0044] Step 203: Acquire a first image of each rectangular sub-region in the set of rectangular sub-regions, and stitch the first image of each rectangular sub-region into a second image.
[0045] The second image includes the display content of the target rectangular area.
[0046] Exemplarily, the above-mentioned rectangular sub-region set includes multiple rectangular sub-regions. After dividing the target rectangular region into multiple rectangular regions, each rectangular sub-region is screenshotted respectively to obtain a first image of each of the multiple rectangular sub-regions. Thereafter, the multiple first images are spliced to obtain a complete image of the target rectangular region.
[0047] It should be noted that the method for obtaining the first image of each rectangular sub-area in the above-mentioned set of rectangular sub-areas can be to obtain the image within the viewport range of the target map by identifying the map viewport, or to obtain the image of the above-mentioned rectangular sub-area by other methods. For example, the first image of each rectangular sub-area in the above-mentioned set of rectangular areas can be obtained by the html2canvas tool.
[0048] For example, Figure 3 As shown, it is a flow chart of the screenshot method provided by an embodiment of the present invention, wherein the target rectangular area 31 covered by the target overlay can be divided into 6 rectangular areas according to the size of the viewport 32 of the target map, and the electronic device can obtain the images of the above 6 rectangular areas respectively by moving the viewport of the target map to obtain 6 images (images a, b, c, d, e, f), and then, splice the above 6 images to obtain a complete image of the target rectangular area 31.
[0049] The screenshot method provided by the embodiment of the present invention, after obtaining the first pixel coordinate information of the target rectangular area in the target map, divides the target rectangular area into a set of rectangular sub-areas based on the viewport information of the target map and the first pixel coordinate information. Afterwards, the first image of each rectangular sub-area is obtained, and the obtained multiple first images are image stitched to obtain a second image containing the display content of the target rectangular area, so that a complete image of the rectangular area covered by a map overlay of any size on a map of any zoom level can be obtained.
[0050] Optionally, in the embodiment of the present invention, in order to facilitate the division of the target rectangular area and reduce the amount of calculation of the electronic device, before obtaining the first pixel coordinate information of the target rectangular area in the above step 201, the screenshot method provided by the embodiment of the present invention may further include the following step 204:
[0051] Step 204: Draw a target overlay on the target map, and adjust the zoom level of the target overlay based on the target information.
[0052] The target information includes at least one of the following: the content included in the target overlay, and the zoom level of the target map.
[0053] For example, the target overlay drawn on the target map cannot be too large, otherwise it will not only increase the area of the rectangular area of the overlay map, but also increase the computational complexity of the electronic device. Therefore, after drawing the target overlay on the target map, the zoom level of the target overlay needs to be adjusted according to the target information.
[0054] It is understandable that when the zoom level of the target map meets the user's needs for map display content, the zoom level of the target overlay can be adjusted according to the zoom level of the target map to make the display effects of the two more coordinated. At the same time, the zoom level of the target overlay can also be adjusted according to the content contained in the target overlay. For example, when the target overlay contains less content, the zoom level of the target overlay can be appropriately reduced (the smaller the zoom level, the simpler the displayed content), otherwise, the zoom level of the target overlay can be appropriately increased.
[0055] The screenshot method provided by the present invention can adjust the zoom level of the target overlay according to the content contained in the target overlay and / or the zoom level of the target map after drawing the target overlay on the target map, so as to reduce the calculation amount when the electronic device takes screenshots and improve the screenshot efficiency.
[0056] Optionally, in the embodiment of the present invention, in order to conveniently obtain the first image of each rectangular sub-region in the above set of rectangular sub-regions, after the above step 201, the screenshot method provided by the embodiment of the present invention may further include the following steps 205 and 206:
[0057] Step 205: Determine the second pixel coordinate information of the target feature point based on the first pixel coordinate information.
[0058] The target feature point is any vertex of the target rectangular area.
[0059] Exemplarily, after obtaining the above-mentioned first pixel coordinate information, the pixel coordinates of any vertex of the target rectangular area can be determined according to the first pixel coordinate information. The any vertex can be any of the four vertices of the upper left corner, lower left corner, upper right corner or lower right corner of the target rectangular area.
[0060] Step 206: Obtain the size information of the target map, and adjust the center point of the target map based on the size information of the target map and the second pixel coordinate information.
[0061] The adjusted target map uses the target feature points as rectangular vertices.
[0062] It should be noted that the pixel coordinates of each pixel point of the target map are obtained based on the center point of the target map.
[0063] Exemplarily, taking the target feature point as the upper left corner vertex of the target rectangular area, after obtaining the pixel coordinates of the target feature point, the center point of the target map is adjusted with the target feature point as the vertex, and the pixel coordinates of the target feature point on the adjusted target map are (0,0).
[0064] For example, taking the method of obtaining the first image of each rectangular sub-region in the above set of rectangular sub-regions by using the html2canvas tool as an example, before obtaining the first image by using the html2canvas tool, the following steps a1 to a6 may be followed:
[0065] Step a1: Initialize the target map and set the width mapw and height maph of the map size.
[0066] For example, the map size can be set to 1000px*1000px. After setting the map size of the target map, the pixel coordinates of any position on the target map can be obtained.
[0067] Step a2: Draw a target overlay on the target map, and adjust the zoom level of the target overlay according to the target information.
[0068] Step a3: Calculate the width and height of the target rectangular area covered by the target covering object.
[0069] For example, if there is one target covering object and the target covering object has a getBounds method, the getBounds method is called to obtain the longitude and latitude coordinates of the rectangular area covered by the target covering object. Otherwise, the getPath or getPosition method is called to obtain the set of geographic coordinate points constituting the target covering object.
[0070] If the target cover includes multiple covers, traverse the cover set and call the getPath or getPosition method to obtain the longitude and latitude coordinate point set of all covers. Then, use the longitude and latitude coordinate point set to create a polygon object, and use the above method to obtain the longitude and latitude coordinates of the rectangular area covered by each cover.
[0071] It should be noted that, for ease of understanding, the embodiment of the present invention is explained with respect to one covering. When the target covering includes multiple coverings, the image of each covering is acquired according to the screenshot method of one covering.
[0072] Step a4, after obtaining the latitude and longitude coordinates of the vertices of the target rectangular area, convert the latitude and longitude coordinates of each vertex into pixel coordinates through the pointToPixel method, and calculate the size of the target rectangular area. For example, the width of the target rectangular area is rectw, and the height is recth. If you want the final second image to include an outer border, you can set the outer margin, in this case, rectw = rectw + magrin * 2, recth = recth + margin * 2.
[0073] Step a5: adjust the center point of the target map according to mapw and maph in step a1 and the coordinates (x1, y1) of the upper left corner vertex of the target rectangular area (ie, the above-mentioned target feature point).
[0074] It can be understood that the pixel coordinates of the above target feature points are obtained based on the initialized target map. When the center point of the target map is adjusted, the pixel coordinates of the target feature points will also change accordingly.
[0075] If you want to adjust the center point of the target map, you need to set a new center point for the target map. The pixel coordinates of the new center point are (x1+mapw / 2, y1+maph / 2). If you want the final image to have an outer border, you can set the outer margin. The pixel coordinates of the center point are (x1+mapw / 2-margin, y1+maph / 2-margin). After obtaining the pixel coordinates of the new center point, use the pixelToPoint method to convert the pixel coordinates of the new center point into longitude and latitude coordinates, and use the setCenter method to set the longitude and latitude coordinates as the new center point of the target map.
[0076] In order to facilitate calculation, the screenshot method provided by the present invention can use the target feature point as the vertex of the target map, and adjust the center point of the target map so that the pixel coordinates of the target feature point on the adjusted target map are zero.
[0077] Further optionally, in an embodiment of the present invention, after obtaining the size information of the target map and adjusting the center point of the target map based on the size information of the target map and the second pixel coordinate information, the pixel coordinate information of the target rectangular area may be updated based on the adjusted target map.
[0078] Exemplarily, after the above step 206, the screenshot method provided by the embodiment of the present invention may further include the following step 207:
[0079] Step 207: Update the first pixel coordinate information based on the adjusted target map.
[0080] Exemplarily, the above step 202 may specifically include the following steps 202a:
[0081] Step 202a: based on the viewport information of the target map and the updated first pixel coordinate information, the target rectangular area is divided into regions to obtain a set of rectangular sub-regions.
[0082] It is understandable that after the center point of the target map is adjusted, if the target rectangular area is still divided according to the original first pixel coordinate information, the division will be confused, and the generated second image does not include all the contents displayed by the target rectangular area.
[0083] The screenshot method provided by the present invention updates the first pixel coordinate information of the target rectangular area after adjusting the center point of the target map, thereby avoiding the situation where the screenshot is incomplete.
[0084] Further optionally, after dividing the target rectangular area into regions, the above step 203 may specifically obtain the first image of each rectangular sub-region according to the method shown in step 203a:
[0085] Step 203a: taking the target feature point as the starting point and the rectangular side length of the rectangular sub-region as the offset, adjusting the viewport of the target map, and obtaining the display content of the viewport of the target map after each adjustment as the first image.
[0086] The size of each rectangular sub-region in the above set of rectangular sub-regions is smaller than or equal to the size of the rectangular region that can be displayed by the viewport of the target map.
[0087] It is understandable that, combined with Figure 3 The electronic device takes the target feature point in the upper left corner as the starting point, captures the image of the content displayed in the current map viewport, then moves the map viewport, adjusts to the next rectangular area, and captures the image again, thus traversing each rectangular sub-area in the above rectangular sub-area set. Then, the multiple first images obtained are stitched together to obtain a complete image of the target rectangular area.
[0088] It is understandable that the electronic device can only load the map content of the target rectangular area, or the map content within the target map viewport, without having to first load all the content that needs to be screenshotted as in the traditional screenshot method.
[0089] For example, taking the use of the html2canvas tool to obtain the first image of each rectangular sub-region in the above set of rectangular sub-regions as an example, when the html2canvas tool is used to obtain the first image, the following steps b1 to b6 may be followed:
[0090] Step b1, define variables x=0, y=0, isEndX=false, isEndY=false, canvasGroup=[], and the cropping area size is shotsize*shotsize. The width and height of the cropping area can be different, but they are the same for easier calculation. The cropping area size can also be set according to the size of the viewport of the target map.
[0091] Step b2: Use a timer to perform polling (such as setInterval) and obtain a collection array canvasGroup containing multiple first images. The polling content includes:
[0092] Define variables width = shotsize, height = shotsize. If x + shotsize > = rectw, set width = rectw-x, isEndX = true, indicating that the screenshot area is the rightmost side of the rectangular area. If y + shotsize > = recth, set height = recth-y, isEndY = true, indicating that the screenshot area is the bottommost side of the rectangular area. Use html2canvas to take screenshots of map DOM elements. Get the canvas object in the callback function of html2canvas, and store the {x, y, width, height, canvas} object as a child element in the canvasGroup array. To get the screenshot progress, calculate the ratio of the number of screenshots to the total number of screenshots required, and update the screenshot progress percentage. If isEndX == false, use the panBy() method of the map instance to move the map to the left by the distance of shotsize, and set x = x + width to end this polling.
[0093] If isEndX==true and isEndY==false, use the panBy method of the map instance to move the map to the left by the distance of rectw-width, that is, back to the initial left, move it upward by the distance of shotsize, and set y=y+height, x=0, isEndX=false, indicating that the screenshot starts from left to right again. End this polling.
[0094] If isEndX==true and isEndY==true, it means that the screenshot of the entire rectangular area is completed, and the timer is cleared at this time.
[0095] Step b3: Create a new canvas object and define the variable canvas.
[0096] canvas = document.createElement('canvas'). Set the width of canvas to rectw*window.devicePixelRatio and the height to recth*window.devicePixelRatio. Use canvas.getContext('2d') to get the ctx object.
[0097] Set ctx.scale(window.devicePixelRatio,window.devicePixelRatio) to ensure the clarity of the composite image on the HD screen.
[0098] If you need to add additional information to the canvas, such as adding a picture description at the top, the display height is titleh.
[0099] Set the width of the canvas to (rectw+infoh)*window.devicePixelRatio. Use fillText and other methods of the ctx object to draw the description information to be displayed on the canvas. Traverse the image cropping collection canvasGroup, the traversal item is item, and draw the traversed canvas object on the canvas.
[0100] Depending on the added content, you can execute the following different methods: ctx.drawImage(item.canvas,item.x,item.y,item.width,item.height), or ctx.drawImage(item.canvas,item.x,item.y+titleh,item.width,item.height).
[0101] Step b4, download the generated image according to the following process.
[0102] Create an a element defined as a link: document.createElement("a"). Execute canvas.toDataURL("image / jpeg",1) on the obtained canvas object to get the dataURI containing the image display, set it as the href of the link, set the download of the link to the file name 'xxx.jpg', and set the display of the link to none.
[0103] Execute document.body.appendChild(link) to insert the link into the document. Then execute link.click() to download the image.
[0104] Finally, execute document.body.removeChild(link) to remove link from the document.
[0105] The screenshot method provided by the present invention obtains the first image of each rectangular sub-area in the above-mentioned rectangular sub-area set by moving the viewport of the target map, so that the electronic device does not need to load too much map content at the same time, and can adapt to maps of various zoom levels and map overlays of various sizes.
[0106] It should be noted that the screenshot method provided in the embodiment of the present invention can be executed by a screenshot device or a control module in the screenshot device for executing the screenshot method. The screenshot device provided in the embodiment of the present invention is described by taking the screenshot device executing the screenshot method as an example.
[0107] It should be noted that, in the embodiments of the present invention, the screenshot methods shown in the above-mentioned method drawings are all illustrated by combining one of the drawings in the embodiments of the present invention as an example. In specific implementation, the screenshot methods shown in the above-mentioned method drawings can also be implemented in combination with any other drawings that can be combined as shown in the above-mentioned embodiments, which will not be repeated here.
[0108] The present invention is described below, and the screenshot method described below and the screenshot method described above can be referenced to each other.
[0109] Figure 4 A schematic diagram of the structure of a screenshot device provided by an embodiment of the present invention is shown as follows: Figure 4 As shown, specifically including:
[0110] An acquisition module 401, a division module 402 and an image processing module 403; the acquisition module 401 is used to acquire the first pixel coordinate information of the target rectangular area in the target map, the first pixel coordinate information is used to indicate the relative position and coverage of the target cover on the target map; the division module 402 is used to divide the target rectangular area into regions based on the viewport information of the target map and the first pixel coordinate information to obtain a set of rectangular sub-regions; the image processing module 403 is used to acquire the first image of each rectangular sub-region in the set of rectangular sub-regions, and stitch the first image of each rectangular sub-region into a second image; wherein the area displayed by the viewport of the target map is smaller than the coverage of the target cover; the second image includes the display content of the target rectangular area.
[0111] The screenshot device provided by the embodiment of the present invention, after obtaining the first pixel coordinate information of the target rectangular area in the target map, divides the target rectangular area into a set of rectangular sub-areas based on the viewport information of the target map and the first pixel coordinate information. After that, the first image of each rectangular sub-area is obtained, and the obtained multiple first images are image stitched to obtain a second image containing the display content of the target rectangular area, so that a complete image of the rectangular area covered by a map overlay of any size on a map of any zoom level can be obtained.
[0112] Optionally, the device further includes: an adjustment module 404; the adjustment module 404 is used to draw a target overlay on the target map and adjust the zoom level of the target overlay based on the target information; wherein the target information includes at least one of the following: content included in the target overlay, and the zoom level of the target map.
[0113] The screenshot device provided by the present invention can adjust the zoom level of the target overlay according to the content contained in the target overlay and / or the zoom level of the target map after drawing the target overlay on the target map, so as to reduce the calculation amount when the electronic device takes screenshots and improve the screenshot efficiency.
[0114] Optionally, the device also includes: a determination module 405; the determination module 405 is used to determine the second pixel coordinate information of the target feature point based on the first pixel coordinate information, and the target feature point is any vertex of the target rectangular area; an adjustment module 404 is used to obtain the size information of the target map, and adjust the center point of the target map based on the size information of the target map and the second pixel coordinate information; wherein the adjusted target map has the target feature point as a rectangular vertex.
[0115] For the convenience of calculation, the screenshot device provided by the present invention can use the target feature point as the vertex of the target map and adjust the center point of the target map so that the pixel coordinates of the target feature point on the adjusted target map are zero.
[0116] Optionally, the adjustment module 404 is further used to update the first pixel coordinate information based on the adjusted target map; the division module 402 is specifically used to divide the target rectangular area into regions based on the viewport information of the target map and the updated first pixel coordinate information to obtain a set of rectangular sub-regions.
[0117] The screenshot device provided by the present invention updates the first pixel coordinate information of the target rectangular area after adjusting the center point of the target map, thereby avoiding the situation where the screenshot is incomplete.
[0118] Optionally, the image processing module 403 is specifically used to adjust the viewport of the target map with the target feature point as the starting point and the rectangular side length of the rectangular sub-area as the offset, and obtain the display content of the viewport of the target map after each adjustment; wherein the size of each rectangular sub-area in the rectangular sub-area set is less than or equal to the size of the rectangular area that can be displayed by the viewport of the target map.
[0119] The screenshot device provided by the present invention obtains the first image of each rectangular sub-area in the above-mentioned rectangular sub-area set by moving the viewport of the target map, so that the electronic device does not need to load too much map content at the same time, and can adapt to maps of various zoom levels and map overlays of various sizes.
[0120] Figure 5 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530 and a communication bus 540, wherein the processor 510, the communication interface 520 and the memory 530 communicate with each other through the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the screenshot method, which includes: obtaining the first pixel coordinate information of the target rectangular area in the target map, wherein the first pixel coordinate information is used to indicate the relative position and coverage of the target cover on the target map; based on the viewport information of the target map and the first pixel coordinate information, the target rectangular area is divided into regions to obtain a set of rectangular sub-regions; obtaining the first image of each rectangular sub-region in the set of rectangular sub-regions, and splicing the first image of each rectangular sub-region into a second image; wherein the area displayed by the viewport of the target map is smaller than the coverage of the target cover; the second image includes the display content of the target rectangular area.
[0121] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0122] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the screenshot method provided by the above-mentioned methods, and the method includes: obtaining first pixel coordinate information of a target rectangular area in a target map, wherein the first pixel coordinate information is used to indicate the relative position and coverage of a target overlay on the target map; based on the viewport information of the target map and the first pixel coordinate information, dividing the target rectangular area into a set of rectangular sub-areas; obtaining a first image of each rectangular sub-area in the set of rectangular sub-areas, and splicing the first image of each rectangular sub-area into a second image; wherein the area displayed by the viewport of the target map is smaller than the coverage of the target overlay; the second image includes the display content of the target rectangular area.
[0123] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the processor executes the above-mentioned screenshot methods, the method comprising: obtaining first pixel coordinate information of a target rectangular area in a target map, wherein the first pixel coordinate information is used to indicate the relative position and coverage of a target overlay on the target map; dividing the target rectangular area into regions based on the viewport information of the target map and the first pixel coordinate information to obtain a set of rectangular sub-regions; obtaining a first image of each rectangular sub-region in the set of rectangular sub-regions, and splicing the first image of each rectangular sub-region into a second image; wherein the area displayed by the viewport of the target map is smaller than the coverage of the target overlay; and the second image includes the display content of the target rectangular area.
[0124] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0125] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0126] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A screenshot method, characterized in that: include: Acquire first pixel coordinate information of a target rectangular area in a target map, wherein the first pixel coordinate information is used to indicate a relative position and a coverage range of a target covering object on the target map; Based on the viewport information of the target map and the first pixel coordinate information, the target rectangular area is divided into regions to obtain a set of rectangular sub-regions; Acquire a first image of each rectangular sub-region in the set of rectangular sub-regions, and stitch the first image of each rectangular sub-region into a second image; The area displayed by the viewport of the target map is smaller than the coverage of the target cover; the second image includes the display content of the target rectangular area; After obtaining the first pixel coordinate information of the target rectangular area in the target map, the method further includes: Based on the first pixel coordinate information, determine the second pixel coordinate information of the target feature point, wherein the target feature point is any vertex of the target rectangular area; Acquire the size information of the target map, and adjust the center point of the target map based on the size information of the target map and the second pixel coordinate information; Based on the adjusted target map, updating the first pixel coordinate information; The adjusted target map uses the target feature points as rectangular vertices.
2. The method according to claim 1, characterized in that Before obtaining the first pixel coordinate information of the target rectangular area in the target map, the method further includes: Drawing the target overlay on the target map, and adjusting a zoom level of the target overlay based on target information; The target information includes at least one of the following: the content included in the target overlay, and the zoom level of the target map.
3. The method according to claim 1, characterized in that The step of dividing the target rectangular area based on the viewport information of the target map and the first pixel coordinate information to obtain a set of rectangular sub-areas includes: Based on the viewport information of the target map and the updated first pixel coordinate information, the target rectangular area is divided into regions to obtain a set of rectangular sub-regions.
4. The method according to claim 3, characterized in that The acquiring the first image of each rectangular sub-region in the set of rectangular sub-regions comprises: Taking the target feature point as a starting point and the rectangular side length of the rectangular sub-region as an offset, adjusting the viewport of the target map, and acquiring the display content of the viewport of the target map after each adjustment as a first image; Wherein, the size of each rectangular sub-region in the collection of rectangular sub-regions is smaller than or equal to the size of the rectangular region that can be displayed by the viewport of the target map.
5. A screenshot device, characterized in that: The device comprises: An acquisition module, used for acquiring first pixel coordinate information of a target rectangular area in a target map, wherein the first pixel coordinate information is used for indicating a relative position and a coverage range of a target covering object on the target map; A division module, configured to divide the target rectangular area into regions based on the viewport information of the target map and the first pixel coordinate information to obtain a set of rectangular sub-regions; An image processing module, used for acquiring a first image of each rectangular sub-region in the set of rectangular sub-regions, and splicing the first image of each rectangular sub-region into a second image; The area displayed by the viewport of the target map is smaller than the coverage of the target cover; the second image includes the display content of the target rectangular area; The device also includes: a determination module and an adjustment module; The determination module is used to determine second pixel coordinate information of a target feature point based on the first pixel coordinate information, wherein the target feature point is any vertex of the target rectangular area; The adjustment module is used to obtain the size information of the target map, and adjust the center point of the target map based on the size information of the target map and the second pixel coordinate information; The adjustment module is further used to update the first pixel coordinate information based on the adjusted target map; The adjusted target map uses the target feature points as rectangular vertices.
6. The device according to claim 5, characterized in that The adjustment module is used to draw the target overlay on the target map and adjust the zoom level of the target overlay based on the target information; The target information includes at least one of the following: the content included in the target overlay, and the zoom level of the target map.
7. A non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the screenshot method according to any one of claims 1 to 4.
8. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instructions are executed by a processor, the steps of the screenshot method described in any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
System and method for generating and monitoring feedback of a published webpage as implemented on a remote client
US20170337168A1
