CN113628295A - Method for drawing poster - Google Patents

Method for drawing poster Download PDF

Info

Publication number
CN113628295A
CN113628295A CN202110879201.3A CN202110879201A CN113628295A CN 113628295 A CN113628295 A CN 113628295A CN 202110879201 A CN202110879201 A CN 202110879201A CN 113628295 A CN113628295 A CN 113628295A
Authority
CN
China
Prior art keywords
canvas
pixel
poster
rendering
ratio
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110879201.3A
Other languages
Chinese (zh)
Inventor
陈文昊
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Inspur Software Co Ltd
Original Assignee
Inspur Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Inspur Software Co Ltd filed Critical Inspur Software Co Ltd
Priority to CN202110879201.3A priority Critical patent/CN113628295A/en
Publication of CN113628295A publication Critical patent/CN113628295A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/001Texturing; Colouring; Generation of texture or colour
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9577Optimising the visualization of content, e.g. distillation of HTML documents

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • Image Processing (AREA)

Abstract

The invention relates to the field of internet front ends, and particularly provides a poster drawing method, which is realized on the basis of a canvas interface provided by a browser, adjusts canvas elements and a canvas background, ensures that one physical pixel corresponds to one CSS pixel, and simultaneously zooms and zooms equipment. Compared with the prior art, the method can solve the problem of compatibility of the existing plug-in when the webpage is drawn and converted into the canvas; and the problem of drawing distortion existing in a basic interface and an original drawing method during drawing the canvas by hand can be solved. The problems of equipment adaptation and precision optimization can be realized only by calling the packaging code.

Description

Method for drawing poster
Technical Field
The invention relates to the field of internet front ends, and particularly provides a poster drawing method.
Background
Today, the popularization of internet products becomes an important means for each internet company to seize the market, and it is a common means to draw new users by sharing personalized posters with existing customers. The prior art approaches mainly include conversion of the rendering of a webpage into a canvas to derive a picture and rendering directly through the canvas to derive the picture. Although there are various implementation plug-ins for the method of drawing a canvas through a web page, there are more or less compatibility problems. The method of drawing directly through the canvas also has certain distortion problems.
Disclosure of Invention
The invention provides a poster drawing method with strong practicability aiming at the defects of the prior art.
The technical scheme adopted by the invention for solving the technical problems is as follows:
a method for drawing posters is realized on the basis of a canvas interface provided by a browser, canvas elements and a canvas background are adjusted, it is ensured that one physical pixel corresponds to one CSS pixel, and the size of equipment is zoomed at the same time.
Further, a fixed height and a fixed width are given to the canvas elements, and a device pixel ratio and a size multiplied by the fixed height and the fixed width are set for the canvas background, namely, the canvas is drawn on a piece of enlarged canvas with the size multiplied by the device pixel ratio.
Furthermore, after drawing on a canvas with the enlarged pixel ratio multiple size of the equipment, reducing the pixel ratio multiple of the equipment, and then placing the canvas in a canvas frame with the original size.
Further, according to the canvas rendering mechanism, the canvas may expand from the centerline to both sides when rendering the pixel width, i.e., the width of one side may become half.
Further, in the rendering mechanism, the pixels cannot be decimal, so the pixels can be rounded, and the loss of the approximation can be reduced by firstly enlarging and drawing the canvas and then reducing the canvas.
Preferably, one physical pixel is guaranteed to correspond to one CSS pixel, and the ratio of CSS pixels to physical pixels is the device pixel ratio.
Further, the canvas background is enlarged, all the elements of the positions and the sizes of the drawn images need to be enlarged in the same proportion, and therefore a zooming interface of the canvas needs to be called, and all the images on the background are drawn and enlarged in the proportion at one time.
Further, in scaling the device size, referring to the minimum of the width scaling ratio and the height scaling ratio, both the canvas element size setting and the canvas background size setting and the canvas scaling ratio should be multiplied by this minimum scaling ratio.
Compared with the prior art, the method for drawing the poster has the following outstanding advantages:
the invention can solve the compatibility problem of the existing plug-in when the webpage is drawn and converted into canvas; and the problem of drawing distortion existing in a basic interface and an original drawing method during drawing the canvas by hand can be solved. The problems of equipment adaptation and precision optimization can be realized only by calling the packaging code.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a schematic diagram of the conversion of physical pixels to CSS pixels in a method of drawing a poster.
Detailed Description
The present invention will be described in further detail with reference to specific embodiments in order to better understand the technical solutions of the present invention. It is to be understood that the described embodiments are merely exemplary of the invention, and not restrictive of the full scope of the invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
A preferred embodiment is given below:
as shown in fig. 1, the method for drawing a poster in this embodiment is implemented on the basis of a canvas-canvas interface provided by a browser, and because the canvas interface is an interface that must be implemented by each large browser, the problem of mobile phone system compatibility can be avoided.
As for the problem of drawing distortion, a fixed height and a fixed width are given to drawing elements, then the size of multiplying the device pixel ratio by the fixed height and the fixed width is set for a canvas background, and therefore the method is equivalent to that after drawing is finished on a canvas with the size of amplifying the device pixel ratio by multiple, the canvas is placed in a canvas frame with the original size after the device pixel ratio by multiple is reduced.
But it is reasonable to say that there is no difference between zooming in and zooming out, why there is a difference between this, which is actually caused by the canvas rendering mechanism.
The canvas expands from the middle line to two sides when the width of the pixel is rendered, so that the width of a single side can become half, however, the pixel cannot be a decimal number, so the pixel can be rounded off, and the loss of the drawing is reduced when the canvas is enlarged and drawn and then reduced.
As for the reason that the magnification factor is selected by adopting the device pixel ratio, it is more obvious that if the precision is improved to the maximum extent, one physical pixel is ensured to correspond to one CSS pixel, and the ratio of the CSS pixel to the physical pixel is the device pixel ratio. Similarly, the background is enlarged, all elements such as the position and the size of the image of the drawing are enlarged in the same scale, and at the moment, a zooming interface of the canvas can be called, so that all the images on the background can be enlarged in the scale at one time.
In addition, the size of the canvas element does not vary with the size of the device, so we should also consider the scaling of the device size when setting the canvas element size and the canvas background size.
The device scaling for the common elements is only based on width scaling, but since the size of the poster does not exceed the current screen, the minimum value of the width scaling ratio and the height scaling ratio should be referred to here to ensure that no single side exceeds the screen. The canvas element size setting and the canvas background size setting, as well as the canvas scaling ratio, should both be multiplied by this minimum scaling ratio. This ensures that the poster size fits with the device.
As shown in FIG. 1, the CSS pixel is larger than the physical pixel, but the canvas with multiple pixel ratio of the device is drawn, so that the number of unit pixels is increased, and the CSS pixel occupies one physical pixel by reducing.
The above embodiments are only specific ones of the present invention, and the scope of the present invention includes but is not limited to the above embodiments, and any appropriate changes or substitutions according to the claims of a method of drawing a poster according to the present invention and by any person skilled in the art should fall within the scope of the present invention.
Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that changes, modifications, substitutions and alterations can be made in these embodiments without departing from the principles and spirit of the invention, the scope of which is defined in the appended claims and their equivalents.

Claims (8)

1. A method for drawing posters is characterized in that the method is realized on the basis of a canvas interface provided by a browser, canvas elements and a canvas background are adjusted, one physical pixel is ensured to correspond to one CSS pixel, and the equipment size is zoomed at the same time.
2. A method of rendering a poster as claimed in claim 1, characterised in that the canvas elements are given a fixed height and width and the canvas background is set to a device pixel ratio multiplied by the fixed height and width, i.e. rendered on an enlarged canvas of a multiple of the device pixel ratio.
3. A method of rendering a poster according to claim 2, wherein after rendering on a canvas of an enlarged device pixel ratio multiple size, the device pixel ratio multiple is reduced and then placed in a canvas frame of the original size.
4. A method of drawing a poster according to claim 3, wherein the canvas expands from mid-line to both sides when rendering the pixel width, i.e. the width of a single side becomes half, according to the canvas rendering mechanism.
5. A method of rendering a poster as claimed in claim 4, wherein in the rendering mechanism, the pixels cannot be fractional and so are rounded, and the penalty is reduced by the canvas being enlarged and then reduced.
6. A method of drawing a poster according to claim 5, wherein it is ensured that one physical pixel corresponds to one CSS pixel, the ratio of CSS pixels to physical pixels being the device pixel ratio.
7. A method of drawing a poster of claim 6, wherein the canvas background is enlarged and all of the rendered image position size elements are enlarged to the same scale, which calls the canvas zoom interface to enlarge all of the image rendering on all of the background at once.
8. A method of drawing a poster of claim 7, wherein in scaling of the device size, the canvas element size setting and the canvas background size setting and the canvas scaling ratio should all be multiplied by the minimum of the width scaling ratio and the height scaling ratio.
CN202110879201.3A 2021-08-02 2021-08-02 Method for drawing poster Pending CN113628295A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110879201.3A CN113628295A (en) 2021-08-02 2021-08-02 Method for drawing poster

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110879201.3A CN113628295A (en) 2021-08-02 2021-08-02 Method for drawing poster

Publications (1)

Publication Number Publication Date
CN113628295A true CN113628295A (en) 2021-11-09

Family

ID=78382279

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110879201.3A Pending CN113628295A (en) 2021-08-02 2021-08-02 Method for drawing poster

Country Status (1)

Country Link
CN (1) CN113628295A (en)

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105204853A (en) * 2015-09-14 2015-12-30 新浪网技术(中国)有限公司 Canvas drawing method and device of web browser
CN106775600A (en) * 2015-11-19 2017-05-31 北京国双科技有限公司 The processing method and processing device of HTML5 canvas painting canvas
CN107204023A (en) * 2017-06-22 2017-09-26 网易(杭州)网络有限公司 Avoid the method and apparatus of aliasing being plotted in canvas painting canvas
CN107608993A (en) * 2016-07-12 2018-01-19 腾讯科技(深圳)有限公司 The method and apparatus of web animation generation
WO2018076560A1 (en) * 2016-10-27 2018-05-03 深圳市元征科技股份有限公司 Picture display method and apparatus
CN108665520A (en) * 2018-04-24 2018-10-16 微梦创科网络科技(中国)有限公司 A kind of method and device that page animation renders
CN109032742A (en) * 2018-07-26 2018-12-18 浙江数链科技有限公司 A kind of painting canvas clarity compatibility method and device
CN109543130A (en) * 2018-11-06 2019-03-29 新华三大数据技术有限公司 The display methods and device of label under three-dimensional scenic
CN111626031A (en) * 2020-06-02 2020-09-04 浪潮软件股份有限公司 Implementation method of big data front-end table component
CN112148398A (en) * 2019-06-28 2020-12-29 杭州海康机器人技术有限公司 Image processing method and device
CN112698898A (en) * 2020-12-29 2021-04-23 卡莱特(深圳)云科技有限公司 Method and system for generating thermodynamic diagram snapshot of play box terminal

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105204853A (en) * 2015-09-14 2015-12-30 新浪网技术(中国)有限公司 Canvas drawing method and device of web browser
CN106775600A (en) * 2015-11-19 2017-05-31 北京国双科技有限公司 The processing method and processing device of HTML5 canvas painting canvas
CN107608993A (en) * 2016-07-12 2018-01-19 腾讯科技(深圳)有限公司 The method and apparatus of web animation generation
WO2018076560A1 (en) * 2016-10-27 2018-05-03 深圳市元征科技股份有限公司 Picture display method and apparatus
CN107204023A (en) * 2017-06-22 2017-09-26 网易(杭州)网络有限公司 Avoid the method and apparatus of aliasing being plotted in canvas painting canvas
CN108665520A (en) * 2018-04-24 2018-10-16 微梦创科网络科技(中国)有限公司 A kind of method and device that page animation renders
CN109032742A (en) * 2018-07-26 2018-12-18 浙江数链科技有限公司 A kind of painting canvas clarity compatibility method and device
CN109543130A (en) * 2018-11-06 2019-03-29 新华三大数据技术有限公司 The display methods and device of label under three-dimensional scenic
CN112148398A (en) * 2019-06-28 2020-12-29 杭州海康机器人技术有限公司 Image processing method and device
CN111626031A (en) * 2020-06-02 2020-09-04 浪潮软件股份有限公司 Implementation method of big data front-end table component
CN112698898A (en) * 2020-12-29 2021-04-23 卡莱特(深圳)云科技有限公司 Method and system for generating thermodynamic diagram snapshot of play box terminal

Similar Documents

Publication Publication Date Title
CN109308155A (en) Adjust method, apparatus, computer equipment and the storage medium of the page
US20070237425A1 (en) Image resolution increasing method and apparatus for the same
CN108920048B (en) Large drawing browsing method, system, server and computer readable storage medium
CN107256259B (en) Page display method and device, electronic equipment and storage medium
KR100867131B1 (en) Apparatus and method for image displaying in portable terminal
Liu et al. Adaptive image retargeting using saliency-based continuous seam carving
CN113055615B (en) Conference all-in-one machine, screen segmentation display method and storage device
CN108881743B (en) Video image processing method, device and system based on splicing wall
CN101419532B (en) Method for changing information content dimension in mobile terminal and the mobile terminal
EP2874054A1 (en) Application text adjusting method, device, and terminal
CN112073647A (en) Image zooming display method, image processing device and display system
CN107402757B (en) Page rendering method and device
CN111275615B (en) Video image scaling method based on bilinear interpolation improvement
CN109102463B (en) Super-resolution image reconstruction method and device
CN113628295A (en) Method for drawing poster
CN111045576B (en) Display control method, display control device, terminal equipment and electronic equipment
CN105791524A (en) Method and device for adjusting page font
CN107506119A (en) Picture display method, device, equipment and storage medium
CN103327261B (en) A kind of simple and quick video reorientation method
JP2005130379A (en) Method for variably magnifying image and photographic printer for executing same
JP2009098692A (en) Size change method of image, resizer, image processing device and electronics apparatus
CN109978766B (en) Image amplifying method and image amplifying device
CN113536392A (en) Cross-platform electronic signature method based on background service
CN113055592A (en) Image display method and device, electronic equipment and computer readable storage medium
CN113760205A (en) Picture display method and device

Legal Events

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