WO2013078788A1 - 一种显示文字的方法及装置 - Google Patents

一种显示文字的方法及装置 Download PDF

Info

Publication number
WO2013078788A1
WO2013078788A1 PCT/CN2012/071315 CN2012071315W WO2013078788A1 WO 2013078788 A1 WO2013078788 A1 WO 2013078788A1 CN 2012071315 W CN2012071315 W CN 2012071315W WO 2013078788 A1 WO2013078788 A1 WO 2013078788A1
Authority
WO
WIPO (PCT)
Prior art keywords
text
pixel
color
bitmap
transparency
Prior art date
Application number
PCT/CN2012/071315
Other languages
English (en)
French (fr)
Inventor
朱勇
Original Assignee
中兴通讯股份有限公司
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 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2013078788A1 publication Critical patent/WO2013078788A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/20Drawing from basic elements, e.g. lines or circles
    • G06T11/203Drawing of straight lines or curves

Definitions

  • the present invention relates to the field of word processing technology, and in particular, to a method and apparatus for displaying characters. Background technique
  • font engines on mobile phones generally only support monochrome fonts. If you want to draw “ABC”, the text may be red, blue, or other colors, and the whole appears as a single color.
  • the font engine can only draw a single color when drawing a single word, and the existing font engine cannot achieve multi-color display of a single word, such as a gradient color.
  • the technical problem to be solved by the present invention is to provide a method and apparatus for displaying characters, which can realize multi-color display of characters.
  • a method for displaying characters according to the present invention includes:
  • Creating a cache bitmap filling a background color of the cache bitmap, drawing a text on the cache bitmap, calculating a transparency of each pixel in the cache bitmap, and setting a display color of the text;
  • calculating a transparency of each pixel in the cache bitmap including:
  • the transparency of each pixel in the cache bitmap is calculated based on the original color of the text, the background color of the cache bitmap, and the color of the text on the cache bitmap.
  • the method further comprises:
  • the transparency of each pixel in the calculated cache bitmap is saved to the alpha table, and the transparency of each pixel in the alpha table corresponds to the position of the pixel.
  • the original color of the text is CI (Rl, Gl, B1)
  • the cache bitmap The background color is C2 ( R2, G2, B2 ).
  • the color of the text on the cache bitmap is C3 ( R3 , G3 , ⁇ 3 )
  • filling the background color of the cache bitmap includes: filling a background color of the cache bitmap as a complementary color of the original color of the text.
  • determining the fill color of each pixel of the text filled on the target bitmap includes: traversing each pixel The transparency of the dot, when the transparency of the pixel is fully transparent, the filling color of the pixel at the pixel is determined as the background color of the target bitmap; when the transparency of the pixel is opaque, the filling color of the character at the pixel is determined to be The display color of the text at the pixel; when the transparency of the pixel is translucent, according to the transparency of the pixel, the background color of the target bitmap and the display color of the text at the pixel are synthesized as the text at the pixel Fill the color.
  • the background color of the target bitmap and the display color of the text at the pixel are synthesized, including:
  • the invention also provides an apparatus for displaying characters, comprising: a cache text drawing module, an alpha table creating module, a text color table building module and a target text drawing module, wherein:
  • the cache text drawing module is configured to: create a cache bitmap, fill a background color of the cache bitmap, and draw a text on the cache bitmap;
  • the alpha table creation module is configured to: calculate transparency of each pixel in the cache bitmap
  • the text color table construction module is set to: set a display color of the text
  • the target text drawing module is configured to: draw text on the target bitmap, and determine the text to be filled onto the target bitmap according to the transparency of each pixel in the cache bitmap, the background color of the target bitmap, and the display color of the text.
  • the fill color of each pixel is filled and the color is filled.
  • the alpha table creation module is configured to: calculate each pixel in the cache bitmap according to an original color of the text, a background color of the cache bitmap, and a color of the text on the cache bitmap
  • the transparency of the point, the transparency of each pixel in the calculated cache bitmap is saved in the alpha table, and the transparency of each pixel in the alpha table corresponds to the position of the pixel.
  • the target text drawing module is configured to: traverse the transparency of each pixel, and when the transparency of the pixel is completely transparent, determine that the filling color of the character at the pixel is the background color of the target bitmap; When the transparency of the dot is opaque, it is determined that the filling color of the character at the pixel is the display color of the text at the pixel; when the transparency of the pixel is translucent, the background color of the target bitmap is synthesized according to the transparency of the pixel. And the display color of the text at the pixel, as the fill color of the text at that pixel.
  • the embodiment of the present invention can realize various effects display of characters, for example, neon characters, gradient texts, and even filling characters with patterns, which greatly enhances the display effect of text on the interface, and additionally refreshes the screen.
  • characters for example, neon characters, gradient texts, and even filling characters with patterns
  • the alpha table is needed to draw the text, and it is not necessary to repeatedly draw the text on the screen, which can improve the speed of displaying the text on the screen.
  • FIG. 1 is a flowchart of a method of displaying characters according to an embodiment of the present invention
  • FIG. 2 is a block diagram showing the structure of an apparatus for displaying characters according to an embodiment of the present invention. Preferred embodiment of the invention
  • the background color of the cached bitmap can be filled with the complementary color of the text, the transparency of the cached bitmap is calculated, and the calculated transparency is saved, for example, can be saved to be created.
  • the text color table In the alpha table; get or calculate the text color table, the text color table to save the text to display the color, draw the text on the target bitmap, according to the text color table, the transparency in the alpha table and the background color of the target bitmap
  • the text should be drawn in color and drawn onto the screen.
  • the method for displaying characters in this embodiment includes:
  • Step 101 Create a cache bitmap
  • the created cache bitmap can be the same size as the text display area.
  • Step 102 Fill the background color of the cache bitmap with the complementary color of the original color of the text, and draw the text on the cache bitmap;
  • the cache bitmap is created to calculate the transparency of each pixel on the cached bitmap.
  • Step 103 Construct an alpha table, calculate the transparency of each pixel in the cache bitmap, and record it in the created alpha table;
  • the alpha table is used to record the transparency information of each pixel.
  • the transparency of each pixel in the alpha table corresponds to the position of the pixel.
  • any one of (1), (2), and (3) can be used to calculate o, and the calculated ⁇ is saved to the corresponding position of the alpha table.
  • Step 104 Create a text color table, set a display color table of the text (the color to be displayed), and save the display color of each pixel of the text into the text color table; According to the effect that needs to be displayed, create a corresponding color table.
  • the display color of each pixel is calculated as follows:
  • Step 105 Draw text on the target bitmap.
  • the target bitmap is equivalent to the display screen.
  • the text will eventually be drawn to a background color or image, that is, the target bitmap area.
  • the target bitmap itself will have a background or pattern.
  • Step 106 According to the base table of the alpha table, the target bitmap, and the text color table, determine the color of each pixel filled to the text, and fill the color. According to the color table of the text, the base table of the alpha table and the target bitmap, the effect is drawn, and the transparency of each pixel on the alpha table is traversed.
  • the reserved text is The color of the pixel is the background color of the target bitmap; if the transparency of the pixel is 0 (opaque), it is determined that the color of the pixel at the pixel is the display color corresponding to the pixel in the color table; Between 0 and 255 (translucent), the background color of the target bitmap on the pixel and the display color in the color table are synthesized according to the transparency of the pixel.
  • the composition formula is:
  • R3 [Rlx +R2x(255- )]/255 (7)
  • G3 [Gl +G2x(255- )]/255 (8)
  • the embodiment further provides a text display device, including: a cache text drawing module, an alpha table creating module, a text color table building module, and a target text drawing module, wherein:
  • a cache text drawing module for creating a cache bitmap, filling a background color of the cache bitmap, and drawing the text on the cache bitmap
  • the alpha table creation module is configured to calculate the transparency of each pixel in the cache bitmap;
  • the text color table construction module is configured to set the display color of the text;
  • the target text drawing module is configured to draw text on the target bitmap, and determine each of the characters filled on the target bitmap according to the transparency of each pixel in the cache bitmap, the background color of the target bitmap, and the display color of the text. Fill the color of the pixels and fill the color.
  • the alpha table creation module is specifically configured to calculate the transparency of each pixel in the cache bitmap according to the original color of the text, the background color of the cache bitmap, and the color of the text on the cache bitmap, and calculate each of the cached bitmaps.
  • the transparency of the pixel is saved to the alpha table, and the transparency of each pixel in the alpha table corresponds to the position of the pixel.
  • the original color of the text is CI (Rl, Gl, B1)
  • the background color of the cache bitmap is C2 (R2,
  • the target text drawing module is specifically configured to traverse the transparency of each pixel.
  • the filling color of the pixel at the pixel is determined as the background color of the target bitmap; the transparency at the pixel is opaque
  • the fill color of the pixel at the pixel is the display color of the text at the pixel; when the transparency of the pixel is translucent, according to the transparency of the pixel, the background color and the text of the target bitmap are synthesized at the pixel.
  • the display color of the point as the fill color of the text at that pixel.
  • the display color of the text at the pixel is (Rl, Gl, B1), and the background color of the target bitmap is (R2,
  • modules or steps of the present invention can be implemented by a general-purpose computing device, which can be concentrated on a single computing device or distributed over a network composed of multiple computing devices. Alternatively, they may be implemented by program code executable by the computing device, such that they may be stored in the storage device by the computing device and, in some cases, may be different from the order herein.
  • the steps shown or described are performed, or they are separately fabricated into individual integrated circuit modules, or a plurality of modules or steps are fabricated as a single integrated circuit module.
  • the invention is not limited to any particular combination of hardware and software.
  • the embodiments of the present invention can realize various effects display of characters, for example, neon characters, gradation texts, and even filling characters with patterns, which greatly enhances the display effect of characters on the interface, and additionally during the refresh process of the screen. You only need to use the alpha table to draw the text, you don't need to repeat the text on the screen, you can improve the speed of the text displayed on the screen.

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Image Generation (AREA)
  • Controls And Circuits For Display Device (AREA)

Abstract

本发明公开了一种显示文字的方法及装置,包括:创建缓存位图,填充所述缓存位图的底色,在所述缓存位图上绘制文字,计算所述缓存位图中每个像素点的透明度,并设置文字的显示颜色;在目标位图上绘制文字,根据缓存位图中每个像素点的透明度、目标位图的底色和文字的显示颜色,确定填充到目标位图上的文字的每个像素点的填充颜色,并进行颜色的填充。本发明能够实现文字的多种效果显示,比如,霓虹灯文字、渐变文字,甚至用图案填充文字等,极大地增强了界面上的文字的显示效果,另外在屏幕的刷新过程中只需要利用阿尔法表进行文字的绘制,不需要重复将文字绘制在屏幕,可以提高屏幕显示文字的速度。

Description

一种显示文字的方法及装置
技术领域
本发明涉及文字处理技术领域, 尤其涉及一种显示文字的方法及装置。 背景技术
目前, 手机上的字体引擎一般只支持单色字体。 假如要绘制 "ABC" , 那么该文本可能是红色、 蓝色或其他颜色, 整体上表现为单色。
从根本上来说, 字体引擎在绘制单个字时只能绘制单色, 现有的字体引 擎无法实现单个字的多颜色显示, 比如渐变色等。 发明内容
本发明要解决的技术问题是提供一种显示文字的方法及装置, 能够实现 对文字的多颜色显示。
为解决上述技术问题, 本发明的一种显示文字的方法, 包括:
创建緩存位图, 填充所述緩存位图的底色, 在所述緩存位图上绘制文字, 计算所述緩存位图中每个像素点的透明度, 并设置文字的显示颜色;
在目标位图上绘制文字, 根据緩存位图中每个像素点的透明度、 目标位 图的底色和文字的显示颜色, 确定填充到目标位图上的文字的每个像素点的 填充颜色, 并进行颜色的填充。
优选地, 计算所述緩存位图中每个像素点的透明度, 包括:
根据所述文字的原始颜色、 緩存位图的底色和所述文字在所述緩存位图 上的颜色计算所述緩存位图中每个像素点的透明度。
优选地, 还包括:
将计算得到的緩存位图中每个像素点的透明度保存到阿尔法表中, 在所 述阿尔法表中每个像素点的透明度与像素点的位置对应。
优选地, 在所述文字的原始颜色为 CI ( Rl , Gl , B1 ) , 所述緩存位图 的底色为 C2 ( R2, G2, B2 ) , 所述文字在所述緩存位图上的颜色为 C3 ( R3 , G3 , Β3 )时, 所述每个像素点的透明度 α按照, α = [(R3-R2)x255]/(R1-R2)、 α = [(G3-G2)x255]/(G1-G2), 或者 α = [(Β3-Β2)χ255]/(Β1-Β2)进行计算。
优选地, 填充所述緩存位图的底色, 包括: 填充所述緩存位图的底色为 所述文字的原始颜色的补色。
优选地, 根据緩存位图中每个像素点的透明度、 目标位图的底色和文字 的显示颜色, 确定填充到目标位图上的文字的每个像素点的填充颜色包括: 遍历每一像素点的透明度, 在像素点的透明度为全透明时, 确定文字在 该像素点的填充颜色为目标位图的底色; 在像素点的透明度为不透明时, 确 定文字在该像素点的填充颜色为文字在该像素点的显示颜色; 在像素点的透 明度为半透明时, 按照该像素点的透明度, 合成目标位图的底色和文字在该 像素点的显示颜色, 作为文字在该像素点的填充颜色。
优选地, 按照该像素点的透明度, 合成目标位图的底色和文字在该像素 点的显示颜色, 包括:
在所述文字在该像素点的显示颜色为(Rl , Gl , B1 ) , 目标位图的底色 为 (R2, G2, Β2 ) , 像素点的透明度为 α时, 合成得到的文字在该像素点的 填充颜色(R3 , G3 , Β3 )为: R3 = [Rl +R2x(255- )]/255; G3 = [Gl +G2x(255- )]/255; B3 = [Βΐ χ α +Β2χ(255- a )]/255。
本发明还提供了一种显示文字的装置, 包括: 緩存文字绘制模块、 阿尔 法表创建模块、 文字颜色表构建模块和目标文字绘制模块, 其中:
所述緩存文字绘制模块设置为: 创建緩存位图, 填充所述緩存位图的底 色, 在所述緩存位图上绘制文字;
所述阿尔法表创建模块设置为: 计算所述緩存位图中每个像素点的透明 度;
所述文字颜色表构建模块设置为: 设置文字的显示颜色;
所述目标文字绘制模块设置为: 在目标位图上绘制文字, 根据緩存位图 中每个像素点的透明度、 目标位图的底色和文字的显示颜色, 确定填充到目 标位图上的文字的每个像素点的填充颜色, 并进行颜色的填充。 优选地, 所述阿尔法表创建模块是设置为: 根据所述文字的原始颜色、 緩存位图的底色和所述文字在所述緩存位图上的颜色计算所述緩存位图中每 个像素点的透明度, 计算得到的緩存位图中每个像素点的透明度保存到阿尔 法表中, 在所述阿尔法表中每个像素点的透明度与像素点的位置对应。
优选地, 所述目标文字绘制模块是设置为: 遍历每一像素点的透明度, 在像素点的透明度为全透明时, 确定文字在该像素点的填充颜色为目标位图 的底色; 在像素点的透明度为不透明时, 确定文字在该像素点的填充颜色为 文字在该像素点的显示颜色; 在像素点的透明度为半透明时, 按照该像素点 的透明度, 合成目标位图的底色和文字在该像素点的显示颜色, 作为文字在 该像素点的填充颜色。
综上所述, 本发明实施例能够实现文字的多种效果显示, 比如, 霓虹灯 文字、 渐变文字, 甚至用图案填充文字等, 极大地增强了界面上的文字的显 示效果, 另外在屏幕的刷新过程中只需要利用阿尔法表进行文字的绘制, 不 需要重复将文字绘制在屏幕, 可以提高屏幕显示文字的速度。 附图概述
图 1为本发明实施方式的显示文字的方法的流程图;
图 2为本发明实施方式的显示文字的装置的结构框图。 本发明的较佳实施方式
本实施方式中通过将文字绘制于创建的緩存位图中, 緩存位图的底色可 以用文字的补色填充, 对緩存位图进行透明度计算, 对计算出的透明度进行 保存, 如可以保存到创建的阿尔法表中; 获取或计算出文字颜色表, 文字颜 色表中保存文字需要显示的颜色, 在目标位图上绘制文字, 根据文字颜色表、 阿尔法表中的透明度和目标位图的底色计算出文字应该绘制的颜色, 并绘制 到屏幕上。 本实施方式可以灵活实现单个文字的多种颜色效果, 以增强界面 上的文字显示效果。
下面结合各个附图对本实施方式的具体实现过程予以进一步详细说明。 如图 1所示, 本实施方式的显示文字的方法, 包括:
步骤 101 : 创建緩存位图;
创建的緩存位图可以与文字显示区域的大小相同。
步骤 102: 将緩存位图的底色填充为文字的原始颜色的补色, 在緩存位 图上绘制文字;
创建緩存位图是为了计算出緩存位图上每个像素点的透明度。
将緩存位图的底色填充为文字的原始颜色的补色是为了让字体与緩存位 图的背景色形成最大反差, 从而在提取透明度时能够最大程度的降低误差。 在緩存位图上绘制文字后, 就可以得到一张有文字的具有单色背景的緩存位 图。
步骤 103: 构建阿尔法表, 计算緩存位图中每个像素点的透明度, 并记 录在创建的阿尔法表中;
由于文字轮廓上的像素点具有透明度, 阿尔法表用于记录各像素点的透 明度信息, 阿尔法表中每个像素点的透明度与像素点的位置对应, 当阿尔法 表中所有位置的透明度都计算完成后, 文字的基准轮廓就可以确定了。
假设文字的原始颜色为 C1 , 补色为 C2, 緩存位图中对应像素点的颜色 为 C3 , 分解 Cl、 C2和 C3可以分别得到 (Rl , Gl , Bl ) 、 ( R2, G2, B2 ) 和(R3 , G3 , B3 ) , 假定该点透明度为 α , 像素点的透明度可按照如下方式 计算:
= [(R3-R2)x255]/(R1-R2) (1)
= [(G3-G2)x255]/(G1-G2) (2)
= [(Β3-Β2)χ255]/(Β1-Β2) (3)
在具体实施中可釆用(1)、(2)和 (3)中的任意一个公式计算 o , 将计算得到 的 α保存到阿尔法表的对应位置。
通过以上步骤即可得到緩存位图上每个像素点的透明度。
步骤 104: 创建文字颜色表, 设置文字的显示颜色表(文字需要显示的 颜色) , 将文字每个像素点的显示颜色保存到文字颜色表中; 根据需要显示的效果, 创建对应的颜色表, 对渐变颜色效果, 每个像素 点的显示颜色按如下方式计算:
Rx= [(x2-x)xR4+(xl-x)xR5]/(x2-xl) (4)
Gx= [(χ2-χ) G4+(xl -x) G5]/(x2-xl ) (5)
Bx= [(x2-x)xB4+(xl-x)xB5]/(x2-xl) (6)
其中, (R4, G4, B4)和(R5, G5, B5 )为文字的颜色区间, [xl, x2] 为文字的起始坐标, (Rx, Gx, Bx)为坐标为 x的像素点的显示颜色。
对另外一些没有算法的颜色效果, 可以直接将颜色值写入颜色表中。 步骤 105: 在目标位图上绘制文字, 目标位图相当于显示屏幕; 文字最终会绘制到一个背景色或图片上, 即目标位图区域, 目标位图本 身会有底色或图案。
步骤 106: 根据阿尔法表、 目标位图的底色和文字颜色表, 确定填充到 文字的每个像素点上的颜色, 并进行颜色的填充。 根据文字的颜色表、 阿尔法表和目标位图的底色, 进行效果的绘制, 遍 历阿尔法表上的每一像素点的透明度, 若像素点的透明度为 255 (全透明) , 则保留文字在该像素点的颜色为目标位图的底色;若像素点的透明度为 0(不 透明), 则确定文字在该像素点的颜色为颜色表中该像素点对应的显示颜色; 若像素点的透明度介于 0~255之间 (半透明) , 则按照像素点的透明度合成 该像素点上的目标位图的底色和颜色表中的显示颜色,作为该像素点的颜色, 合成公式为:
R3 = [Rlx +R2x(255- )]/255 (7)
G3 = [Gl +G2x(255- )]/255 (8)
B3 = [Βΐχ +Β2χ(255- )]/255 (9)
其中, (Rl, Gl, Bl ) 为像素点在文字颜色表中的显示颜色, (R2, G2, B2)为像素点对应的目标位图的底色, a为像素点在阿尔法表中的透明 度, (R3, G3, B3)为最终的合成色, 并将合成色填充到目标位图中的对应 像素点上, 至此就完成了文字最后效果的绘制。 如图 2所示, 本实施方式还提供了一种文字显示的装置, 包括: 緩存文 字绘制模块、 阿尔法表创建模块、 文字颜色表构建模块和目标文字绘制模块, 其中:
緩存文字绘制模块, 用于创建緩存位图, 填充緩存位图的底色, 在緩存 位图上绘制文字;
阿尔法表创建模块, 用于计算緩存位图中每个像素点的透明度; 文字颜色表构建模块, 用于设置文字的显示颜色;
目标文字绘制模块, 用于在目标位图上绘制文字, 根据緩存位图中每个 像素点的透明度、 目标位图的底色和文字的显示颜色, 确定填充到目标位图 上的文字的每个像素点的填充颜色, 并进行颜色的填充。
阿尔法表创建模块, 具体用于根据文字的原始颜色、 緩存位图的底色和 文字在緩存位图上的颜色计算緩存位图中每个像素点的透明度, 计算得到的 緩存位图中每个像素点的透明度保存到阿尔法表中, 在阿尔法表中每个像素 点的透明度与像素点的位置对应。
在文字的原始颜色为 CI (Rl, Gl, B1 ) , 緩存位图的底色为 C2 (R2,
G2, B2) , 文字在緩存位图上的颜色为 C3 (R3, G3, B3 ) 时, 每个像素点 的透明度 o按照, α = [(R3-R2)x255]/(R1-R2)、 α = [(G3-G2)x255]/(G1-G2) 或者 α = [(Β3-Β2)χ255]/(Β1-Β2)进行计算。
目标文字绘制模块, 具体用于遍历每一像素点的透明度, 在像素点的透 明度为全透明时, 确定文字在该像素点的填充颜色为目标位图的底色; 在像 素点的透明度为不透明时, 确定文字在该像素点的填充颜色为文字在该像素 点的显示颜色; 在像素点的透明度为半透明时, 按照该像素点的透明度, 合 成目标位图的底色和文字在该像素点的显示颜色, 作为文字在该像素点的填 充颜色。
在文字在该像素点的显示颜色为(Rl, Gl, B1 ), 目标位图的底色为(R2,
G2, Β2) , 像素点的透明度为 α时, 合成得到的文字在该像素点的填充颜色 (R3,G3,B3 )为: R3 = [R1 a +R2x(255- )]/255; G3 = [Gl +G2x(255- )]/255; Β3 = [Βΐχ α+Β2χ(255- α)]/255。 本实施方式装置的具体工作过程请参阅上述方法中相关内容的描述, 这 里不再给予过多赘述。
显然, 本领域的技术人员应该明白, 上述的本发明的各模块或各步骤可 以用通用的计算装置来实现, 它们可以集中在单个的计算装置上, 或者分布 在多个计算装置所组成的网络上, 可选地, 它们可以用计算装置可执行的程 序代码来实现, 从而, 可以将它们存储在存储装置中由计算装置来执行, 并 且在某些情况下, 可以以不同于此处的顺序执行所示出或描述的步骤, 或者 将它们分别制作成各个集成电路模块, 或者将它们中的多个模块或步骤制作 成单个集成电路模块来实现。 这样, 本发明不限制于任何特定的硬件和软件 结合。
以上所述仅为本发明的优选实施例而已, 并不用于限制本发明, 对于本 领域的技术人员来说, 本发明可以有各种更改和变化。 凡在本发明的精神和 原则之内, 所作的任何修改、 等同替换、 改进等, 均应包含在本发明的保护 范围之内。
工业实用性 本发明实施例能够实现文字的多种效果显示, 比如, 霓虹灯文字、 渐变 文字, 甚至用图案填充文字等, 极大地增强了界面上的文字的显示效果, 另 外在屏幕的刷新过程中只需要利用阿尔法表进行文字的绘制, 不需要重复将 文字绘制在屏幕, 可以提高屏幕显示文字的速度。

Claims

1、 一种显示文字的方法, 包括:
创建緩存位图, 填充所述緩存位图的底色, 在所述緩存位图上绘制文字, 计算所述緩存位图中每个像素点的透明度, 并设置文字的显示颜色;
在目标位图上绘制文字, 根据緩存位图中每个像素点的透明度、 目标位 图的底色和文字的显示颜色, 确定填充到目标位图上的文字的每个像素点的 填充颜色, 并进行颜色的填充。
2、 如权利要求 1所述的方法,其中,计算所述緩存位图中每个像素点的 透明度, 包括:
根据所述文字的原始颜色、 緩存位图的底色和所述文字在所述緩存位图 上的颜色计算所述緩存位图中每个像素点的透明度。
3、 如权利要求 2所述的方法, 其中, 还包括:
将计算得到的緩存位图中每个像素点的透明度保存到阿尔法表中, 在所 述阿尔法表中每个像素点的透明度与像素点的位置对应。
4、 如权利要求 2所述的方法, 其中,
在所述文字的原始颜色为 CI ( Rl , Gl , B1 ) , 所述緩存位图的底色为 C2 ( R2, G2, B2 ) , 所述文字在所述緩存位图上的颜色为 C3 ( R3 , G3 , B3 ) 时, 所述每个像素点的透明度 α按照, α = [(R3-R2)x255]/(R1-R2)、 α = [(G3-G2)x255]/(G1-G2), 或者 α = [(Β3-Β2)χ255]/(Β1-Β2)进行计算。
5、 如权利要求 1所述的方法, 其中, 填充所述緩存位图的底色, 包括: 填充所述緩存位图的底色为所述文字的原始颜色的补色。
6、 如权利要求 1所述的方法,其中,根据緩存位图中每个像素点的透明 度、 目标位图的底色和文字的显示颜色, 确定填充到目标位图上的文字的每 个像素点的填充颜色包括:
遍历每一像素点的透明度, 在像素点的透明度为全透明时, 确定文字在 该像素点的填充颜色为目标位图的底色; 在像素点的透明度为不透明时, 确 定文字在该像素点的填充颜色为文字在该像素点的显示颜色; 在像素点的透 明度为半透明时, 按照该像素点的透明度, 合成目标位图的底色和文字在该 像素点的显示颜色, 作为文字在该像素点的填充颜色。
7、 如权利要求 6所述的方法, 其中, 按照该像素点的透明度, 合成目标 位图的底色和文字在该像素点的显示颜色, 包括:
在所述文字在该像素点的显示颜色为(Rl , Gl , B1 ) , 目标位图的底色 为 (R2, G2, B2 ) , 像素点的透明度为 α时, 合成得到的文字在该像素点的 填充颜色(R3 , G3 , Β3 )为: R3 = [Rl +R2x(255- )]/255; G3 = [Gl +G2x(255- )]/255; B3 = [Βΐ χ α +Β2χ(255- a )]/255。
8、 一种显示文字的装置,包括:緩存文字绘制模块、阿尔法表创建模块、 文字颜色表构建模块和目标文字绘制模块, 其中:
所述緩存文字绘制模块设置为: 创建緩存位图, 填充所述緩存位图的底 色, 在所述緩存位图上绘制文字;
所述阿尔法表创建模块设置为: 计算所述緩存位图中每个像素点的透明 度;
所述文字颜色表构建模块设置为: 设置文字的显示颜色;
所述目标文字绘制模块设置为: 在目标位图上绘制文字, 根据緩存位图 中每个像素点的透明度、 目标位图的底色和文字的显示颜色, 确定填充到目 标位图上的文字的每个像素点的填充颜色, 并进行颜色的填充。
9、 如权利要求 8所述的装置, 其中,
所述阿尔法表创建模块是设置为: 根据所述文字的原始颜色、 緩存位图 的底色和所述文字在所述緩存位图上的颜色计算所述緩存位图中每个像素点 的透明度, 计算得到的緩存位图中每个像素点的透明度保存到阿尔法表中, 在所述阿尔法表中每个像素点的透明度与像素点的位置对应。
10、 如权利要求 8所述的装置, 其中, 所述目标文字绘制模块是设置为: 遍历每一像素点的透明度, 在像素点 的透明度为全透明时, 确定文字在该像素点的填充颜色为目标位图的底色; 在像素点的透明度为不透明时, 确定文字在该像素点的填充颜色为文字在该 像素点的显示颜色; 在像素点的透明度为半透明时, 按照该像素点的透明度, 合成目标位图的底色和文字在该像素点的显示颜色, 作为文字在该像素点的 填充颜色。
PCT/CN2012/071315 2011-11-29 2012-02-20 一种显示文字的方法及装置 WO2013078788A1 (zh)

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN201110387434.8 2011-11-29
CN201110387434 2011-11-29
CN2012100370052A CN103136169A (zh) 2011-11-29 2012-02-17 一种显示文字的方法及装置
CN201210037005.2 2012-02-17

Publications (1)

Publication Number Publication Date
WO2013078788A1 true WO2013078788A1 (zh) 2013-06-06

Family

ID=48496010

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2012/071315 WO2013078788A1 (zh) 2011-11-29 2012-02-20 一种显示文字的方法及装置

Country Status (2)

Country Link
CN (1) CN103136169A (zh)
WO (1) WO2013078788A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107358637A (zh) * 2017-06-28 2017-11-17 广州酷狗计算机科技有限公司 文字绘制方法及装置、终端及存储介质

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107689071A (zh) * 2016-08-04 2018-02-13 创盛视联数码科技(北京)有限公司 文字动画生成的方法
CN106657821B (zh) * 2016-12-28 2020-04-28 杭州趣维科技有限公司 一种效果百变的动画字幕绘制方法
CN106940878A (zh) * 2017-02-27 2017-07-11 深圳华盛昌机械实业有限公司 一种显示方法和装置
CN110032712A (zh) * 2018-01-12 2019-07-19 北京方正手迹数字技术有限公司 一种字体渲染装置及终端

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010020956A1 (en) * 1997-12-09 2001-09-13 Zyris Plc. Graphic image design
CN101908216A (zh) * 2010-07-20 2010-12-08 中兴通讯股份有限公司 一种实现矢量字体的方法及装置
CN101968888A (zh) * 2010-09-08 2011-02-09 东莞电子科技大学电子信息工程研究院 一种适用于移动终端的矢量图形填充方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20010020956A1 (en) * 1997-12-09 2001-09-13 Zyris Plc. Graphic image design
CN101908216A (zh) * 2010-07-20 2010-12-08 中兴通讯股份有限公司 一种实现矢量字体的方法及装置
CN101968888A (zh) * 2010-09-08 2011-02-09 东莞电子科技大学电子信息工程研究院 一种适用于移动终端的矢量图形填充方法

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107358637A (zh) * 2017-06-28 2017-11-17 广州酷狗计算机科技有限公司 文字绘制方法及装置、终端及存储介质
CN107358637B (zh) * 2017-06-28 2020-09-25 广州酷狗计算机科技有限公司 文字绘制方法及装置、终端及存储介质

Also Published As

Publication number Publication date
CN103136169A (zh) 2013-06-05

Similar Documents

Publication Publication Date Title
US10134106B2 (en) Method and device for selective display refresh
US9129581B2 (en) Method and apparatus for displaying images
WO2013078788A1 (zh) 一种显示文字的方法及装置
US20160171642A1 (en) Overlap Aware Reordering of Rendering Operations for Efficiency
US20150287220A1 (en) Rendering text using anti-aliasing techniques, cached coverage values, and/or reuse of font color values
JP2016091543A (ja) レンダリング方法、レンダリング装置及び電子装置
CN105487848B (zh) 一种3d应用的显示刷新方法及系统
CN101908216B (zh) 一种实现矢量字体的方法及装置
WO2018119575A1 (zh) 一种显示方法及电子设备
EP2766874B1 (en) Caching coverage values for rendering text using anti-aliasing techniques
WO2018000372A1 (zh) 画面显示的方法和终端
CN107908336A (zh) 列表控件的刷新方法、装置、存储介质及终端
US20160378272A1 (en) Systems and methods for providing multi-focus to applications for collaboration
CN103400565B (zh) 一种基于gdi的界面分块刷新方法
WO2022179362A1 (zh) 一种图像融合方法以及装置
US10643580B2 (en) Method and device for switching playing mode of a mobile terminal, storage medium and program
CN110473273A (zh) 矢量图形的绘制方法、装置、存储介质及终端
CN105427358B (zh) 一种基于安卓的视图动画生成方法及系统
CN105096365A (zh) 一种3d界面局部刷新方法及系统
WO2014050845A1 (ja) グラフィックス描画装置
CN109598672B (zh) 一种地图道路渲染方法及装置
CN106354449B (zh) 一种文档在线演示方法及客户端
CN104503954A (zh) 一种文字组合显示方法及显示系统
CN102902658A (zh) 一种炫彩字显示方法和装置
CA2390390C (en) Graphics stack system and method

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 12854056

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 12854056

Country of ref document: EP

Kind code of ref document: A1