I need to compress monochromatic bitmap with modified huffman algorithm

here's the algorithm: http://www.iet.unipi.it/m.luise/HTML...n%20Coding.htm


as you see i need to replace pixel (bits) sequence with some bits sequence variable length

so im not sure which type to use for bits manipulation

iI found this class for bits http://www.codeguru.com/cpp/cpp/cpp_...nipulation.htm

and this for bits array http://www.codeguru.com/cpp/cpp/cpp_...ms-of-Bits.htm

so the dificult part is that all those are variable length i need to work with

should I use:

vector<vector<CBitPointer>>

or

CByteArray array;
CBitStream stream(array);

any help is appreciated!

Recommended Answers

All 4 Replies

the URL for your huffman algorithm is not working.

Could you provide a link to the next page so I can see figure 10.6, an example of how to code a scan line.. the 'next' link doesn't work (none of the links work for me)

the algorithm isn't problem yet,because I have problem dumping even unchanged bits array to file.bin

help me dump bit_array_c to file.bin

I used class for making bit stream,found it here http://michael.dipperstein.com/bitlibs/

the last link on the bottom "ISO C++ bitarray_cpp-0.4.zip"

it looked like it suits my needs,so I've put bitarray.h and bitarray.cpp into project

I've passed bitmap data field buffer to constructor

bit_array_c vektBitova(pPocetak, brBitova);

and it looked fine

but the problem is i cant dump bit_array_c to file.bin

there is function PutBits() in class and it dumps just EOF char every time, except when I pass all zeros (completly black monochrome bitmap),also there is runtime error with assert msgbox...

although it dumps all when i comment some if's in PutBits() implementation in bitarray.cpp (debug PutBits() and see for yourself)

in bit_array_c class there is also PutBitsLE() for little endian and that function works when I set it public (its protected by default),also I have AMD processor,I don't know what endian it is...

so if you could help me dump bit_array_c to file.bin without errors

I made test case for you in VC6 here it is: http://uppit.com/2w90bziybs7z/mp2.rar

The code is in mpDlg.cpp file,I've put comments

this is problematic function call:

bit_file_c fajl("fajl.bin", BF_WRITE);	
	fajl.PutBits(vektBitova.m_Array/*pPocetak*/, brBitova);
	fajl.Close();

any help is appreciated!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.