

技术领域technical field
本发明涉及一种图像处理方法,尤其涉及一种在flash上进行位图微像素处理的方法。The invention relates to an image processing method, in particular to a method for processing bitmap micro-pixels on flash.
背景技术Background technique
flash内部度量对象位置和尺寸的单位是缇(Twips),目的是为了让应用程序元素输出到不同设备时都能保持一致的计算方式。一般可以使用以下换算公式将英寸或厘米转换为缇或磅(1缇为1/20磅):The internal unit of flash to measure the position and size of an object is twips (Twips), the purpose of which is to maintain a consistent calculation method when application elements are output to different devices. Generally, the following conversion formula can be used to convert inches or centimeters to twips or pounds (1 twip is 1/20 of a pound):
1磅=1/72英寸=20缇1 pound = 1/72 inch = 20 twips
1英寸=72磅=1440缇1 inch = 72 pounds = 1440 twips
1厘米=567缇1 cm = 567 twips
但是在flash中操作显示对象的API(Application Programming Interface,应用程序接口,又称为应用编程接口,就是软件系统不同组成部分衔接的约定)的参数类型大部分是双精度浮点数的数据类型,比如设置DisplayObjetct(DisplayObject类是可放在显示列表中的所有对象的基类)的width(宽),height(高),x,y等属性,这时程序可能表达出比缇精度更高的数值导致flash需要对该值进行取舍。这样的话在某种精度要求很高或有缩放的环境下会导致显示上的sub-pixelbug(亚像素错误)。如图1所示,图1a中3个图片的Scale(比例)设置为1,图1b中3个图片的Scale(比例)设置为1.0006;可以看出图1b的第二和第三个图片中间有一条缝隙,而有的时候这条缝隙是必须处理掉的。However, most of the parameter types of the API (Application Programming Interface, application programming interface, also known as the application programming interface, which is the agreement for the connection of different components of the software system) to operate the display object in flash are double-precision floating-point data types, such as Set the width (width), height (height), x, y and other properties of DisplayObject (DisplayObject class is the base class of all objects that can be placed in the display list), and the program may express values with higher precision than twips. Flash needs to round up this value. In this case, it will cause sub-pixel bugs (sub-pixel errors) on the display in certain environments with high precision requirements or scaling. As shown in Figure 1, the Scale (proportion) of the three pictures in Figure 1a is set to 1, and the Scale (proportion) of the three pictures in Figure 1b is set to 1.0006; it can be seen that the middle of the second and third pictures in Figure 1b There is a gap, and sometimes this gap has to be dealt with.
解决上述问题有以下几个难点:There are several difficulties in solving the above problems:
难点1:此类问题不易被发觉和重现。因为此类问题需要特定的缩放环境才能产生,所以一般不易被察觉和重现。当出现时往往认为是程序上的bug而去反复的检查程序,这样给问题的定位带来了困难。Difficulty 1: Such problems are not easy to be discovered and reproduced. Because such problems require a specific zoom environment to occur, they are generally not easy to detect and reproduce. When it occurs, it is often considered a bug in the program and the program is checked repeatedly, which makes it difficult to locate the problem.
难点2:修复对象的尺寸和位置难以确定。选择一个合适的精度对对象的位置和大小进行修复是比较困难的。Difficulty 2: It is difficult to determine the size and position of the repaired object. It is more difficult to choose an appropriate precision to inpaint the object's position and size.
发明内容Contents of the invention
本发明要解决的技术问题是提供一种在flash上进行位图微像素处理的方法,该方法可以有效地解决sub-pixel bug(亚像素错误)问题。The technical problem to be solved by the present invention is to provide a method for bitmap micro-pixel processing on flash, which can effectively solve the sub-pixel bug (sub-pixel error) problem.
为解决上述技术问题,本发明提供一种在flash上进行位图微像素处理的方法,包括如下步骤:In order to solve the above-mentioned technical problems, the present invention provides a kind of method that carries out bitmap micro-pixel processing on flash, comprises the steps:
(1)如果出现亚像素错误问题,判断图像是否为简单的平铺方式;如果是则用flash draw API(指在flash创作环境中的绘画的接口方法)提供的beginBitmapFill API方法来解决亚像素错误问题;如果否则进入步骤(2);(1) If there is a sub-pixel error problem, determine whether the image is a simple tiling method; if so, use the beginBitmapFill API method provided by the flash draw API (referring to the interface method of painting in the flash creation environment) to solve the sub-pixel error question; if otherwise go to step (2);
(2)判断图像是否可以在父层统一缩放;如果是则在其父层进行统一缩放,以解决亚像素错误问题;如果否则进入步骤(3);(2) Determine whether the image can be uniformly scaled at the parent layer; if so, then uniformly scale at its parent layer to solve the sub-pixel error problem; otherwise enter step (3);
(3)修复对象的位置和尺寸,判断对象的位置和尺寸是否小于flash中能处理的基于缇(Twips)为单位所对应的像素值;如是则对该对象的位置和尺寸基于缇为单位所对应的像素值进行修正,以解决亚像素错误问题。(3) Repair the position and size of the object, and judge whether the position and size of the object are smaller than the pixel value corresponding to the unit based on twips (Twips) that can be processed in the flash; The corresponding pixel values are corrected to solve the problem of sub-pixel errors.
步骤(1)中,所述用flash draw API提供的beginBitmapFill API方法来解决亚像素错误问题,具体为:用beginBitmapFill API方法设置平铺方式为重复,即设置repeat参数为true来解决亚像素错误问题。In step (1), use the beginBitmapFill API method provided by the flash draw API to solve the sub-pixel error problem, specifically: use the beginBitmapFill API method to set the tiling method to repeat, that is, set the repeat parameter to true to solve the sub-pixel error problem .
步骤(3)具体包括如下步骤:Step (3) specifically comprises the following steps:
A.计算flash中能处理的最小像素值:1磅=1/72英寸=20缇,假设屏幕DPI等于72DPI,则flash中能处理的最小像素值为0.05px,即1/20缇;A. Calculate the minimum pixel value that can be processed in flash: 1 pound = 1/72 inch = 20 twips, assuming that the screen DPI is equal to 72DPI, then the minimum pixel value that can be processed in flash is 0.05px, which is 1/20 twips;
B.计算对象的实际尺寸并进行修正:将对象的尺寸X乘以其缩放比例Y得到结果M,发现其结果M非0.05px的整数倍,这时需要对该结果M基于0.05的精度进行四舍五入得结果N;B. Calculate the actual size of the object and correct it: Multiply the size X of the object by its zoom ratio Y to get the result M, and find that the result M is not an integer multiple of 0.05px, then the result M needs to be rounded based on the precision of 0.05 Get the result N;
C.设置对象修正后的尺寸和位置:将步骤B的结果N除以对象的尺寸X得到缩放比例Y’,根据该缩放比例Y’来计算设置对象修正后的尺寸和位置。C. Set the corrected size and position of the object: Divide the result N of step B by the size X of the object to obtain the scaling ratio Y', and calculate the corrected size and position of the setting object according to the scaling ratio Y'.
本发明的有益效果在于:本发明可以有效地解决sub-pixel bug(亚像素错误)问题,且步骤简单,可操作性强。The beneficial effect of the present invention is that: the present invention can effectively solve the problem of sub-pixel bug (sub-pixel error), and has simple steps and strong operability.
附图说明Description of drawings
图1是现有在flash中操作显示对象时导致显示上出现sub-pixel bug(亚像素错误)的示意图;其中,图1a中3个图片的Scale(比例)设置为1;图1b中3个图片的Scale(比例)设置为1.0006;Figure 1 is a schematic diagram of a sub-pixel bug (sub-pixel error) on the display caused by operating a display object in flash; among them, the Scale (proportion) of the three pictures in Figure 1a is set to 1; the three pictures in Figure 1b The Scale (ratio) of the picture is set to 1.0006;
图2是本发明方法的流程示意图。Fig. 2 is a schematic flow chart of the method of the present invention.
具体实施方式Detailed ways
如图2所示,本发明一种在flash上进行位图微像素处理的方法,包括如下步骤:As shown in Figure 2, a kind of method that the present invention carries out bitmap micro-pixel processing on flash, comprises the following steps:
1.如果出现sub-pixel bug(亚像素错误)问题,判断图像是否为简单的平铺方式;如果是则使用flash draw API(指在flash创作环境中的绘画的接口方法,属于本领域公知的方法)提供的beginBitmapFill API(设置平铺方式为重复,即设置repeat参数为true)来完成此工作(即解决sub-pixel bug问题);如果否则进入步骤2。1. If a sub-pixel bug (sub-pixel error) problem occurs, judge whether the image is a simple tiling method; if so, use the flash draw API (referring to the interface method of painting in the flash creation environment, which belongs to the well-known in the art method) provides beginBitmapFill API (set the tiling method to repeat, that is, set the repeat parameter to true) to complete this work (that is, solve the sub-pixel bug problem); otherwise, go to step 2.
例如:(代码示例//开头表示注释行)For example: (code example //begins with a comment line)
//已知的位图对象(bitmapdata)//Known bitmap object (bitmapdata)
//创建一个简单形状并命名为shape://Create a simple shape and name it shape:
var shape:Shape=new Shape();var shape: Shape = new Shape();
//获取shape的矢量图形的对象的引用并命名为graphic:// Get a reference to the shape's vector graphics object and name it graphic:
var graphic:Graphics=shape.graphic;var graphics: Graphics = shape.graphic;
//调用graphic的画图API,填充一张位图bitmapdata,设置repeat参数为true://Call the graphic drawing API, fill a bitmap bitmapdata, and set the repeat parameter to true:
graphic.beginBitmapFill(bitmapdata,null,true);graphic.beginBitmapFill(bitmapdata, null, true);
//将该位图bitmapdata填充到坐标(0,0)大小bitmapdata.width,bitmapdata.height的区域中://Fill the bitmap data into the coordinate (0, 0) size bitmapdata.width, bitmapdata.height area:
graphic.drawRect(0,0,bitmapdata.width,bitmapdata.height);graphic.drawRect(0, 0, bitmapdata.width, bitmapdata.height);
//画图程序结束:// end of drawing program:
graphic.endFill()。graphic. endFill().
2.判断图像是否可以在父层(即父层容器或父容器)统一缩放;如果是则在其父层对其所有子显示对象进行统一的缩放,以解决sub-pixel bug问题;如果否则进入步骤3。2. Determine whether the image can be uniformly scaled in the parent layer (that is, the parent layer container or parent container); if so, uniformly scale all its child display objects in its parent layer to solve the sub-pixel bug problem; otherwise, enter Step 3.
例如:(代码示例//开头表示注释行)For example: (code example //begins with a comment line)
//已知的位图对象(bitmapdataA,bitmapdataB,父容器spriteA)//Known bitmap objects (bitmapdataA, bitmapdataB, parent container spriteA)
//声明一个变量并命名为scaleX值为1.0006:// Declare a variable and name it scaleX with a value of 1.0006:
var scaleX:Number=1.0006;var scaleX:Number=1.0006;
//设置位图对象bitmapdataA的水平方向缩放为scaleX,即1.0006://Set the horizontal scaling of the bitmap object bitmapdataA to scaleX, which is 1.0006:
bitmapdataA.scaleX=scaleX;bitmapdataA.scaleX = scaleX;
//设置位图对象bitmapdataA的水平方向的坐标为0://Set the horizontal coordinates of the bitmap object bitmapdataA to 0:
bitmapdataA.x=0;bitmapdataA.x = 0;
//设置位图对象bitmapdataB的水平方向缩放为scaleX,即1.0006://Set the horizontal scaling of the bitmap object bitmapdataB to scaleX, which is 1.0006:
bitmapdataB.scaleX=scaleX;bitmapdataB.scaleX = scaleX;
//设置位图对象bitmapdataB的水平方向的坐标值为:bitmapdataA在水平方向上的缩放值乘以bitmapdataA的实际宽度://Set the horizontal coordinate value of the bitmap object bitmapdataB: multiply the scaling value of bitmapdataA in the horizontal direction by the actual width of bitmapdataA:
bitmapdataB.x=bitmapdataA.scaleX*bitmapdataA.width;bitmapdataB.x = bitmapdataA.scaleX*bitmapdataA.width;
(改成)(change to)
//声明一个变量并命名为scaleX值为1.0006:// Declare a variable and name it scaleX with a value of 1.0006:
var scaleX:Number=1.0006;var scaleX:Number=1.0006;
//设置显示对象sprite的水平方向缩放为scaleX,即为1.0006://Set the horizontal scaling of the display object sprite to scaleX, which is 1.0006:
sprite.scaleX=scaleX。sprite.scaleX=scaleX.
3.修复对象的位置和尺寸,判断对象的位置和尺寸是否小于flash中能处理的基于缇(Twips)为单位所对应的像素值。如是则对该对象的位置和尺寸基于缇(Twips)为单位所对应的像素值进行修正,以解决sub-pixel bug(亚像素错误)问题;3. Repair the position and size of the object, and judge whether the position and size of the object are smaller than the pixel value corresponding to the unit of twips (Twips) that can be processed in the flash. If so, correct the position and size of the object based on the pixel value corresponding to the unit of Twips to solve the sub-pixel bug (sub-pixel error) problem;
假设有显示对象displayObjectA,displayObjectB,displayObjectA的宽度为345px(像素),displayObjectB的宽度为456px(像素),现需要将display0bjectA缩放至1.006,displayObjectB缩放至1.007,然后将displayObjectA、displayObjectB两个显示对象水平排列。Suppose there are display objects displayObjectA, displayObjectB, the width of displayObjectA is 345px (pixels), and the width of displayObjectB is 456px (pixels), now you need to scale display0bjectA to 1.006, displayObjectB to 1.007, and then arrange the two display objects displayObjectA and displayObjectB horizontally .
具体步骤:Specific steps:
1)计算flash中能够处理的最小像素值:1磅=1/72英寸=20缇,假设屏幕DPI(Dots Per Inch的缩写,每英寸所打印的点数或线数)等于72DPI,则flash中能够处理的最小像素值为0.05px(像素),即1/20缇。1) Calculate the minimum pixel value that can be processed in flash: 1 pound = 1/72 inch = 20 twips, assuming that the screen DPI (abbreviation of Dots Per Inch, the number of dots or lines printed per inch) is equal to 72DPI, then the flash can The minimum pixel value processed is 0.05px (pixel), which is 1/20 twip.
2)计算对象的实际尺寸并进行修正:345px(displayObjectA的宽度单位像素)*1.006=347.07,发现非0.05px(像素)的整数倍(flash会对该结果进行不可控的取舍,是屏幕出现亚像素错误问题根本原因),这时需要对结果347.07基于0.05的精度进行四舍五入,即对347.07的小数点后的第二位进行四舍五入,即347.07=》347.1。2) Calculate the actual size of the object and correct it: 345px (the width unit pixel of displayObjectA) * 1.006 = 347.07, it is found that it is not an integer multiple of 0.05px (pixel) (flash will make uncontrollable trade-offs for this result, which is the result of sub-pixels appearing on the screen. The root cause of the pixel error problem), at this time, it is necessary to round the result 347.07 based on the precision of 0.05, that is, to round the second digit after the decimal point of 347.07, that is, 347.07=>347.1.
3)设置对象修正后的尺寸和位置:3) Set the corrected size and position of the object:
A.重新计算displayObjectA的正确缩放值scale为:A. Recalculate the correct zoom value scale of displayObjectA as:
scale=347.1/345;scale=347.1/345;
B.设置displayObjectA的缩放的水平方向上的缩放为scale:B. Set the scaling of displayObjectA in the horizontal direction to scale:
displayObjectA.scaleX=scale;displayObjectA.scaleX=scale;
displayObjectA.x=0;displayObjectA.x = 0;
C.根据displayObjectA的水平方向上的缩放和displayObjectA在水平方向上的位置来设置displayObjectB的水平方向上的位置:C. Set the horizontal position of displayObjectB according to the horizontal scaling of displayObjectA and the horizontal position of displayObjectA:
displayObjectB.x=displayObjectA.width*scale+displayObjectA.x。displayObjectB.x=displayObjectA.width*scale+displayObjectA.x.
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201010523252.4ACN102456218B (en) | 2010-10-28 | 2010-10-28 | A kind of method processed in the enterprising line position figure micro-pixels of flash |
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201010523252.4ACN102456218B (en) | 2010-10-28 | 2010-10-28 | A kind of method processed in the enterprising line position figure micro-pixels of flash |
| Publication Number | Publication Date |
|---|---|
| CN102456218Atrue CN102456218A (en) | 2012-05-16 |
| CN102456218B CN102456218B (en) | 2016-06-08 |
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN201010523252.4AActiveCN102456218B (en) | 2010-10-28 | 2010-10-28 | A kind of method processed in the enterprising line position figure micro-pixels of flash |
| Country | Link |
|---|---|
| CN (1) | CN102456218B (en) |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US5847706A (en)* | 1995-11-30 | 1998-12-08 | Hewlett Packard Company | Sizeable window for tabular and graphical representation of data |
| CN101123061A (en)* | 2001-05-09 | 2008-02-13 | 克雷沃耶提实验室有限公司 | Conversion of one sub-pixel format data to another sub-pixel data format |
| CN101571954A (en)* | 2008-04-29 | 2009-11-04 | 奥多比公司 | Subpixel registration |
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| US5847706A (en)* | 1995-11-30 | 1998-12-08 | Hewlett Packard Company | Sizeable window for tabular and graphical representation of data |
| CN101123061A (en)* | 2001-05-09 | 2008-02-13 | 克雷沃耶提实验室有限公司 | Conversion of one sub-pixel format data to another sub-pixel data format |
| CN101571954A (en)* | 2008-04-29 | 2009-11-04 | 奥多比公司 | Subpixel registration |
| Title |
|---|
| 姆科: "《ActionScript 3.0编程精髓》", 31 May 2008, 北京:机械工业出版社* |
| 布劳恩斯坦: "《ActionScript 3.0宝典》", 30 September 2008* |
| Publication number | Publication date |
|---|---|
| CN102456218B (en) | 2016-06-08 |
| Publication | Publication Date | Title |
|---|---|---|
| US10331393B2 (en) | Vehicle-mounted terminal and method for obtaining resolution of a screen of a handheld terminal | |
| CN103984720B (en) | Method and device for creating tile map based on OpenGL | |
| CN105590311A (en) | Graphical plane data analysis system and method | |
| CN104809940B (en) | Projection device and projection method for geometric solid figure | |
| US20140244219A1 (en) | Method of creating a pipe route line from a point cloud in three-dimensional modeling software | |
| CN112085814B (en) | Electronic map display method, device, equipment and readable storage medium | |
| CN108200416B (en) | Coordinate mapping method, device and the projection device of projected image in projection device | |
| CN114240737B (en) | Method, device, apparatus and medium for generating digital models from drawings | |
| CN103824310B (en) | A kind of method and device generating light literal with special effect | |
| CN114723894B (en) | Three-dimensional coordinate acquisition method and device and electronic equipment | |
| CN102663685B (en) | Geometric correction method based on nonlinearity | |
| CN102456218B (en) | A kind of method processed in the enterprising line position figure micro-pixels of flash | |
| CN104035661B (en) | A kind of cursor display method and device of ultrahigh resolution combination | |
| JP5923604B2 (en) | Method and system for generating instructions in accordance with changes in font outline | |
| CN109523481B (en) | Method, device and computer-readable storage medium for correcting image distortion of projector | |
| CN116117810B (en) | Method and device for secondary calibration after data conversion among different robots | |
| CN101866242A (en) | Coordinate Calibration Method of Electronic Flat Display Touch Positioning System | |
| CN103246761A (en) | Centrifugal signage scale character computerized drawing method | |
| CN102982198B (en) | Computer drawing method for centrifugal label calibration tail | |
| CN102522058A (en) | Four-point positioning deformity correction algorithm based on display | |
| CN109410296B (en) | Method and device for realizing data display | |
| CN114373051A (en) | Map updating method and device, electronic equipment and storage medium | |
| CN100561522C (en) | Integerization Processing Method of Liang-Barsky Parametric Clipping Algorithm | |
| CN105225258A (en) | The anti-aliasing display packing of a kind of circle | |
| CN112256368A (en) | Method for quickly adapting Android application screen |
| 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 | ||
| TR01 | Transfer of patent right | ||
| TR01 | Transfer of patent right | Effective date of registration:20190227 Address after:201203 7, 1 Lane 666 lane, Zhang Heng Road, Pudong New Area, Shanghai. Patentee after:SHANGHAI ZHANGMEN SCIENCE AND TECHNOLOGY Co.,Ltd. Address before:201203 No. 356 GuoShoujing Road, Zhangjiang High-tech Park, Pudong New Area, Shanghai Patentee before:Shengle Information Technology (Shanghai) Co.,Ltd. | |
| CP03 | Change of name, title or address | ||
| CP03 | Change of name, title or address | Address after:201203 7, 1 Lane 666 lane, Zhang Heng Road, Pudong New Area, Shanghai. Patentee after:Shanghai Zongzhang Technology Group Co.,Ltd. Country or region after:China Address before:201203 7, 1 Lane 666 lane, Zhang Heng Road, Pudong New Area, Shanghai. Patentee before:SHANGHAI ZHANGMEN SCIENCE AND TECHNOLOGY Co.,Ltd. Country or region before:China |