CN101216944B - Method and device for realizing gradient shading in typesetting process - Google Patents
Method and device for realizing gradient shading in typesetting process Download PDFInfo
- Publication number
- CN101216944B CN101216944B CN2008100557062A CN200810055706A CN101216944B CN 101216944 B CN101216944 B CN 101216944B CN 2008100557062 A CN2008100557062 A CN 2008100557062A CN 200810055706 A CN200810055706 A CN 200810055706A CN 101216944 B CN101216944 B CN 101216944B
- Authority
- CN
- China
- Prior art keywords
- gradient
- color data
- area
- template bitmap
- information
- 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.)
- Expired - Fee Related
Links
- 238000000034 method Methods 0.000 title claims abstract description 56
- 239000011159 matrix material Substances 0.000 claims abstract description 75
- 238000004364 calculation method Methods 0.000 claims abstract description 25
- 238000005457 optimization Methods 0.000 claims abstract description 17
- 238000012545 processing Methods 0.000 claims description 29
- 238000012946 outsourcing Methods 0.000 claims 4
- 229910003460 diamond Inorganic materials 0.000 claims 1
- 239000010432 diamond Substances 0.000 claims 1
- 230000000750 progressive effect Effects 0.000 claims 1
- 230000000694 effects Effects 0.000 abstract description 17
- 238000010586 diagram Methods 0.000 description 8
- 238000005516 engineering process Methods 0.000 description 5
- 239000003086 colorant Substances 0.000 description 4
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 230000009191 jumping Effects 0.000 description 2
- 238000006243 chemical reaction Methods 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
Images
Landscapes
- Image Generation (AREA)
Abstract
Description
技术领域technical field
本发明涉及图像处理技术领域,尤其涉及在排版过程中实现渐变底纹的技术。The invention relates to the technical field of image processing, in particular to the technology for realizing gradient shading in the typesetting process.
背景技术Background technique
在平面设计、广告制作、商业印刷、排版等领域,经常为了丰富版面艺术效果,为文字块、图元块、图像块设置渐变色,并用设置的渐变色来填充不同渐变类型的渐变底纹。In the fields of graphic design, advertising production, commercial printing, typesetting, etc., in order to enrich the artistic effect of the layout, gradient colors are often set for text blocks, graphic element blocks, and image blocks, and the gradient shading patterns of different gradient types are filled with the set gradient colors.
所谓渐变色是由多个渐变点组成的一组颜色,相邻两个渐变点之间存在渐变中心。第一个渐变点确定为渐变色的起始点,最后一个渐变点确定为渐变色的终止点,渐变色起始点到终止点变化50%颜色对应的位置确定为渐变色的中心点。The so-called gradient color is a group of colors composed of multiple gradient points, and there is a gradient center between two adjacent gradient points. The first gradient point is determined as the start point of the gradient color, the last gradient point is determined as the end point of the gradient color, and the position corresponding to the 50% color change from the start point of the gradient color to the end point is determined as the center point of the gradient color.
所谓渐变底纹是用渐变色来填充,并且对应不同渐变类型的底纹。The so-called gradient shading is filled with gradient colors, and corresponds to different gradient types of shading.
目前排版领域中存在的用渐变色填充渐变底纹的方法很多,一般有以下几种:At present, there are many ways to fill gradient shading with gradient color in the field of typesetting, generally there are the following:
(1)、将需要填充渐变色的渐变底纹进行分割,形成多个小的矩形区域块,计算每个矩形区域块对应的颜色值,根据得到的颜色值找到每个矩形区域块对应的颜色,并把此矩形区域块的所有像素点填充成一个颜色,这样填充得到的渐变色底纹颜色渐变不够平滑,颜色变化有跳跃感,并且图像放大后会失真。(1) Divide the gradient shading that needs to be filled with gradient color to form multiple small rectangular area blocks, calculate the color value corresponding to each rectangular area block, and find the corresponding color of each rectangular area block according to the obtained color value , and fill all the pixels of this rectangular area block into one color, so that the color gradient of the gradient color shading obtained by filling in this way is not smooth enough, the color change has a sense of jumping, and the image will be distorted after being enlarged.
(2)、排版领域中存在的渐变类型主要是线型渐变类型和圆形渐变类型。这两种渐变类型都需要计算渐变色的起始点和终止点的颜色值,并将得到颜色值作为系统函数的输入参数。如果渐变色的起始点和终止点的位置较近,则需要进行多次运算才能得到对象每个像素点在不同角度的颜色数据,计算量巨大,影响渐变底纹的显示速度;如果起始点和终止点的位置较远,根据渐变色起始点和终止点的颜色值对应的颜色,对底纹模板进行线性填充,那么颜色变化不够平滑,颜色变化有跳跃感。(2) The gradient types that exist in the field of typesetting are mainly linear gradient types and circular gradient types. Both gradient types need to calculate the color value of the start point and end point of the gradient color, and use the obtained color value as the input parameter of the system function. If the start point and end point of the gradient color are close, multiple calculations are required to obtain the color data of each pixel of the object at different angles. The amount of calculation is huge, which will affect the display speed of the gradient shading; if the start point and The position of the end point is relatively far away. According to the color corresponding to the color value of the start point and end point of the gradient color, the shading template is filled linearly, so the color change is not smooth enough, and the color change has a sense of jumping.
(3)、直接计算对象的底纹位图,该底纹位图的像素点一般比较多,这样计算该位图像素点的颜色数据时,计算量比较大从而导致计算速度较慢。(3) Directly calculate the shading bitmap of the object. Generally, the shading bitmap has more pixels, so when calculating the color data of the bitmap pixels, the amount of calculation is relatively large, resulting in slower calculation speed.
随着排版技术的飞速发展,在排版过程中对图像处理的功能和效果提出了越来越高的要求,现有的线形和圆形渐变类型已经无法满足排版技术对排版版面的要求,以及对生成渐变底纹的效果的准确性的要求,并且生成渐变底纹的显示速度也有待提高。With the rapid development of typesetting technology, higher and higher requirements are put forward for the function and effect of image processing in the typesetting process. The existing linear and circular gradient types can no longer meet the requirements of typesetting technology for typesetting layout, and the The accuracy of the effect of generating gradient shading is required, and the display speed of generating gradient shading also needs to be improved.
发明内容Contents of the invention
本发明提供了在排版过程中实现渐变底纹的方法及装置,增加了渐变底纹的渐变类型,并且提高了渐变底纹的显示速度,使渐变底纹的实现效果更准确,图像放大后颜色渐变更加平滑。The invention provides a method and device for realizing gradient shading in the typesetting process, increases the gradient type of gradient shading, and improves the display speed of gradient shading, so that the realization effect of gradient shading is more accurate, and the color of the enlarged image Gradients are smoother.
本发明实施例通过如下技术方案实现:Embodiments of the present invention are realized through the following technical solutions:
本发明实施例提供了一种在排版过程中实现渐变底纹的方法,该方法包括:An embodiment of the present invention provides a method for realizing gradient shading in the typesetting process, the method comprising:
得到包含对象信息的矩阵;以及,得到对象外包框尺寸和屏幕显示区域尺寸;Obtain a matrix containing object information; and, obtain the size of the object's outer frame and the size of the screen display area;
根据得到的包含对象信息的矩阵、对象外包框尺寸和屏幕显示区域尺寸,计算对象的有效区域;Calculate the effective area of the object according to the obtained matrix containing the object information, the size of the object's outer frame and the size of the screen display area;
计算对象的有效区域相对于设定尺寸的模板位图的缩放比例,并根据得到的缩放比例以及用户设置的渐变角度、渐变中心点、渐变半径,得到所述模板位图的渐变角度、渐变中心点、渐变半径;以及,根据用户设置的渐变类型,计算所述模板位图中每个像素点的颜色数据;Calculate the scaling ratio of the effective area of the object relative to the template bitmap of the set size, and obtain the gradient angle and gradient center of the template bitmap according to the obtained scaling ratio and the gradient angle, gradient center point, and gradient radius set by the user point, gradient radius; and, according to the gradient type set by the user, calculate the color data of each pixel in the template bitmap;
根据所述模板位图的渐变角度、渐变中心点、渐变半径以及所述模板位图中每个像素点的颜色数据,生成渐变模板位图,并在确定所述缩放比例不为1时,对生成的渐变模版位图进行二次线性插值处理,并根据插值处理的结果生成相应的渐变模版位图;According to the gradient angle of the template bitmap, the gradient center point, the gradient radius and the color data of each pixel in the template bitmap, a gradient template bitmap is generated, and when it is determined that the scaling ratio is not 1, the The generated gradient template bitmap is subjected to quadratic linear interpolation processing, and a corresponding gradient template bitmap is generated according to the result of the interpolation processing;
根据得到的包含对象信息的矩阵计算包含对象新信息的矩阵;根据所述包含对象新信息的矩阵以及所述缩放比例,将所述生成的渐变模板位图覆盖对象的位图。Calculate a matrix containing new object information according to the obtained matrix containing object information; and cover the object bitmap with the generated gradient template bitmap according to the matrix containing new object information and the scaling ratio.
本发明实施例还提供了一种渐变底纹实现装置,该渐变底纹实现装置包括:矩阵获得单元、有效区域获得单元、渐变信息获得单元、颜色数据获得单元、模板位图生成单元、覆盖单元;The embodiment of the present invention also provides a gradient shading realization device, the gradient shading realization device includes: a matrix acquisition unit, an effective area acquisition unit, a gradient information acquisition unit, a color data acquisition unit, a template bitmap generation unit, and an overlay unit ;
其中,矩阵获得单元,用于得到包含对象信息的矩阵;以及,得到对象外包框尺寸和屏幕显示区域尺寸;Wherein, the matrix obtaining unit is used to obtain the matrix containing the object information; and obtain the size of the outer frame of the object and the size of the screen display area;
有效区域获得单元,用于根据得到的包含对象信息的矩阵、对象外包框尺寸和屏幕显示区域尺寸,计算对象的有效区域;an effective area obtaining unit, configured to calculate the effective area of the object according to the obtained matrix containing object information, the size of the object's outer frame and the size of the screen display area;
渐变信息获得单元,用于计算对象的有效区域相对于设定尺寸的模板位图的缩放比例,并根据得到的缩放比例以及用户设置的渐变角度、渐变中心点、渐变半径,得到所述模板位图的渐变角度、渐变中心点、渐变半径;The gradient information obtaining unit is used to calculate the scaling ratio of the effective area of the object relative to the template bitmap of the set size, and obtain the template bitmap according to the obtained scaling ratio and the gradient angle, gradient center point, and gradient radius set by the user. Gradient angle, gradient center point, and gradient radius of the graph;
颜色数据获得单元,用于根据用户设置的渐变类型,计算所述模板位图中每个像素点的颜色数据;A color data obtaining unit, configured to calculate the color data of each pixel in the template bitmap according to the gradient type set by the user;
模板位图生成单元,用于根据所述模板位图的渐变角度、渐变中心点、渐变半径以及所述模板位图中每个像素点的颜色数据,生成渐变模板位图;A template bitmap generating unit, configured to generate a gradient template bitmap according to the gradient angle, gradient center point, gradient radius, and color data of each pixel in the template bitmap;
模板位图处理单元,用于当所述缩放比例不等于1时,对所生成的渐变模板位图进行二次线性插值处理,并根据二次线性插值处理的结果,生成相应的渐变模板位图;A template bitmap processing unit, configured to perform quadratic linear interpolation processing on the generated gradient template bitmap when the scaling ratio is not equal to 1, and generate a corresponding gradient template bitmap according to the result of the quadratic linear interpolation processing ;
覆盖单元,用于根据得到的包含对象信息的矩阵计算包含对象新信息的矩阵;根据所述包含对象新信息的矩阵以及所述缩放比例,将所述生成的渐变模板位图覆盖对象的位图。The covering unit is used to calculate the matrix containing the new information of the object according to the obtained matrix containing the object information; according to the matrix containing the new information of the object and the scaling ratio, cover the bitmap of the object with the generated gradient template bitmap .
通过以上技术方案,本发明实施例通过设置尺寸远小于对象的模板位图,大大降低了计算每个像素点的颜色数据的复杂度,提高了渐变底纹的显示速度;同时,通过计算模板位图中每个像素点的颜色数据,在保证显示速度的同时也使渐变底纹的实现效果更准确,图像放大后颜色渐变更加平滑。Through the above technical solutions, the embodiment of the present invention greatly reduces the complexity of calculating the color data of each pixel by setting the template bitmap whose size is much smaller than the object, and improves the display speed of the gradient shading; at the same time, by calculating the template bitmap The color data of each pixel in the picture not only guarantees the display speed, but also makes the effect of gradient shading more accurate, and the color gradient becomes smoother after the image is enlarged.
附图说明Description of drawings
图1为本发明第一实施例的在排版过程中实现渐变底纹的方法流程图;Fig. 1 is a flowchart of a method for realizing gradient shading in the typesetting process according to the first embodiment of the present invention;
图2为本发明第一实施例的计算线形和圆形渐变类型的标准渐变模版位图中每个像素点的颜色数据的流程图;Fig. 2 is the flowchart of calculating the color data of each pixel in the standard gradient template bitmap of the linear and circular gradient types according to the first embodiment of the present invention;
图3为本发明第一实施例的计算方形和菱形渐变类型的标准渐变模版位图中每个像素点的颜色数据的流程图;Fig. 3 is the flowchart of calculating the color data of each pixel in the standard gradient template bitmap of the square and rhombus gradient types according to the first embodiment of the present invention;
图4为本发明第一实施例的计算锥形和双锥形渐变类型的标准渐变模版位图中每个像素点的颜色数据的流程图;Fig. 4 is the flow chart of calculating the color data of each pixel in the standard gradient template bitmap of cone and bicone gradient types in the first embodiment of the present invention;
图5为本发明第一实施例的单线形渐变底纹的效果图;Fig. 5 is an effect diagram of a single-line gradient shading pattern according to the first embodiment of the present invention;
图6为本发明第一实施例的双线形渐变底纹的效果图;Fig. 6 is an effect diagram of a double-line gradient shading pattern according to the first embodiment of the present invention;
图7为本发明第一实施例的圆形渐变底纹的效果图;Fig. 7 is an effect diagram of the circular gradient shading of the first embodiment of the present invention;
图8为本发明第一实施例的方形渐变底纹的效果图;Fig. 8 is an effect diagram of a square gradient shading pattern according to the first embodiment of the present invention;
图9为本发明第一实施例的菱形渐变底纹的效果图;Fig. 9 is an effect diagram of a rhombus gradient shading pattern according to the first embodiment of the present invention;
图10为本发明第一实施例的锥形渐变底纹的效果图;Fig. 10 is an effect diagram of the tapered gradient shading of the first embodiment of the present invention;
图11为本发明第一实施例的双锥形渐变底纹的效果图;Fig. 11 is an effect diagram of the biconical gradient shading of the first embodiment of the present invention;
图12为本发明第二实施例的在排版过程中实现渐变底纹的装置示意图。FIG. 12 is a schematic diagram of an apparatus for realizing gradient shading in the typesetting process according to the second embodiment of the present invention.
具体实施方式Detailed ways
本发明提供了在排版过程中实现渐变底纹的方法及装置,针对现有技术提供的渐变底纹种类较少,并且图像放大后失真,实现效果不理想的问题,提出了以下技术方案,现结合说明书附图及具体实施例对该技术进行详细说明:The present invention provides a method and device for realizing gradient shading in the typesetting process. Aiming at the problems that the prior art provides less types of gradient shading, and the enlarged image is distorted and the effect is not ideal, the following technical solutions are proposed. Now The technology is described in detail in conjunction with the accompanying drawings and specific embodiments:
本发明第一实施例提供了在排版过程中实现渐变底纹的方法,结合附图1流程图对该方法进行详细说明:The first embodiment of the present invention provides a method for realizing gradient shading in the typesetting process, and the method is described in detail in conjunction with the flow chart of Figure 1:
S101、得到包含对象信息的矩阵,并根据得到的包含对象信息的矩阵计算包含对象新信息的矩阵;以及,得到对象外包框尺寸和屏幕显示区域尺寸,并根据得到的对象外包框尺寸和屏幕显示区域尺寸计算对象的有效区域。S101. Obtain the matrix containing the object information, and calculate the matrix containing the new information of the object according to the obtained matrix containing the object information; and obtain the size of the object outer frame and the size of the screen display area, and based on the obtained object outer frame size and screen display The area size calculates the effective area of the object.
通过系统函数可以得到当前对象设备上下文(DC,Device Context)的包含对象信息的矩阵Mo;The matrix Mo containing object information of the current object device context (DC, Device Context) can be obtained through the system function;
从矩阵Mo中获得对象的缩放信息,并将得到的缩放信息放入矩阵Mg中,参与计算:Mn=Mo*Mg′,其中矩阵Mn为包含对象新信息的矩阵,Mg′为矩阵Mg的逆矩阵。Obtain the scaling information of the object from the matrix Mo, put the obtained scaling information into the matrix Mg, and participate in the calculation: Mn=Mo*Mg', where the matrix Mn is the matrix containing the new information of the object, and Mg' is the inverse of the matrix Mg matrix.
通过系统函数分别得到以毫米为单位的对象外包框的中心点Pm和以像素为单位的对象外包框的中心点Pp,将Pm的单位由毫米转化为像素,计算以像素为单位的Pm和Pp的差值,并将该差值作为对象的水平和垂直转换偏差放入包含对象新信息的矩阵Mn中。Through the system function, the center point Pm of the object frame in millimeters and the center point Pp of the object frame in pixels are respectively obtained, the unit of Pm is converted from millimeters to pixels, and Pm and Pp in pixels are calculated. , and put the difference as the horizontal and vertical conversion deviation of the object into the matrix Mn containing the new information of the object.
计算对象的有效区域,主要包括如下步骤:Calculating the effective area of an object mainly includes the following steps:
从系统中获得表示对象外包框尺寸的矩形区域Ro和表示屏幕显示区域尺寸的矩形区域Rs,该矩形区域Ro和Rs表示的区域尺寸都以毫米为单位;Obtain a rectangular area Ro representing the size of the object's outer frame and a rectangular area Rs representing the size of the screen display area from the system, and the area sizes represented by the rectangular area Ro and Rs are both in millimeters;
利用系统函数将矩形区域Ro和Rs表示的区域尺寸的单位由毫米转换为像素,重新得到表示对象外包框尺寸的矩形区域Ro和表示屏幕显示区域尺寸的矩形区域Rs,该矩形区域Ro和Rs表示的区域尺寸都以像素为单位;Use the system function to convert the unit of the area size represented by the rectangular area Ro and Rs from millimeters to pixels, and obtain the rectangular area Ro representing the size of the object's outer frame and the rectangular area Rs representing the size of the screen display area. The rectangular area Ro and Rs represent The size of the area is in pixels;
根据得到的表示像素单位区域尺寸的矩形区域Ro与Rs的顶点坐标,计算Rs与Ro的交叉区域,并将得到的交叉区域作为对象的有效区域Rv,该有效区域Rv以像素为单位。According to the obtained vertex coordinates of the rectangular areas Ro and Rs representing the size of the pixel unit area, the intersection area of Rs and Ro is calculated, and the obtained intersection area is used as the target effective area Rv, and the effective area Rv is in pixels.
若对象被旋转或错切,则根据包含对象信息的矩阵中包含的具体信息,对表示屏幕显示区域尺寸的矩形区域Rs进行处理,并根据处理后得到的新矩形区域计算交叉区域,具体处理过程包括:If the object is rotated or staggered, according to the specific information contained in the matrix containing the object information, the rectangular area Rs representing the size of the screen display area is processed, and the intersection area is calculated according to the new rectangular area obtained after processing. The specific processing process include:
当包含对象信息的矩阵中包含旋转信息,则利用表示屏幕显示区域尺寸的矩形区域Rs乘以包含旋转信息的矩阵的逆矩阵,得到新的矩形区域,并计算得到的新的矩形区域和表示对象外包框尺寸的矩形区域Ro的交叉区域,将得到的交叉区域作为对象的有效区域;When the matrix containing object information contains rotation information, multiply the rectangular area Rs representing the size of the screen display area by the inverse matrix of the matrix containing rotation information to obtain a new rectangular area, and calculate the new rectangular area and represent the object The intersection area of the rectangular area Ro of the outer box size, and the obtained intersection area is used as the effective area of the object;
或者,or,
当包含对象信息的矩阵中包含错切信息,则利用表示屏幕显示区域尺寸的矩形区域Rs乘以包含错切信息的矩阵的逆矩阵,得到新的矩形区域,并计算得到的新的矩形区域和表示对象外包框尺寸的矩形区域Ro的交叉区域,将得到的交叉区域作为对象的有效区域;When the matrix containing object information contains miscutting information, multiply the rectangular area Rs representing the size of the screen display area by the inverse matrix of the matrix containing miscutting information to obtain a new rectangular area, and calculate the obtained new rectangular area and Represent the intersection area of the rectangular area Ro of the size of the object's outer frame, and use the obtained intersection area as the effective area of the object;
或者,or,
当包含对象信息的矩阵中包含旋转信息和错切信息,则利用表示屏幕显示区域尺寸的矩形区域Rs乘以包含旋转信息和错切信息的矩阵的逆矩阵,得到新的矩形区域,并计算得到的新的矩形区域和表示对象外包框尺寸的矩形区域Ro的交叉区域,将得到的交叉区域作为对象的有效区域。When the matrix containing object information contains rotation information and miscut information, multiply the rectangular area Rs representing the size of the screen display area by the inverse matrix of the matrix containing rotation information and miscut information to obtain a new rectangular area, and calculate The intersection area between the new rectangular area of , and the rectangular area Ro representing the size of the object's outer frame, and the obtained intersection area is taken as the effective area of the object.
S102、根据对象的有效区域Rv,得到该有效区域Rv相对于设定尺寸的模版位图的水平和垂直的缩放比例η,根据所得到的缩放比例η和用户设置的渐变角度、渐变半径、渐变中心点,得到模版位图的渐变角度、渐变半径、渐变中心点;S102. According to the effective area Rv of the object, obtain the horizontal and vertical scaling ratio η of the effective area Rv relative to the template bitmap of the set size, according to the obtained scaling ratio η and the gradient angle, gradient radius, and gradient set by the user Center point, get the gradient angle, gradient radius, and gradient center point of the template bitmap;
其中,模板位图的尺寸设置为128*128像素。Wherein, the size of the template bitmap is set to 128*128 pixels.
S103、根据用户设置的渐变类型,计算模版位图中每个像素点的颜色数据。具体包括:S103. Calculate the color data of each pixel in the template bitmap according to the gradient type set by the user. Specifically include:
根据用户设置的渐变类型,确定对应渐变类型的模板位图的渐变色的中心点、起始点和终止点;According to the gradient type set by the user, determine the center point, start point and end point of the gradient color of the template bitmap corresponding to the gradient type;
根据确定的渐变色的中心点、起始点和终止点得到像素点对应位置的渐变色变化的位置比例,根据得到的位置比例和系统中渐变色信息得到该像素点对应位置的颜色数据,并将得到的对应位置的颜色数据作为该像素点的颜色数据。According to the determined central point, starting point and end point of the gradient color, the position ratio of the gradient color change at the corresponding position of the pixel point is obtained, and the color data of the corresponding position of the pixel point is obtained according to the obtained position ratio and the gradient color information in the system, and the The obtained color data of the corresponding position is used as the color data of the pixel point.
下面分别以单线形渐变类型、双线形渐变类型、圆形渐变类型、方形渐变类型、菱形渐变类型、锥形渐变类型以及双锥形渐变类型为例,分别对计算模版位图中每个像素点的颜色数据的过程进行详细说明:The following takes the single-line gradient type, double-line gradient type, circular gradient type, square gradient type, rhombus gradient type, tapered gradient type, and double-cone gradient type as examples to calculate each pixel in the template bitmap. The process of point color data is described in detail:
单线形渐变类型:Single linear gradient type:
将上述步骤S102中得到的模版位图的渐变中心点作为该单线形渐变类型的渐变色的中心点,将模版位图的渐变直径的两端分别作为该单线形渐变类型的渐变色的起始点和终止点,所述渐变直径是根据对象外包框和缩放比例计算出来的,根据渐变直径确定渐变色的渐变范围;Use the gradient center point of the template bitmap obtained in the above step S102 as the center point of the gradient color of the single-line gradient type, and use the two ends of the gradient diameter of the template bitmap as the starting points of the gradient color of the single-line gradient type respectively and the end point, the gradient diameter is calculated according to the object's outer box and the scaling ratio, and the gradient range of the gradient color is determined according to the gradient diameter;
根据上述确定的渐变色的中心点、起始点和终止点得到像素点对应位置的渐变色变化的位置比例,根据得到的位置比例和系统中渐变色信息得到该像素点对应位置的颜色数据,并将得到的对应位置的颜色数据作为该像素点的颜色数据,结合图2流程图对该过程进行详细说明:According to the center point, starting point and end point of the gradient color determined above, the position ratio of the gradient color change at the corresponding position of the pixel point is obtained, and the color data of the corresponding position of the pixel point is obtained according to the obtained position ratio and the gradient color information in the system, and The color data obtained at the corresponding position is used as the color data of the pixel point, and the process is described in detail in conjunction with the flowchart in Figure 2:
S201、构造直角三角形,得到该单线形渐变类型模版位图的基准渐变线,具体过程包括:S201. Construct a right-angled triangle to obtain the reference gradient line of the single-line gradient type template bitmap. The specific process includes:
以步骤S102中得到的模版位图的渐变中心点作为三角形斜边中点、渐变直径作为斜边长度、渐变角度作为斜边和水平边的夹角,创建直角三角形;计算斜边的两个顶点坐标,将两个顶点连线,得到的连线就是基准渐变线,根据渐变角度,判定所述基准渐变线一端为渐变色的起始点,另一端为渐变色的终止点。Create a right-angled triangle with the gradient center point of the template bitmap obtained in step S102 as the midpoint of the hypotenuse, the gradient diameter as the length of the hypotenuse, and the gradient angle as the angle between the hypotenuse and the horizontal side; calculate the two vertices of the hypotenuse coordinates, connect two vertices, and the obtained connection line is the reference gradient line. According to the gradient angle, it is determined that one end of the reference gradient line is the starting point of the gradient, and the other end is the end point of the gradient.
S202、判断对象是否对称,若确定对象没有对称性,则执行步骤S203;确定对象关于x轴或y轴或圆点对称,则执行步骤S208。S202. Determine whether the object is symmetrical. If it is determined that the object is not symmetrical, then perform step S203; if it is determined that the object is symmetrical about the x-axis or y-axis or the dot, then perform step S208.
可以根据确定的渐变色的中心点、起始点和终止点,确定对象的对称性。The symmetry of the object can be determined based on the determined center point, start point, and end point of the gradient color.
S203、计算对象中第n行第一个像素点的颜色数据。S203. Calculate the color data of the first pixel in the nth row in the object.
取对象第n行第一个像素点,做该像素点到基准渐变线的垂线,得到垂足,将得到的垂足与基准渐变线的渐变色的起始点连线,得到线段,计算得到的线段与直径的比例,并将得到的比例作为该像素点对应位置的渐变色变化的位置比例;Take the first pixel point of the nth row of the object, draw a vertical line from this pixel point to the reference gradient line, and obtain the vertical foot, connect the obtained vertical foot with the starting point of the gradient color of the reference gradient line, obtain a line segment, and calculate The ratio of the line segment to the diameter, and use the obtained ratio as the position ratio of the gradient color change at the corresponding position of the pixel point;
根据得到的位置比例和系统中渐变色信息得到该像素点对应位置的颜色数据,并将得到的对应位置的颜色数据作为该像素点的颜色数据。According to the obtained position ratio and the gradient color information in the system, the color data of the corresponding position of the pixel point is obtained, and the obtained color data of the corresponding position is used as the color data of the pixel point.
S204、计算第n行中相邻像素点之间的渐变步长。包括:S204. Calculate the gradient step size between adjacent pixels in the nth row. include:
所述相邻像素点之间的渐变步长根据公式:cosd*x计算得到,其中d是渐变角度,x是相邻两个像素点在x方向上的差值。The gradient step size between adjacent pixels is calculated according to the formula: cosd*x, where d is the gradient angle, and x is the difference between two adjacent pixels in the x direction.
S205、根据上述得到的第n行第一个像素点的颜色数据和第n行中相邻像素点之间的渐变步长依次计算第n行其它像素点的颜色数据。S205. Calculate the color data of other pixels in the nth row sequentially according to the obtained color data of the first pixel in the nth row and the gradient step size between adjacent pixels in the nth row.
S206、取第n=n+1行。S206. Get the n=n+1th row.
S207、判断计算是否结束,如果对象中每行像素点的颜色数据都计算完毕,则结束计算;否则执行步骤S203。S207 , judging whether the calculation is finished, if the color data of each row of pixels in the object has been calculated, the calculation is ended; otherwise, step S203 is executed.
S208、根据确定的渐变色的中心点、起始点和终止点,确定对象的对称性,并根据确定的对称性,采用优化算法计算每个像素点的颜色数据。S208. Determine the symmetry of the object according to the determined center point, start point and end point of the gradient color, and calculate the color data of each pixel by using an optimization algorithm according to the determined symmetry.
当确定对象关于x轴对称时,计算对象中每行中第一个像素点的颜色数据和每行对象的1/2行相邻像素点之间的渐变步长,并根据得到的每行第一个像素点的颜色数据和得到的渐变步长依次计算每行对象的1/2行其它像素点的颜色数据,并根据对称性得到模板位图全部像素点的颜色数据;When it is determined that the object is symmetrical about the x-axis, calculate the color data of the first pixel in each row of the object and the gradient step between the adjacent pixels in 1/2 rows of each row of objects, and calculate the gradient step according to the obtained first pixel in each row Calculate the color data of one pixel and the obtained gradient step in turn to calculate the color data of other pixels in 1/2 row of each row of objects, and obtain the color data of all pixels of the template bitmap according to the symmetry;
或者,or,
当确定对象关于y轴对称时,计算对象中每列中第一个像素点的颜色数据和每列对象的1/2列相邻像素点之间的渐变步长,并根据得到的每列第一个像素点的颜色数据和得到的渐变步长依次计算每列对象的1/2列其它像素点的颜色数据,并根据对称性得到模板位图全部像素点的颜色数据;When it is determined that the object is symmetrical about the y-axis, calculate the color data of the first pixel in each column of the object and the gradient step between the adjacent pixels in 1/2 columns of each column of the object, and obtain the first pixel in each column according to the obtained Calculate the color data of one pixel and the obtained gradient step in turn to calculate the color data of 1/2 columns of other pixels in each column of objects, and obtain the color data of all pixels in the template bitmap according to the symmetry;
或者,or,
当确定对象关于圆点对称时,根据对象的对称性取对象1/4区域,计算该1/4区域对象中每个像素点的颜色数据。具体包括:When it is determined that the object is symmetrical about the dot, 1/4 area of the object is taken according to the symmetry of the object, and the color data of each pixel in the 1/4 area object is calculated. Specifically include:
计算该1/4区域对象中每行的第一个像素点的颜色数据和该1/4区域对象中每行的相邻像素点之间的渐变步长,并根据得到的每行的第一个像素点的颜色数据和得到每行的相邻像素点之间的渐变步长依次计算该1/4区域中其它像素点的颜色数据,并根据对称性得到模板位图全部像素点的颜色数据;Calculate the color data of the first pixel of each row in the 1/4 area object and the gradient step size between the adjacent pixels of each row in the 1/4 area object, and according to the obtained first pixel of each row The color data of each pixel and the gradient step size between adjacent pixels in each row are calculated in turn to calculate the color data of other pixels in the 1/4 area, and the color data of all pixels in the template bitmap are obtained according to the symmetry. ;
或者,or,
计算该1/4区域对象中每列的第一个像素点的颜色数据和该1/4区域对象中每列的相邻像素点之间的渐变步长,并根据得到的每列的第一个像素点的颜色数据和得到每列的相邻像素点之间的渐变步长依次计算该1/4区域中其它像素点的颜色数据,并根据对称性得到模板位图全部像素点的颜色数据。Calculate the color data of the first pixel of each column in the 1/4 area object and the gradient step between the adjacent pixels of each column in the 1/4 area object, and according to the obtained first pixel of each column The color data of each pixel and the gradient step size between adjacent pixels of each column are calculated in turn to calculate the color data of other pixels in the 1/4 area, and the color data of all pixels in the template bitmap are obtained according to the symmetry. .
双线形渐变类型:Bilinear gradient type:
将上述步骤S102中得到的模版位图的渐变中心点作为该双线形渐变的渐变色的起始点,模版位图的渐变直径的两端作为该双线形渐变的渐变色的终止点;The gradient center point of the template bitmap obtained in the above step S102 is used as the starting point of the gradient color of the double-line gradient, and the two ends of the gradient diameter of the template bitmap are used as the end points of the gradient color of the double-line gradient;
根据上述确定的渐变色起始点和终止点得到像素点对应位置的渐变色变化的位置比例,根据得到的位置比例和系统中渐变色信息得到该像素点对应位置的颜色数据,并将得到的对应位置的颜色数据作为该像素点的颜色数据,具体计算过程与单线形渐变类型的模版位图中每个像素点的颜色数据的计算过程相同,此处不再作详细描述。According to the above determined starting point and ending point of the gradient color, the position ratio of the gradient color change at the corresponding position of the pixel point is obtained, and the color data of the corresponding position of the pixel point is obtained according to the obtained position ratio and the gradient color information in the system, and the obtained corresponding The color data of the position is used as the color data of the pixel, and the specific calculation process is the same as the calculation process of the color data of each pixel in the template bitmap of the single-line gradient type, and will not be described in detail here.
需要指出的是该双线形渐变的模板位图以渐变中心点为对称轴对称,而单线型渐变的模板位图并没有该对称性。It should be pointed out that the template bitmap of the double-line gradient is symmetrical with the center point of the gradient as the axis of symmetry, but the template bitmap of the single-line gradient does not have this symmetry.
圆形渐变类型:Circular Gradient Type:
将上述步骤S102中得到的模版位图的渐变中心点作为该圆形渐变的渐变色的中心点和该圆形渐变的渐变色的起始点,渐变半径的另一端为渐变色的终止点;The gradient center point of the template bitmap obtained in the above step S102 is used as the center point of the gradient color of the circular gradient and the starting point of the gradient color of the circular gradient, and the other end of the gradient radius is the termination point of the gradient color;
根据上述确定的渐变色的中心点、起始点和终止点得到像素点对应位置的渐变色变化的位置比例,根据得到的位置比例和系统中渐变色信息得到该像素点对应位置的颜色数据,并将得到的对应位置的颜色数据作为该像素点的颜色数据,具体计算过程与单线形渐变类型的模版位图中每个像素点的颜色数据的计算过程相同,此处不再作详细描述。According to the center point, starting point and end point of the gradient color determined above, the position ratio of the gradient color change at the corresponding position of the pixel point is obtained, and the color data of the corresponding position of the pixel point is obtained according to the obtained position ratio and the gradient color information in the system, and The obtained color data at the corresponding position is used as the color data of the pixel, and the specific calculation process is the same as the calculation process of the color data of each pixel in the template bitmap of the single-line gradient type, and will not be described in detail here.
需要指出的是,在计算该圆渐变的模板位图中每个像素点的颜色数据之前,要判断需要计算的像素点是否在渐变区域内,具体包括:It should be pointed out that before calculating the color data of each pixel in the template bitmap of the circular gradient, it is necessary to determine whether the pixel to be calculated is within the gradient area, specifically including:
判断需要计算的像素点与模版位图的渐变中心点的连线得到的线段是否大于半径,如果得到的线段大于或等于半径,则将该像素点作为渐变色的终止点,并取该终止点的颜色数据作为该像素点的颜色数据;如果得到的线段小于半径,则根据上述计算线形渐变类型的模板位图中每个像素点的颜色数据的方法计算该像素点的颜色数据。Determine whether the line segment obtained by connecting the pixel point to be calculated and the gradient center point of the template bitmap is greater than the radius, if the obtained line segment is greater than or equal to the radius, use the pixel point as the end point of the gradient color, and take the end point The color data of the pixel is used as the color data of the pixel; if the obtained line segment is smaller than the radius, the color data of the pixel is calculated according to the above method of calculating the color data of each pixel in the template bitmap of the linear gradient type.
方形渐变类型:Square gradient type:
将上述步骤S102中得到的标准渐变模版位图的渐变中心点作为该方形渐变的渐变色的中心点,标准渐变模版位图的渐变半径的一端为渐变色的终止点,所述渐变半径是线形渐变半径开平方的一半;The gradient center point of the standard gradient template bitmap obtained in the above step S102 is used as the center point of the gradient color of the square gradient, and one end of the gradient radius of the standard gradient template bitmap is the termination point of the gradient color, and the gradient radius is a linear Half of the square root of the gradient radius;
根据上述确定的渐变色的中心点和起始点得到像素点对应位置的渐变色变化的位置比例,根据得到的位置比例和系统中渐变色信息得到该像素点对应位置的颜色数据,并将得到的对应位置的颜色数据作为该像素点的颜色数据,结合图3流程图对该计算过程进行详细说明:According to the center point and starting point of the gradient color determined above, the position ratio of the gradient color change at the corresponding position of the pixel point is obtained, and the color data of the corresponding position of the pixel point is obtained according to the obtained position ratio and the gradient color information in the system, and the obtained The color data of the corresponding position is used as the color data of the pixel, and the calculation process is described in detail in conjunction with the flow chart in Figure 3:
S301、确定该方形渐变类型的渐变模版位图的渐变区域,具体过程包括:S301. Determine the gradient area of the gradient template bitmap of the square gradient type, and the specific process includes:
以步骤S102中得到的模版位图的渐变直径作为该方形渐变的渐变直径,根据上述信息计算得到方形渐变的四个起始点A1,A2,A3,A4,连接四点,形成矩形区域,该矩形区域就是该方形渐变类型的标准渐变模版位图的渐变区域。Use the gradient diameter of the template bitmap obtained in step S102 as the gradient diameter of the square gradient, and calculate the four starting points A1, A2, A3, A4 of the square gradient according to the above information, connect the four points to form a rectangular area, the rectangle The area is the gradient area of the standard gradient template bitmap of the square gradient type.
S302、判断对象是否对称,确定对象没有对称性,则执行步骤S303;确定对象关于x轴或y轴或圆点对称,则执行步骤S309。S302. Determine whether the object is symmetrical. If it is determined that the object is not symmetrical, execute step S303; if it is determined that the object is symmetrical about the x-axis or y-axis or the dot, execute step S309.
可以根据确定的渐变色的中心点、起始点和终止点,来判断对象的对称性。The symmetry of the object can be judged according to the determined center point, start point and end point of the gradient color.
S303、取第n行第m列像素点的坐标,判断该坐标是否在步骤S301形成的矩形区域内,如果不在此区域内,则执行步骤S304;如果在矩形区域内,则执行步骤S305。S303. Get the coordinates of the pixel point in the nth row and the mth column, and judge whether the coordinates are within the rectangular area formed in step S301. If not, execute step S304; if they are within the rectangular area, execute step S305.
S304、设置该坐标不在矩形区域内的像素点为渐变色的终止点,并取该终止点的颜色数据作为该坐标不在矩形区域内的像素点的颜色数据,然后转入步骤S306。S304. Set the pixel point whose coordinates are not in the rectangular area as the end point of the gradient color, and take the color data of the end point as the color data of the pixel point whose coordinates are not in the rectangular area, and then turn to step S306.
S305、根据渐变角度计算该第n行第m列像素点到渐变中心点的水平和垂直距离中较长的与半径的比值,并将得到的比例作为该像素点对应位置的渐变色变化的位置比例,根据得到的位置比例和系统中渐变色信息得到该像素点对应位置的颜色数据,并将得到的对应位置的颜色数据作为该像素点的颜色数据。S305. Calculate the ratio of the longer horizontal and vertical distance to the radius from the nth row, mth column pixel point to the gradient center point according to the gradient angle, and use the obtained ratio as the position of the gradient color change at the corresponding position of the pixel point Ratio, according to the obtained position ratio and the gradient color information in the system, the color data of the corresponding position of the pixel point is obtained, and the obtained color data of the corresponding position is used as the color data of the pixel point.
S306、依次计算第n行其它列像素点的颜色数据。S306, sequentially calculate the color data of pixels in other columns of the nth row.
S307、取第n=n+1行。S307. Get the n=n+1th row.
S308、判断所有像素点的颜色数据是否计算结束,如果未计算结束,则执行步骤S303;如果计算结束,则结束流程。S308 , judging whether the calculation of the color data of all pixels is completed, if not, execute step S303 ; if the calculation is completed, end the process.
S309、根据确定的渐变色的中心点、起始点和终止点,确定对象的对称性,并根据确定的对称性,采用优化算法计算每个像素点的颜色数据。S309. Determine the symmetry of the object according to the determined center point, start point and end point of the gradient color, and calculate the color data of each pixel by using an optimization algorithm according to the determined symmetry.
优化算法的具体过程与上述步骤S305所述计算像素点的颜色数据的方法一致,当确定对象关于x轴对称时,只需计算对象每行1/2行像素点的颜色数据,然后根据对称性确定对象全部像素点的颜色数据;当确定对象关于y轴对称时,只需计算对象每列1/2列像素点的颜色数据,然后根据对称性确定对象全部像素点的颜色数据;当确定对象关于圆点对称时,只需按照对称性取对象1/4区域,然后计算该1/4区域内像素点的颜色数据,然后根据对称性得到对象全部像素点的颜色数据。The specific process of the optimization algorithm is consistent with the method for calculating the color data of the pixels described in the above step S305. When it is determined that the object is symmetrical about the x-axis, it is only necessary to calculate the color data of 1/2 row of pixels in each row of the object, and then according to the symmetry Determine the color data of all the pixels of the object; when it is determined that the object is symmetrical about the y-axis, it is only necessary to calculate the color data of 1/2 columns of pixels in each column of the object, and then determine the color data of all the pixels of the object according to the symmetry; when the object is determined When it is symmetrical about the dot, it only needs to take 1/4 area of the object according to the symmetry, and then calculate the color data of the pixels in the 1/4 area, and then obtain the color data of all the pixels of the object according to the symmetry.
菱形渐变类型:Rhombus Gradient Type:
渐变色中心点和终止点的设置与方形渐变类型的设置相同,该菱形渐变类型的模板位图的渐变半径为其中R为方形渐变类型的模板位图的渐变半径;The settings of the center point and end point of the gradient color are the same as those of the square gradient type, and the gradient radius of the template bitmap of the rhombus gradient type is Where R is the gradient radius of the template bitmap of the square gradient type;
根据上述确定的渐变色的中心点和终止点得到像素点对应位置的渐变色变化的位置比例,根据得到的位置比例和系统中渐变色信息得到该像素点对应位置的颜色数据,并将得到的对应位置的颜色数据作为该像素点的颜色数据,具体计算过程与方形渐变类型的模版位图中每个像素点的颜色数据的计算过程相同,此处不再作详细描述。According to the center point and end point of the gradient color determined above, the position ratio of the gradient color change at the corresponding position of the pixel point is obtained, and the color data of the corresponding position of the pixel point is obtained according to the obtained position ratio and the gradient color information in the system, and the obtained The color data of the corresponding position is used as the color data of the pixel. The specific calculation process is the same as the calculation process of the color data of each pixel in the template bitmap of the square gradient type, and will not be described in detail here.
需要指出的是,该菱形渐变类型对应的渐变角度等于方形渐变类型对应的渐变角度+π/4。It should be noted that the gradient angle corresponding to the rhombus gradient type is equal to the gradient angle +π/4 corresponding to the square gradient type.
锥形渐变类型:Tapered Gradient Type:
将上述步骤S102中得到的模版位图的渐变中心点作为该锥形渐变的渐变色的中心点;Use the gradient center point of the template bitmap obtained in the above step S102 as the center point of the gradient color of the tapered gradient;
根据上述确定的渐变色的中心点得到像素点对应位置的渐变色变化的位置比例,根据得到的位置比例和系统中渐变色信息得到该像素点对应位置的颜色数据,并将得到的对应位置的颜色数据作为该像素点的颜色数据,结合图4流程图对该计算过程进行详细说明:According to the center point of the gradient color determined above, the position ratio of the gradient color change at the corresponding position of the pixel point is obtained, and the color data of the corresponding position of the pixel point is obtained according to the obtained position ratio and the gradient color information in the system, and the obtained corresponding position is obtained. The color data is used as the color data of the pixel, and the calculation process is described in detail in conjunction with the flowchart in Figure 4:
S401、得到模版位图的渐变中心点的坐标,根据得到的坐标依次计算第n行中每个像素点和中心点连线得到的线段与x轴的夹角angle。S401. Obtain the coordinates of the center point of the gradient of the template bitmap, and sequentially calculate the angle angle between the x-axis and the line segment obtained by connecting each pixel point and the center point in the nth row according to the obtained coordinates.
S402、将得到的第n行中每个像素点的angle/2π作为该像素点对应位置的渐变色变化的位置比例,并根据得到的位置比例和系统中渐变色信息得到该像素点对应位置的颜色数据,并将得到的对应位置的颜色数据作为该像素点的颜色数据;S402, taking the obtained angle/2π of each pixel in the nth row as the position ratio of the gradient color change at the corresponding position of the pixel point, and obtaining the position ratio of the corresponding position of the pixel point according to the obtained position ratio and the gradient color information in the system color data, and use the obtained color data of the corresponding position as the color data of the pixel point;
依次计算第n行中每个像素点的颜色数据。Calculate the color data of each pixel in the nth row in turn.
S403、取第n=n+1行。S403. Get the n=n+1th row.
S404、判断计算是否结束,如果计算结束,则结束;否则执行步骤S401。S404. Determine whether the calculation is over, if the calculation is over, then end; otherwise, execute step S401.
双锥形渐变类型:Biconical gradient type:
将上述步骤S102中得到的模版位图的渐变中心点作为该双锥形渐变的渐变色的中心点,将上述步骤S402中angle/2π改为agle/π就可得到像素点对应位置的渐变色变化的位置比例,其它计算过程与计算锥形渐变类型模板位图中每个像素点的颜色数据的过程相同,此处不再进行详细描述。Use the gradient center point of the template bitmap obtained in the above step S102 as the center point of the gradient color of the biconical gradient, and change angle/2π in the above step S402 to angle/π to obtain the gradient color at the corresponding position of the pixel point The changing position ratio, other calculation processes are the same as the process of calculating the color data of each pixel in the bitmap of the tapered gradient type template, and will not be described in detail here.
S104、根据得到的模版位图中每个像素点的颜色数据和步骤S102中得到的模版位图的渐变角度、渐变半径和渐变中心点,生成渐变模板位图。S104. Generate a gradient template bitmap according to the obtained color data of each pixel in the template bitmap and the gradient angle, gradient radius, and gradient center point of the template bitmap obtained in step S102.
S105、根据步骤S102得到缩放比例η,判断对像是否缩放。如果η不等于1,则执行步骤S106;如果η等于1,则执行步骤S107。S105. Obtain the zoom ratio η according to step S102, and determine whether the object is zoomed. If n is not equal to 1, execute step S106; if n is equal to 1, execute step S107.
S106、当所述缩放比例不等于1时,对步骤S104中所生成的渐变模板位图进行二次线性插值处理,并根据二次线性插值处理的结果,生成相应的渐变模板位图。S106. When the scaling ratio is not equal to 1, perform quadratic linear interpolation processing on the gradient template bitmap generated in step S104, and generate a corresponding gradient template bitmap according to the result of the quadratic linear interpolation processing.
步骤S106具体包括:Step S106 specifically includes:
根据缩放比例和步骤S101中得到的对象的有效区域,计算步骤S104中所生成的渐变模板位图的有效区域;According to the effective area of the object obtained in the scaling and step S101, calculate the effective area of the gradient template bitmap generated in the step S104;
根据对象的有效区域,将得到的渐变模板位图的有效区域进行缩放,并在缩放过程中对得到的渐变模板位图的有效区域进行二次线性插值处理,并根据二次线性插值处理的结果,生成相应的渐变模板位图。Scale the effective area of the obtained gradient template bitmap according to the effective area of the object, and perform quadratic linear interpolation on the effective area of the obtained gradient template bitmap during the scaling process, and according to the result of the quadratic linear interpolation , to generate the corresponding gradient template bitmap.
S107、将步骤S101中得到的包含对象水平和垂直缩放信息的矩阵Mn设置在当前DC上,如果缩放比例等于1,则将步骤S103中生成的渐变模板位图覆盖对象的位图;否则将步骤S106中生成的新的渐变模板位图覆盖对象的位图上。S107, set the matrix Mn containing the horizontal and vertical scaling information of the object obtained in step S101 on the current DC, if the scaling ratio is equal to 1, then cover the bitmap of the object with the gradient template bitmap generated in step S103; otherwise, the step The new gradient template bitmap generated in S106 covers the bitmap of the object.
通过上述方法,就可以根据用户设置的渐变类型生成对应类型的渐变模板位图,并利用生成的渐变模板位图覆盖对象的位图,图5到图11分别对应单线形渐变类型、双线形渐变类型、圆形渐变类型、方形渐变类型、菱形渐变类型、锥形渐变类型和双锥形渐变类型的渐变底纹的效果图。Through the above method, the corresponding type of gradient template bitmap can be generated according to the gradient type set by the user, and the generated gradient template bitmap can be used to cover the bitmap of the object. Figure 5 to Figure 11 correspond to the single-line gradient type and double-line gradient type respectively. Effects of gradient shading for gradient type, circular gradient type, square gradient type, rhombus gradient type, tapered gradient type, and double tapered gradient type.
本发明第二实施例提供了在排版过程中实现渐变底纹的装置,如图12所示,包括:矩阵获得单元、有效区域获得单元、渐变信息获得单元、颜色数据获得单元、模板位图生成单元和覆盖单元;The second embodiment of the present invention provides a device for realizing gradient shading in the typesetting process, as shown in Figure 12, including: a matrix acquisition unit, an effective area acquisition unit, a gradient information acquisition unit, a color data acquisition unit, and template bitmap generation unit and overlay unit;
其中,矩阵获得单元,用于得到包含对象信息的矩阵;以及,得到对象外包框尺寸和屏幕显示区域尺寸;Wherein, the matrix obtaining unit is used to obtain the matrix containing the object information; and obtain the size of the outer frame of the object and the size of the screen display area;
有效区域获得单元,用于根据得到的包含对象信息的矩阵、对象外包框尺寸和屏幕显示区域尺寸,计算对象的有效区域;an effective area obtaining unit, configured to calculate the effective area of the object according to the obtained matrix containing object information, the size of the object's outer frame and the size of the screen display area;
渐变信息获得单元,用于计算对象的有效区域相对于设定尺寸的模板位图的缩放比例,并根据得到的缩放比例以及用户设置的渐变角度、渐变中心点、渐变半径,得到所述模板位图的渐变角度、渐变中心点、渐变半径;The gradient information obtaining unit is used to calculate the scaling ratio of the effective area of the object relative to the template bitmap of the set size, and obtain the template bitmap according to the obtained scaling ratio and the gradient angle, gradient center point, and gradient radius set by the user. Gradient angle, gradient center point, and gradient radius of the graph;
颜色数据获得单元,用于根据用户设置的渐变类型,计算所述模板位图中每个像素点的颜色数据;A color data obtaining unit, configured to calculate the color data of each pixel in the template bitmap according to the gradient type set by the user;
模板位图生成单元,用于根据所述模板位图的渐变角度、渐变中心点、渐变半径以及所述模板位图中每个像素点的颜色数据,生成渐变模板位图;A template bitmap generating unit, configured to generate a gradient template bitmap according to the gradient angle, gradient center point, gradient radius, and color data of each pixel in the template bitmap;
覆盖单元,用于根据得到的包含对象信息的矩阵计算包含对象新信息的矩阵;根据所述包含对象新信息的矩阵以及所述缩放比例,将所述生成的渐变模板位图覆盖对象的位图。The covering unit is used to calculate the matrix containing the new information of the object according to the obtained matrix containing the object information; according to the matrix containing the new information of the object and the scaling ratio, cover the bitmap of the object with the generated gradient template bitmap .
根据包含对象信息的矩阵中包含的信息的不同,所述有效区域获得单元,可以包括:有效区域获得第一子单元、或有效区域获得第二子单元、或有效区域获得第三子单元;According to different information contained in the matrix containing object information, the effective area obtaining unit may include: a first subunit for obtaining an effective area, or a second subunit for obtaining an effective area, or a third subunit for obtaining an effective area;
其中,有效区域获得第一子单元,用于当包含对象信息的矩阵中包含旋转信息,则利用表示屏幕显示区域的像素单位尺寸的矩形区域乘以包含旋转信息的矩阵的逆矩阵,得到新的矩形区域,并计算得到的新的矩形区域和表示对象外包框的像素单位尺寸的矩形区域的交叉区域,将得到的交叉区域作为对象的有效区域;Wherein, the first sub-unit for obtaining the effective area is used to obtain a new Rectangular area, and the crossing area between the calculated new rectangular area and the rectangular area representing the pixel unit size of the object's outer frame, and the obtained crossing area is used as the effective area of the object;
或者,or,
有效区域获得第二子单元,用于当包含对象信息的矩阵中包含错切信息,则利用表示屏幕显示区域的像素单位尺寸的矩形区域乘以包含错切信息的矩阵的逆矩阵,得到新的矩形区域,并计算得到的新的矩形区域和表示对象外包框的像素单位尺寸的矩形区域的交叉区域,将得到的交叉区域作为对象的有效区域;The effective area obtains the second subunit, which is used to obtain a new Rectangular area, and the crossing area between the calculated new rectangular area and the rectangular area representing the pixel unit size of the object's outer frame, and the obtained crossing area is used as the effective area of the object;
或者,or,
有效区域获得第三子单元,用于当包含对象信息的矩阵中包含旋转信息和错切信息,则利用表示屏幕显示区域的像素单位尺寸的矩形区域乘以包含旋转信息和错切信息的矩阵的逆矩阵,得到新的矩形区域,并计算得到的新的矩形区域和表示对象外包框的像素单位尺寸的矩形区域的交叉区域,将得到的交叉区域作为对象的有效区域。The effective area obtains the third subunit, which is used to multiply the matrix containing the rotation information and the miscut information by the rectangular area representing the pixel unit size of the screen display area when the matrix containing the object information contains the rotation information and the miscut information. Inverse the matrix to obtain a new rectangular area, and calculate the intersection area between the obtained new rectangular area and the rectangular area representing the pixel unit size of the object's outer frame, and use the obtained intersection area as the effective area of the object.
所述颜色数据获得单元,包括:渐变色信息确定子单元和颜色数据计算子单元;The color data obtaining unit includes: a gradient color information determination subunit and a color data calculation subunit;
其中,渐变色信息确定子单元,用于根据用户设置的渐变类型,确定对应渐变类型的模板位图的渐变色的中心点、起始点和终止点;Wherein, the gradient color information determination subunit is used to determine the center point, start point and end point of the gradient color of the template bitmap corresponding to the gradient type according to the gradient type set by the user;
颜色数据计算子单元,用于根据确定的渐变色的中心点、起始点和终止点得到像素点对应位置的渐变色变化的位置比例,根据得到的位置比例和系统中渐变色信息得到该像素点对应位置的颜色数据,并将得到的对应位置的颜色数据作为该像素点的颜色数据。The color data calculation subunit is used to obtain the position ratio of the gradient color change at the corresponding position of the pixel point according to the determined center point, start point and end point of the gradient color, and obtain the pixel point according to the obtained position ratio and the gradient color information in the system The color data of the corresponding position is obtained, and the obtained color data of the corresponding position is used as the color data of the pixel point.
根据对象的对称性,所述颜色数据获得单元,包括:According to the symmetry of the object, the color data obtaining unit comprises:
优化子单元,用于根据确定的对应渐变类型的渐变色的中心点、起始点和终止点,确定对象的对称性,并根据所确定的对称性,计算模板位图中每个像素点的颜色数据。The optimization subunit is used to determine the symmetry of the object according to the determined center point, start point and end point of the gradient color corresponding to the gradient type, and calculate the color of each pixel in the template bitmap according to the determined symmetry data.
所述优化子单元,进一步包括:第一优化模块、或第二优化模块、或第三优化模块;The optimization subunit further includes: a first optimization module, or a second optimization module, or a third optimization module;
其中,第一优化模块,用于当确定对象关于x轴对称时,计算每行对象的1/2行像素点的颜色数据,并根据对称性得到模板位图全部像素点的颜色数据;Wherein, the first optimization module is used to calculate the color data of 1/2 row of pixels of each row of objects when the object is determined to be symmetrical about the x-axis, and obtain the color data of all pixels of the template bitmap according to the symmetry;
或者,or,
第二优化模块,用于当确定对象关于y轴对称时,计算每列对象的1/2列像素点的颜色数据,并根据对称性得到模板位图全部像素点的颜色数据;The second optimization module is used to calculate the color data of 1/2 columns of pixels of each column of objects when the object is determined to be symmetrical about the y axis, and obtain the color data of all pixels of the template bitmap according to the symmetry;
或者,or,
第三优化模块,用于当确定对象关于圆点对称时,计算对象1/4区域中每个像素点的颜色数据,并根据对称性得到模板位图全部像素点的颜色数据。The third optimization module is used to calculate the color data of each pixel in the 1/4 area of the object when it is determined that the object is symmetrical about the dot, and obtain the color data of all the pixels of the template bitmap according to the symmetry.
根据所述缩放比例的大小,所述渐变底纹实现装置,还包括:According to the size of the scaling ratio, the device for implementing gradient shading further includes:
模板位图处理单元,用于当所述缩放比例不等于1时,对所生成的渐变模板位图进行二次线性插值处理,并根据二次线性插值处理的结果,生成相应的渐变模板位图。A template bitmap processing unit, configured to perform quadratic linear interpolation processing on the generated gradient template bitmap when the scaling ratio is not equal to 1, and generate a corresponding gradient template bitmap according to the result of the quadratic linear interpolation processing .
所述模板位图处理单元,包括:有效区域获得子单元和模板位图处理子单元;The template bitmap processing unit includes: a valid area obtaining subunit and a template bitmap processing subunit;
其中,有效区域获得子单元,用于根据所述缩放比例和对象的有效区域,计算生成的渐变模板位图的有效区域;Wherein, the effective area acquisition subunit is used to calculate the effective area of the generated gradient template bitmap according to the scaling ratio and the effective area of the object;
模板位图处理子单元,用于根据对象的有效区域,将得到的渐变模板位图的有效区域进行缩放,并在缩放过程中对渐变模板位图的有效区域进行二次线性插值处理,并根据二次线性插值处理的结果生成相应的渐变模板位图。The template bitmap processing subunit is used to scale the effective area of the obtained gradient template bitmap according to the effective area of the object, and perform quadratic linear interpolation processing on the effective area of the gradient template bitmap during the scaling process, and according to The result of the quadratic linear interpolation process generates the corresponding gradient template bitmap.
通过上述技术方案,使渐变底纹的实现效果更准确,图像放大后颜色渐变更加平滑;另外,除了提供线形和圆形渐变类型,还提供了方形渐变类型、菱形渐变类型、锥形和双锥形渐变类型,丰富了版面的艺术效果;另外,根据对象的对称性采用了优化算法计算每个像素点的颜色数据,减少了计算量;另外,通过计算对象有效区域中像素点的颜色数据,提高了渐变底纹的显示速度。Through the above technical solution, the realization effect of the gradient shading is more accurate, and the color gradient is smoother after the image is enlarged; in addition, in addition to providing linear and circular gradient types, it also provides square gradient types, rhombus gradient types, cones and double cones The shape gradient type enriches the artistic effect of the layout; in addition, according to the symmetry of the object, an optimized algorithm is used to calculate the color data of each pixel, which reduces the amount of calculation; in addition, by calculating the color data of the pixels in the effective area of the object, Improved display speed of gradient shading.
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention also intends to include these modifications and variations.
Claims (13)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2008100557062A CN101216944B (en) | 2008-01-07 | 2008-01-07 | Method and device for realizing gradient shading in typesetting process |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN2008100557062A CN101216944B (en) | 2008-01-07 | 2008-01-07 | Method and device for realizing gradient shading in typesetting process |
Publications (2)
Publication Number | Publication Date |
---|---|
CN101216944A CN101216944A (en) | 2008-07-09 |
CN101216944B true CN101216944B (en) | 2011-08-03 |
Family
ID=39623372
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN2008100557062A Expired - Fee Related CN101216944B (en) | 2008-01-07 | 2008-01-07 | Method and device for realizing gradient shading in typesetting process |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN101216944B (en) |
Families Citing this family (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101655969B (en) * | 2008-08-19 | 2011-12-21 | 方正国际软件(北京)有限公司 | Method for editing color gradient attributes |
CN102752545B (en) * | 2011-05-11 | 2017-04-12 | 新奥特(北京)视频技术有限公司 | Method for achieving special effect of cubism of subtitles |
CN103862899A (en) * | 2012-12-12 | 2014-06-18 | 昆山研达电脑科技有限公司 | Manufacturing method of product with gradient shading |
CN106569684A (en) * | 2015-10-13 | 2017-04-19 | 北京国双科技有限公司 | Color gradient graphic display method and device |
CN106095360B (en) * | 2016-05-31 | 2018-11-27 | 福州瑞芯微电子股份有限公司 | Image processing method and image processing apparatus based on palette |
CN106445888B (en) * | 2016-09-30 | 2019-06-14 | 广州视睿电子科技有限公司 | Method and device for making artistic words |
CN107608671A (en) * | 2017-08-22 | 2018-01-19 | 北京京东尚科信息技术有限公司 | A kind of method and apparatus for realizing text color gradual change |
CN111475875B (en) * | 2020-02-27 | 2022-11-22 | 杭州群核信息技术有限公司 | Automatic generation method and system for tile combination gradual change paving |
CN114463344A (en) * | 2021-12-20 | 2022-05-10 | 北京镁伽科技有限公司 | Gradient image generation method, generation device and image signal generator |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6597363B1 (en) * | 1998-08-20 | 2003-07-22 | Apple Computer, Inc. | Graphics processor with deferred shading |
US6870954B1 (en) * | 2001-04-04 | 2005-03-22 | Adobe Systems Incorporated | Methods apparatus for generating shaped gradient fills |
-
2008
- 2008-01-07 CN CN2008100557062A patent/CN101216944B/en not_active Expired - Fee Related
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6597363B1 (en) * | 1998-08-20 | 2003-07-22 | Apple Computer, Inc. | Graphics processor with deferred shading |
US6870954B1 (en) * | 2001-04-04 | 2005-03-22 | Adobe Systems Incorporated | Methods apparatus for generating shaped gradient fills |
Also Published As
Publication number | Publication date |
---|---|
CN101216944A (en) | 2008-07-09 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101216944B (en) | Method and device for realizing gradient shading in typesetting process | |
CN105513110A (en) | GPU-based method for drawing linetype map symbol with gradually-varied width | |
CN105022731B (en) | A kind of method of map vector tile caching | |
US20200279415A1 (en) | Efficiently Computed Distance Fields | |
JPH03208094A (en) | Treatment of outline of symbol image of various sizes and computor display device | |
JP4327105B2 (en) | Drawing method, image generation apparatus, and electronic information device | |
US9955065B2 (en) | Dynamic motion path blur user interface | |
CN100481000C (en) | Window and icon setting system and method thereof | |
US20170236020A1 (en) | Method and system for generating and selectively outputting two types of ink vector data | |
CN101216934A (en) | Digital image zooming method and device with adjustable gradient difference | |
CN101188020A (en) | Method for precisely getting pixel geometric location mapping relation between projector image and computer frame buffer image | |
CN112164127A (en) | Picture generation method and device, electronic equipment and readable storage medium | |
US9779484B2 (en) | Dynamic motion path blur techniques | |
CN109544668A (en) | Texture coordinate processing method, terminal device and computer readable storage medium | |
JP4775067B2 (en) | Digital content creation system, digital content creation program, and digital content creation method | |
CN104133809B (en) | Font style bolding method | |
CN102063523A (en) | Method for realizing anti-aliasing of line segment integrating floating points and fixed points by using supersampling algorithm | |
CN204857142U (en) | Signal extension display device | |
JP6297169B2 (en) | Drawing apparatus and drawing method | |
CN106227737A (en) | Quickly generate advertising pictures platform | |
CN105159645B (en) | A kind of mobile terminal Tang poetry self-adaptive layout method | |
CN101567091A (en) | Method for clearing target render by three-dimension virtual reality engine | |
JP2012108825A (en) | Information processing device, information processing method and program | |
CN103839217A (en) | Watermark image realization method | |
CN111739120B (en) | Drawing method of plain text histogram |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20110803 Termination date: 20190107 |
|
CF01 | Termination of patent right due to non-payment of annual fee |