Thread: Rle8

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    404

    Rle8

    I'm trying to implement a simple 8-bit run length encoder. For my testing, I am using the pixel data of a 100x100 black bitmap image. It is saved as a 24 bit image, this resulting in 100 * 100 * 30 = 30000 bytes of pixel data, all of which are 0x00.

    So I know the nature of RLE8 is [1 byte header][1 byte data].
    So doing the math, I came up with:
    236 occurrences of 0xFF 0x00 and 1 occurrence of 0x9C 0x00, totaling with 474 bytes, preceded by a bitmap header.

    My code outputs this as expected, but when I try to open my image with paint or some other paint-like programs, it fails. I am sure to change my bitmap header correctly.
    Code:
    bitmapfileheader.size = 474 + 54;
    bitmapinfoheader.compression = 1;
    A couple questions I have:
    Do I need to change bitmapinfoheader.size to 30000, which is the uncompressed number of pixel data? I have tried it both ways, being 0 or 30000, and neither have made a difference.

    Could it be that many of these paint programs don't support RLE8 encoded bitmaps?

    If you need to see code, I would be more than happy to post some, but hopefully having a basic image should help as well.

    Thanks ahead of time!

    Edit: Just thought of something, can you even encode a 24-bit image a RLE8, or must you stick with an encoding that has the same data size, like RLE24?
    Last edited by carrotcake1029; 03-18-2009 at 01:36 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. RLE8 Bitmap Encoding
    By MrWizard in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 06-24-2002, 05:01 AM