Writing Compressed Image Files

This is a discussion on Writing Compressed Image Files within the C++ Programming forums, part of the General Programming Boards category; Hi, first time poster here. I am making an image compressor that just takes in Bitmaps and produces a compressed ...

  1. #1
    Registered User
    Join Date
    Mar 2005
    Posts
    1

    Writing Compressed Image Files

    Hi, first time poster here.

    I am making an image compressor that just takes in Bitmaps and produces a compressed output however I'm having a big problem, I cannot find a way to write values lower than 8-Bit Integers to files.

    is there a way to do this? Cause it's kinda pointless oututting 1011 as 00001011!

    Thanks

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    I cannot find a way to write values lower than 8-Bit Integers to files. is there a way to do this?
    Not that I'm aware. A byte is the smallest unit you can write to a file at a time.

    There are two ways to go about this. One way is to use the C++ STL bitset class, which allows you to manipulate individual bits (set, clear, etc). To use this, include <bitset>.

    A second way is to use the shift operators. That way you can take say 4 bits, shift them to the left, then use the or (|) operator to add 4 more.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. fopen vs. _open (for BIG image files)
    By reversaflex in forum C Programming
    Replies: 3
    Last Post: 04-01-2007, 12:52 AM
  2. Output of image files
    By JulleH in forum C++ Programming
    Replies: 3
    Last Post: 03-18-2005, 03:55 PM
  3. writing number 10 to files
    By variable in forum C Programming
    Replies: 6
    Last Post: 01-30-2005, 09:25 PM
  4. reading and writing to files in windows
    By Dohojar in forum Windows Programming
    Replies: 8
    Last Post: 06-26-2003, 02:07 AM
  5. Writing Bitmap Files
    By HappyDude in forum C++ Programming
    Replies: 1
    Last Post: 10-13-2001, 05:48 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21