]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
camera: likelimg: bit endian justified to match Portable BitMap and hue.c convention
authorMarek Peca <mp@duch.cz>
Sun, 19 Apr 2009 15:34:15 +0000 (17:34 +0200)
committerMarek Peca <mp@duch.cz>
Sun, 19 Apr 2009 15:34:15 +0000 (17:34 +0200)
src/camera/rozpuk/likelimg.c

index f7a3212434f97a65aff8d16a8fd75efdaa19980c..dbfa9d03d57bbfac73e12692b2cfd732f8bc0d46 100644 (file)
@@ -58,7 +58,7 @@ double spot_probability(pdfmask_t *pdf, char *bitmap) {
        yp < pdf->h*pdf->w;
        yp += pdf->w, yb += (IMG_WIDTH/8))
     for (xp = 0, xb = pdf->x; xp < pdf->w; xp++, xb++)
-      if (bitmap[yb+(xb/8)] & (1<<(xb%8)))
+      if (bitmap[yb+(xb/8)] & (1<<(7-(xb%8))))
        p += pdf->pdf[yp+xp];
 
   return pdf->scale*(double)p;
@@ -68,7 +68,8 @@ double spot_probability(pdfmask_t *pdf, char *bitmap) {
 int main() {
   FILE *f;
   uint8_t graymap[320*480], bitmap[320*480/8];
-  int i, j;
+  int i, ib, j;
+  uint8_t b;
 
   f = fopen("pdfmask.bin", "rb");
   pdfmask_load_all(f);
@@ -76,11 +77,11 @@ int main() {
 
   fread(graymap, 320*480, 1, stdin);
 
-  for (i = 0; i < 320*480; i += 8) {
-    bitmap[i/8] = 0;
-    for (j = 0; j < 8; j++)
-      if (graymap[i+j])
-       bitmap[i/8] += (1<<j);
+  for (i = ib = 0; i < 320*480; ib++) {
+    bitmap[ib] = 0;
+    for (b = 1<<7; b; b >>= 1, i++)
+      if (graymap[i])
+       bitmap[ib] += b;
   }
 
   double W[N_SPOTS];
@@ -92,7 +93,6 @@ int main() {
 
   double L[10];
   int k;
-  char b;
 
   for (k = 0; k < 10; k++) {
     L[k] = 0.0;