/* Example program taking two pictures using the Scribbler 2 and shows a
 *  picture composed of pieces of the two pictures */

#include <stdio.h>
#include <MyroC.h>

int
main()
{
  Picture  pic1,  pic2,  spliced;
  int width, height, midcol, midrow;

  rConnect ("/dev/rfcomm0");

  pic1 = rTakePicture();
  rTurnLeft (1, 1);
  pic2 = rTakePicture();

  rDisplayPicture (pic1, 5, "Picture 1");
  rDisplayPicture (pic2, 5, "Picture 2");

  width = pic1.width;
  height = pic1.height;
  midcol = width / 2;
  midrow = height / 2;

  spliced.width = width;
  spliced.height = height;

  int col,row;
  for (col = 0; col < width ; col++)
    {
      for (row = 0; row < height; row++)
        {
          if ( ((col < midcol) && (row < midrow))      // top-left quadrant
	       || ((col > midcol) && (row > midrow)) ) // bottom-right quadrant
	    spliced.pix_array[col][row]=pic1.pix_array[col][row];           
	  else
            spliced.pix_array[col][row]=pic2.pix_array[col][row]; 
        } // row
    } // col

  rDisplayPicture (spliced,-3,"Spliced Picture");
  rDisconnect();
  return 0;
} // main
