CN109271540A - A kind of implementation method of combination picture lossy compression and record transparence information - Google Patents

A kind of implementation method of combination picture lossy compression and record transparence information Download PDF

Info

Publication number
CN109271540A
CN109271540A CN201811123480.5A CN201811123480A CN109271540A CN 109271540 A CN109271540 A CN 109271540A CN 201811123480 A CN201811123480 A CN 201811123480A CN 109271540 A CN109271540 A CN 109271540A
Authority
CN
China
Prior art keywords
format
file
png
byte stream
length
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
CN201811123480.5A
Other languages
Chinese (zh)
Other versions
CN109271540B (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 CN201811123480.5A priority Critical patent/CN109271540B/en
Publication of CN109271540A publication Critical patent/CN109271540A/en
Application granted granted Critical
Publication of CN109271540B publication Critical patent/CN109271540B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N19/00Methods or arrangements for coding, decoding, compressing or decompressing digital video signals
    • H04N19/85Methods or arrangements for coding, decoding, compressing or decompressing digital video signals using pre-processing or post-processing specially adapted for video compression

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Signal Processing (AREA)
  • Compression Of Band Width Or Redundancy In Fax (AREA)
  • Compression Or Coding Systems Of Tv Signals (AREA)

Abstract

The invention discloses the implementation methods of a kind of combination picture lossy compression and record transparence information.The present invention includes two parts, is converted into specified format from png format and is converted into png format from specified format.The thought of this method is to combine jpg format and png format, has both obtained the high benefit of jpg format compression rate, and png format of having got back supports the benefit of transparence information, significantly shortens file size on the whole.

Description

A kind of implementation method of combination picture lossy compression and record transparence information
Technical field
The invention belongs to data compression, computer graphic image process field, the height in conjunction with lossy compression is especially needed The method that can be used when the requirement of compression ratio and record transparence information.
Background technique
With the rapid development of computer and networks, picture is one of highly important media, the compress mode point of picture For two major classes, lossy compression and lossless compression, wherein lossy compression is the sensitive journey according to human eye to color, brightness, details etc. Degree, selectively abandons some insensitive data, achievees the effect that reduce space hold, common are damage compressed file at present Format is jpg format, but jpg format does not support storage transparence information.Transparence information in the practical application of picture be also Very important, the image comprising transparence information can enable the edge of color image smoothly merge with any background, from And thoroughly eliminate edge and the phenomenon that sawtooth occur, the format comprising transparence information common at present is png format, but png Format is not supported to carry out lossy compression to image data.This method combines the advantages of jpg format and png format, can use Lossy compression improves compression ratio, and can store transparence information, adapts to wider usage scenario.
Summary of the invention
The purpose of the present invention is being directed to the blank of the prior art, lossy compression and storage can be used by providing one kind The method of transparence information.The present invention includes two parts, is turned from png format conversion cost method format and from this method format Change png format into.
Specific steps of the method for the present invention from png format conversion cost method format are as follows:
Step 1: reading in png image file to be processed using open source image procossing class libraries CXImage, it is denoted as SRC, so The Encode method of SRC is called afterwards, and type parameter is set as CXIMAGE_FORMAT_JPG, SRC is converted to the memory of jpg format Byte stream is denoted as M1, calls the Encode2RGBA method of SRC, gets the memory byte stream of SRC transparence information, is denoted as M2。
Step 2: file header is written in new file, file header includes the about definite value I for identifying file type, wherein Using the length of byte stream M1, the length of byte stream M2 as the content of file header, content, the content of byte stream M2 of byte stream M1 As the content of new file, to complete the write-in of new file.
The present invention is converted into the specific steps of png format from this method format are as follows:
Step 3: file header is read from the file of this method format, about definite value II, picture including identifying file type The length L1 of lossy compression data, picture transparence information length L2, if the about definite value II of the mark file type read It is identical as about definite value I, then enter step four;If the about definite value II of the mark file type read is different from about definite value I, then it is assumed that It is not the format of this method, convert failed.
Step 4: reading the byte stream that length is L1, the i.e. image data of jpg format after file header, used CXImage decoding, obtains the RGB data of image, is denoted as DST, then proceedes to read the byte stream that length is L2, i.e. transparency is believed The memory byte stream of breath calls the AlphaSet function of DST, and transparence information is arranged into the picture material of DST, is then adjusted With the Encode function of DST, type parameter, which is set as CXIMAGE_FORMAT_PNG, can be obtained the result of final png format.
The present invention has the beneficial effect that:
The thought of this method is to combine jpg format and png format, has both obtained high good of jpg format compression rate Place, png format of having got back support the benefit of transparence information, significantly shorten file size on the whole.
Specific embodiment
Below with reference to embodiment, the invention will be further described.
By taking img_answer_tc.png as an example, original document size is 15232 bytes, uses open source image procossing class libraries CXImage reads in img_answer_tc.png to be processed, is denoted as SRC, then calls the Encode method of SRC, type parameter It is set as CXIMAGE_FORMAT_JPG, is converted into the memory byte stream of jpg format, is denoted as M1, the length of M1 is 7431 words Then section calls the Encode2RGBA method of SRC, gets the memory byte stream of transparence information, be denoted as M2, the length of M2 For 1425 bytes, in addition file header, the file total length ultimately produced is 8888 bytes, and the space occupied is original document 58%.
Read in file header from file section start to be decompressed, obtain the about definite value II of mark file type, jpg format it is interior Deposit the memory byte stream length L2=1425 of byte stream length L1=7431, transparence information, will about definite value II and about definite value I into Row compares, and confirmation is this method format;Then 7431 bytes are read in again, it is decoded using CXImage, obtains image RGB data is denoted as DST;Then 1425 bytes are read in again, are the memory byte stream of transparence information, are called DST's The memory byte stream of transparence information is arranged into the picture material of DST AlphaSet function, then calls DST's Encode function, type parameter be set as CXIMAGE_FORMAT_PNG can be obtained final png format as a result, last recovery File size be 15048 bytes, reason of different sizes is that this method contains lossy compression process with original document, through over-voltage Data and initial data after contracting and decompression are not quite identical.

Claims (1)

1. the implementation method of a kind of combination picture lossy compression and record transparence information, it is characterised in that this method includes two Part is converted into specified format from png format and is converted into png format from specified format, and the specific implementation steps are as follows:
The specific steps of specified format are converted into from png format are as follows:
Step 1: reading in png image file to be processed using open source image procossing class libraries CXImage, it is denoted as SRC, is then adjusted With the Encode method of SRC, type parameter is set as CXIMAGE_FORMAT_JPG, and SRC is converted to the memory byte of jpg format Stream, is denoted as M1, calls the Encode2RGBA method of SRC, get the memory byte stream of SRC transparence information, be denoted as M2;
Step 2: file header is written in new file, file header includes the about definite value I for identifying file type, wherein by word Content of the length, the length of byte stream M2 of throttling M1 as file header, the content conduct of the content, byte stream M2 of byte stream M1 The content of new file, to complete the write-in of new file;
The specific steps of png format are converted into from specified format are as follows:
Step 3: reading file header from the file of specified format, about definite value II, picture including mark file type are damaged The transparence information length L2 of the length L1 of compressed data, picture, if the about definite value II of the mark file type read with arrange Value I is identical, then enters step four;If the about definite value II of the mark file type read is different from about definite value I, then it is assumed that be not this The format of method, convert failed;
Step 4: reading the byte stream that length is L1, the i.e. image data of jpg format after file header, used CXImage decoding, obtains the RGB data of image, is denoted as DST, then proceedes to read the byte stream that length is L2, i.e. transparency is believed The memory byte stream of breath calls the AlphaSet function of DST, and transparence information is arranged into the picture material of DST, is then adjusted With the Encode function of DST, type parameter, which is set as CXIMAGE_FORMAT_PNG, can be obtained the result of final png format.
CN201811123480.5A 2018-09-26 2018-09-26 Implementation method for combining picture lossy compression and recording transparency information Active CN109271540B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811123480.5A CN109271540B (en) 2018-09-26 2018-09-26 Implementation method for combining picture lossy compression and recording transparency information

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811123480.5A CN109271540B (en) 2018-09-26 2018-09-26 Implementation method for combining picture lossy compression and recording transparency information

Publications (2)

Publication Number Publication Date
CN109271540A true CN109271540A (en) 2019-01-25
CN109271540B CN109271540B (en) 2021-05-25

Family

ID=65197556

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811123480.5A Active CN109271540B (en) 2018-09-26 2018-09-26 Implementation method for combining picture lossy compression and recording transparency information

Country Status (1)

Country Link
CN (1) CN109271540B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080219553A1 (en) * 2005-08-23 2008-09-11 Toshio Akiyama Controlling format of a compound image
CN102036059A (en) * 2009-09-25 2011-04-27 腾讯科技(深圳)有限公司 Method, device and system for compressing and decompressing transparent images
CN105430393A (en) * 2014-09-19 2016-03-23 腾讯科技(深圳)有限公司 Picture processing method, picture processing device and picture processing platform
CN105491398A (en) * 2014-09-19 2016-04-13 腾讯科技(深圳)有限公司 Picture processing method, picture processing device and picture processing platform
CN106937132A (en) * 2017-04-08 2017-07-07 腾讯科技(深圳)有限公司 A kind of photograph document handling method
CN108154542A (en) * 2017-12-22 2018-06-12 北京小鱼在家科技有限公司 A kind of method for increasing translucent attribute to JPG files

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080219553A1 (en) * 2005-08-23 2008-09-11 Toshio Akiyama Controlling format of a compound image
CN102036059A (en) * 2009-09-25 2011-04-27 腾讯科技(深圳)有限公司 Method, device and system for compressing and decompressing transparent images
CN105430393A (en) * 2014-09-19 2016-03-23 腾讯科技(深圳)有限公司 Picture processing method, picture processing device and picture processing platform
CN105491398A (en) * 2014-09-19 2016-04-13 腾讯科技(深圳)有限公司 Picture processing method, picture processing device and picture processing platform
CN106937132A (en) * 2017-04-08 2017-07-07 腾讯科技(深圳)有限公司 A kind of photograph document handling method
CN108154542A (en) * 2017-12-22 2018-06-12 北京小鱼在家科技有限公司 A kind of method for increasing translucent attribute to JPG files

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
吴昊: "基于Android手机应用开发的png图片压缩打包技术研究", 《中国新通信》 *

Also Published As

Publication number Publication date
CN109271540B (en) 2021-05-25

Similar Documents

Publication Publication Date Title
WO2018184458A1 (en) Picture file processing method and device, and storage medium
RU2517398C2 (en) Method, device and system for compression and recovery of compressed picture
JP4151684B2 (en) Encoding apparatus, encoding method, encoding program, and imaging apparatus
TWI553626B (en) Backwards compatible extended image format
CN102821279A (en) Picture compression method keeping with alpha channel
JP2006345315A5 (en)
KR20110025359A (en) Block unit data compression and decompression method and apparatus thereof
JPWO2007125697A1 (en) Video processing apparatus, recording medium, video signal processing method, video signal processing program, and integrated circuit
US20060257133A1 (en) Imaging device, processing method of the device, and program for executing the method by computer
CN103093074B (en) In audit report, embed the method for DICOM medical image
US10304212B2 (en) Graphic data compression device and graphic data compression method
CN105912289A (en) Startup LOGO image conversion and storage method and apparatus, and startup LOGO image displaying method and apparatus
US8411106B2 (en) Converting digital values corresponding to colors of an image from a source color space to a destination color space
CN105144726A (en) Custom data indicating nominal range of samples of media content
CN105719321A (en) Texture compression method and device
US20090154802A1 (en) Method and apparatus for image compression and decompression
US7314180B2 (en) Memory card and reproducing apparatus
CN102572207B (en) Color space transformation method suitable for joint photographic experts group (JPEG) image
CN109271540A (en) A kind of implementation method of combination picture lossy compression and record transparence information
KR20110101792A (en) System and method for lossless compression and decompression of image data
JP6990179B2 (en) Methods and equipment for selecting processes to be applied to video data from a candidate process set driven by a common information dataset.
CN109905715A (en) It is inserted into the code stream conversion method and system of SEI data
CN106780322A (en) A kind of method for compressing image and device
CN108154542A (en) A kind of method for increasing translucent attribute to JPG files
CN110955381B (en) Device and method for compressing file outgoing package

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
CP02 Change in the address of a patent holder
CP02 Change in the address 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 EDUCATION SCIENCE AND TECHNOLOGY STOCK CO.,LTD.

Address before: Room 1406, Hangzhou e-commerce building, 118 Wensan West Road, Xihu District, Hangzhou City, Zhejiang Province, 310013

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.