CN105938625A - Method for processing alpha channel data in PNG picture format - Google Patents

Method for processing alpha channel data in PNG picture format Download PDF

Info

Publication number
CN105938625A
CN105938625A CN201610159057.5A CN201610159057A CN105938625A CN 105938625 A CN105938625 A CN 105938625A CN 201610159057 A CN201610159057 A CN 201610159057A CN 105938625 A CN105938625 A CN 105938625A
Authority
CN
China
Prior art keywords
channel data
alpha channel
alpha
data
pixel number
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.)
Granted
Application number
CN201610159057.5A
Other languages
Chinese (zh)
Other versions
CN105938625B (en
Inventor
刘鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Wanpeng Digital Intelligence Technology Co ltd
Original Assignee
Zhejiang Wanpeng Education Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Wanpeng Education Technology Co Ltd filed Critical Zhejiang Wanpeng Education Technology Co Ltd
Priority to CN201610159057.5A priority Critical patent/CN105938625B/en
Publication of CN105938625A publication Critical patent/CN105938625A/en
Application granted granted Critical
Publication of CN105938625B publication Critical patent/CN105938625B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T9/00Image coding

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The invention discloses a method for processing alpha channel data in a PNG picture format. The method comprises: (1), head data of a 32-bit PNG picture data are analyzed to obtain a height h and a width w of the PNG picture; (2), an alpha channel data set DSA is established; (3), each pixel point data Pi is traversed to obtain a set DSA, wherein the DSA meets a formula: DSA={A1, A2, ..., An-1, An}; and (4), the alpha channel data in the set DSA are analyzed and the alpha channel data are processed based on an analysis result. With the method, resources like the storage space and the network transmission flow can be saved effectively.

Description

A kind of process the method for alpha channel data in PNG picture format
Technical field
The invention belongs to data compression, computer graphic image process field, relate to a kind of processing the method for alpha channel data in PNG picture format.
Background technology
PNG, a kind of image file storage format, it is characterized in supporting transparent effect.PNG can be that original image defines 256 transparent levels so that the edge of coloured image smoothly can merge with any background, thus eliminates jagged edges up hill and dale.This function is that a lot of picture format is unexistent, the most common BMP picture format, JPEG picture form, does not the most support transparent effect.
Actually used PNG picture format data when, be often required to store data, network transmission etc. processes, and this relates to the compression of data.In most cases, the space of storage is the smaller the better, and the data volume of network transmission is the smaller the better.
The most frequently used PNG picture format data are the PNG data forms of 32, wherein contain the color channel data of 24 and the alpha channel data of 8, and alpha channel data is exactly transparency data.Compression facing to 32 PNG data processes, and the method that presently, there are the most does not carries out special handling to 8 alpha channel datas, is substantially with universal compressed engine compression once.
Summary of the invention
It is an object of the invention to for the deficiencies in the prior art, it is provided that a kind of process the method for alpha channel data in PNG picture format.
The technical solution adopted for the present invention to solve the technical problems comprises the steps:
Step (1), the header data of 32 PNG image datas of parsing, obtain the height h and width w of PNG picture, and this PNG image data contains n pixel number evidence, n=h × w;Each pixel number evidence has 32, wherein color channel data 24, alpha channel data 8;Memory space sp=8 × n that now alpha channel data needs, in units of bit;
Step (2), set up alpha channel data set DSA;
Step (3), travel through each pixel number according to Pi, 1≤i≤n, wherein pixel number is according to PiAlpha channel data be Ai, by AiPut into set DSA;Finally give set DSA={A1, A2..., An-1,An}
Step (4), the alpha channel data analyzed in set DSA;If meeting condition: A1=A2=...=An-1=An=KZ, say, that each data in set DSA are identical, jump to step (5);Otherwise, step (6) is jumped to;
Step (5), need not preserve the value of the alpha channel data of each pixel number evidence, 0 alpha channel data is used to express, because the alpha channel data values of all pixel number evidences is all the constant value KZ of 8, preserve a KZ value;The memory space sp=8 that now alpha channel data needs, in units of bit, alpha channel data is disposed;
Step (6) is if meeting condition: Ax1=Ax2=...=Axi=K1 and Ay1=Ay2=...=Ayi=K2,1≤xi≤n, 1≤yi≤n, K1 and K2 is 8 constants, K1 ≠ K2, say, that the alpha channel data of all pixel number evidences only has two values, K1 or K2, jumps to step (7);Otherwise, step (8) is jumped to;
Step (7), 1 alpha channel data is used to express, for each pixel number according to preserving the value of 1 alpha channel data, respectively 0 and 1, wherein 0 represent K1 value, 1 represents K2 value;Memory space sp=1 × n that now alpha channel data needs, in units of bit, alpha channel data is disposed;
Step (8), alpha channel data is not done special handling, for each pixel number according to the value preserving 8 alpha channel datas;Memory space sp=8 × n that now alpha channel data needs, in units of bit;Alpha channel data is disposed.
The present invention has the beneficial effect that:
The present invention is mainly characterized by 8 alpha channel datas in 32 the most frequently used PNG image datas have been carried out special handling disaggregatedly.Wherein 0 alpha passage, it is not necessary to preserve alpha channel value for each pixel, only needs 8 constants;1 alpha passage, it is only necessary to preserve the value of 1 alpha passage for each pixel.In practical business, the PNG picture of above-mentioned two situations is the most, effectively saves the resource such as memory space, network traffic flow.
Accompanying drawing explanation
Fig. 1 is the flow chart of the present invention;
Fig. 2 is 0 alpha access diagram, the alpha all 255 of each pixel of PNG picture;
Fig. 3 is 0 alpha access diagram, the alpha all 128 of each pixel of PNG picture;
Fig. 4 is 1 alpha passage figure schematic diagram, and the alpha value of the one part of pixel point of PNG picture is 0, and the alpha value of another part pixel is 255;
Fig. 5 is 8 alpha passage figures;
Detailed description of the invention
The invention will be further described below in conjunction with the accompanying drawings.
As described in Figure 1, a kind of process the method for alpha channel data in PNG picture format, specifically include following steps:
Step (1), the header data of 32 PNG data of parsing, obtain the height h and width w of picture, and this PNG data contains n pixel number evidence, n=h × w;Each pixel number evidence has 32, wherein color channel data 24, alpha channel data 8;The memory space that now alpha channel data needs is sp=8 × n, in units of bit
Step (2), set up data acquisition system DSA;
Step (3), travel through each pixel number according to Pi, 1≤i≤n, wherein PiAlpha channel data be Ai, by AiPut into set DSA;Finally give set DSA={A1, A2..., An-1,An}
Step (4), the data of analysis set DSA;If meeting condition: A1=A2=...=An-1=An=KZ, say, that each data in set DSA are identical, go to step (5);Otherwise, (6) are gone to step;
Step (5), as shown in Figures 2 and 3, this situation can use 0 alpha channel data to express, it is not necessary for each pixel and preserves the value of alpha passage, because the alpha value of all pixels is all the constant value KZ of 8, preserve a KZ value;The memory space that now alpha channel data needs is only sp=8, in units of bit;Go to step (9);
Step (6) is if meeting condition: Ax1=Ax2=...=Axi=K1 and Ay1=Ay2=...=Ayi=K2,1≤xi≤n, 1≤yi≤n, K1 and K2 is 8 constants, K1 ≠ K2, say, that the alpha passage of all pixels only has two values, K1 or K2, goes to step (7);Otherwise, (8) are gone to step;
Step (7), as shown in Figure 4, this situation can use 1 alpha channel data to express, it is only necessary to preserving the value of 1 alpha passage, respectively 0 and 1 for each pixel, wherein 0 represent K1 value, 1 represents K2 value;The memory space that now alpha channel data needs is sp=1 × n, in units of bit;Go to step (9);
Step (8), it is not belonging to above-mentioned two situations, alpha data is not done special handling, preserve the value of 8 alpha passages for each pixel;The memory space that now alpha channel data needs is sp=8 × n, in units of bit;Go to step (9);As shown in Figure 5.
Step (9), alpha channel data are disposed.

Claims (1)

1. one kind processes the method for alpha channel data in PNG picture format, it is characterised in that include as Lower step:
Step (1), the header data of 32 PNG image datas of parsing, obtain the height h of PNG picture With width w, this PNG image data contains n pixel number evidence, n=h × w;Each pixel number evidence There are 32, wherein color channel data 24, alpha channel data 8;Now alpha port number According to the memory space sp=8 × n needed, in units of bit;
Step (2), set up alpha channel data set DSA;
Step (3), travel through each pixel number according to Pi, 1≤i≤n, wherein pixel number is according to PiAlpha Channel data is Ai, by AiPut into set DSA;Finally give set DSA={A1, A2..., An-1,An} Step (4), the alpha channel data analyzed in set DSA;If meeting condition: A1=A2=...=An-1=An=KZ, say, that each data in set DSA are identical, jump to step (5); Otherwise, step (6) is jumped to;
Step (5), need not preserve the value of the alpha channel data of each pixel number evidence, use 0 Alpha channel data is expressed, because the alpha channel data values of all pixel number evidences is all one 8 Constant value KZ, preserve a KZ value;The memory space sp=8 that now alpha channel data needs, In units of bit, alpha channel data is disposed;
Step (6) is if meeting condition: Ax1=Ax2=...=Axi=K1 and Ay1=Ay2=...=Ayi=K2,1≤xi≤ N, 1≤yi≤n, K1 and K2 is 8 constants, K1 ≠ K2, say, that the alpha of all pixel number evidences Channel data only has two values, K1 or K2, jumps to step (7);Otherwise, step (8) is jumped to;
Step (7), 1 alpha channel data of use are expressed, for each pixel number according to preserving 1 alpha The value of channel data, respectively 0 and 1, wherein 0 represent K1 value, 1 represents K2 value;Now alpha Memory space sp=1 × n that channel data needs, in units of bit, alpha channel data is disposed;
Step (8), alpha channel data is not done special handling, for each pixel number according to preserving 8 The value of alpha channel data;Memory space sp=8 × n that now alpha channel data needs, with bit For unit;Alpha channel data is disposed.
CN201610159057.5A 2016-03-18 2016-03-18 A method of alpha channel datas in processing PNG picture formats Active CN105938625B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610159057.5A CN105938625B (en) 2016-03-18 2016-03-18 A method of alpha channel datas in processing PNG picture formats

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610159057.5A CN105938625B (en) 2016-03-18 2016-03-18 A method of alpha channel datas in processing PNG picture formats

Publications (2)

Publication Number Publication Date
CN105938625A true CN105938625A (en) 2016-09-14
CN105938625B CN105938625B (en) 2018-10-12

Family

ID=57151392

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610159057.5A Active CN105938625B (en) 2016-03-18 2016-03-18 A method of alpha channel datas in processing PNG picture formats

Country Status (1)

Country Link
CN (1) CN105938625B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115550661A (en) * 2022-11-25 2022-12-30 统信软件技术有限公司 Image compression method, image restoration method, computing device and readable storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101742317A (en) * 2009-12-31 2010-06-16 北京中科大洋科技发展股份有限公司 Video compressing and encoding method with alpha transparent channel
CN103533352A (en) * 2013-09-27 2014-01-22 桂林力港网络科技有限公司 Compression method and device and decompression method and device for image with transparency
US8655086B1 (en) * 2011-11-01 2014-02-18 Zynga, Inc. Image compression with alpha channel data
CN104966309A (en) * 2015-06-25 2015-10-07 桂林力港网络科技有限公司 Automatic compression system and processing method for image with transparency

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101742317A (en) * 2009-12-31 2010-06-16 北京中科大洋科技发展股份有限公司 Video compressing and encoding method with alpha transparent channel
US8655086B1 (en) * 2011-11-01 2014-02-18 Zynga, Inc. Image compression with alpha channel data
CN103533352A (en) * 2013-09-27 2014-01-22 桂林力港网络科技有限公司 Compression method and device and decompression method and device for image with transparency
CN104966309A (en) * 2015-06-25 2015-10-07 桂林力港网络科技有限公司 Automatic compression system and processing method for image with transparency

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
S DAI , M HAN , W XU , Y WU , Y GONG: "Soft Edge Smoothness Prior for Alpha Channel Super Resolution", 《IEEE CONFERENCE ON COMPUTER VISION & PATTERN RECOGNITION》 *
蒋毅飞 , 郇丹丹 , 解鑫: "具有可变数据格式的透明度压缩", 《计算机辅助设计与图形学学报》 *
马颖峰: "Alpha通道在多媒体教育软件开发中的应用", 《电化教育研究》 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115550661A (en) * 2022-11-25 2022-12-30 统信软件技术有限公司 Image compression method, image restoration method, computing device and readable storage medium

Also Published As

Publication number Publication date
CN105938625B (en) 2018-10-12

Similar Documents

Publication Publication Date Title
CN108229470B (en) Character image processing method, device, equipment and storage medium
CN101833542B (en) Method and device for rendering fonts of user interface
US20200042837A1 (en) Detecting, redacting, and scoring confidential information in images
WO2018103608A1 (en) Text detection method, device and storage medium
US9697423B1 (en) Identifying the lines of a table
CN108921820B (en) Saliency target detection method based on color features and clustering algorithm
EP3876546A1 (en) Video processing method and apparatus, and electronic device and storage medium
CN103412701A (en) Method and device for processing remote desktop images
EP3819820B1 (en) Method and apparatus for recognizing key identifier in video, device and storage medium
CN103391442A (en) Rapid video image transmission compression algorithm based on regional division and difference comparison
CN110235176B (en) Image processing method and device, data transmission method and device and storage medium
CN110428382B (en) Efficient video enhancement method and device for mobile terminal and storage medium
EP3952312A1 (en) Method and apparatus for video frame interpolation, and device and storage medium
CN102547147A (en) Method for realizing enhancement processing for subtitle texts in video images and device
CN109242776B (en) Double-lane line detection method based on visual system
CN105550246A (en) System and method for loading network picture under Android platform
Wang et al. Semantic segmentation of high-resolution images
CN101794566A (en) Method and related device for determining font data of character to be displayed in mobile terminal
CN113486881B (en) Text recognition method, device, equipment and medium
CN105938625A (en) Method for processing alpha channel data in PNG picture format
CN114581926A (en) Multi-line text recognition method, device, equipment and medium
CN110996026B (en) OSD display method, device, equipment and storage medium
CN102521847A (en) Method and device for segmenting bitmap (BMP) image with ultra-high resolution
He et al. FPGA-based high definition image processing system
CN110633663A (en) Method for automatically cutting multi-mode data in sign language video

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
CP02 Change in the address of a patent holder
CP02 Change in the address of a patent holder

Address after: 310051 12 / F, building 8, No. 19, Jugong Road, Xixing street, Binjiang District, Hangzhou City, Zhejiang Province

Patentee after: ZHEJIANG WANPENG EDUCATION SCIENCE AND TECHNOLOGY STOCK Co.,Ltd.

Address before: Electronic Commerce Building No. 118 Xihu District West Road, Hangzhou City, Zhejiang Province, 310013 room 1406

Patentee before: ZHEJIANG WANPENG EDUCATION SCIENCE AND TECHNOLOGY STOCK Co.,Ltd.

CP01 Change in the name or title of a patent holder
CP01 Change in the name or title of a patent holder

Address after: 12 / F, building 8, No. 19, Jugong Road, Xixing street, Binjiang District, Hangzhou City, Zhejiang Province, 310051

Patentee after: Zhejiang Wanpeng Digital Intelligence Technology Co.,Ltd.

Address before: 12 / F, building 8, No. 19, Jugong Road, Xixing street, Binjiang District, Hangzhou City, Zhejiang Province, 310051

Patentee before: ZHEJIANG WANPENG EDUCATION SCIENCE AND TECHNOLOGY STOCK CO.,LTD.