Struct xbe::LogoBitmap[][src]

pub struct LogoBitmap { /* fields omitted */ }

A 100x17 grayscale logo stored in the XBE file.

The logo can be retrieved using Xbe::logo.

Methods

impl LogoBitmap
[src]

Decode the bitmap from compressed data in an XBE image.

The encoding is a run-length encoding (RLE) with two different kinds of commands or "chunks", one sized 1 Byte, the other sized 2 Bytes. If the least significant bit of the next Byte is set, it's a 1-Byte chunk. Otherwise, the second-to-least significant bit must be set and it's a 2-Byte chunk. Graphically:

1-Byte / 8-bit chunk:
+----------+----------+---+
|   Data   |  Length  | 1 |
| (4 bits) | (3 bits) |   |
+----------+----------+---+
MSb                     LSb

2-Byte / 16-bit chunk:
+----------+-----------+---+---+
|   Data   |  Length   | 1 | 0 |
| (4 bits) | (10 bits) |   |   |
+----------+-----------+---+---+
MSb                          LSb
Second Byte      |    First Byte (Xbox is a Little Endian system)

After decoding length and data, both chunk types work the same: The 4-bit data value describes a pixel value to use for the next length pixels in the output image. The output image is scanned line by line from left to right, and whenever we decode a chunk, we set the next length pixels to the data value.

A data value of 0 is black, while a data value of 15 is the brightest color, white. In order to convert to full 8 bits of color depth, it might be attractive to just shift data to the left by 4 bits. However, this would make a data value of 15 (0b00001111) convert to 0b11110000, which is just 240 instead of the 255 we'd like to get, resulting in a darker than expected image.

We can fix this by "stretching" the result proportional to the resulting color value (since we want to add nothing when the value is small, but a lot if the value gets large). The correct way to do this is by dividing the resulting grayscale value by 16 (the maximum value that can be encoded in data) and adding that onto the result we already have.

(Note that this is assuming the Xbox does it properly - it might just use data << 4 for the final 8-bit value)

Converts this grayscale bitmap to a multiline string resembling ASCII art of the bitmap. Each character represents a pixel and is chosen to somewhat match its brightness.

Note that the resulting text is distorted: The actual image is much thinner and wider. This is a consequence of using a character to represent each pixel.

Converts this image to a pixel buffer storing 8-bit grayscale pixels.

The resulting buffer can be displayed to the user.

The pixels are encoded in row-major order, meaning that the first 100 bytes in the returned buffer are the color values of the first row of pixels, followed by 100 bytes for the second row.

Trait Implementations

impl Debug for LogoBitmap
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for LogoBitmap

impl Sync for LogoBitmap