2bit image from a number?

Tech-Archive recommends: Fix windows errors by optimizing your registry



I want to generate every possible combination of 5x5 1bit bitmaps

There are 33554432 different combinations? 2^5^5?

33554432 in binary is 1100110011001100110011 which is 22 bits?

It seems to me that the easiest and fastest way to do it is to iterate through the numbers 0 to 33554431, convert each number to bits, write that into bitmapdata using Marshal, and save it?

33554432 fits into 22 bits, the smallest type that will fit in is an unsigned 32 bit int?

I tried using for each number:

Byte[ ] bytes = BitConverter.GetBytes( number );

for( int i = 0; i < bytes.Length; i++ ) {
Marshal.WriteByte( bitmapData.Scan0, i, bytes[ i ] );
}

Doesn't work.

I am obviously making an incorrect assumption about how something works here, any ideas? byte order is wrong? Something to do with putting a number that fits into 22 bits into a 32 bit int? Something to do with the offset in WriteByte?

Or is my whole approach fundamentally flawed?

.



Relevant Pages

  • Re: Loading bitmap from stream
    ... The "standards" on 16 bpp bitmaps are a bit ambiguous and I ... > protected virtual int OnNotifyMessage ... > internal uint dword1; ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: GDI+ Image::Save() function returns InvalidParameter
    ... If that fails, ... It should be image data in one of the formats GDI+ understands, ... massage it into one of the formats compatible with Windows bitmaps, ... could use Bitmapor Bitmap(int, int, int, ...
    (microsoft.public.vc.language)
  • Re: malloc
    ... I used lcc this times and it had ... fits with this code. ... Use int mainto avoid this diagnostic message in future. ...
    (comp.lang.c)
  • [PATCH] reiserfs: fix unaligned bitmap usage
    ... The bitmaps associated with generation numbers for directory entries ... The following patch uses the standard bitmap declaration macros to ... int de_entrylen; ...
    (Linux-Kernel)
  • Re: Array elements
    ... Kumar said: ... used to describe a collection of bits that naturally fits into a register, ... Whether a type half the size of an int ...
    (comp.lang.c)