Takes a screen capture of the given dimensions.

@param dimensions the dimensions of which to take a screen capture
@return a capture of the designated dimensions
@throws IOException if an I/O exception occurs
779388
public static ScreenCapture of(Dimension dimensions) throws IOException {
    ScreenCapture capture = new ScreenCapture(dimensions);

    try {
      capture.take();
    } catch (AWTException e) {
      throw new IOException(e);
    }

    return capture;
  }
1179620
private static Dimension getDimension(InputStream fis, AtomicReference<ByteBuffer> lastTkhdHolder)
      throws IOException {

    while (fis.available() > 0) {
      byte[] header = new byte[8];
      fis.read(header);

      long size = readUint32(header, 0);
      String type = new String(header, 4, 4, "ISO-8859-1");
      if (containers.contains(type)) {

        Dimension dimension = getDimension(fis, lastTkhdHolder);
        if (dimension != null) {
          return dimension;
        }

      } else if (type.equals("tkhd")) {
        byte[] lastTkhd = new byte[(int) (size - 8)];
        lastTkhdHolder.set(ByteBuffer.wrap(lastTkhd));
        fis.read(lastTkhd);
      } else if (type.equals("hdlr")) {
        byte[] hdlr = new byte[(int) (size - 8)];
        fis.read(hdlr);
        if (hdlr[8] == 0x76 && hdlr[9] == 0x69 && hdlr[10] == 0x64 && hdlr[11] == 0x65) {
          byte[] lastTkhd = lastTkhdHolder.get().array();
          return new Dimension((int) readFixedPoint1616(lastTkhd, lastTkhd.length - 8),
              (int) readFixedPoint1616(lastTkhd, lastTkhd.length - 4));
        }
      } else {
        fis.skip(size - 8);
      }
    }

    return null;
  }
1228032
public static SVGGraphics2D createSvgGraphics(final Dimension size)
            throws ParserConfigurationException {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document document = db.getDOMImplementation().createDocument(null, "svg", null);

        SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(document);
        ctx.setStyleHandler(new OpacityAdjustingStyleHandler());
        ctx.setComment("Generated by GeoTools2 with Batik SVG Generator");

        SVGGraphics2D g2d = new SVGGraphics2D(ctx, true);
        g2d.setSVGCanvasSize(size);

        return g2d;
    }
1132698
public VectorSize readVectorSize(VectorInfo info) throws IOException {
        // Always read the vector size
        int size = getInt();

        // For coordinate vectors we also read the number of entries
        if (info.isDense())
            return new VectorSize(size);
        else {
            int numEntries = getInt();
            return new VectorSize(size, numEntries);
        }
    }
892996
public Webcam getWebcam(String name, Dimension dimension) {
        if (name == null) {
            return getWebcam(dimension);
        }

        Webcam webcam = webcams.get(name);
        openWebcam(webcam, dimension);
        return webcam;
    }
1045195
protected Map<String, String> getAdditionalFlashPlayerFlashVars(Media media, Dimension dimension) {
    Map<String, String> flashvars = new HashMap<String, String>();

    flashvars.put("autoPlay", "false");
    flashvars.put("loop", "false");

    return flashvars;
  }
1228815
public void setDimensions(java.util.Collection<Dimension> dimensions) {
        if (dimensions == null) {
            this.dimensions = null;
            return;
        }

        this.dimensions = new com.amazonaws.internal.SdkInternalList<Dimension>(dimensions);
    }
510195
public List<String> getSearchDimensions() {
    List<String> dimensions = new ArrayList<String>();
    for (int i = 0; i < m_Space.dimensions(); ++i) {
      dimensions.add(m_Space.getDimension(i).getLabel());
    }
    return dimensions;
  }
1216888
def from_dimensions(cls, width, height, channels, filename=None,
                        grayscale=False, channel_bitdepth=8,
                        has_alpha=False, palette=None):
        
        assert 1 <= channels <= 4, "PNG only supports 1 to 4 channels per pixel. Error writing %s." % filename

        dimensions = (height, width, channels)
        if channels == 1:
            dimensions = (height, width)  # keep the array 2-dimensional when possible

        _array = numpy.zeros(dimensions, dtype=PNGWriter.get_dtype(channel_bitdepth))
        return cls(_array, filename,
                   grayscale=grayscale, channel_bitdepth=channel_bitdepth,
                   has_alpha=has_alpha, palette=palette, channels=channels)
1010942
public static Dimension getDimensions(String fileName,String mimeType,InputStream input)
		throws ImageSizeException,FormatNotSuported, DaoManagerException{


		if (isGIF(mimeType)){
			try {
				return getGifDimensions(input);
			}catch(IOException e){
				throw new ImageSizeException(e,"while getting dimension for file:"+fileName+" mimeType:"+mimeType);
			}
	
		} else if (isJPEG(mimeType) ){
			try {
				Dimension dim=getJpgDimensions(input);
				if (dim!=null){
					return dim;
				} else {
					throw new ImageSizeException("Illegal size for file:"+fileName+" mimeType:"+mimeType);
				}
			}catch(IOException e){
				throw new ImageSizeException(e,"while getting dimension for file:"+fileName+" mimeType:"+mimeType);
			}
	
		} else if (isPNG(mimeType) ){
			try {
				Dimension dim=getPngDimensions(input);
				if (dim!=null){
					return dim;
				} else {
					throw new ImageSizeException("Illegal size for file:"+fileName+" mimeType:"+mimeType);
				}
			}catch(IOException e){
				throw new ImageSizeException(e,"while getting dimension for file:"+fileName+" mimeType:"+mimeType);
			}
	
		} else {
			throw new FormatNotSuported("Mime type:"+mimeType+" not supported.");
		}

	}
1068536
private void handleSetSurfaceTexture(int textureId) throws IOException {
        synchronized (mSurfaceTextureFence) {
            if (mSurfaceTexture != null) {
                // We're hot-swapping the display EGLContext after
                // creating the initial SurfaceTexture for camera display
                mInputWindowSurface.makeCurrent();
                mSurfaceTexture.detachFromGLContext();
                // Release the EGLSurface and EGLContext.
                mInputWindowSurface.releaseEglSurface();
                mFullScreen.release();
                mEglCore.release();

                // Create a new EGLContext and recreate the window surface.
                mEglCore = new EglCore(mEglSaver.getSavedEGLContext(), EglCore.FLAG_RECORDABLE);
                mInputWindowSurface.recreate(mEglCore);
                mInputWindowSurface.makeCurrent();

                // Create new programs and such for the new context.
                mTextureId = textureId;
                mFullScreen = new FullFrameRect(
                        new Texture2dProgram(Texture2dProgram.ProgramType.TEXTURE_EXT));
                mFullScreen.getProgram().setTexSize(mSessionConfig.getVideoWidth(), mSessionConfig.getVideoHeight());
                mIncomingSizeUpdated = true;
                mSurfaceTexture.attachToGLContext(mTextureId);
                //mEglSaver.makeNothingCurrent();
            } else {
                // We're setting up the initial SurfaceTexture
                prepareEncoder(mEglSaver.getSavedEGLContext(),
                        mSessionConfig.getVideoWidth(),
                        mSessionConfig.getVideoHeight(),
                        mSessionConfig.getVideoBitrate(),
                        mSessionConfig.getMuxer());
                mTextureId = textureId;
                mSurfaceTexture = new SurfaceTexture(mTextureId);
                if (VERBOSE)
                    Log.i(TAG + "-SurfaceTexture", " SurfaceTexture created. pre setOnFrameAvailableListener");
                mSurfaceTexture.setOnFrameAvailableListener(this);
                openAndAttachCameraToSurfaceTexture();
                mReadyForFrames = true;
            }
        }
    }
78330
public static int size(DataBuffer buffer, int dimension) {
        int rank = rank(buffer);
        if (dimension >= rank)
            throw new IllegalArgumentException("Invalid dimension " + dimension + " for rank " + rank + " array");
        return buffer.getInt(1 + dimension);
    }
951380
private void writeDimensions(DataOutputStream os, MLArray array) throws IOException
    {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        DataOutputStream bufferDOS = new DataOutputStream(buffer);
        
        int[] dims = array.getDimensions();
        for ( int i = 0; i < dims.length; i++ )
        {
            bufferDOS.writeInt(dims[i]);
        }
        OSArrayTag tag = new OSArrayTag(MatDataTypes.miINT32, buffer.toByteArray() );
        tag.writeTo( os );
        
    }
1148876
public MatrixSize readArraySize() throws IOException {
        int numRows = getInt(), numColumns = getInt();

        return new MatrixSize(numRows, numColumns, numRows * numColumns);
    }
856505
public SpaceDimension spaceDimension() throws Exception {
    String[]  	items;

    items = getItems();
    return new ListSpaceDimension(0, items.length - 1, items, getProperty());
  }
72057
public Texture createTexture(final int width, final int height, final int filter) throws IOException {
    	ImageData ds = new EmptyImageData(width, height);
    	
    	return getTexture(ds, filter);
    }
297726
public static int size(IntBuffer buffer, int dimension) {
        int rank = rank(buffer);
        if (dimension >= rank)
            throw new IllegalArgumentException("Invalid dimension " + dimension + " for rank " + rank + " array");
        return buffer.get(1 + dimension);
    }