SLAA548A october   2012  – august 2023 CC430F5123 , CC430F5125 , CC430F5133 , CC430F5135 , CC430F5137 , CC430F5143 , CC430F5145 , CC430F5147 , CC430F6125 , CC430F6126 , CC430F6127 , CC430F6135 , CC430F6137 , CC430F6147 , MSP430AFE221 , MSP430AFE222 , MSP430AFE223 , MSP430AFE231 , MSP430AFE232 , MSP430AFE233 , MSP430AFE251 , MSP430AFE252 , MSP430AFE253 , MSP430BT5190 , MSP430F1101A , MSP430F1111A , MSP430F1121A , MSP430F1122 , MSP430F1132 , MSP430F122 , MSP430F1222 , MSP430F123 , MSP430F1232 , MSP430F133 , MSP430F135 , MSP430F147 , MSP430F1471 , MSP430F148 , MSP430F1481 , MSP430F149 , MSP430F1491 , MSP430F155 , MSP430F156 , MSP430F157 , MSP430F1610 , MSP430F1611 , MSP430F1612 , MSP430F167 , MSP430F168 , MSP430F169 , MSP430F2001 , MSP430F2002 , MSP430F2003 , MSP430F2011 , MSP430F2012 , MSP430F2013 , MSP430F2013-EP , MSP430F2101 , MSP430F2111 , MSP430F2112 , MSP430F2121 , MSP430F2122 , MSP430F2131 , MSP430F2132 , MSP430F2232 , MSP430F2234 , MSP430F2252 , MSP430F2254 , MSP430F2272 , MSP430F2274 , MSP430F233 , MSP430F2330 , MSP430F235 , MSP430F2350 , MSP430F2370 , MSP430F2410 , MSP430F2416 , MSP430F2417 , MSP430F2418 , MSP430F2419 , MSP430F247 , MSP430F2471 , MSP430F248 , MSP430F2481 , MSP430F249 , MSP430F2491 , MSP430F2616 , MSP430F2617 , MSP430F2618 , MSP430F2619 , MSP430F412 , MSP430F413 , MSP430F4132 , MSP430F415 , MSP430F4152 , MSP430F417 , MSP430F423 , MSP430F423A , MSP430F425 , MSP430F4250 , MSP430F425A , MSP430F4260 , MSP430F427 , MSP430F4270 , MSP430F427A , MSP430F435 , MSP430F4351 , MSP430F436 , MSP430F4361 , MSP430F437 , MSP430F4371 , MSP430F438 , MSP430F439 , MSP430F447 , MSP430F448 , MSP430F4481 , MSP430F449 , MSP430F4491 , MSP430F4616 , MSP430F46161 , MSP430F4617 , MSP430F46171 , MSP430F4618 , MSP430F46181 , MSP430F4619 , MSP430F46191 , MSP430F47126 , MSP430F47127 , MSP430F47163 , MSP430F47166 , MSP430F47167 , MSP430F47173 , MSP430F47176 , MSP430F47177 , MSP430F47183 , MSP430F47186 , MSP430F47187 , MSP430F47193 , MSP430F47196 , MSP430F47197 , MSP430F477 , MSP430F478 , MSP430F4783 , MSP430F4784 , MSP430F479 , MSP430F4793 , MSP430F4794 , MSP430F5212 , MSP430F5214 , MSP430F5217 , MSP430F5219 , MSP430F5222 , MSP430F5224 , MSP430F5229 , MSP430F5232 , MSP430F5234 , MSP430F5237 , MSP430F5239 , MSP430F5242 , MSP430F5244 , MSP430F5247 , MSP430F5249 , MSP430F5252 , MSP430F5253 , MSP430F5254 , MSP430F5255 , MSP430F5256 , MSP430F5257 , MSP430F5258 , MSP430F5259 , MSP430F5304 , MSP430F5308 , MSP430F5309 , MSP430F5310 , MSP430F5324 , MSP430F5325 , MSP430F5326 , MSP430F5327 , MSP430F5328 , MSP430F5329 , MSP430F5333 , MSP430F5335 , MSP430F5336 , MSP430F5338 , MSP430F5340 , MSP430F5341 , MSP430F5342 , MSP430F5418 , MSP430F5418A , MSP430F5419 , MSP430F5419A , MSP430F5435 , MSP430F5435A , MSP430F5436 , MSP430F5436A , MSP430F5437 , MSP430F5437A , MSP430F5438 , MSP430F5438A , MSP430F5500 , MSP430F5501 , MSP430F5502 , MSP430F5503 , MSP430F5504 , MSP430F5505 , MSP430F5506 , MSP430F5507 , MSP430F5508 , MSP430F5509 , MSP430F5510 , MSP430F5630 , MSP430F5631 , MSP430F5632 , MSP430F5633 , MSP430F5634 , MSP430F5635 , MSP430F5636 , MSP430F5637 , MSP430F5638 , MSP430F6433 , MSP430F6435 , MSP430F6436 , MSP430F6438 , MSP430F6630 , MSP430F6631 , MSP430F6632 , MSP430F6633 , MSP430F6634 , MSP430F6635 , MSP430F6636 , MSP430F6637 , MSP430F6638 , MSP430F6659 , MSP430F6779 , MSP430FE423 , MSP430FE4232 , MSP430FE423A , MSP430FE4242 , MSP430FE425 , MSP430FE4252 , MSP430FE425A , MSP430FE427 , MSP430FE4272 , MSP430FE427A , MSP430FG4250 , MSP430FG4260 , MSP430FG4270 , MSP430FG4616 , MSP430FG4617 , MSP430FG4618 , MSP430FG4619 , MSP430FG477 , MSP430FG478 , MSP430FG479 , MSP430FR5720 , MSP430FR5721 , MSP430FR5722 , MSP430FR5723 , MSP430FR5724 , MSP430FR5725 , MSP430FR5726 , MSP430FR5727 , MSP430FR5728 , MSP430FR5729 , MSP430FR5730 , MSP430FR5731 , MSP430FR5732 , MSP430FR5733 , MSP430FR5734 , MSP430FR5735 , MSP430FR5736 , MSP430FR5737 , MSP430FR5738 , MSP430FR5739 , MSP430FW423 , MSP430FW425 , MSP430FW427 , MSP430FW428 , MSP430FW429 , MSP430G2001 , MSP430G2101 , MSP430G2102 , MSP430G2111 , MSP430G2112 , MSP430G2121 , MSP430G2131 , MSP430G2132 , MSP430G2152 , MSP430G2153 , MSP430G2201 , MSP430G2202 , MSP430G2203 , MSP430G2211 , MSP430G2212 , MSP430G2213 , MSP430G2221 , MSP430G2231 , MSP430G2232 , MSP430G2233 , MSP430G2252 , MSP430G2253 , MSP430G2302 , MSP430G2303 , MSP430G2312 , MSP430G2313 , MSP430G2332 , MSP430G2333 , MSP430G2352 , MSP430G2353 , MSP430G2402 , MSP430G2403 , MSP430G2412 , MSP430G2413 , MSP430G2432 , MSP430G2433 , MSP430G2452 , MSP430G2453 , MSP430G2513 , MSP430G2533 , MSP430G2553 , MSP430G2955 , MSP430L092

 

  1.   1
  2.   Design Considerations When Using MSP430 Graphics Library
  3.   Trademarks
  4. 1Introduction to the MSP430 Graphics Library
  5. 2System Overview
  6. 3Hardware Implementation - LCD Bus Type
    1. 3.1 Parallel Bus
    2. 3.2 SPI Bus
  7. 4Software Implementation- LCD Display Driver Layer
    1. 4.1 Driver Layer Components
    2. 4.2 Creating New LCD Driver Files
    3. 4.3 Optimizing the LCD Display Driver Layer for Speed
      1. 4.3.1 Utilizing LCD Controller Features
      2. 4.3.2 Coding Optimizations
    4. 4.4 Images in the MSP430 Graphics Library
      1. 4.4.1 Image Format
      2. 4.4.2 Image Conversion
      3. 4.4.3 MSP430 Image Reformer
      4. 4.4.4 Palette Conversion
      5. 4.4.5 Compression Types
        1. 4.4.5.1 Compressing Images With 16 Colors or Less
        2. 4.4.5.2 Compressing 256 Color Images
        3. 4.4.5.3 Choosing a Compression Type
  8. 5Design Example
    1. 5.1 Hardware Implementation
    2. 5.2 Bus Comparison
    3. 5.3 Software Implementation
  9. 6References
  10. 7Revision History

Compression Types

Run length encoding (RLE) is a type of compression that thrives when long runs of pixels are present. The algorithm is simple to understand and can drastically reduce storage size and draw speeds. There are two different types of run length encoding used in the GUI to compress images: 4-bit run length encoding (RLE4) and 8-bit run length encoding (RLE8).

Run length encoding an image results pixel data being compressed into two components: run length and pixel index. This replaces the string of consecutive pixel data bytes with encoded bytes. This compression is not lossy, meaning it does not change the contents of the image data, it simply stores the data in a different format. Storing the data differently can allow for various size and speed tradeoffs for the image to be drawn.

The difference between RLE4 and RLE8 is the number of bits reserved for both the run length and the pixel value. RLE4 uses 4 bits for run length and 4 bits for the pixel index. RLE4 encoding limits run length to 16 pixels and can only be used for 1BPP or 4BPP images with 16 pixels or less in the palette. Run length has a minimum length of 1 pixel, so the value 0x00 for run length indicates a run of 1, 0x01 indicates a run of 2, and so on.

Figure 4-8 is a 7x8 pixel image consisting of five different colors. This image is used to compare multiple types of compression supported in the MSP430 Graphics Library.

GUID-DE613343-96D0-4E17-9DB5-EBEE5F5AA46E-low.gifFigure 4-8 MSP430 Image Reformer – Example 7x8 Pixel Image

Image data with all available compression options is presented below. The palette remains the same for all types of image compression.

For uncompressed pixel data each line of the image must end on an even byte boundary. The uncompressed 4BPP pixel data below illustrates how the bytes are padded with extra zeroes on the last byte of the line to achieve this. This padding occurs when 4BPP images have a width that is not a multiple of 2, and 1BPP images have width that is not a multiple of 8. Run length encoded images do not require a line to end on an even byte boundary, and runs can extend onto the next line if the pixel color is still the same.

                              Color Palette
                             0x0000FF,  (Blue)
                             0x00FF00,  (Green)
                             0xFF0000,  (Red)
                             0xFF00FF,  (Purple)
                             0xFFFFFF   (White)
0x00, 0x04, 0x11, 0x10,                            0x20, 0x04, 0x21, 0x10, 0x24, 0x11,
0x00, 0x44, 0x41, 0x10,                            0x00, 0x14, 0x03, 0x14, 0x01, 0x14,
0x04, 0x43, 0x44, 0x10,                            0x23, 0x24, 0x43, 0xF4, 0x04, 0x22,
0x44, 0x33, 0x34, 0x40,                            0x14
0x43, 0x33, 0x33, 0x40,
0x44, 0x44, 0x44, 0x40, 
0x44, 0x44, 0x44, 0x40,
0x44, 0x22, 0x24, 0x40
Uncompressed 4BPP Pixel Data                       RLE4 Compressed Pixel Data
                               Color Palette
                              0x0000FF,  (Blue)
                              0x00FF00,  (Green)
                              0xFF0000,  (Red)
                              0xFF00FF,  (Purple)
                              0xFFFFFF   (White)
0x00, 0x00, 0x00, 0x04, 0x01, 0x01, 0x01,          0x02, 0x00, 0x00, 0x04, 0x02, 0x01,
0x00, 0x00, 0x04, 0x04, 0x04, 0x01, 0x01,          0x01, 0x00, 0x02, 0x04, 0x01, 0x01,
0x00, 0x04, 0x04, 0x03, 0x04, 0x04, 0x01,          0x00, 0x00, 0x01, 0x04, 0x00, 0x03,
0x04, 0x04, 0x03, 0x03, 0x03, 0x04, 0x04,          0x01, 0x04, 0x00, 0x01, 0x01, 0x04,
0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x04,          0x02, 0x03, 0x02, 0x04, 0x04, 0x03,
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,          0x10, 0x04, 0x02, 0x02, 0x01, 0x04
0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
0x04, 0x04, 0x02, 0x02, 0x02, 0x04, 0x04
Uncompressed 8BPP Pixel Data                       RLE8 Compressed Pixel Data

Each type of run length encoding has tradeoffs. RLE4 is better with shorter runs because it requires 1 byte to encode the run + data where RLE8 requires 2 bytes to encode. However, RLE8 is much better with longer runs because it supports runs up to 256 pixels long where RLE4 supports runs up to only 16 pixels long. In this example image, there were several short runs leading the RLE8 method to require twice the number of bytes. There was one long run of 17 white pixels where RLE4 required two separate runs to produce. The amount the image pixel data is compressed is very image dependent because of these tradeoffs.

Table 4-2 Tradeoffs of RLE4, RLE8, and Uncompressed Image Formats
1BPP 4BPP 8BPP
Advantages
  • Typically best compression with 4BPP images
  • Much faster byte and second drawing speeds than RLE4 (approximately 1.5-4x faster)
  • Only option that supports image clipping for images extending beyond the bounds of the LCD
  • Works best with very complex images such as photographs
Disadvantages
  • Can become larger than uncompressed image
  • Contains unused bits with 1BPP images
  • Cannot use with 8BPP images
  • Image must stay within LCD boundary
  • Can become larger than uncompressed image
  • Contains unused bits with 1BPP and 4BPP images
  • Image must stay within LCD boundary
  • Sometimes larger and slower than its compressed counterpart