Changeset 202

Show
Ignore:
Timestamp:
03/21/06 20:41:17 (3 years ago)
Author:
goodea
Message:

reindent only

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/hal/lpc2106-cmucam3/cc3.c

    r200 r202  
    2929static inline uint8_t _cc3_pixbuf_read_subpixel (void); 
    3030 
    31 static inline void _cc3_pixbuf_read_pixel (uint8_t *pixel, 
    32                                            uint8_t *saved, 
    33                                            uint8_t off0, 
    34                                            uint8_t off1, 
    35                                            uint8_t off2); 
     31static inline void _cc3_pixbuf_read_pixel (uint8_t * pixel, 
     32                                           uint8_t * saved, 
     33                                           uint8_t off0, 
     34                                           uint8_t off1, uint8_t off2); 
    3635 
    3736static inline void _cc3_pixbuf_skip_subpixel (void); 
     
    8281  uint32_t i; 
    8382  for (i = 0; i < size * 4; i++) { 
    84     _cc3_fifo_read_inc(); 
     83    _cc3_fifo_read_inc (); 
    8584  } 
    8685} 
     
    116115  // Skip left  
    117116  if (cc3_g_current_frame.x_loc < cc3_g_current_frame.x0) { 
    118     _cc3_pixbuf_skip_pixels (cc3_g_current_frame.x0  
    119                             * cc3_g_current_frame.x_step); 
     117    _cc3_pixbuf_skip_pixels (cc3_g_current_frame.x0 
     118                             * cc3_g_current_frame.x_step); 
    120119    cc3_g_current_frame.x_loc = cc3_g_current_frame.x0; 
    121120  } 
     
    132131  // Skip right and down  
    133132  _cc3_pixbuf_skip_pixels (cc3_g_current_frame.raw_width - 
    134                     (cc3_g_current_frame.x_loc * cc3_g_current_frame.x_step)); 
     133                           (cc3_g_current_frame.x_loc * 
     134                            cc3_g_current_frame.x_step)); 
    135135  cc3_g_current_frame.x_loc = 0; 
    136136  cc3_g_current_frame.y_loc++; 
     
    168168} 
    169169 
    170 void _cc3_pixbuf_read_pixel (uint8_t *pixel, 
    171                              uint8_t *saved, 
    172                              uint8_t off0, 
    173                              uint8_t off1, 
    174                              uint8_t off2) 
     170void _cc3_pixbuf_read_pixel (uint8_t * pixel, 
     171                             uint8_t * saved, 
     172                             uint8_t off0, uint8_t off1, uint8_t off2) 
    175173{ 
    176174  if (_cc3_second_green_valid) { 
     
    185183 
    186184  // otherwise, load a new thing 
    187   _cc3_second_green = _cc3_pixbuf_read_subpixel(); 
    188   *(pixel + off0) = _cc3_pixbuf_read_subpixel(); 
    189   *(pixel + off1) = _cc3_pixbuf_read_subpixel(); 
    190   *(pixel + off2) = _cc3_pixbuf_read_subpixel(); 
     185  _cc3_second_green = _cc3_pixbuf_read_subpixel (); 
     186  *(pixel + off0) = _cc3_pixbuf_read_subpixel (); 
     187  *(pixel + off1) = _cc3_pixbuf_read_subpixel (); 
     188  *(pixel + off2) = _cc3_pixbuf_read_subpixel (); 
    191189 
    192190  _cc3_second_green_valid = true; 
     
    251249  if (cc3_g_current_frame.coi == CC3_ALL) { 
    252250    channels = 3; 
    253   } else { 
     251  } 
     252  else { 
    254253    channels = 1; 
    255254  } 
     
    283282    off1 = 1; 
    284283    off2 = 2; 
    285   } else if (_cc3_g_current_camera_state.colorspace == CC3_YCRCB) { 
     284  } 
     285  else if (_cc3_g_current_camera_state.colorspace == CC3_YCRCB) { 
    286286    off0 = 1; 
    287287    off1 = 0; 
    288288    off2 = 2; 
    289   } else { 
     289  } 
     290  else { 
    290291    off0 = 0; 
    291292    off1 = 1; 
     
    305306    if (cc3_g_current_frame.coi == CC3_ALL) { 
    306307      for (j = 0; j < cc3_g_current_frame.width; j++) { 
    307         uint8_t *p = ((uint8_t *) mem) + 
    308           (r * cc3_g_current_frame.width + j * 3); 
    309         _cc3_pixbuf_read_pixel (p, p - 3, 
    310                                 off0, off1, off2); 
    311         _cc3_advance_x_loc (); 
     308        uint8_t *p = ((uint8_t *) mem) + 
     309          (r * cc3_g_current_frame.width + j * 3); 
     310        _cc3_pixbuf_read_pixel (p, p - 3, off0, off1, off2); 
     311        _cc3_advance_x_loc (); 
    312312      } 
    313     } else { 
     313    } 
     314    else { 
    314315      // ... 
    315316    } 
  • trunk/lib/cc3_ilp/cc3_color_track.c

    r198 r202  
    1717 * 
    1818 */ 
    19 uint8_t cc3_track_color(cc3_track_pkt_t *pkt) 
     19uint8_t cc3_track_color (cc3_track_pkt_t * pkt) 
    2020{ 
    2121  uint16_t y, x; 
    2222 
    23   x=pkt->scratch_x; 
    24   y=pkt->scratch_y; 
    25  
    26   if( (pkt->lower_bound.channel[0]>pkt->upper_bound.channel[0]) || 
    27       (pkt->lower_bound.channel[1]>pkt->upper_bound.channel[1]) || 
    28       (pkt->lower_bound.channel[2]>pkt->upper_bound.channel[2]) ) return 0; 
    29   pkt->num_pixels=0; 
    30   pkt->x0=UINT16_MAX; 
    31   pkt->y0=UINT16_MAX; 
    32   pkt->x1=0; 
    33   pkt->y1=0; 
    34   pkt->centroid_x=0; 
    35   pkt->centroid_y=0; 
    36  
    37  
    38   for(y=0; y<cc3_g_current_frame.height; y++ ) 
    39     for(x=0; x<cc3_g_current_frame.width; x++ ) 
    40       { 
    41         bool pixel_good=0; 
    42         cc3_pixbuf_read(); 
    43         if(cc3_g_current_frame.coi==CC3_ALL ) {  
    44           if(cc3_g_current_pixel.channel[0]>=pkt->lower_bound.channel[0] &&  
    45              cc3_g_current_pixel.channel[0]<=pkt->upper_bound.channel[0] &&  
    46              cc3_g_current_pixel.channel[1]>=pkt->lower_bound.channel[1] &&  
    47              cc3_g_current_pixel.channel[1]<=pkt->upper_bound.channel[1] &&  
    48              cc3_g_current_pixel.channel[2]>=pkt->lower_bound.channel[2] &&  
    49              cc3_g_current_pixel.channel[2]<=pkt->upper_bound.channel[2] ) pixel_good=1;  
    50         } else 
    51           { 
    52             if(cc3_g_current_pixel.channel[cc3_g_current_frame.coi]>=pkt->lower_bound.channel[cc3_g_current_frame.coi] &&  
    53                cc3_g_current_pixel.channel[cc3_g_current_frame.coi]<=pkt->upper_bound.channel[cc3_g_current_frame.coi] ) pixel_good=1;  
    54           } 
    55  
    56         if(pixel_good) 
    57           { 
    58             pkt->num_pixels++; 
    59             if(pkt->x0 > x ) pkt->x0=x;  
    60             if(pkt->y0 > y ) pkt->y0=y;  
    61             if(pkt->x1 < x ) pkt->x1=x;  
    62             if(pkt->y1 < y ) pkt->y1=y;  
    63             pkt->centroid_x+=x; 
    64             pkt->centroid_y+=y; 
    65           } 
    66       } 
    67  
    68  
    69   if(pkt->num_pixels>0 ) 
    70     { 
    71       // FIXME:  Density hack to keep it an integer 
    72       pkt->int_density=(pkt->num_pixels*1000) / ((pkt->x1 - pkt->x0)*(pkt->y1 - pkt->y0)); 
    73       pkt->centroid_x= pkt->centroid_x / pkt->num_pixels; 
    74       pkt->centroid_y= pkt->centroid_y / pkt->num_pixels; 
    75  
     23  x = pkt->scratch_x; 
     24  y = pkt->scratch_y; 
     25 
     26  if ((pkt->lower_bound.channel[0] > pkt->upper_bound.channel[0]) || 
     27      (pkt->lower_bound.channel[1] > pkt->upper_bound.channel[1]) || 
     28      (pkt->lower_bound.channel[2] > pkt->upper_bound.channel[2])) 
     29    return 0; 
     30  pkt->num_pixels = 0; 
     31  pkt->x0 = UINT16_MAX; 
     32  pkt->y0 = UINT16_MAX; 
     33  pkt->x1 = 0; 
     34  pkt->y1 = 0; 
     35  pkt->centroid_x = 0; 
     36  pkt->centroid_y = 0; 
     37 
     38 
     39  for (y = 0; y < cc3_g_current_frame.height; y++) 
     40    for (x = 0; x < cc3_g_current_frame.width; x++) { 
     41      bool pixel_good = 0; 
     42      cc3_pixbuf_read (); 
     43      if (cc3_g_current_frame.coi == CC3_ALL) { 
     44        if (cc3_g_current_pixel.channel[0] >= pkt->lower_bound.channel[0] 
     45            && cc3_g_current_pixel.channel[0] <= pkt->upper_bound.channel[0] 
     46            && cc3_g_current_pixel.channel[1] >= pkt->lower_bound.channel[1] 
     47            && cc3_g_current_pixel.channel[1] <= pkt->upper_bound.channel[1] 
     48            && cc3_g_current_pixel.channel[2] >= pkt->lower_bound.channel[2] 
     49            && cc3_g_current_pixel.channel[2] <= pkt->upper_bound.channel[2]) 
     50          pixel_good = 1; 
     51      } 
     52      else { 
     53        if (cc3_g_current_pixel.channel[cc3_g_current_frame.coi] >= 
     54            pkt->lower_bound.channel[cc3_g_current_frame.coi] 
     55            && cc3_g_current_pixel.channel[cc3_g_current_frame.coi] <= 
     56            pkt->upper_bound.channel[cc3_g_current_frame.coi]) 
     57          pixel_good = 1; 
     58      } 
     59 
     60      if (pixel_good) { 
     61        pkt->num_pixels++; 
     62        if (pkt->x0 > x) 
     63          pkt->x0 = x; 
     64        if (pkt->y0 > y) 
     65          pkt->y0 = y; 
     66        if (pkt->x1 < x) 
     67          pkt->x1 = x; 
     68        if (pkt->y1 < y) 
     69          pkt->y1 = y; 
     70        pkt->centroid_x += x; 
     71        pkt->centroid_y += y; 
     72      } 
    7673    } 
    77   else  
    78     { 
    79       pkt->int_density=0; 
    80       pkt->x0=0; 
    81       pkt->y0=0; 
    82       pkt->x1=0; 
    83       pkt->y1=0; 
    84       pkt->centroid_x=0; 
    85       pkt->centroid_y=0; 
    86  
     74 
     75 
     76  if (pkt->num_pixels > 0) { 
     77    // FIXME:  Density hack to keep it an integer 
     78    pkt->int_density = 
     79      (pkt->num_pixels * 1000) / ((pkt->x1 - pkt->x0) * (pkt->y1 - pkt->y0)); 
     80    pkt->centroid_x = pkt->centroid_x / pkt->num_pixels; 
     81    pkt->centroid_y = pkt->centroid_y / pkt->num_pixels; 
     82 
     83  } 
     84  else { 
     85    pkt->int_density = 0; 
     86    pkt->x0 = 0; 
     87    pkt->y0 = 0; 
     88    pkt->x1 = 0; 
     89    pkt->y1 = 0; 
     90    pkt->centroid_x = 0; 
     91    pkt->centroid_y = 0; 
     92 
     93  } 
     94  return 1; 
     95
     96 
     97uint8_t cc3_track_color_img (cc3_image_t * img, cc3_track_pkt_t * pkt) 
     98
     99 
     100 
     101
     102 
     103 
     104uint8_t cc3_track_color_scanline_start (cc3_track_pkt_t * pkt) 
     105
     106 
     107  if ((pkt->lower_bound.channel[0] > pkt->upper_bound.channel[0]) || 
     108      (pkt->lower_bound.channel[1] > pkt->upper_bound.channel[1]) || 
     109      (pkt->lower_bound.channel[2] > pkt->upper_bound.channel[2])) 
     110    return 0; 
     111  pkt->num_pixels = 0; 
     112  pkt->x0 = UINT16_MAX; 
     113  pkt->y0 = UINT16_MAX; 
     114  pkt->x1 = 0; 
     115  pkt->y1 = 0; 
     116  pkt->centroid_x = 0; 
     117  pkt->centroid_y = 0; 
     118  pkt->scratch_x = 0; 
     119  pkt->scratch_y = 0; 
     120  return 1; 
     121
     122 
     123uint8_t cc3_track_color_scanline (cc3_image_t * img, cc3_track_pkt_t * pkt) 
     124
     125  uint32_t x, y; 
     126 
     127  for (x = 0; x < MAX_BINARY_WIDTH; x++) 
     128    pkt->binary_scanline[x] = 0; 
     129 
     130  for (y = pkt->scratch_y; y < (pkt->scratch_y + img->height); y++) 
     131    for (x = 0; x < img->width; x++) { 
     132      bool pixel_good = 0; 
     133      cc3_pixel_t cp; 
     134      //cc3_pixbuf_read(); 
     135      cc3_get_pixel (img, x, 0, &cp); 
     136      if (cc3_g_current_frame.coi == CC3_ALL) { 
     137        if (cp.channel[0] >= pkt->lower_bound.channel[0] && 
     138            cp.channel[0] <= pkt->upper_bound.channel[0] && 
     139            cp.channel[1] >= pkt->lower_bound.channel[1] && 
     140            cp.channel[1] <= pkt->upper_bound.channel[1] && 
     141            cp.channel[2] >= pkt->lower_bound.channel[2] && 
     142            cp.channel[2] <= pkt->upper_bound.channel[2]) 
     143          pixel_good = 1; 
     144      } 
     145      else { 
     146        if (cp.channel[cc3_g_current_frame.coi] >= 
     147            pkt->lower_bound.channel[cc3_g_current_frame.coi] 
     148            && cp.channel[cc3_g_current_frame.coi] <= 
     149            pkt->upper_bound.channel[cc3_g_current_frame.coi]) 
     150          pixel_good = 1; 
     151      } 
     152 
     153      /*      pkt->binary_scanline[0]=0x01020304;  
     154         pkt->binary_scanline[1]=0x05060708;  
     155         pkt->binary_scanline[2]=0x090A0B0C;  
     156         pkt->binary_scanline[3]=0x0D0E0F10;  
     157         pkt->binary_scanline[4]=0x11121314;  
     158       */ if (pixel_good) { 
     159        uint8_t block, offset; 
     160        block = x / 8; 
     161        offset = x % 8; 
     162        offset = 7 - offset; 
     163        pkt->binary_scanline[block] |= (1 << offset); 
     164        pkt->num_pixels++; 
     165        if (pkt->x0 > x) 
     166          pkt->x0 = x; 
     167        if (pkt->y0 > y) 
     168          pkt->y0 = y; 
     169        if (pkt->x1 < x) 
     170          pkt->x1 = x; 
     171        if (pkt->y1 < y) 
     172          pkt->y1 = y; 
     173        pkt->centroid_x += x; 
     174        pkt->centroid_y += y; 
     175      } 
    87176    } 
     177 
     178  pkt->scratch_y = y; 
     179 
    88180  return 1; 
    89181} 
    90182 
    91 uint8_t cc3_track_color_img(cc3_image_t *img, cc3_track_pkt_t *pkt) 
    92 
    93  
    94  
    95 
    96  
    97  
    98 uint8_t cc3_track_color_scanline_start(cc3_track_pkt_t *pkt) 
    99 
    100  
    101   if( (pkt->lower_bound.channel[0]>pkt->upper_bound.channel[0]) || 
    102       (pkt->lower_bound.channel[1]>pkt->upper_bound.channel[1]) || 
    103       (pkt->lower_bound.channel[2]>pkt->upper_bound.channel[2]) ) return 0; 
    104   pkt->num_pixels=0; 
    105   pkt->x0=UINT16_MAX; 
    106   pkt->y0=UINT16_MAX; 
    107   pkt->x1=0; 
    108   pkt->y1=0; 
    109   pkt->centroid_x=0; 
    110   pkt->centroid_y=0; 
    111   pkt->scratch_x=0; 
    112   pkt->scratch_y=0; 
    113   return 1; 
    114 
    115  
    116 uint8_t cc3_track_color_scanline(cc3_image_t *img, cc3_track_pkt_t *pkt) 
    117 
    118   uint32_t x,y; 
    119  
    120   for(x=0; x<MAX_BINARY_WIDTH; x++ ) pkt->binary_scanline[x]=0; 
    121  
    122   for(y=pkt->scratch_y; y<(pkt->scratch_y+img->height); y++ ) 
    123     for(x=0; x<img->width; x++ ) 
    124       { 
    125         bool pixel_good=0; 
    126         cc3_pixel_t cp; 
    127         //cc3_pixbuf_read(); 
    128         cc3_get_pixel( img, x, 0, &cp );         
    129         if(cc3_g_current_frame.coi==CC3_ALL ) {  
    130           if(cp.channel[0]>=pkt->lower_bound.channel[0] &&  
    131              cp.channel[0]<=pkt->upper_bound.channel[0] &&  
    132              cp.channel[1]>=pkt->lower_bound.channel[1] &&  
    133              cp.channel[1]<=pkt->upper_bound.channel[1] &&  
    134              cp.channel[2]>=pkt->lower_bound.channel[2] &&  
    135              cp.channel[2]<=pkt->upper_bound.channel[2] ) pixel_good=1;  
    136         } else 
    137           { 
    138             if(cp.channel[cc3_g_current_frame.coi]>=pkt->lower_bound.channel[cc3_g_current_frame.coi] &&  
    139                cp.channel[cc3_g_current_frame.coi]<=pkt->upper_bound.channel[cc3_g_current_frame.coi] ) pixel_good=1;  
    140           } 
    141  
    142         /*      pkt->binary_scanline[0]=0x01020304;  
    143           pkt->binary_scanline[1]=0x05060708;  
    144           pkt->binary_scanline[2]=0x090A0B0C;  
    145           pkt->binary_scanline[3]=0x0D0E0F10;  
    146           pkt->binary_scanline[4]=0x11121314;  
    147         */      if(pixel_good) 
    148           { 
    149             uint8_t block,offset; 
    150             block=x/8; 
    151             offset=x%8; 
    152             offset=7-offset; 
    153             pkt->binary_scanline[block] |= (1<<offset); 
    154             pkt->num_pixels++; 
    155             if(pkt->x0 > x ) pkt->x0=x;  
    156             if(pkt->y0 > y ) pkt->y0=y;  
    157             if(pkt->x1 < x ) pkt->x1=x;  
    158             if(pkt->y1 < y ) pkt->y1=y;  
    159             pkt->centroid_x+=x; 
    160             pkt->centroid_y+=y; 
    161           } 
    162       } 
    163  
    164   pkt->scratch_y=y; 
    165  
    166   return 1; 
    167 
    168  
    169  
    170  
    171 uint8_t cc3_track_color_scanline_finish(cc3_track_pkt_t *pkt) 
    172 
    173   if(pkt->num_pixels>0 ) 
    174     { 
    175       // FIXME:  Density hack to keep it an integer 
    176       pkt->int_density=(pkt->num_pixels*1000) / ((pkt->x1 - pkt->x0)*(pkt->y1 - pkt->y0)); 
    177       pkt->centroid_x= pkt->centroid_x / pkt->num_pixels; 
    178       pkt->centroid_y= pkt->centroid_y / pkt->num_pixels; 
    179  
    180     } 
    181   else  
    182     { 
    183       pkt->int_density=0; 
    184       pkt->x0=0; 
    185       pkt->y0=0; 
    186       pkt->x1=0; 
    187       pkt->y1=0; 
    188       pkt->centroid_x=0; 
    189       pkt->centroid_y=0; 
    190  
    191     } 
    192  
    193  
    194 
    195  
    196  
    197  
     183 
     184 
     185uint8_t cc3_track_color_scanline_finish (cc3_track_pkt_t * pkt) 
     186
     187  if (pkt->num_pixels > 0) { 
     188    // FIXME:  Density hack to keep it an integer 
     189    pkt->int_density = 
     190      (pkt->num_pixels * 1000) / ((pkt->x1 - pkt->x0) * (pkt->y1 - pkt->y0)); 
     191    pkt->centroid_x = pkt->centroid_x / pkt->num_pixels; 
     192    pkt->centroid_y = pkt->centroid_y / pkt->num_pixels; 
     193 
     194  } 
     195  else { 
     196    pkt->int_density = 0; 
     197    pkt->x0 = 0; 
     198    pkt->y0 = 0; 
     199    pkt->x1 = 0; 
     200    pkt->y1 = 0; 
     201    pkt->centroid_x = 0; 
     202    pkt->centroid_y = 0; 
     203 
     204  } 
     205 
     206 
     207
  • trunk/lib/cc3_ilp/cc3_ilp.c

    r198 r202  
    44#include <stdio.h> 
    55 
    6 void cc3_send_image_direct(void) 
     6void cc3_send_image_direct (void) 
    77{ 
    8     uint32_t x, y; 
    9     uint32_t size_x, size_y; 
     8  uint32_t x, y; 
     9  uint32_t size_x, size_y; 
    1010 
    11    cc3_set_led(1); 
    12    size_x=cc3_g_current_frame.width;  
    13    size_y=cc3_g_current_frame.height;  
    14     cc3_pixbuf_load (); 
    15     putchar (1); 
    16     putchar (size_x); 
    17     if (size_y > 255) 
    18         size_y = 255; 
    19     putchar (size_y); 
    20     for (y = 0; y < size_y; y++) { 
    21         putchar (2); 
    22         for (x = 0; x < size_x; x++) { 
    23             cc3_pixbuf_read (); 
    24             putchar (cc3_g_current_pixel.channel[CC3_RED]); 
    25             putchar (cc3_g_current_pixel.channel[CC3_GREEN]); 
    26             putchar (cc3_g_current_pixel.channel[CC3_BLUE]); 
    27         } 
     11  cc3_set_led (1); 
     12  size_x = cc3_g_current_frame.width; 
     13  size_y = cc3_g_current_frame.height; 
     14  cc3_pixbuf_load (); 
     15  putchar (1); 
     16  putchar (size_x); 
     17  if (size_y > 255) 
     18    size_y = 255; 
     19  putchar (size_y); 
     20  for (y = 0; y < size_y; y++) { 
     21    putchar (2); 
     22    for (x = 0; x < size_x; x++) { 
     23      cc3_pixbuf_read (); 
     24      putchar (cc3_g_current_pixel.channel[CC3_RED]); 
     25      putchar (cc3_g_current_pixel.channel[CC3_GREEN]); 
     26      putchar (cc3_g_current_pixel.channel[CC3_BLUE]); 
    2827    } 
    29     putchar (3); 
     28  } 
     29  putchar (3); 
    3030} 
    3131 
    32 uint8_t cc3_load_img_rows( cc3_image_t *img, uint16_t rows
     32uint8_t cc3_load_img_rows (cc3_image_t * img, uint16_t rows
    3333{ 
    3434 
     
    3636} 
    3737 
    38 void cc3_get_pixel(cc3_image_t *img, uint16_t x, uint16_t y, cc3_pixel_t *out_pix) 
     38void cc3_get_pixel (cc3_image_t * img, uint16_t x, uint16_t y, 
     39                    cc3_pixel_t * out_pix) 
    3940{ 
    40 if(img->channels>1) 
    41 
    42   out_pix->channel[0]=((uint8_t *)img->pix)[y*img->width+(x*3)];  
    43         out_pix->channel[1]=((uint8_t *)img->pix)[y*img->width+(x*3)+1];  
    44         out_pix->channel[2]=((uint8_t *)img->pix)[y*img->width+(x*3)+2];  
    45 }  
    46 else { 
    47         out_pix->channel[0]=((uint8_t *)img->pix)[y*img->width+x];  
    48 
     41  if (img->channels > 1) { 
     42    out_pix->channel[0] = ((uint8_t *) img->pix)[y * img->width + (x * 3)]; 
     43    out_pix->channel[1] = 
     44      ((uint8_t *) img->pix)[y * img->width + (x * 3) + 1]; 
     45    out_pix->channel[2] = 
     46      ((uint8_t *) img->pix)[y * img->width + (x * 3) + 2]; 
     47  } 
     48  else { 
     49    out_pix->channel[0] = ((uint8_t *) img->pix)[y * img->width + x]; 
     50  } 
    4951 
    5052} 
    5153 
    5254 
    53 void cc3_set_pixel(cc3_image_t *img, uint16_t x, uint16_t y, cc3_pixel_t *in_pix) 
     55void cc3_set_pixel (cc3_image_t * img, uint16_t x, uint16_t y, 
     56                    cc3_pixel_t * in_pix) 
    5457{ 
    55 if(img->channels>1) 
    56 
    57         ((uint8_t *)img->pix)[y*img->width+(x*3)]=in_pix->channel[0];  
    58         ((uint8_t *)img->pix)[y*img->width+(x*3)+1]=in_pix->channel[1];  
    59         ((uint8_t *)img->pix)[y*img->width+(x*3)+2]=in_pix->channel[2];  
    60 
    61 else { 
    62         ((uint8_t *)img->pix)[y*img->width+x]=in_pix->channel[0];  
    63 
     58  if (img->channels > 1) { 
     59    ((uint8_t *) img->pix)[y * img->width + (x * 3)] = in_pix->channel[0]; 
     60    ((uint8_t *) img->pix)[y * img->width + (x * 3) + 1] = in_pix->channel[1]; 
     61    ((uint8_t *) img->pix)[y * img->width + (x * 3) + 2] = in_pix->channel[2]; 
     62  } 
     63  else { 
     64    ((uint8_t *) img->pix)[y * img->width + x] = in_pix->channel[0]; 
     65  } 
    6466 
    6567 
    6668} 
    67  
    68  
    69  
    70  
    71