CN101546434A - Method and system for compressing and decompressing BMP picture file - Google Patents
Method and system for compressing and decompressing BMP picture file Download PDFInfo
- Publication number
- CN101546434A CN101546434A CN200810066377A CN200810066377A CN101546434A CN 101546434 A CN101546434 A CN 101546434A CN 200810066377 A CN200810066377 A CN 200810066377A CN 200810066377 A CN200810066377 A CN 200810066377A CN 101546434 A CN101546434 A CN 101546434A
- Authority
- CN
- China
- Prior art keywords
- file
- bitmap
- value
- color value
- head
- 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.)
- Pending
Links
Images
Landscapes
- Compression Of Band Width Or Redundancy In Fax (AREA)
Abstract
The invention is applicable in the technical field of image processing, and provides a method and a system for compressing and decompressing a BMP picture file. The compressing method comprises the following steps: reading a bitmap file header, a bitmap information header and a color table of the BMP picture file; writing the bitmap file header, the bitmap information header and the color table into a compressed file; and reading bitmap data of the BMP picture file sequentially, writing a color value of image pixels and corresponding Num value thereof into the compressed file, and only writing one color value and the corresponding Num value which is the number of the continuous same color value when writing a plurality of continuous same color values. The compression method not only can achieve the aim of compressing the BMP picture, but also has a simple algorithm, and small operation amount.
Description
Technical field
The invention belongs to technical field of image processing, relate in particular to a kind of compression, decompression method and system of BMP picture file.
Background technology
At present, all need to use a large amount of pictures in many application programs, for example: patterned User Interface, and along with the development of various application programs, its requirement to picture size is also more and more stricter.Because it is bigger to take storage space without the BMP picture that compresses, especially in embedded system, storage space is very limited, therefore, generally all can compress these pictures.At present, use maximum picture compression modes to compress as JPEG, promptly the file after the compression is the JPG file.
JPEG (Joint Photographic Experts Group) is an expert group that is constituted jointly by ISO and two organizational structures of IEC, be responsible to define static digital image data compression coding standard, the algorithm of this expert group's exploitation is called jpeg algorithm, and become general in the world standard, therefore be called Joint Photographic Experts Group again.Joint Photographic Experts Group is a static image data compression standard that the scope of application is very wide, not only can be used for gray level image but also can be used for coloured image.JPEG expert group has developed two kinds of basic compression algorithms, and a kind of is that (Discrete Cosine Transform DCT) is the lossy compression method algorithm on basis, and another kind is the lossless compression algorithm that adopts based on forecasting techniques with discrete cosine transform in employing.When using the lossy compression method algorithm, be under the situation of 25:1 at ratio of compression, the image that the reduction of compression back obtains is compared with original image, and non-image expert is difficult to find out the difference between them, has therefore obtained using widely.Though utilize jpeg algorithm to compress the BMP picture file, the algorithm of the decompression method of this compression method and correspondence thereof is comparatively complicated, and operand is bigger.
Summary of the invention
The purpose of the embodiment of the invention is to provide a kind of compression method of BMP picture file, and the algorithm that is intended to solve existing compression method is complicated, the problem that operand is big.
The embodiment of the invention is achieved in that a kind of compression method of BMP picture file, and described compression method may further comprise the steps:
Read the bitmap file head of BMP picture file, message bit pattern head and color table;
With described bitmap file head, message bit pattern head and color table write compressed file;
Sequentially read the data bitmap of BMP image file, the color value of image pixel and corresponding Num value thereof are write compressed file, and when writing continuously a plurality of identical color value, only write the Num value of one of them color value and correspondence, wherein, Num is the number of consecutive identical color value.
Another purpose of the embodiment of the invention is to provide a kind of compressibility of BMP picture file, and described compressibility comprises:
BMP picture file read module is used to read the bitmap file head of BMP picture file, message bit pattern head and color table;
The compressed file writing module is used for described bitmap file head, and message bit pattern head and color table write compressed file; And
The data bitmap compression module, be used for sequentially reading the data bitmap of BMP image file, the color value and the corresponding Num value thereof of image pixel are write compressed file, and when writing continuously a plurality of identical color value, only write one of them color value and corresponding Num value, wherein, Num is the number of consecutive identical color value.
Another purpose of the embodiment of the invention is to provide a kind of decompression method of BMP picture, and described decompression method may further comprise the steps:
Read the bitmap file head of compressed file, message bit pattern head and color table;
With described bitmap file head, message bit pattern head and color table write the BMP picture file;
Sequentially read the color value and the Num value of the image pixel of compressed file data bitmap, and the color value of described image pixel is write BMP picture file Num time, wherein, Num is the number of consecutive identical image pixel color value.
Another purpose of the embodiment of the invention is to provide a kind of decompression systems of BMP picture, and described decompression systems comprises:
The compressed file read module is used to read the bitmap file head of compressed file, message bit pattern head and color table;
BMP picture file writing module is used for described bitmap file head, and message bit pattern head and color table write the BMP picture file; And
The data bitmap decompression module is used for sequentially reading the color value and the Num value of the image pixel of compressed file data bitmap, and the color value of described image pixel is write BMP picture file Num time, and Num is the number of consecutive identical image pixel color value.
In an embodiment of the present invention, do not change the bitmap file head of BMP picture file, message bit pattern figure and color table, and for the color value of the consecutive identical image pixel of data bitmap part in the BMP picture file, only write compressed file with the color value of one of them image pixel and with the number of consecutive identical image pixel, thereby reached the purpose of compression BMP picture, and the algorithm of this compression method is comparatively simple, operand is less.
Description of drawings
Fig. 1 is the implementing procedure figure of the compression method of the BMP picture file that provides of the embodiment of the invention;
Fig. 2 is the implementing procedure figure of the decompression method of the BMP picture file that provides of the embodiment of the invention;
Fig. 3 is the compression of the BMP picture file that provides of the embodiment of the invention, the structural representation of decompression systems.
Embodiment
In order to make purpose of the present invention, technical scheme and advantage clearer,, the present invention is further elaborated below in conjunction with drawings and Examples.Should be appreciated that specific embodiment described herein only in order to explanation the present invention, and be not used in qualification the present invention.
In an embodiment of the present invention, do not change the bitmap file head of BMP picture file, the data of message bit pattern figure and color table, and for the color value of the consecutive identical image pixel of data bitmap part in the BMP picture file, only write compressed file with the color value of one of them image pixel and with the number of consecutive identical image pixel, thereby reached the purpose of compression BMP picture, and the algorithm of this compression method is comparatively simple, operand is less.
Fig. 1 shows the implementing procedure of the compression method of the BMP picture file that the embodiment of the invention provides, and details are as follows:
In step S101, read bitmap file head, message bit pattern head, the color table of BMP picture file.
In step S102, with this bitmap file head, message bit pattern head and color table write compressed file.
In step S103, read the color value of i image pixel of data bitmap in the BMP file, and the value of putting Num is 1.Wherein, operation parameter Num writes down the number of the color value of consecutive identical image pixel, and the initial value of i is 1.
In step S104, judge whether to exist i+1 image pixel.When not having i+1 image pixel, execution in step S105; When having i+1 image pixel, execution in step S106.
In step S105, with the color value of i image pixel, and corresponding Num value writes compressed file.When not having i+1 image pixel, last pixel that i image pixel is data bitmap is described, at this moment, color value with i image pixel, and a color value numerical value Num of the image pixel of consecutive identical (identical with i image pixel) writes compressed file, compressed file generates and finishes, and finishes whole flow process.
In step S106, read the color value of i+1 image pixel.
In step S107, judge whether the color value of i+1 image pixel is identical with the color value of i image pixel.When color value is inequality, execution in step S108; When color value is identical, execution in step S109.
In step S108, with the color value of i image pixel, reach corresponding Num value and write compressed file, and make the value of i increase by 1.Behind the execution of step S108, return execution in step S103.
In step S109, make the value of Num increase by 1, the value of i increases by 1.Behind the execution of step S109, return execution in step S104.
For the ease of understanding, the BMP picture with 24bit true color bitmap is an example below, makes brief description, certainly, and the method that the BMP picture of 8bit, 16bit and other bitmaps also can use the embodiment of the invention to provide.In the data bitmap of 24bit true color bitmap, the color of each point is respectively R, G, B by 3 byte representations, and each scan line of image is made up of the continuous byte of presentation video pixel.For the continuous a plurality of image pixels (being continuous a plurality of identical bytes groups in the data bitmap) in the BMP picture data bitmap with identical R, G, B value, compressed file only writes down R, G, the B value of an image pixel, and increase by 1 byte parameter N um, note the number of consecutive identical image pixel color value with Num.For example: have the color value of continuous 4 image pixels all to be in the BMP picture (100,101,102), promptly R is 100, and G is 101, and B is 102; The recording mode of data bitmap is in the BMP picture: 100,101,102,100,101,102,100,101,102,100,101,102, need 12 byte representations altogether, and the recording mode of compressed file is: 100,101,102,4, and totally 4 bytes.Therefore, the adjacent image pixel with identical color value is many more, and ratio of compression is high more.
Fig. 2 shows the implementing procedure of the decompression method of the BMP picture file that the embodiment of the invention provides, and details are as follows:
In step S201, read bitmap file head, message bit pattern head, the color table of compressed file.
In step S202, with this bitmap file head, message bit pattern head and color table write the BMP file.
In step S203, sequentially read the color value and the corresponding Num value thereof of the image pixel of compressed file.In order to make things convenient for order to read, as embodiments of the invention, can indicate the current position of reading with an indicator, before reading, first image pixel of this indicator indication compressed file.
In step S204, the color value of this image pixel is write BMP file Num time.
In step S205, judge whether next image pixel exists.When not existing, illustrating decompresses finishes, and finishes whole flow process.When having next image pixel, return execution in step S203, at this moment, need make indicator indicate next image pixel.
Fig. 3 shows the compression of the BMP picture file that the embodiment of the invention provides, the structure of decompression systems, and this system comprises compression unit and decompression unit.
In the process that 31 pairs of BMP picture files of compression unit compress, BMP picture file read module 311 reads the bitmap file head of BMP picture file, message bit pattern head and color table.Compressed file writing module 312 is with this bitmap file head, and message bit pattern head and color table write compressed file.Data bitmap compression module 313 sequentially reads the data bitmap of BMP image file, the color value and the corresponding Num value thereof of image pixel are write compressed file, and when writing continuously a plurality of identical color value, only write one of them color value and corresponding Num value, wherein, Num is the number of consecutive identical color value.
In the process that 32 pairs of compressed files of decompression unit decompress, compressed file read module 321 reads the bitmap file head of compressed file, message bit pattern head and color table.BMP picture file writing module 322 is with this bitmap file head, and message bit pattern head and color table write the BMP picture file.Data bitmap decompression module 323 sequentially reads the color value and the Num value of the image pixel of compressed file data bitmap, and the color value of this image pixel is write BMP picture file Num time.
In an embodiment of the present invention, do not change the bitmap file head of BMP picture file, the data of message bit pattern figure and color table, and for the color value of the consecutive identical image pixel of data bitmap part in the BMP picture file, only write compressed file with the color value of one of them image pixel and with the number of consecutive identical image pixel, thereby reached the purpose of compression BMP picture, and the algorithm of this compression method is comparatively simple, operand is less.
The above only is preferred embodiment of the present invention, not in order to restriction the present invention, all any modifications of being done within the spirit and principles in the present invention, is equal to and replaces and improvement etc., all should be included within protection scope of the present invention.
Claims (4)
1, a kind of compression method of BMP picture file is characterized in that, described compression method may further comprise the steps:
Read the bitmap file head of BMP picture file, message bit pattern head and color table;
With described bitmap file head, message bit pattern head and color table write compressed file;
Sequentially read the data bitmap of BMP image file, the color value of image pixel and corresponding Num value thereof are write compressed file, and when writing continuously a plurality of identical color value, only write the Num value of one of them color value and correspondence, wherein, Num is the number of consecutive identical color value.
2, a kind of compressibility of BMP picture file is characterized in that, described compressibility comprises:
BMP picture file read module is used to read the bitmap file head of BMP picture file, message bit pattern head and color table;
The compressed file writing module is used for described bitmap file head, and message bit pattern head and color table write compressed file; And
The data bitmap compression module, be used for sequentially reading the data bitmap of BMP image file, the color value and the corresponding Num value thereof of image pixel are write compressed file, and when writing continuously a plurality of identical color value, only write one of them color value and corresponding Num value, wherein, Num is the number of consecutive identical color value.
3, a kind of decompression method of BMP picture file is characterized in that, described decompression method may further comprise the steps:
Read the bitmap file head of compressed file, message bit pattern head and color table;
With described bitmap file head, message bit pattern head and color table write the BMP picture file;
Sequentially read the color value and the Num value of the image pixel of compressed file data bitmap, and the color value of described image pixel is write BMP picture file Num time, wherein, Num is the number of consecutive identical image pixel color value.
4, a kind of decompression systems of BMP picture file is characterized in that, described decompression systems comprises:
The compressed file read module is used to read the bitmap file head of compressed file, message bit pattern head and color table;
BMP picture file writing module is used for described bitmap file head, and message bit pattern head and color table write the BMP picture file; And
The data bitmap decompression module is used for sequentially reading the color value and the Num value of the image pixel of compressed file data bitmap, and the color value of described image pixel is write BMP picture file Num time, and Num is the number of consecutive identical image pixel color value.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN200810066377A CN101546434A (en) | 2008-03-28 | 2008-03-28 | Method and system for compressing and decompressing BMP picture file |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN200810066377A CN101546434A (en) | 2008-03-28 | 2008-03-28 | Method and system for compressing and decompressing BMP picture file |
Publications (1)
Publication Number | Publication Date |
---|---|
CN101546434A true CN101546434A (en) | 2009-09-30 |
Family
ID=41193553
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN200810066377A Pending CN101546434A (en) | 2008-03-28 | 2008-03-28 | Method and system for compressing and decompressing BMP picture file |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN101546434A (en) |
Cited By (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102013105A (en) * | 2010-08-19 | 2011-04-13 | 上海闻泰电子科技有限公司 | Picture file compression method |
CN107147914A (en) * | 2017-06-07 | 2017-09-08 | 广东工业大学 | A kind of embedded system and monochrome bitmap compression method, main frame |
CN107294538A (en) * | 2017-06-09 | 2017-10-24 | 深圳市华星光电技术有限公司 | The compensation gauge pressure compression method and decompressing method of OLED display |
CN107357545A (en) * | 2017-07-18 | 2017-11-17 | 惠州Tcl移动通信有限公司 | A kind of method, storage medium and the intelligent watch of enhancing UI display effects |
CN108492339A (en) * | 2018-03-28 | 2018-09-04 | 腾讯科技(深圳)有限公司 | Obtain method, apparatus, electronic equipment and the storage medium of resource compressed package |
CN110572664A (en) * | 2019-08-14 | 2019-12-13 | 中国地质大学(武汉) | Novel BMP image compression method and system |
CN113362254A (en) * | 2021-06-30 | 2021-09-07 | 广东电网有限责任公司 | Image restoration method, device, equipment and storage medium |
CN113971702A (en) * | 2021-10-29 | 2022-01-25 | 深圳市道通科技股份有限公司 | Picture compression method, decompression method and electronic equipment |
CN116309893A (en) * | 2023-05-18 | 2023-06-23 | 深圳市微克科技有限公司 | Picture compression method and device, storage medium and electronic equipment |
-
2008
- 2008-03-28 CN CN200810066377A patent/CN101546434A/en active Pending
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102013105A (en) * | 2010-08-19 | 2011-04-13 | 上海闻泰电子科技有限公司 | Picture file compression method |
CN107147914A (en) * | 2017-06-07 | 2017-09-08 | 广东工业大学 | A kind of embedded system and monochrome bitmap compression method, main frame |
CN107294538A (en) * | 2017-06-09 | 2017-10-24 | 深圳市华星光电技术有限公司 | The compensation gauge pressure compression method and decompressing method of OLED display |
CN107294538B (en) * | 2017-06-09 | 2020-09-01 | 深圳市华星光电半导体显示技术有限公司 | Compression method and decompression method for compensation gauge of OLED display device |
CN107357545A (en) * | 2017-07-18 | 2017-11-17 | 惠州Tcl移动通信有限公司 | A kind of method, storage medium and the intelligent watch of enhancing UI display effects |
CN108492339A (en) * | 2018-03-28 | 2018-09-04 | 腾讯科技(深圳)有限公司 | Obtain method, apparatus, electronic equipment and the storage medium of resource compressed package |
CN108492339B (en) * | 2018-03-28 | 2021-06-01 | 腾讯科技(深圳)有限公司 | Method and device for acquiring resource compression packet, electronic equipment and storage medium |
CN110572664A (en) * | 2019-08-14 | 2019-12-13 | 中国地质大学(武汉) | Novel BMP image compression method and system |
CN113362254A (en) * | 2021-06-30 | 2021-09-07 | 广东电网有限责任公司 | Image restoration method, device, equipment and storage medium |
CN113971702A (en) * | 2021-10-29 | 2022-01-25 | 深圳市道通科技股份有限公司 | Picture compression method, decompression method and electronic equipment |
CN116309893A (en) * | 2023-05-18 | 2023-06-23 | 深圳市微克科技有限公司 | Picture compression method and device, storage medium and electronic equipment |
CN116309893B (en) * | 2023-05-18 | 2023-08-11 | 深圳市微克科技有限公司 | Picture compression method and device, storage medium and electronic equipment |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101546434A (en) | Method and system for compressing and decompressing BMP picture file | |
CN102523367B (en) | Real time imaging based on many palettes compresses and method of reducing | |
CN109600618B (en) | Video compression method, decompression method, device, terminal and medium | |
JP7431742B2 (en) | Method and apparatus for encoding/decoding a point cloud representing a three-dimensional object | |
CN101272442B (en) | Digital image nondestructive compression method and device, resolution method and image encoder | |
CN101331480A (en) | Compressing images in documents | |
CN103124350B (en) | Based on method for compressing image and the device of RLE | |
Husseen et al. | Image compression using proposed enhanced run length encoding algorithm | |
CN102308582B (en) | Method for the segmentation encoding of an image | |
JP2000295113A (en) | Huffman coded data compressor | |
CN100591089C (en) | Method for compressing and decompressing JPEG image without loss | |
CN102263946B (en) | Techniques for storing and retrieving pixel data | |
Chawla et al. | Image compression techniques: a review | |
US20100257375A1 (en) | System and method for compressing compressed data | |
CN103873868A (en) | Bitmap data compression method | |
US9060171B2 (en) | Image processing system and method | |
US20090169121A1 (en) | Static image compression method and computer readable data structure and computer readable storage medium | |
CN112887713B (en) | Picture compression and decompression method and device | |
CN102495878B (en) | File and method for storing machine vision detection result | |
CN112672164B (en) | Video compression system and method, and video decompression system and method | |
CN101489018A (en) | Static image compression method and computer readable storage apparatus | |
US10283094B1 (en) | Run-length compression and decompression of media tiles | |
AU2003226616B2 (en) | Repetition coded compression for highly correlated image data | |
CN215956541U (en) | Automatic video data compression and decompression system | |
CN101754034A (en) | Uncompressing system of discrete cosine transform compression diagram data with transparent attribute and method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C12 | Rejection of a patent application after its publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20090930 |