public ImageData addSnippedImage(Rectangle rect){
		ImageData.resetId(getSheetData().getAllImageData());
		boolean autoColl = Boolean.parseBoolean(Preferences.PREFS.get("coll_auto"));
		boolean autoHull = Boolean.parseBoolean(Preferences.PREFS.get("hull_auto"));
		boolean autoAnchor = Boolean.parseBoolean(Preferences.PREFS.get("anchor_auto"));
		
		if (sheetData.hasImage() && rect != null){
			// Check if this rect overlaps another.
			for (ImageData iData : sheetData.getAllImageData()){
				if (iData.getType().equals(ImageType.IMAGE) && iData.getRect().intersects(rect)){
					System.out.println("Image intersects another");
					return null;
				}
			}
			
			BufferedImage img = sheetData.getImage().getSubimage(rect.x, rect.y, rect.width, rect.height);
			ImageIcon ii = new ImageIcon(getMaxScaledInstance(img, THUMB_WIDTH));
			JButton button = new JButton(ii);
			button.setFocusPainted(false);
			button.setBackground(Color.WHITE);
			button.setBorder(new LineBorder(Color.BLACK));
			Dimension size = new Dimension(THUMB_WIDTH, THUMB_HEIGHT);
			button.setPreferredSize(size);
			button.setMinimumSize(size);
			button.setMaximumSize(size);
			lowerRight.add(button);
			lowerRight.revalidate();
			lowerRight.repaint();
			
			button.addActionListener(new ActionListener()
			{
				@Override
				public void actionPerformed(ActionEvent event)
				{
					Tools.setButtonEnabledState(ImageType.IMAGE);
					ImagePanel.this.switchImage((JButton) event.getSource(), ImageType.IMAGE);
				}
			});
			
			ImageData iData = sheetData.newImageData(rect, img, button);
			if (autoHull){
				iData.generateConvexHullPoly();
			} else if (autoColl){
				// Autogenerate and add a collision box
				int collX = Integer.valueOf(Preferences.PREFS.get("coll_x"));
				int collY = Integer.valueOf(Preferences.PREFS.get("coll_y"));
				int collW = Integer.valueOf(Preferences.PREFS.get("coll_w"));
				int collH = Integer.valueOf(Preferences.PREFS.get("coll_h"));
				
				Polygon p = new Polygon();
				// Wrapping the box clockwise
				p.addPoint(collX, collY);
				p.addPoint(collX + collW, collY);
				p.addPoint(collX + collW, collY + collH);
				p.addPoint(collX, collY + collH);
				
				iData.setPoly(p);
			}
			if (autoAnchor){
				int aX = Integer.valueOf(Preferences.PREFS.get("anchor_x"));
				int aY = Integer.valueOf(Preferences.PREFS.get("anchor_y"));
				iData.setAnchor(aX, aY);
			}
			return iData;
		}
		return null;
	}