2bit image from a number?
- From: "Nik Coughlin" <nrkn.com@xxxxxxxxx>
- Date: Tue, 23 Sep 2008 22:00:40 +1200
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?
.
- Follow-Ups:
- Re: 2bit image from a number?
- From: Bob Powell [MVP]
- Re: 2bit image from a number?
- From: TAB
- Re: 2bit image from a number?
- Prev by Date: Re: How to compose png and jpg to save png alpha?
- Next by Date: Re: 2bit image from a number?
- Previous by thread: IsOutlineVisible preformance
- Next by thread: Re: 2bit image from a number?
- Index(es):
Relevant Pages
|