For what its worth, for an SD850 IS, it is 3336 x 2480. pixels, which I got with a web search and verified by determining the size of the CRW file (the resolution quoted in some documents wasn't the exact number of pixels - I think what was quoted was useable pixels). However, I also do not apparently understand the format, and am also trying to roll my own reader.
I understand that the CRW data is 10 bit little endian, but what I read out isn't correct - there are dark columns spaced 8 pixels apart, though they appear to have at least some of the scene info in them.
So say we have a pixel with an ADU value of 1000 and the next consecutive pixel read out has a value of 5.
The ten bits for each would be 1111101000 and 0000000101 respectively. I was assuming that consecutive 10 bit ADU values get packed into consecutive 8 bit bytes LSB first as follows:
00010111 11101000 0000xxxx etc.
But when I read out based on that assumption it seems to not quite be right. I've tried a simple case where I know what the bit pattern is and the program seems to read as I expect. As far as I can tell, the artifacts are not due to the Bayer pattern either, as they have the wrong pattern, and are present even if I take a "dark" frame - e.g. values should all be near zero. So can someone explain where my assumption is wrong?