Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var imageData = new byte[64];
- var imageWidth = 8;
- var imageHeight = 8;
- var bitDepth = 1;
- var dstData = new byte[imageData.Length / (8 / bitDepth)];
- var dstIndex = 0;
- var dstSubIndex = 0;
- // initialize imageData
- for (var i = 0;i<imageData.Length;++i)
- {
- imageData[i] = (byte)( 0==(i % 2) ? 0 : 0xFF);
- }
- for(var y = 0;y<imageHeight;++y)
- {
- for(var x = 0;x<imageWidth;++x)
- {
- var luma = imageData[y * imageWidth + x];
- luma >>= (8 - bitDepth);
- luma <<= (dstSubIndex++ * bitDepth);
- dstData[dstIndex] |= luma;
- if (dstSubIndex == (8 / bitDepth))
- {
- dstSubIndex = 0;
- ++dstIndex;
- }
- }
- }
- for(var i = 0;i<dstData.Length;++i)
- {
- Console.Write(dstData[i].ToString("X2"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement