public void setMode(int w, int h) {
	  if (w>width) {
		  int j=0;
		  Vector<Integer> _map = new Vector<Integer>();
		  for (int y=0;y<(height/8);y++) {
			  for (int x=0;x<(width/8);x++) {
				  _map.add(map.get(j));
				  j++;
		       }
			  for (int k=0;k<(w/8)-(width/8);k++)
				  _map.add(0);
	      }
		  map = _map;
	  } else if (w<width) {
		  Vector<Integer> _map = new Vector<Integer>();
		  int j=0;
		  for (int y=0;y<(height/8);y++) {
			  for (int x=0;x<(w/8);x++) {
				  _map.add(map.get(j));
				  j++;
		       }
			  j=j+((width/8)-(w/8));
	      }
		  map = _map;
	  }
	  width = w;
	  if (h>height) {
		  for (int i=0;i<(h/8)-(height/8);i++) {
			  for(int j = 0;j<(width/8);j++) map.add(0);
		  }
	 } else if (h<height) {
		 Vector<Integer> _map = new Vector<Integer>();
		 for (int i=0;i<(w/8)*(h/8);i++)
		 _map.add(map.get(i));
		 map = _map;
	  }
	  height = h;
	  offsetPaint.flush();
	  offsetPaint=createImage(width*zoom +1, height*zoom +1);
	  selection.flush();
      selection = new BufferedImage(width*zoom + 1, height*zoom + 1, BufferedImage.TYPE_INT_ARGB);
	  if (grid.getWidth()<width*zoom+1 || grid.getHeight()<height*zoom+1) {
		  grid.flush();
		  grid = new BufferedImage(width*zoom + 1, height*zoom + 1, BufferedImage.TYPE_INT_ARGB);
		  Graphics g = grid.getGraphics();
		  g.setColor(new Color(0, 0, 0, 50));
		  for (int x = 0; x <width*zoom; x=x+(8*zoom)) {
			  for (int y=0;y<height*zoom;y=y+(8*zoom)) {
				  g.drawRect(x, y, 8*zoom, 8*zoom);
			  }
		  }
	  }
	  toRefresh=true;
	  repaint();
  }