Index: /trunk/include/cc3.h
===================================================================
--- /trunk/include/cc3.h	(revision 210)
+++ /trunk/include/cc3.h	(revision 243)
@@ -84,4 +84,5 @@
   cc3_subsample_mode_t subsample_mode;
   uint16_t width, height;
+  uint8_t channels;
 } cc3_frame_t;
 
Index: /trunk/hal/lpc2106-cmucam3/cc3.c
===================================================================
--- /trunk/hal/lpc2106-cmucam3/cc3.c	(revision 228)
+++ /trunk/hal/lpc2106-cmucam3/cc3.c	(revision 243)
@@ -213,13 +213,6 @@
 uint8_t *cc3_malloc_rows (uint32_t rows)
 {
-  int channels;
+  int channels = cc3_g_current_frame.channels;
   int width = cc3_g_current_frame.width;
-
-  if (cc3_g_current_frame.coi == CC3_ALL) {
-    channels = 3;
-  }
-  else {
-    channels = 1;
-  }
 
   return (uint8_t *) malloc (width * channels * rows);
@@ -487,4 +480,7 @@
     return 0;                   // Sanity check on bounds
   cc3_g_current_frame.coi = chan;
+
+  cc3_g_current_frame.channels = (chan == CC3_ALL ? 3 : 1);
+
   return 1;
 }
@@ -527,5 +523,4 @@
 void cc3_frame_default ()
 {
-  cc3_g_current_frame.coi = CC3_ALL;
   cc3_g_current_frame.x_step = 1;
   cc3_g_current_frame.y_step = 1;
@@ -536,4 +531,6 @@
   cc3_g_current_frame.y_loc = 0;
   cc3_g_current_frame.subsample_mode = CC3_NEAREST;
+
+  cc3_pixbuf_set_coi(CC3_ALL);
 
   _cc3_update_frame_bounds (&cc3_g_current_frame);
