/**
 * \brief Symmetrize the exposure
 *
 * The M26C has an interlaced CCD which reads the different fields and
 * colors from different sides of the chip. This only works for symmetric
 * exposures, symmetric with respect to the center of the CCD chip. This
 * method computes a symmetrized exposure object.
 */
Exposure	SxCcdM26C::symmetrize(const Exposure& exp) const {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "symmetrizing exposure %s",
		exp.toString().c_str());
	Exposure	symexp = exp;
	int	x[4], y[4];
	x[0] = exp.x();
	y[0] = exp.y();
	x[1] = M26C_WIDTH - x[0];
	y[1] = M26C_HEIGHT - y[0];
	x[2] = exp.x() + exp.width();
	y[2] = exp.y() + exp.height();
	x[3] = M26C_WIDTH - x[2];
	y[3] = M26C_HEIGHT - y[2];
	debug(LOG_DEBUG, DEBUG_LOG, 0, "x[] = %d %d %d %d",
		x[0], x[1], x[2], x[3]);
	debug(LOG_DEBUG, DEBUG_LOG, 0, "y[] = %d %d %d %d",
		y[0], y[1], y[2], y[3]);

	// symmetrized origin
	ImagePoint	origin(min(x, 4), min(y, 4));
	
	// symmetrize size
	unsigned int	sizex = max(x, 4) - symexp.x();
	if (sizex > 3900) {
		sizex = 3900;
	}
	unsigned int	sizey = max(y, 4) - symexp.y();
	ImageSize	size(sizex, sizey);
	ImageRectangle	frame(origin, size);
	symexp.frame(frame);

	debug(LOG_DEBUG, DEBUG_LOG, 0, "symmetrized exposure: %s",
		symexp.toString().c_str());
	return symexp;
}
/**
 * \brief Symmetrize the exposure
 *
 * The M26C has an interlaced CCD which reads the different fields and
 * colors from different sides of the chip. This only works for symmetric
 * exposures, symmetric with respect to the center of the CCD chip. This
 * method computes a symmetrized exposure object.
 */
Exposure	SxCcdM26C::symmetrize(const Exposure& exp) const {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "symmetrizing exposure %s",
		exp.toString().c_str());
	Exposure	symexp = exp;

	int	x[4], y[4];
	// compute all the possible corner coordinates
	x[0] = exp.x();			y[0] = exp.y();
	x[1] = M26C_WIDTH - x[0]; 	y[1] = M26C_HEIGHT - y[0];
	x[2] = exp.x() + exp.width(); 	y[2] = exp.y() + exp.height();
	x[3] = M26C_WIDTH - x[2]; 	y[3] = M26C_HEIGHT - y[2];
	debug(LOG_DEBUG, DEBUG_LOG, 0, "x[] = %d %d %d %d",
		x[0], x[1], x[2], x[3]);
	debug(LOG_DEBUG, DEBUG_LOG, 0, "y[] = %d %d %d %d",
		y[0], y[1], y[2], y[3]);

	// make the origin with the right divisibility
	int	xmin = ((min(x, 4) >> 2) << 2) - 4;
	if (xmin < 0) { xmin = 0; }
	int	xmax = M26C_WIDTH - xmin;
	int	ymin = ((min(y, 4) >> 2) << 2) - 4;
	if (ymin < 0) { ymin = 0; }
	int	ymax = M26C_HEIGHT - ymin;

	// symmetrized origin
	ImagePoint	origin(xmin, ymin);

	// symmetrize size
	unsigned int	sizex = xmax - xmin;
	if (sizex > 3900) {
		sizex = 3900;
	}
	unsigned int	sizey = ymax - ymin;
	ImageSize	size(sizex, sizey);
	ImageRectangle	frame(origin, size);
	symexp.frame(frame);

	debug(LOG_DEBUG, DEBUG_LOG, 0, "symmetrized exposure: %s",
		symexp.toString().c_str());
	return symexp;
}