CN108154542B - Method for adding semitransparent property to JPG file - Google Patents

Method for adding semitransparent property to JPG file Download PDF

Info

Publication number
CN108154542B
CN108154542B CN201711402632.0A CN201711402632A CN108154542B CN 108154542 B CN108154542 B CN 108154542B CN 201711402632 A CN201711402632 A CN 201711402632A CN 108154542 B CN108154542 B CN 108154542B
Authority
CN
China
Prior art keywords
data
jpg
alpha channel
channel data
format
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.)
Active
Application number
CN201711402632.0A
Other languages
Chinese (zh)
Other versions
CN108154542A (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.)
Shanghai Xiaodu Technology Co Ltd
Original Assignee
Shanghai Xiaodu 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 Shanghai Xiaodu Technology Co Ltd filed Critical Shanghai Xiaodu Technology Co Ltd
Priority to CN201711402632.0A priority Critical patent/CN108154542B/en
Publication of CN108154542A publication Critical patent/CN108154542A/en
Application granted granted Critical
Publication of CN108154542B publication Critical patent/CN108154542B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/001Texturing; Colouring; Generation of texture or colour
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/50Lighting effects
    • G06T15/503Blending, e.g. for anti-aliasing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2210/00Indexing scheme for image generation or computer graphics
    • G06T2210/32Image data format
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2210/00Indexing scheme for image generation or computer graphics
    • G06T2210/62Semi-transparency

Abstract

The invention provides a method for adding a semitransparent attribute to a JPG picture file, which comprises the following steps: storing Alpha channel data into an unoccupied segment in a JPG format; identifying a segment for storing Alpha channel data from the JPG format data; decoding data in the identified segment into Alpha channel data; and combining the Alpha channel data with the RGB data channel decoded and converted from the JPG scanning line to form an RGBA data format required for realizing translucency. The method can realize that the semitransparent attribute is added to the JPG picture file, the picture volume is effectively reduced, and for application software which uses a large number of PNG pictures, the volume of an installation package can be effectively reduced by using the expanded JPG file, and the network flow cost brought by downloading the software installation package is reduced.

Description

Method for adding semitransparent property to JPG file
Technical Field
The invention relates to the field of image processing, in particular to a method for adding a semitransparent attribute to a JPG picture file, which is used for decoding the JPG file.
Technical Field
The image displayed by the computer is formed by one pixel point, and the color of one pixel point is defined by three color channels of R (Red), G (Green) and B (blue) in the computer. Although RGB defines the color value of a dot, it does not define how this color value blends with the background color when displayed (translucency). To solve this problem, the drawing API (application program interface) of the computer generally supports the use of an Alpha channel (semi-transparent channel) to define the degree of mixing of foreground and background when displaying an image. When Alpha channels are included in the computed image, these drawing APIs can use the data of this channel to achieve translucency of the drawing. Alpha channel refers to the transparency and translucency of a picture. For example: a picture stored using 16 bits may have 5 bits for red, 5 bits for green, 5 bits for blue, and 1 bit for alpha. In this case, it may represent transparent or opaque. A picture using 32-bit storage, each 8 bits representing red, green, and blue, and Alpha channels. In this case, neither light can represent transparent or opaque, and the Alpha channel can also represent 256 levels of translucency. In order to realize storage of computer images, many image storage formats are designed, and PNG, JPG, and the like are commonly used. The PNG format supports storing RGB and Alpha 4 data channels, while the JPG format supports only RGB 3 data channels.
The PNG format provides an alpha channel (the alpha channel is a numerical value that defines a mixing operation between a pixel point in a picture and a corresponding pixel on a background picture during drawing), and is widely used in computer image effect display. PNG adopts zip algorithm to make data compression, zip is a lossless data compression algorithm, and has the advantages of retaining complete image information and relatively low compression rate. The JPG image format is another widely used picture format, and JPG adopts a lossy compression algorithm, so that the data compression rate can be effectively improved, and meanwhile, the effective information of the original picture is basically maintained. However, the existing JPG picture format only defines red, green and blue (RGB) three data channels, and is usually only used for storing photos although the compression rate is high, and JPG is rarely used as UI materials in software development.
Disclosure of Invention
The invention provides a method for adding a semitransparent attribute to a JPG image file, which solves the problem that fused display (namely semitransparent display) with a background can not be realized during display due to the lack of an Alpha channel during storage in a JPG image file format.
Specifically, the method for adding the semitransparent property to the JPG picture file provided by the invention comprises the following steps:
storing Alpha channel data into an unoccupied segment in a JPG format;
identifying a segment for storing Alpha channel data from the JPG format data;
decoding data in the identified segment into Alpha channel data; and
and combining the Alpha channel data with the RGB data channel decoded and converted from the JPG scanning line to form an RGBA data format required for realizing translucency.
Preferably, in the step of storing Alpha channel data into an unoccupied segment in the JPG format, the Alpha channel data is stored directly.
Preferably, in the step of storing the Alpha channel data into the unoccupied segment in the JPG format, the Alpha channel data is stored in a data compression manner.
Preferably, in the step of storing Alpha channel data into unoccupied segments in the JPG format, the number of segments in the JPG format in which the Alpha channel data is stored is greater than or equal to 1.
Preferably, the step of storing Alpha channel data into unoccupied segments in a JPG format comprises storing any one of data segments (APP0-APPn) of a plurality of data channels in the JPG format.
Preferably, the first arbitrary byte of the data field for storing Alpha channel data represents the length of the Alpha channel data.
Preferably, the step of identifying a segment storing Alpha channel data from JPG format data comprises: the JPG decoder identifies the segment storing Alpha channel data by changing the version number of the JPG format.
According to the method for adding the semitransparent attribute to the JPG picture file, provided by the invention, the picture volume can be effectively reduced, and for application software using a large number of PNG pictures, the volume of an installation package can be effectively reduced by using the expanded JPG file, and the network flow cost brought by downloading the software installation package is reduced.
Drawings
Other features, objects and advantages of the invention will become more apparent upon reading of the detailed description of non-limiting embodiments made with reference to the following drawings:
fig. 1 is a flowchart of a method for adding a semi-transparent attribute to a JPG picture file according to an embodiment of the present invention.
Detailed Description
In order to make the objects, contents and advantages of the present invention clearer, the following detailed description of the embodiments of the present invention will be made in conjunction with the accompanying drawings and examples.
The JPG file format is a file format that describes an image using a plurality of data segments. Specific file format descriptions may refer to ISO/IEC 10918-5:2013(http:// www.iso.org/ISO/ISO _ catalog/catalog _ tc/catalog _ detail. htmscs number 54989) or wiki (https:// en. wikipedia. org/wiki/JPEG). The segment types and identification codes refer to the following table.
Figure BDA0001519697180000041
Several segments of APPn, EOI, COM are of interest here. The APP0 segment defines the version information of the picture format, the COM segment can write the annotation, and the EOI ends the code picture. In addition to these several segments, the other segments have a well-defined meaning (EOI has a well-defined meaning of course, but since it codes the picture end, the additional data does not affect the picture format resolution either).
Since the picture stored by JPG may be a gray scale, and may be in YCbCr/YIQ format for 3 channels of data or CMYK format for 4 channels (defined in section SOF 0), none of them contains Alpha channels. As shown in step S101 of fig. 1, in order to achieve the semi-transparent effect, only Alpha channel data needs to be stored into other unoccupied segments of the JPG format. The number of the JPG format segments for storing Alpha channel data is more than or equal to 1. Or any one of the data segments (APP0-APPn) of the multi-way data channel in the JPG format can be used for storage. The existence of these data segments in the picture file does not affect the picture format parsing process of a general application program, so that an expanded JPG picture can still be recognized by the existing software, but an expanded Alpha channel cannot be used. And the application program for recognizing and analyzing the Alpha data can fully utilize the Alpha channel data to realize the same Alpha mixing effect as the PNG format.
In step S102, the segment storing Alpha channel data is identified from the JPG format data, and preferably, the JPG decoder may identify the segment storing Alpha channel data by changing the version number of the JPG format. It is assumed that the Alpha channel data is stored in the APP3 data segment, and the data in the version of the APP0 data segment is changed to 0102(1.02) (in order to be compatible with the parsing of the conventional picture decoder), at this time, the JPG decoder can recognize that the APP3 data segment in the JPG format stores the Alpha channel data. Preferably, the first arbitrary bytes of one or more data segments used for storing Alpha channel data represent the length of the Alpha channel data, e.g. the first 2 bytes of the APP3 segment, so that a segment can store 65535 bytes at maximum (including segment length 2 bytes), and these data segments can be reused if a segment is insufficient to accommodate the number of an Alpha channel. In step 103, the data in the identified segment is decoded into Alpha channel data, and finally, in step 104, the Alpha channel data and the RGB data channel decoded and converted from the JPG scanning line are combined to form the RGBA data format required for realizing translucency. Data in Alpha channels can be stored directly or using other data compression schemes (e.g., JPG, ZLIB, etc.).
Although the present invention has been described in detail with respect to the exemplary embodiments and advantages thereof, it should be understood that various changes, substitutions, and alterations can be made hereto without departing from the spirit and scope of the invention as defined by the appended claims. For other examples, one of ordinary skill in the art will readily appreciate that the order of the measurement methods may be varied while maintaining the scope of the present invention.
Moreover, the scope of the present application is not intended to be limited to the particular embodiments of the process, machine, manufacture, composition of matter, means, methods and steps described in the specification. As one of ordinary skill in the art will readily appreciate from the disclosure of the present invention, processes, machines, manufacture, compositions of matter, means, methods, or steps, presently existing or later to be developed, that perform substantially the same function or achieve substantially the same result as the corresponding embodiments described herein may be utilized according to the present invention. Accordingly, the appended claims are intended to include within their scope such processes, machines, manufacture, compositions of matter, means, methods, or steps.

Claims (6)

1. A method for adding a semitransparent property to a JPG picture file comprises the following steps:
storing Alpha channel data into an unoccupied segment in a JPG format, wherein the existence of the unoccupied segment does not influence the picture format analysis process of an application program;
identifying a segment for storing Alpha channel data from the JPG format data;
decoding data in the identified segment into Alpha channel data; and
combining the Alpha channel data with the RGB data channel decoded and converted from the JPG scanning line to form an RGBA data format required for realizing translucency;
wherein the step of identifying a segment storing Alpha channel data from JPG format data comprises: the JPG decoder identifies the segment storing Alpha channel data by changing the version number of the JPG format.
2. The method as claimed in claim 1, wherein in the step of storing Alpha channel data in an unoccupied segment in the JPG format, the Alpha channel data is stored directly.
3. The method as claimed in claim 1, wherein in the step of storing Alpha channel data in an unoccupied segment of the JPG format, the Alpha channel data is stored in a data compression manner.
4. The method as claimed in claim 1, wherein the number of JPG-formatted segments storing Alpha channel data in the step of storing Alpha channel data into unoccupied segments of JPG format is greater than or equal to 1.
5. The method of claim 1, wherein the step of storing Alpha channel data into unoccupied segments in JPG format comprises storing any one of data segments APP0-APPN of multiple data channels in JPG format.
6. The method of claim 5, wherein a pre-arbitrary byte of a data field for storing Alpha channel data represents a length of the Alpha channel data.
CN201711402632.0A 2017-12-22 2017-12-22 Method for adding semitransparent property to JPG file Active CN108154542B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711402632.0A CN108154542B (en) 2017-12-22 2017-12-22 Method for adding semitransparent property to JPG file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711402632.0A CN108154542B (en) 2017-12-22 2017-12-22 Method for adding semitransparent property to JPG file

Publications (2)

Publication Number Publication Date
CN108154542A CN108154542A (en) 2018-06-12
CN108154542B true CN108154542B (en) 2021-11-02

Family

ID=62465204

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711402632.0A Active CN108154542B (en) 2017-12-22 2017-12-22 Method for adding semitransparent property to JPG file

Country Status (1)

Country Link
CN (1) CN108154542B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109271540B (en) * 2018-09-26 2021-05-25 浙江万朋教育科技股份有限公司 Implementation method for combining picture lossy compression and recording transparency information

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101639928A (en) * 2009-08-20 2010-02-03 无敌科技(西安)有限公司 Image data encryption and decryption method and system thereof
CN105430393A (en) * 2014-09-19 2016-03-23 腾讯科技(深圳)有限公司 Picture processing method, picture processing device and picture processing platform

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101277712B1 (en) * 2006-11-13 2013-06-24 삼성전자주식회사 Method and apparatus for image processing
US20140111640A1 (en) * 2012-10-19 2014-04-24 Candid Color Systems, Inc. Method of sending and processing event images

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101639928A (en) * 2009-08-20 2010-02-03 无敌科技(西安)有限公司 Image data encryption and decryption method and system thereof
CN105430393A (en) * 2014-09-19 2016-03-23 腾讯科技(深圳)有限公司 Picture processing method, picture processing device and picture processing platform

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
JFIF百度百科-2017-07-29历史版本;百度百科;《URL:http://baike.baidu.com/historylist/jfif/10098594》;20170729;1-2 *

Also Published As

Publication number Publication date
CN108154542A (en) 2018-06-12

Similar Documents

Publication Publication Date Title
US20090010533A1 (en) Method and apparatus for displaying an encoded image
CN106791937B (en) Video image annotation method and system
TWI680674B (en) Method and device for signaling in a bitstream a picture/video format of an ldr picture and a picture/video format of a decoded hdr picture obtained from said ldr picture and an illumination picture
US9807402B2 (en) Method of color palette coding applicable to electronic device and electronic device using the same
US8713456B2 (en) Establishing a graphical user interface (‘GUI’) theme
CN105959724B (en) Video data processing method and device
JP2018142974A (en) Backwards compatible extended image format
Kainz et al. Technical introduction to OpenEXR
WO2020248879A1 (en) Animation data encoding and decoding methods and apparatuses, storage medium, and computer device
US9020299B2 (en) Hybrid image format
AU2018233015A1 (en) System and method for image processing
CN112714357A (en) Video playing method, video playing device, electronic equipment and storage medium
CN108154542B (en) Method for adding semitransparent property to JPG file
CN105144726A (en) Custom data indicating nominal range of samples of media content
US20180139360A1 (en) Method and device for processing color image data representing colors of a color gamut
CN102176205A (en) File format for storage of chain code image sequence and decoding algorithm
TW201601518A (en) Method and device for signaling in a bitstream a picture/video format of an LDR picture and a picture/video format of a decoded HDR picture obtained from said LDR picture and an illumination picture
US9317891B2 (en) Systems and methods for hardware-accelerated key color extraction
WO2017072011A1 (en) Method and device for selecting a process to be applied on video data from a set of candidate processes driven by a common set of information data
KR20180037837A (en) Method and apparatus for determining the number of bits assigned a channel based on a variation of the channel
US11881008B2 (en) Encoding enhanced information into pixel channels
CN113099232B (en) Video decoding the method is a device(s) electronic device and computing machine storage medium
TW201601524A (en) Method and device for signaling in a bitstream a picture/video format of an LDR picture and a picture/video format of a decoded HDR picture obtained from said LDR picture and an illumination picture
EP1287493A1 (en) A method for enabling file format compatibility
CN109982087B (en) Image processing circuit and related image processing method

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
TA01 Transfer of patent application right

Effective date of registration: 20210518

Address after: 201210 4 / F, building 1, 701 Naxian Road, Shanghai pilot Free Trade Zone, Pudong New Area, Shanghai, China

Applicant after: Shanghai Xiaodu Technology Co.,Ltd.

Address before: 100088 room 2031, building 2, 5 Huayuan Road, Haidian District, Beijing.

Applicant before: AINEMO Inc.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant