public void mouseReleased(MouseEvent evt) {
		//Fill in pixels in between and connect the first to the last
		int N = selectionBorder.size();		
		if (N == 0 || (state != SELECTING && state != DRAGGING))
			return;
			
		if (state == SELECTING) {
			for (int n = 0; n < N; n++) {
				int startx = selectionBorder.get(n).x;
				int starty = selectionBorder.get(n).y;
				int totalDX = selectionBorder.get((n+1)%N).x - startx;
				int totalDY = selectionBorder.get((n+1)%N).y - starty;
				int numAdded = Math.abs(totalDX) + Math.abs(totalDY);
				for (int t = 0; t < numAdded; t++) {
					double frac = (double)t / (double)numAdded;
					int x = (int)Math.round(frac*totalDX) + startx;
					int y = (int)Math.round(frac*totalDY) + starty;
					selectionBorder.add(new Coord(x, y));
				}
			}
			/*selection.clear();
			for (int x = 0; x < Width; x++) {
				for (int y = 0; y < Height; y++) {
					if (mask[x][y])
						selection.add(new Coord(x, y));
				}
			}*/
			updateMask();
			getSelectionArea();
			state = DRAGGING;
			dragValid = false;
			dx = 0;
			dy = 0;
		}
		else if (state == DRAGGING) {
			dragValid = false;
			updateMask();
		}
		canvas.repaint();
	}