CN114387356A - A PNG format encoding and decoding method and device - Google Patents
A PNG format encoding and decoding method and device Download PDFInfo
- Publication number
- CN114387356A CN114387356A CN202011111269.9A CN202011111269A CN114387356A CN 114387356 A CN114387356 A CN 114387356A CN 202011111269 A CN202011111269 A CN 202011111269A CN 114387356 A CN114387356 A CN 114387356A
- Authority
- CN
- China
- Prior art keywords
- image
- bit depth
- color
- pixel
- png
- 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
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T9/00—Image coding
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T7/00—Image analysis
- G06T7/90—Determination of colour characteristics
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T2207/00—Indexing scheme for image analysis or image enhancement
- G06T2207/10—Image acquisition modality
- G06T2207/10024—Color image
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Multimedia (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Compression Or Coding Systems Of Tv Signals (AREA)
Abstract
Description
技术领域technical field
本发明属于图像处理技术领域,具体涉及一种PNG格式的编码、解码方法及装置。The invention belongs to the technical field of image processing, and in particular relates to a PNG format encoding and decoding method and device.
背景技术Background technique
近年来,在智能穿戴、工业控制、物联网控制、医疗电子等方面,MCU芯片得到了广泛的应用,越来越多客户都希望MCU能具备一定的图形运算能力,让人机接口(UI)能更漂亮、绚丽。MCU本身受限于主频、图像处理能力、Memory的限制大小以及接口速率的限制,特别是MCU广泛使用SPI接口屏,受限于SPI接口速率限制,使得对MCU到屏之间传输的像素数据量有较高的要求。提出了要求。MCU中彩屏显示时,RGB565的彩色模式相比于RGB888而言,MCU和彩屏之间的数据传输量可以减少1/3,因此RGB565在MCU产品中得到广泛的应用。In recent years, MCU chips have been widely used in smart wear, industrial control, Internet of Things control, medical electronics, etc. Can be more beautiful and gorgeous. The MCU itself is limited by the main frequency, the image processing capability, the limited size of the Memory, and the interface rate. In particular, the MCU widely uses the SPI interface screen, which is limited by the SPI interface rate limit, which makes the pixel data transmitted between the MCU and the screen. Quantity has higher requirements. made a request. When the color screen is displayed in the MCU, the color mode of RGB565 can reduce the amount of data transmission between the MCU and the color screen by 1/3 compared with RGB888, so RGB565 is widely used in MCU products.
在MCU产品中,通常使用PNG格式进行图像存储,由于其对图像的高压缩率,统计来看,至少可以节约一半的存储器空间,甚至更高。当然,如果采用PNG格式进行图像存储,则需要MCU对PNG图像进行解码,因此对MCU的处理能力提出了要求,此瓶颈一般可以通过设计PNG硬件加速器的方式来解决,在此不做进一步的讨论。In MCU products, the PNG format is usually used for image storage. Due to its high compression rate for images, according to statistics, at least half of the memory space can be saved, or even higher. Of course, if the PNG format is used for image storage, the MCU needs to decode the PNG image, so the processing capability of the MCU is required. This bottleneck can generally be solved by designing a PNG hardware accelerator, which will not be discussed further here. .
PNG是一种采用无损压缩算法的位图格式,其设计目的是试图替代GIF和TIFF文件格式,同时增加一些GIF文件格式所不具备的特性。PNG使用从LZ77派生的无损数据压缩算法,因压缩比高,生成文件体积小,一般应用于JAVA程序、网页或S60程序中。PNG格式主要有8位、24位、32位三种形式,其中8位PNG支持两种不同的透明形式(索引透明和alpha透明),24位PNG不支持透明,32位PNG在24位基础上增加了8位透明通道,因此可展现256级透明程度。PNG is a bitmap format that uses a lossless compression algorithm. Its design purpose is to try to replace the GIF and TIFF file formats, while adding some features that the GIF file format does not have. PNG uses a lossless data compression algorithm derived from LZ77. Due to its high compression ratio and small file size, PNG is generally used in JAVA programs, web pages or S60 programs. The PNG format mainly has three forms: 8-bit, 24-bit, and 32-bit. Among them, 8-bit PNG supports two different forms of transparency (index transparency and alpha transparency), 24-bit PNG does not support transparency, and 32-bit PNG is based on 24-bit. An 8-bit transparency channel has been added, so 256 levels of transparency can be displayed.
PNG的编码过程包括filter(滤波)、deflate(压缩)、chunk(数据分块)编码3个过程;PNG的解码过程包括chunk(分块)解码、inflate(解压缩)、un-filter(滤波还原)3个过程。其中滤波是无损的,滤波是按字节为单位进行,滤波的过程本身不减少数据量的大小,但通过滤波能提高deflate的压缩能力;deflate过程包括LZ77压缩和对压缩后数据采用huffman编码的过程,该过程也是对数据自身进行操作。PNG在标准定义时,只支持颜色的位深度相等的像素图片,比如可以支持颜色位深度为1、2、4、8、16几种格式;由于RGB565及RGB565A这两种格式的三个颜色的位深度不一致,因此PNG的编码过程不支持的RGB565及RGB565A这些格式。The encoding process of PNG includes three processes: filter (filtering), deflate (compression), and chunk (data block); the decoding process of PNG includes chunk (block) decoding, inflate (decompression), and un-filter (filtering restoration). ) 3 processes. Among them, the filtering is lossless, and the filtering is performed in units of bytes. The filtering process itself does not reduce the size of the data volume, but the compression capability of deflate can be improved through filtering; the deflate process includes LZ77 compression and Huffman encoding for compressed data. process, which also operates on the data itself. When PNG is defined by the standard, it only supports pixel images with the same color bit depth. For example, it can support several formats with color bit depths of 1, 2, 4, 8, and 16; The bit depth is inconsistent, so the PNG encoding process does not support RGB565 and RGB565A formats.
另一方面,在MCU上使用PNG时,如果送屏显示用的是RGB565,则对PNG直接支持RGB565、RGB565A提出了需求,那么,为了节约了PNG图像的存储空间,又避免解码的时候多一次RGB888(或RGB888A)到RGB565(或RGB565A)的映射。为此需要对PNG图像格式以及压缩方式进行研究,以实现对颜色位深度不一致的RGB格式进行支持的PNG编码和解码方式。On the other hand, when PNG is used on the MCU, if RGB565 is used for sending the screen to the screen, it is required that PNG directly supports RGB565 and RGB565A. Then, in order to save the storage space of PNG images, it avoids one more decoding time. RGB888 (or RGB888A) to RGB565 (or RGB565A) mapping. Therefore, it is necessary to study the PNG image format and compression method to realize the PNG encoding and decoding method that supports the RGB format with inconsistent color bit depth.
发明内容SUMMARY OF THE INVENTION
基于现有技术存在的问题,本发明提出了一种PNG格式的编码、解码方法及装置;考虑到RGB565的彩色模式占用16位,相比于RGB888的24位在MCU和彩屏之间的数据传输量减少了1/3;因此本发明对PNG图像格式以及其压缩方式进行进一步研究,提供了一种能够使得PNG图像能够直接支持RGB565等格式的编码解码方案。Based on the problems existing in the prior art, the present invention proposes an encoding and decoding method and device in PNG format; considering that the color mode of RGB565 occupies 16 bits, compared with 24 bits of RGB888, the data transmission between the MCU and the color screen is Therefore, the present invention further studies the PNG image format and its compression method, and provides a coding and decoding scheme that enables PNG images to directly support RGB565 and other formats.
具体的,本发明通过如下方案实现:Specifically, the present invention is realized by the following scheme:
在本发明的第一方面,本发明提供了一种PNG格式的编码方法,所述编码方法包括以下步骤:In a first aspect of the present invention, the present invention provides an encoding method in PNG format, the encoding method comprising the following steps:
读取出原始图片中的目标像素,并计算出当前目标像素的位数以及每个目标像素中不同通道的位数;Read out the target pixel in the original image, and calculate the number of bits of the current target pixel and the number of bits of different channels in each target pixel;
识别出当前目标像素的颜色类型并与预设的定义值对应;设置编码过程中允许的位深度指向该定义值;其中所述颜色类型至少包括灰度图像、真彩色图像、索引彩色图像、带α通道数据的灰度图像、带α通道数据的真彩色图像、不等位深度的真彩色图像以及带α通道数据的不等位深度的真彩色图像;Identify the color type of the current target pixel and correspond to the preset defined value; set the allowed bit depth in the encoding process to point to the defined value; wherein the color type at least includes grayscale image, true color image, indexed color image, band Grayscale image with alpha channel data, true color image with alpha channel data, true color image with unequal bit depth, and true color image with unequal bit depth with alpha channel data;
判断需进行编码的颜色类型的定义值的大小,对不等位深度的真彩色图像和带α通道数据的不等位深度的真彩色图像按照第一条件计算出像素中的位深度;对其他颜色类型的图像按照第二条件计算出像素中的位深度;Determine the size of the defined value of the color type to be encoded, and calculate the bit depth in the pixel according to the first condition for true color images with unequal bit depths and true color images with unequal bit depths with alpha channel data; The image of the color type calculates the bit depth in the pixel according to the second condition;
确定需要进行编码时的每个像素的位深度,计算出图像的大小,将图像分块,并在图像头部块中预设压缩算法采用扫描线对计算出的图像下采样;Determine the bit depth of each pixel that needs to be encoded, calculate the size of the image, divide the image into blocks, and preset the compression algorithm in the image header block to downsample the calculated image by scanning lines;
对扫描线数据滤波后按照预设的压缩算法进行压缩,编码出图像数据块,并在图像数据块尾端编码出图像结束块,从而完成PNG图像的编码。After filtering the scan line data, it is compressed according to the preset compression algorithm, the image data block is encoded, and the image end block is encoded at the end of the image data block, thereby completing the encoding of the PNG image.
进一步的,在判断需进行编码的颜色类型的定义值的大小之前还包括读取出的原始图片中的目标像素进行颜色类型转换,即从灰度图像、真彩色图像、索引彩色图像、带α通道数据的灰度图像、带α通道数据的真彩色图像、不等位深度的真彩色图像以及带α通道数据的不等位深度的真彩色图像中任意一种颜色类型转换到另一种与之前不同的颜色类型;并重新确定新的颜色类型的定义值。Further, before judging the size of the definition value of the color type to be encoded, the target pixel in the read out original picture is also included to perform color type conversion, that is, from grayscale image, true color image, indexed color image, band alpha image. A grayscale image with channel data, a true color image with alpha channel data, a true color image with unequal bit depth, and a true color image with unequal bit depth with alpha channel data are converted from any color type to another with Different color types before; and redefine the definition value of the new color type.
所述识别出目标像素的颜色类型并与预设的定义值对应包括为灰度图像、真彩色图像、索引彩色图像、带α通道数据的灰度图像、带α通道数据的真彩色图像分配[0,6]之间的整数值,为不等位深度的真彩色图像以及带α通道数据的不等位深度的真彩色图像分配[7,12]之间的整数值;且所述定义值占用一个字节比特空间。The identifying the color type of the target pixel and corresponding to the preset definition value includes assigning a grayscale image, a true color image, an indexed color image, a grayscale image with alpha channel data, and a true color image with alpha channel data [ an integer value between 0, 6], assigning an integer value between [7, 12] for true color images of unequal bit depth and true color images of unequal bit depth with alpha channel data; and the defined value Occupies one byte of space.
进一步的,所述设置编码过程中允许的位深度指向该定义值包括为灰度图像、真彩色图像、索引彩色图像、带α通道数据的灰度图像、带α通道数据的真彩色图像设置多个可选的第三位深度,且每个通道占用的位深度相等;为不等位深度的真彩色图像以及带α通道数据的不等位深度的真彩色图像设置固定的位深度,所述固定的位深度包括第一位深度和第二位深度;所述第一位深度是该颜色类型中其中一个颜色通道占用的位深度,所述第二位深度是该颜色类型中一个像素所占用的总的位深度。Further, setting the allowable bit depth in the encoding process to point to the defined value includes setting multiple values for grayscale images, true color images, indexed color images, grayscale images with alpha channel data, and true color images with alpha channel data. an optional third bit depth, and the bit depth occupied by each channel is equal; set a fixed bit depth for true color images with unequal bit depths and true color images with unequal bit depths with alpha channel data, the The fixed bit depth includes a first bit depth and a second bit depth; the first bit depth is the bit depth occupied by one of the color channels in the color type, and the second bit depth is the bit depth occupied by a pixel in the color type the total bit depth.
进一步的,所述预设的第一函数表示为f(x)=3A+α,A代表通道的位深度,α代表α通道占用的位深度;所述可调参数的值为±1或者±2。Further, the preset first function is expressed as f(x)=3A+α, A represents the bit depth of the channel, and α represents the bit depth occupied by the α channel; the value of the adjustable parameter is ±1 or ±1. 2.
在本发明的第一方面的基础上,在本发明的第二方面,本发明提供了一种与第一方面所对应的PNG格式的解码方法,所述解码方法包括以下步骤:On the basis of the first aspect of the present invention, in the second aspect of the present invention, the present invention provides a decoding method in PNG format corresponding to the first aspect, the decoding method comprising the following steps:
读取出PNG图像,读取出图像头部块、图像数据块和图像结束块;Read out the PNG image, read out the image header block, the image data block and the image end block;
按照从图像头部块读取出的压缩算法,对所述图像数据块解压缩后并进行滤波还原;According to the compression algorithm read from the image header block, the image data block is decompressed and filtered to restore;
按照从图像头部块读取出的定义值确定出颜色类型,所述颜色类型包括灰度图像、真彩色图像、索引彩色图像、带α通道数据的灰度图像、带α通道数据的真彩色图像、不等位深度的真彩色图像以及带α通道数据的不等位深度的真彩色图像;The color type is determined according to the defined value read from the image header block, and the color type includes grayscale image, true color image, indexed color image, grayscale image with alpha channel data, and true color with alpha channel data. images, true color images of unequal bit depth, and true color images of unequal bit depth with alpha channel data;
按照从图像头部块读取的该颜色类型的允许的位深度,对不等位深度的真彩色图像和带α通道数据的不等位深度的真彩色图像按照第三条件计算出像素中的位深度;对其他颜色类型的图像按照第二条件计算出像素中的位深度;According to the allowable bit depth of the color type read from the image header block, for the true color image of unequal bit depth and the true color image of unequal bit depth with alpha channel data, the third condition is used to calculate the number of pixels in the pixel. Bit depth; for images of other color types, the bit depth in the pixel is calculated according to the second condition;
按照所述每个像素的位深度从PNG图像数据块中解码出图像信息数据;The image information data is decoded from the PNG image data block according to the bit depth of each pixel;
对图像数据块的信息解码完成后,将图像头部块和图像结束块解码的信息分别加载到所述图像块的信息前后,完成对PNG图像的解码。After the decoding of the information of the image data block is completed, the decoded information of the image header block and the image end block are respectively loaded into the information before and after the image block to complete the decoding of the PNG image.
在本发明的第一方面的基础上,在本发明的第三方面,本发明还提供了一种实现第一方面的PNG格式的编码装置,所述编码装置包括:On the basis of the first aspect of the present invention, in the third aspect of the present invention, the present invention also provides an encoding device implementing the PNG format of the first aspect, the encoding device comprising:
第一采集单元,用于采集原始图片中的目标像素;a first collection unit, used for collecting target pixels in the original picture;
第一识别单元,用于识别出目标像素的颜色类型并与预设的定义值对应;The first identification unit is used for identifying the color type of the target pixel and corresponding to the preset definition value;
编码准备单元,用于设置编码过程中允许的位深度指向该定义值;以及用于确定需要进行编码时的每个像素的位深度,从而计算出图像大小并确定图像头部块的内容;An encoding preparation unit, for setting the allowable bit depth in the encoding process to point to the defined value; and for determining the bit depth of each pixel when encoding is required, thereby calculating the image size and determining the content of the image header block;
编码单元,用于按照编码准备单元确定的图像块中进行PNG编码处理,编码出图像头部块、图像数据块和图像结束块。The encoding unit is configured to perform PNG encoding processing according to the image blocks determined by the encoding preparation unit, and encode the image header block, the image data block and the image end block.
在本发明的第二方面和第三方面的基础上,在本方面的第四方面,本发明还提供了一种与第三方面所对应的PNG格式的解码装置,所述编码装置包括:On the basis of the second aspect and the third aspect of the present invention, in the fourth aspect of the present aspect, the present invention also provides a PNG format decoding device corresponding to the third aspect, the encoding device comprising:
第二采集单元,用于采集PNG图像;The second collection unit is used to collect PNG images;
第二识别单元,用于从PNG图像读取出图像头部块、图像数据块和图像结束块;并从图像头部块中识别出颜色类型和允许的位深度;The second identification unit is used to read out the image header block, the image data block and the image end block from the PNG image; and identify the color type and the allowable bit depth from the image header block;
解码准备单元,用于根据颜色类型确定出PNG数据流中的像素的位数和像素中不同通道的位数;The decoding preparation unit is used to determine the number of bits of pixels in the PNG data stream and the number of bits of different channels in the pixels according to the color type;
解码单元,用于根据所述像素的位数和像素中不同通道的位数解析出PNG图像的信息。A decoding unit, configured to parse out the information of the PNG image according to the number of bits of the pixel and the number of bits of different channels in the pixel.
本发明的有益效果:Beneficial effects of the present invention:
本发明在PNG的IHDR上扩展两种颜色类型来支持不等位深度的真彩色图像以及带α通道数据的不等位深度的真彩色图像的编码和解码;通过本发明能有效地减少PNG图像的存储空间、加快解码的速度;尤其适用于支持显示屏为RGB565等彩色格式的MCU芯片及产品上;采用本发明的方法同样适用于扩展PNG对其他颜色类型的支持,并且能够很容易的实现各种颜色类型之间的互换;同时,采用本发明的方法也能比较好兼容原有的PNG的颜色类型格式。The present invention expands two color types on the IHDR of PNG to support encoding and decoding of true color images with unequal bit depths and true color images with unequal bit depths with alpha channel data; the present invention can effectively reduce PNG images It saves storage space and speeds up decoding; it is especially suitable for MCU chips and products that support color formats such as RGB565 on the display screen; the method of the present invention is also suitable for extending PNG’s support for other color types, and can be easily realized Exchange between various color types; meanwhile, the method of the present invention can also be compatible with the original PNG color type format.
附图说明Description of drawings
图1是本发明的PNG格式的编码方法流程图;Fig. 1 is the encoding method flow chart of PNG format of the present invention;
图2是本发明的PNG格式的解码方法流程图;Fig. 2 is the decoding method flow chart of PNG format of the present invention;
图3是本发明的PNG格式的编码装置结构图;Fig. 3 is the structure diagram of the encoding device of PNG format of the present invention;
图4是本发明的PNG格式的解码装置结构图。FIG. 4 is a structural diagram of a decoding apparatus in PNG format according to the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
图1是本发明实施例中的PNG格式的编码方法流程图,所述编码方法包括以下步骤:1 is a flowchart of an encoding method in PNG format in an embodiment of the present invention, and the encoding method includes the following steps:
S101、读取出原始图片中的目标像素,并计算出每个目标像素的位数以及每个目标像素中不同通道的位数;S101, read out the target pixels in the original picture, and calculate the number of bits of each target pixel and the number of bits of different channels in each target pixel;
在本实施例中,原始图片可以是自然图片或者非自然图片,是基于图片的生成方式进行的分类,自然图片是自然生成的图片,例如:相机拍摄的照片、自然风光图像等;非自然图片,通常是人参与生成或者设备自动生成的图片,例如:即时通讯界面的截图、游戏画面等;即时通讯界面的截图和游戏画面有可能既包含人参与的部分,也包含设备自动生成的部分;更具体地,以游戏画面为例:即时对战游戏中,玩家之间会使用文字进行交流,其中文字部分是人参与的部分;其他部分则是设备依计算机程序指令或者单片机控制指令绘制的而成的图片内容。可以理解的是,除了即时通讯界面的截图,这里还可以是整个桌面或者其他应用界面的截图,除了游戏画面还可以是其他任意由计算机绘制的图片,以上关于自然图片和非自然图片的举例不应理解为对本发明实施例的唯一性限定。另外,在本实施例中,原始图片是输入到MCU的图片,该图片的格式可以是MCU能够支持的任意的图片格式;例如:BMP、JPEG、PNG以及GIF格式,或者其他格式。In this embodiment, the original picture may be a natural picture or an unnatural picture, which is classified based on the way of generating the picture. , which are usually pictures generated by human participation or automatically generated by devices, such as screenshots of instant messaging interface, game pictures, etc.; screenshots and game pictures of instant messaging interface may include both the part that people participate in and the part that is automatically generated by the device; More specifically, take the game screen as an example: in real-time battle games, players will use text to communicate, and the text part is the part that people participate in; the other parts are drawn by the equipment according to computer program instructions or single-chip control instructions. image content. It can be understood that, in addition to the screenshots of the instant messaging interface, there can also be screenshots of the entire desktop or other application interfaces. In addition to the game screen, it can also be any other pictures drawn by the computer. The above examples of natural pictures and unnatural pictures are not. It should be understood as a unique limitation to the embodiments of the present invention. In addition, in this embodiment, the original picture is the picture input to the MCU, and the format of the picture can be any picture format that the MCU can support; for example, BMP, JPEG, PNG and GIF format, or other formats.
S102、识别出目标像素的颜色类型并与预设的定义值对应;设置编码过程中允许的位深度指向该定义值;S102, identify the color type of the target pixel and correspond to the preset definition value; set the allowable bit depth in the encoding process to point to the definition value;
其中所述颜色类型至少包括灰度图像、真彩色图像、索引彩色图像、带α通道数据的灰度图像、带α通道数据的真彩色图像、不等位深度的真彩色图像以及带α通道数据的不等位深度的真彩色图像;The color types include at least grayscale images, true color images, indexed color images, grayscale images with alpha channel data, true color images with alpha channel data, true color images with unequal bit depths, and alpha channel data. Truecolor images of unequal bit depths;
对于一个PNG文件来说,标准的文件结构包括PNG文件标志和PNG数据块;PNG定义了两种类型的数据块,一种是称为重要数据块(critical chunk),这是标准的数据块,还有一种叫做辅助数据块(ancillary chunks),这是可选的数据块。重要数据块定义了4个标准数据块,每一个PNG文件都必须包括它们,PNG读写软件也都必需要支持这些数据块。为了简单起见,在我们使用的PNG文件里,将PLTE调色板数据块省略描述;设置了IHDR文件头数据块、IDAT图像数据块以及IEND图像结束块这3个数据块按以上先后顺序进行存储,而且都仅仅出现一次。For a PNG file, the standard file structure includes PNG file logo and PNG data block; PNG defines two types of data blocks, one is called critical data block (critical chunk), which is a standard data block, There is also ancillary chunks called ancillary chunks, which are optional chunks. Important data blocks define 4 standard data blocks, each PNG file must include them, and PNG read and write software must also support these data blocks. For the sake of simplicity, in the PNG file we use, the description of the PLTE palette data block is omitted; the three data blocks of the IHDR file header data block, the IDAT image data block and the IEND image end block are set in the above order. , and both appear only once.
本发明正是对其中的IHDR文件头数据块(图像头部块)进行了扩展改进,以实现对不同颜色类型的图片、像素以及数据流等进行编码解码;它包括有PNG文件里存储的图像数据的基本信息,并作为第一个数据块出现在PNG数据流中,并且一个PNG数据流中仅仅能有一个文件头数据块。先说明一下现有技术中的IHDR中定义的颜色类型如表1所示:The present invention expands and improves the IHDR file header data block (image header block), so as to realize encoding and decoding of pictures, pixels and data streams of different color types; it includes the images stored in the PNG file. The basic information of the data, and appears as the first data block in the PNG data stream, and there can only be one file header data block in a PNG data stream. First explain the color types defined in IHDR in the prior art as shown in Table 1:
表1 PNG标准定义中的IHDR颜色类型Table 1 IHDR color types in the definition of the PNG standard
本发明在PNG标准定义的颜色类型的基础上,新增了定义两种颜色类型的格式,用于支持不等位深度的真彩色图像和带α通道数据的不等位深度的真彩色图像,如表2所示。On the basis of the color types defined by the PNG standard, the present invention adds formats for defining two color types, which are used to support true color images with unequal bit depths and true color images with unequal bit depths with alpha channel data, As shown in table 2.
表2本发明PNG标准定义中的IHDR颜色类型Table 2 IHDR color types in the definition of the PNG standard of the present invention
其中,颜色类型=8表示该PNG为不等位深度的真彩色图像,以RGB565格式为例,此时每个像素(pixel)占用16bit,Red通道占用5bit,Green通道占用6bit,Blue通道占用5bit,位深度设定为5bit;颜色类型=12表示该PNG为带α通道数据的不等位深度的真彩色图像,尤其以RGB565A格式为例,此时每个像素占用24bit,Red通道占用5bit,Green通道占用6bit,Blue通道占用5bit,α通道占用8bit,位深度仍然可以设定为5bit。Among them, the color type=8 indicates that the PNG is a true color image with unequal bit depth. Taking the RGB565 format as an example, each pixel occupies 16 bits, the Red channel occupies 5 bits, the Green channel occupies 6 bits, and the Blue channel occupies 5 bits. , the bit depth is set to 5bit; color type = 12 indicates that the PNG is a true color image with unequal bit depth with alpha channel data, especially taking the RGB565A format as an example, at this time, each pixel occupies 24bit, and the Red channel occupies 5bit, The Green channel occupies 6 bits, the Blue channel occupies 5 bits, and the alpha channel occupies 8 bits, and the bit depth can still be set to 5 bits.
S103、判断需进行编码的颜色类型的定义值的大小,对不等位深度的真彩色图像和带α通道数据的不等位深度的真彩色图像按照第一条件计算出像素中的位深度;对其他颜色类型的图像按照第二条件计算出像素中的位深度;S103, determine the size of the definition value of the color type that needs to be encoded, and calculate the bit depth in the pixel according to the first condition to the true color image of unequal bit depth and the true color image of unequal bit depth with alpha channel data; Calculate the bit depth in the pixel according to the second condition for images of other color types;
由于传统的等位深度的图像的编码是调用函数进行计算,比如,在真彩色图像中,允许的位深度为8bit时,该类型则表示RGB888格式,为了计算出压缩时所采用的编码字节大小,传统的PNG编码是直接调用函数3A+α计算出RGB888格式中的像素大小,其中A表示允许的位深度,α表示α通道占用的位深度;该函数为允许的位深度乘以通道数,而RGB888格式允许的位深度为8,那么所计算出RGB888格式的一个像素大小为3×8+0=24bit,而由于本发明新增了不等位深度的真彩色图像以及带α通道数据的不等位深度的真彩色图像的设置,采用传统函数所计算出像素大小则与其本身的大小不相同;为了方便说明,以下均以RGB565代表不等位深度的真彩色图像,以RGB565A代表带α通道数据的不等位深度的真彩色图像;可以理解的是,不等位深度的真彩色图像不仅仅限于RGB565,还可以是RGB233等方式,同理带α通道数据的不等位深度的真彩色图像也不仅限于RGB565A。为了与传统的PNG编码方式兼容,所以本发明对RGB565格式所设置的允许的位深度为5bit或者6bit;此时调用函数所计算出的像素位深度则为15bit或者18bit,显然与RGB565格式的像素位深度不同;为了解决调用函数不能得出不等位深度的真彩色图像或者带α通道数据的不等位深度的真彩色图像真实的像素位深度;本发明实施例提供了至少两种方式来解决上述问题:Since the traditional encoding of images of equal bit depth is to call functions for calculation, for example, in a true color image, when the allowable bit depth is 8bit, this type represents RGB888 format, in order to calculate the encoding byte used in compression Size, the traditional PNG encoding is to directly call the function 3A+α to calculate the pixel size in the RGB888 format, where A represents the allowable bit depth, and α represents the bit depth occupied by the alpha channel; this function is the allowable bit depth multiplied by the number of channels , and the allowed bit depth of the RGB888 format is 8, then the calculated pixel size of the RGB888 format is 3×8+0=24bit, and since the present invention adds a true color image with unequal bit depth and data with α channel For the setting of true color images with unequal bit depths, the pixel size calculated by the traditional function is different from its own size; for the convenience of explanation, RGB565 is used to represent the true color images of unequal bit depths, and RGB565A is used to represent the True color images with unequal bit depths of alpha channel data; it is understandable that true color images with unequal bit depths are not limited to RGB565, but can also be RGB233 and other methods. True color images are also not limited to RGB565A. In order to be compatible with the traditional PNG encoding method, the allowable bit depth set by the present invention for the RGB565 format is 5bit or 6bit; at this time, the pixel bit depth calculated by the calling function is 15bit or 18bit, which is obviously similar to the pixel in the RGB565 format. The bit depth is different; in order to solve the problem that the calling function cannot obtain the true pixel bit depth of a true color image with unequal bit depth or a true color image with unequal bit depth with alpha channel data; the embodiment of the present invention provides at least two ways to To solve the above problem:
在一个可实现方式中,为了配合调用函数,本发明对允许的位深度的进行处理;当判断出定义值的大小为8或者为12时,则参考定义表2中的记载,RGB565和RGB565A所允许的位深度是5bit;如果颜色类型等于8,则每个像素总的位深度在计算时需要再加1,即三种颜色R、G、B为(15+1)=16bit;如果颜色类型等于12,则像素总的位深度在计算时也需要加1,则三种颜色R、G、B为(15+1)+alpha(8)=24bit;像素编码为RGB565(或RGB565A)后虽然打破了每个颜色相等的规则,但基于图像像素渐进性的特点以及滤波和压缩对字节进行操作的特点,仍然可以沿用传统的滤波和压缩标准流程。In an achievable manner, in order to cooperate with the calling function, the present invention processes the allowable bit depth; when it is judged that the size of the defined value is 8 or 12, then refer to the records in Definition Table 2, RGB565 and RGB565A The allowable bit depth is 5bit; if the color type is equal to 8, the total bit depth of each pixel needs to be calculated by adding 1, that is, the three colors R, G, and B are (15+1)=16bit; if the color type If it is equal to 12, then the total bit depth of the pixel needs to be added by 1 when calculating, then the three colors R, G, B are (15+1)+alpha(8)=24bit; although the pixel encoding is RGB565 (or RGB565A), although The rule that each color is equal is broken, but the traditional filtering and compression standard process can still be used based on the characteristics of image pixel progressiveness and the characteristics of filtering and compression to operate on bytes.
一个优选实施例中,在判断需进行编码的颜色类型的定义值的大小之前还包括读取出的原始图片中的目标像素进行颜色类型转换,即从灰度图像、真彩色图像、索引彩色图像、带α通道数据的灰度图像、带α通道数据的真彩色图像、不等位深度的真彩色图像以及带α通道数据的不等位深度的真彩色图像中任意一种颜色类型转换到另一种与之前不同的颜色类型;并重新确定新的颜色类型的定义值。这些颜色类型转换所使用的转换函数可以使用现有技术,In a preferred embodiment, before judging the size of the definition value of the color type to be encoded, the target pixel in the read original picture is also included to perform color type conversion, that is, from grayscale image, true color image, indexed color image. , grayscale image with alpha channel data, true color image with alpha channel data, true color image with unequal bit depth, and true color image with unequal bit depth with alpha channel data. Convert any color type to another. A different color type from the previous one; and redefines the definition value of the new color type. The conversion functions used for these color type conversions can use existing techniques,
为了便于理解,举个例子,就RGB888->RGB565而言:其转换的具体思路如下:In order to facilitate understanding, for example, in terms of RGB888->RGB565: the specific ideas of its conversion are as follows:
取RGB888中第一个字节的高5位作为转换后的RGB565的第二个字节的高5位;取RGB888中第二个字节的高3位作为转换后的RGB565第二个字节的低3位;取RGB888中第二个字节的第4~6位,作为转换后的RGB565第一个字节的高3位;取RGB888中第二个字节的第三个字节的高5位作为转换后的RGB565第一个字节的低5位;Take the upper 5 bits of the first byte in RGB888 as the upper 5 bits of the second byte of the converted RGB565; take the upper 3 bits of the second byte in RGB888 as the second byte of the converted RGB565 the lower 3 bits; take the 4th to 6th bits of the second byte in RGB888 as the upper 3 bits of the first byte of the converted RGB565; take the third byte of the second byte in RGB888 The upper 5 bits are used as the lower 5 bits of the first byte of the converted RGB565;
反过来而言,就RGB565->RGB888的转换:Conversely, for the conversion of RGB565->RGB888:
取RGB565第一个字节中低5位作为RGB888的高5位;取RGB565第二个字节中的低3位,将其左移5位,作为RGB888第二个字节的高5位;取RGB565第一个字节的高3位将其右移3位,作为RGB888第二个字节的4~6位;取RGB565第二个字节中的高5位作为RGB888第三个字节。Take the lower 5 bits of the first byte of RGB565 as the upper 5 bits of RGB888; take the lower 3 bits of the second byte of RGB565, move it to the left by 5 bits, as the upper 5 bits of the second byte of RGB888; Take the upper 3 bits of the first byte of RGB565 and shift it to the right by 3 bits as the 4-6 bits of the second byte of RGB888; take the upper 5 bits of the second byte of RGB565 as the third byte of RGB888 .
在一个优选实施例中,本发明还可以采用量化压缩和量化补充对损失的精度进行线性补偿,比如说可以将原数据填充至高位;对于低位,用原始数据的低位进行补偿;如果仍然有未填充的位,继续使用原始数据的低位进行循环补偿。In a preferred embodiment, the present invention can also use quantization compression and quantization supplement to linearly compensate for the loss of precision, for example, the original data can be filled to high bits; for low bits, the low bits of the original data can be used for compensation; The padded bits continue to use the lower bits of the original data for cyclic compensation.
S104、确定需要进行编码时的每个像素的位深度,计算出图像的大小,将图像分块,并在图像头部块中预设压缩算法采用扫描线对计算出的图像下采样;S104, determine the bit depth of each pixel when encoding is required, calculate the size of the image, divide the image into blocks, and downsample the calculated image by using a scan line to preset a compression algorithm in the image header block;
一个PNG图像是一个矩形的像素的数组,每行的像素是从左到右的,扫描行是从上到下的。每个像素的大小是由每个像素的位的数量决定的。A PNG image is a rectangular array of pixels, with pixels in each row from left to right, and scan lines from top to bottom. The size of each pixel is determined by the number of bits per pixel.
一个扫描行的像素总是被打包成字节的序列,像素之间没有多余的比特位。扫描行总是开始于字节边界。允许的位深度和颜色类型被限制是为了在所有的情况下,打包是简单和高效的。The pixels of a scanline are always packed into a sequence of bytes, with no extra bits between pixels. Scan lines always start on byte boundaries. The allowed bit depths and color types are limited so that packing is simple and efficient in all cases.
在PNG的图像中,颜色的类型为0(灰色)每个像素只有一个单独的采样,它可能有小于一个字节的精度(1,2,4位)。这些采样被打包成字节,最左的采样在一个字节的高位,其它的采样紧随其后。In PNG images, the color is of type 0 (gray) and there is only one single sample per pixel, which may have less than one byte of precision (1, 2, 4 bits). The samples are packed into bytes, with the leftmost sample in the high order of a byte, and the other samples immediately after.
在PNG的图像中,颜色的类型为3(索引颜色)每个像素只有一个调色板的索引。这预示着索引被打包成字节的方式,与颜色类型为0的方式是相同的。In PNG images, colors are of type 3 (indexed color) and each pixel has only one index into the palette. This indicates that the index is packed into bytes in the same way that the color type is 0.
当一个字节有多个像素时,一个扫描行的最后一个字节的一些低位可能没有使用。这些没有使用的位的内容没有指定。When a byte has multiple pixels, some low-order bits of the last byte of a scan line may not be used. The contents of these unused bits are not specified.
在本发明实施例中,PNG图像的非索引颜色的图像可能有采样值有16位的位深度。这样的采样值以网络字节序存储和传输。In the embodiment of the present invention, the non-indexed color image of the PNG image may have a bit depth of 16 bits in sample value. Such sample values are stored and transmitted in network byte order.
PNG允许多采样的像素仅有8位或者是16位的采样深度,所以一个像素的多个采样根本不会被打包到一个字节中。PNG allows multi-sampled pixels with only 8-bit or 16-bit sample depth, so multiple samples of a pixel are not packed into a single byte at all.
具体的,以位深度为16bit的RGB565格式为例,扫描线将从左往右、从上往下扫描原始图片的像素,一个像素占用两个字节,一个扫描行中包括多个字节,按照字节序列打包进行编码处理。Specifically, taking the RGB565 format with a bit depth of 16bit as an example, the scan line scans the pixels of the original picture from left to right and from top to bottom. One pixel occupies two bytes, and one scan line includes multiple bytes. Packing and encoding according to the byte sequence.
S105、对扫描线数据滤波后按照预设的压缩算法进行压缩,编码出图像数据块,并在图像数据块尾端编码出图像结束块,从而完成PNG图像的编码。S105 , compress the scan line data according to a preset compression algorithm after filtering, encode an image data block, and encode an image end block at the end of the image data block, thereby completing the encoding of the PNG image.
PNG允许扫描行的数据在它被压缩之前进行过滤。过滤能够提供数据的压缩率。PNG allows the scanline's data to be filtered before it is compressed. Filtering can provide the compression ratio of the data.
过滤器中只有一种过滤方法,但是有多种过滤类型。过滤方法并不会影响数据的大小,也不会影响丢失任何信息,过滤的目的只有一个,为压缩方法提供更好压缩的数据。过滤步骤的本身让字节的结果序列与输入的序列有相同的大小,但是在一个不同的表示,取决于执行的过滤类型。过滤没有把实际的扫描行的数据的大小减少。所有的过滤是严格的无损的。There is only one filtering method in a filter, but there are multiple filtering types. The filtering method does not affect the size of the data, nor does it affect the loss of any information. The purpose of filtering is only one, to provide better compressed data for the compression method. The filtering step itself makes the resulting sequence of bytes the same size as the input sequence, but in a different representation, depending on the type of filtering performed. Filtering does not reduce the size of the actual scan line data. All filtering is strictly lossless.
在国际标准中,只有压缩方法0被定义。压缩方法的其它值被保留给未来的标准化。过滤的扫描行的序列的被压缩并且结果的数据流被分别放入IDAT的多个数据块中。所有的IDAT的数据块的内容的联合组成了一个zlib数据流。这个数据流被压缩成被过滤的PNG图像数据流。In international standards, only compression method 0 is defined. Other values for the compression method are reserved for future standardization. The sequence of filtered scan lines is compressed and the resulting data stream is placed separately into multiple data blocks of the IDAT. The union of the contents of all IDAT data blocks forms a zlib data stream. This data stream is compressed into a filtered PNG image data stream.
在上述实施例的基础上,图2是本发明的PNG格式的解码方法流程图;所述解码方法可以包括以下步骤:On the basis of the above embodiment, FIG. 2 is a flowchart of a decoding method in PNG format of the present invention; the decoding method may include the following steps:
S201、读取出PNG图像,读取出图像头部块、图像数据块和图像结束块;S201, read out the PNG image, read out the image header block, the image data block and the image end block;
首先我们读取出PNG图像,检查它是否是有效PNG文件的字节长度,校验完成后,可以读取出图像头部块、图像数据块和图像结束块。First, we read out the PNG image and check whether it is the byte length of a valid PNG file. After the verification is completed, the image header block, image data block and image end block can be read out.
S202、按照从图像头部块读取出的压缩算法,对所述图像数据块解压缩后并进行滤波还原;S202, according to the compression algorithm read out from the image header block, decompress the image data block and perform filter restoration;
从图像头部块读取出的压缩算法,对所述图像数据块解压缩后并进行滤波还原;为了反转滤波器的效果,解码过程可能需要使用同一行上先前像素的解码值,先前行上当前像素正上方的像素以及上面像素左侧的像素。这意味着解码过程始终需要存储至少一条扫描线的图像数据。即使某些过滤器类型不引用先前的扫描线,但解码过程始终需要在解码时存储每条扫描线,因为下一条扫描线可能会使用引用它的过滤器类型。The compression algorithm read from the image header block decompresses the image data block and performs filter restoration; in order to invert the effect of the filter, the decoding process may need to use the decoded value of the previous pixel on the same line, the previous line The pixel directly above the current pixel and the pixel to the left of the pixel above. This means that the decoding process always needs to store at least one scanline of image data. Even though some filter types do not reference previous scanlines, the decoding process always needs to store each scanline as it is decoded, because the next scanline may use a filter type that references it.
S203、按照所述定义值确定出颜色类型;S203, determining the color type according to the defined value;
所述颜色类型包括灰度图像、真彩色图像、索引彩色图像、带α通道数据的灰度图像、带α通道数据的真彩色图像、不等位深度的真彩色图像以及带α通道数据的不等位深度的真彩色图像;The color types include grayscale images, truecolor images, indexed color images, grayscale images with alpha channel data, truecolor images with alpha channel data, truecolor images with unequal bit depths, and unequal bit depth images with alpha channel data. Truecolor images of equal depth;
S204、按照从图像头部块读取的该颜色类型的允许的位深度,对不等位深度的真彩色图像和带α通道数据的不等位深度的真彩色图像按照第三条件计算出像素中的位深度;对其他颜色类型的图像按照第二条件计算出像素中的位深度;S204, according to the allowable bit depth of the color type read from the image header block, calculate the pixel according to the third condition for the true color image with unequal bit depth and the true color image with unequal bit depth with alpha channel data The bit depth in the pixel; for images of other color types, the bit depth in the pixel is calculated according to the second condition;
所述按照第三条件计算出像素中的位深度包括判断不等位深度的真彩色图像和带α通道数据的不等位深度的真彩色图像允许的位深度是否大于等于8,若大于等于8,则将该允许的位深度作为像素的位深度,否则调用附加有可调参数的第一函数计算出像素的位深度;The said calculating the bit depth in the pixel according to the third condition includes judging whether the allowable bit depth of the true color image of unequal bit depth and the true color image of unequal bit depth with alpha channel data is greater than or equal to 8, if greater than or equal to 8 , then the allowable bit depth is taken as the bit depth of the pixel, otherwise the first function with an adjustable parameter is called to calculate the bit depth of the pixel;
所述对其他颜色类型的图像按照第二条件计算出像素的位深度包括调用预设的第一函数按照其允许的深度计算出像素中的位深度大小。The calculating the bit depth of the pixel according to the second condition for images of other color types includes calling a preset first function to calculate the size of the bit depth in the pixel according to its allowable depth.
举个例子,解码过程中,如果读取出的颜色类型的定义值为8,那么该颜色类型具体可以为RGB565或者RGB232等,为了确定具体的颜色类型,本发明先判断出图像头部块中的允许的位深度是否大于8,如果大于等于8,根据表2的设置,那么该位深度则是16bit,所以直接按照16bit作为像素的位深度,则将该允许的位深度作为像素的位深度,否则调用附加有可调参数的第一函数计算出像素的位深度;比如说允许的位深度为5bit,那么需要调用预设的第一函数表示为f(x)=3A+α,A代表通道的位深度,α代表α通道占用的位深度;同时在预设的第一函数上附件有可调参数;所述可调参数的值为±1或者±2。For example, in the decoding process, if the definition value of the read color type is 8, then the color type can be RGB565 or RGB232, etc. In order to determine the specific color type, the present invention first determines the image header block. Whether the allowable bit depth is greater than 8, if it is greater than or equal to 8, according to the settings in Table 2, then the bit depth is 16bit, so directly according to 16bit as the bit depth of the pixel, then the allowable bit depth as the bit depth of the pixel , otherwise call the first function with adjustable parameters to calculate the bit depth of the pixel; for example, if the allowable bit depth is 5bit, then the preset first function needs to be called and expressed as f(x)=3A+α, where A represents The bit depth of the channel, α represents the bit depth occupied by the α channel; at the same time, an adjustable parameter is attached to the preset first function; the value of the adjustable parameter is ±1 or ±2.
S205、按照所述每个像素的位深度从PNG图像数据块中解码出图像信息数据;S205, decode the image information data from the PNG image data block according to the bit depth of each pixel;
获得每个像素的位深度后,以RGB565为例,每个像素的位深度是16bit,在图像数据块中,按照16bit作为一个像素的方式获取图像信息数据。After the bit depth of each pixel is obtained, taking RGB565 as an example, the bit depth of each pixel is 16 bits. In the image data block, the image information data is obtained by taking 16 bits as a pixel.
S206、对图像数据块的信息解码完成后,将图像头部块和图像结束块解码的信息分别加载到所述图像块的信息前后,完成对PNG图像的解码。S206: After the decoding of the information of the image data block is completed, load the decoded information of the image header block and the image end block into the information before and after the image block respectively, and complete the decoding of the PNG image.
图3是本发明所提供的一种PNG格式的编码装置,如图3所示,所述编码装置包括:Fig. 3 is a kind of encoding device of PNG format provided by the present invention, as shown in Fig. 3, described encoding device comprises:
第一采集单元,用于采集原始图片中的目标像素;a first collection unit, used for collecting target pixels in the original picture;
第一识别单元,用于识别出目标像素的颜色类型并与预设的定义值对应;The first identification unit is used for identifying the color type of the target pixel and corresponding to the preset definition value;
编码准备单元,用于设置编码过程中允许的位深度指向该定义值;以及用于确定需要进行编码时的每个像素的位深度,从而计算出图像大小并确定图像头部块的内容;An encoding preparation unit, for setting the allowable bit depth in the encoding process to point to the defined value; and for determining the bit depth of each pixel when encoding is required, thereby calculating the image size and determining the content of the image header block;
编码单元,用于按照编码准备单元确定的图像块中进行PNG编码处理,编码出图像头部块、图像数据块和图像结束块。The encoding unit is configured to perform PNG encoding processing according to the image blocks determined by the encoding preparation unit, and encode the image header block, the image data block and the image end block.
图4是本发明所提供的一种PNG格式的解码装置,如图4所示,所述解码装置包括:FIG. 4 is a decoding device in PNG format provided by the present invention. As shown in FIG. 4 , the decoding device includes:
第二采集单元,用于采集PNG图像;The second collection unit is used to collect PNG images;
第二识别单元,用于从PNG图像读取出图像头部块、图像数据块和图像结束块;并从图像头部块中识别出颜色类型和允许的位深度;The second identification unit is used to read out the image header block, the image data block and the image end block from the PNG image; and identify the color type and the allowable bit depth from the image header block;
解码准备单元,用于根据颜色类型确定出PNG数据流中的像素的位数和像素中不同通道的位数;The decoding preparation unit is used to determine the number of bits of pixels in the PNG data stream and the number of bits of different channels in the pixels according to the color type;
解码单元,用于根据所述像素的位数和像素中不同通道的位数解析出PNG图像的信息。A decoding unit, configured to parse out the information of the PNG image according to the number of bits of the pixel and the number of bits of different channels in the pixel.
可以理解的,本发明中的PNG格式的编码、解码方法及装置的部分特征可以相互引用,为了避免追溯,本发明不再一一例举。It can be understood that some features of the encoding and decoding methods and apparatuses in the PNG format in the present invention can be referred to each other. In order to avoid retrospect, the present invention will not exemplify them one by one.
本发明通过在传统的PNG格式上扩展出了不等位深度的真彩色图像和带α通道数据的不等位深度的真彩色图像的定义,使得本发明在支持传统的颜色类型以外,还能够支持RGB565、RGB565A等格式编码和解码;便于在MCU等芯片上进行显示;采用本发明的方法同样适用于扩展PNG对其他颜色类型图像颜色的支持,并且能够很容易的实现各种颜色类型之间的互换;同时,采用本发明的方法也能比较好兼容原有的PNG的颜色类型格式。The present invention extends the definition of true color image with unequal bit depth and true color image with alpha channel data on the traditional PNG format, so that the present invention can not only support traditional color types, but also can It supports encoding and decoding of RGB565, RGB565A and other formats; it is convenient to display on chips such as MCU; the method of the present invention is also suitable for expanding the support of PNG for other color types of image colors, and can easily realize the difference between various color types. At the same time, the method of the present invention can also be better compatible with the original PNG color type format.
在本发明中,除非另有明确的规定和限定,术语“安装”、“设置”、“连接”、“固定”、“旋转”等术语应做广义理解,例如,可以是固定连接,也可以是可拆卸连接,或成一体;可以是机械连接,也可以是电连接;可以是直接相连,也可以通过中间媒介间接相连,可以是两个元件内部的连通或两个元件的相互作用关系,除非另有明确的限定,对于本领域的普通技术人员而言,可以根据具体情况理解上述术语在本发明中的具体含义。In the present invention, unless otherwise expressly specified and limited, terms such as "installation", "arrangement", "connection", "fixation" and "rotation" should be understood in a broad sense, for example, it may be a fixed connection or a It can be a detachable connection, or integrated; it can be a mechanical connection or an electrical connection; it can be directly connected or indirectly connected through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between the two elements, Unless otherwise clearly defined, those of ordinary skill in the art can understand the specific meanings of the above terms in the present invention according to specific situations.
尽管已经示出和描述了本发明的实施例,对于本领域的普通技术人员而言,可以理解在不脱离本发明的原理和精神的情况下可以对这些实施例进行多种变化、修改、替换和变型,本发明的范围由所附权利要求及其等同物限定。Although embodiments of the present invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, and substitutions can be made in these embodiments without departing from the principle and spirit of the invention and modifications, the scope of the present invention is defined by the appended claims and their equivalents.
Claims (9)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011111269.9A CN114387356B (en) | 2020-10-16 | 2020-10-16 | A PNG format encoding and decoding method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011111269.9A CN114387356B (en) | 2020-10-16 | 2020-10-16 | A PNG format encoding and decoding method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114387356A true CN114387356A (en) | 2022-04-22 |
CN114387356B CN114387356B (en) | 2025-04-18 |
Family
ID=81193322
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011111269.9A Active CN114387356B (en) | 2020-10-16 | 2020-10-16 | A PNG format encoding and decoding method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114387356B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN119127813A (en) * | 2024-09-02 | 2024-12-13 | 江苏电子信息职业学院 | Image recognition processing system and method based on data analysis |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030007695A1 (en) * | 2001-05-24 | 2003-01-09 | Bossut Philippe J. | System and process for automatically determining optimal image compression methods for reducing file size |
CN103903285A (en) * | 2012-12-25 | 2014-07-02 | 三星电子(中国)研发中心 | Thumbnail extraction method of PNG image and BMP image |
WO2018100332A1 (en) * | 2016-11-29 | 2018-06-07 | Sony Europe Limited | A decoder, encoder, computer program and method |
-
2020
- 2020-10-16 CN CN202011111269.9A patent/CN114387356B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030007695A1 (en) * | 2001-05-24 | 2003-01-09 | Bossut Philippe J. | System and process for automatically determining optimal image compression methods for reducing file size |
CN103903285A (en) * | 2012-12-25 | 2014-07-02 | 三星电子(中国)研发中心 | Thumbnail extraction method of PNG image and BMP image |
WO2018100332A1 (en) * | 2016-11-29 | 2018-06-07 | Sony Europe Limited | A decoder, encoder, computer program and method |
CN110036646A (en) * | 2016-11-29 | 2019-07-19 | 索尼欧洲有限公司 | Decoder, encoder, computer program and method |
Non-Patent Citations (2)
Title |
---|
MAXIONGYING: "PNG文件格式详解", Retrieved from the Internet <URL:https://www.cnblogs.com/senior-engineer/p/9548347.html> * |
孔德超: "基于GPU的PNG加速解码研究", 《中国优秀硕士学位论文全文数据库 信息科技辑 2013年第01期》, 15 January 2013 (2013-01-15), pages 7 - 13 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN119127813A (en) * | 2024-09-02 | 2024-12-13 | 江苏电子信息职业学院 | Image recognition processing system and method based on data analysis |
CN119127813B (en) * | 2024-09-02 | 2025-02-25 | 江苏电子信息职业学院 | Image recognition processing system and method based on data analysis |
Also Published As
Publication number | Publication date |
---|---|
CN114387356B (en) | 2025-04-18 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10672148B2 (en) | Compressing and uncompressing method for high bit-depth medical gray scale images | |
CN109348226B (en) | Picture file processing method and intelligent terminal | |
CN102523367B (en) | Real time imaging based on many palettes compresses and method of reducing | |
US7864190B2 (en) | Methods and apparatus for encoding and decoding images | |
CN100524452C (en) | Digital image storage, displaying method and device | |
CN109842803B (en) | Method and device for image compression | |
CN113170140B (en) | Method for encoding data element, method for decoding data stream, device and medium | |
US20020090140A1 (en) | Method and apparatus for providing clinically adaptive compression of imaging data | |
CN105933708B (en) | A kind of method and apparatus of data compression and decompression | |
CN101099174A (en) | Image Compression for Computer Graphics | |
US8508543B2 (en) | Layered texture compression architecture | |
KR102626217B1 (en) | Frame buffer compressor and Image processing device comprising the same | |
CN104142924A (en) | Compression method and device for animation picture format | |
US11991347B2 (en) | Image processing device | |
CN102308582B (en) | Method for the segmentation encoding of an image | |
CN112887722B (en) | Lossless image compression method | |
CN114387356A (en) | A PNG format encoding and decoding method and device | |
US8600181B2 (en) | Method for compressing images and a format for compressed images | |
KR20220015556A (en) | Frame buffer compressor and image processing apparatus | |
US7043086B2 (en) | JPEG packed block data structure for enhanced image processing | |
KR102465206B1 (en) | Image processing device | |
CN106961601A (en) | The compression and decompression of video data | |
JP2821614B2 (en) | Image transmission apparatus and image transmission method | |
CN119728990A (en) | Image compression method, decompression method, device, storage medium and electronic equipment | |
KR20220149124A (en) | A image signal processor, a method of operating a image signal processor and a image processing system including the image processing device |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |