public void initPF() {
		int allowed_width = winwidth + crop_left + crop_right;
		int allowed_height = winheight + crop_top + crop_bottom;
		// these came from the canvas constructor
		viewnrtilesx=nrtilesx;
		viewnrtilesy=nrtilesy;
		if (prescale) {
			scaledtilex = allowed_width / nrtilesx;
			scaledtiley = allowed_height / nrtilesy;
			double aspectratio = (scaledtilex / (double)scaledtiley)
					/ (tilex / (double)tiley);
			if (aspectratio < min_aspect) {
				// y is too large
				scaledtiley = (int)(scaledtilex / min_aspect);
			} else if (aspectratio > max_aspect) {
				// x is too large
				scaledtilex = (int)(max_aspect * scaledtiley);
			}
			width = scaledtilex*nrtilesx;
			height = scaledtiley*nrtilesy;
		} else {
			scaledtilex = tilex;
			scaledtiley = tiley;
			// XXX aspect ratio is not constrained yet in this case!
			width = winwidth;
			height = winheight;
		}
		x_scale_fac = width  / (double)(tilex*nrtilesx);
		y_scale_fac = height / (double)(tiley*nrtilesy);
		min_scale_fac = Math.min( x_scale_fac, y_scale_fac );
		initBGTiles(nrtilesx, nrtilesy, "");
		// now, calculate the offsets. 
		if (prescale) {
			int x_excess = width-winwidth;
			int y_excess = height-winheight;
			// balance is a number between -1 (shift left) and 1 (shift right)
			double xbalance=0,ybalance=0;
			if (crop_left+crop_right>0 && x_excess>0)
				xbalance = (crop_right-crop_left)/(crop_left+crop_right);
			if (crop_top+crop_bottom>0 && y_excess>0)
				ybalance = (crop_bottom-crop_top)/(crop_top+crop_bottom);
			canvas_xofs = (int)(-x_excess*(0.5 - 0.5*xbalance));
			canvas_yofs = (int)(-y_excess*(0.5 - 0.5*ybalance));
		} // else use default offsets of 0.0
	}