This method checks if the image is a valid JPEG and processes some parameters.
@throws BadElementException
@throws IOException
505376
private void processParameters() throws BadElementException, IOException {
        type = JPEG;
        originalType = ORIGINAL_JPEG;
        InputStream is = null;
        try {
            String errorID;
            if (rawData == null){
                is = url.openStream();
                errorID = url.toString();
            }
            else{
                is = new java.io.ByteArrayInputStream(rawData);
                errorID = "Byte array";
            }
            if (is.read() != 0xFF || is.read() != 0xD8)	{
                throw new BadElementException(errorID + " is not a valid JPEG-file.");
            }
            boolean firstPass = true;
            int len;
            while (true) {
                int v = is.read();
                if (v < 0)
                    throw new IOException("Premature EOF while reading JPG.");
                if (v == 0xFF) {
                    int marker = is.read();
                    if (firstPass && marker == M_APP0) {
                        firstPass = false;
                        len = getShort(is);
                        if (len < 16) {
                            Utilities.skip(is, len - 2);
                            continue;
                        }
                        byte bcomp[] = new byte[JFIF_ID.length];
                        int r = is.read(bcomp);
                        if (r != bcomp.length)
                            throw new BadElementException(errorID + " corrupted JFIF marker.");
                        boolean found = true;
                        for (int k = 0; k < bcomp.length; ++k) {
                            if (bcomp[k] != JFIF_ID[k]) {
                                found = false;
                                break;
                            }
                        }
                        if (!found) {
                            Utilities.skip(is, len - 2 - bcomp.length);
                            continue;
                        }
                        Utilities.skip(is, 2);
                        int units = is.read();
                        int dx = getShort(is);
                        int dy = getShort(is);
                        if (units == 1) {
                            dpiX = dx;
                            dpiY = dy;
                        }
                        else if (units == 2) {
                            dpiX = (int)(dx * 2.54f + 0.5f);
                            dpiY = (int)(dy * 2.54f + 0.5f);
                        }
                        Utilities.skip(is, len - 2 - bcomp.length - 7);
                        continue;
                    }
                    if (marker == M_APPE) {
                        len = getShort(is) - 2;
                        byte[] byteappe = new byte[len];
                        for (int k = 0; k < len; ++k) {
                            byteappe[k] = (byte)is.read();
                        }
                        if (byteappe.length >= 12) {
                            String appe = new String(byteappe, 0, 5, "ISO-8859-1");
                            if (appe.equals("Adobe")) {
                                invert = true;
                            }
                        }
                        continue;
                    }
                    if (marker == M_APP2) {
                        len = getShort(is) - 2;
                        byte[] byteapp2 = new byte[len];
                        for (int k = 0; k < len; ++k) {
                            byteapp2[k] = (byte)is.read();
                        }
                        if (byteapp2.length >= 14) {
                            String app2 = new String(byteapp2, 0, 11, "ISO-8859-1");
                            if (app2.equals("ICC_PROFILE")) {
                                int order = byteapp2[12] & 0xff;
                                int count = byteapp2[13] & 0xff;
                                
                                // some jpeg producers don't know how to count to 1
                                if (order < 1) {
                                	order = 1;
                                }
                                if (count < 1) {
                                	count = 1;
                                }
                                if (icc == null){
                                    icc = new byte[count][];
                                }
                                int idx = order - 1;
                                if( idx >= 0 ) {
                                	icc[idx] = byteapp2;
                                }                                
                            }
                        }
                        continue;
                    }
                    firstPass = false;
                    int markertype = marker(marker);
                    if (markertype == VALID_MARKER) {
                        Utilities.skip(is, 2);
                        if (is.read() != 0x08) {
                            throw new BadElementException(errorID + " must have 8 bits per component.");
                        }
                        scaledHeight = getShort(is);
                        setTop(scaledHeight);
                        scaledWidth = getShort(is);
                        setRight(scaledWidth);
                        colorspace = is.read();
                        bpc = 8;
                        break;
                    }
                    else if (markertype == UNSUPPORTED_MARKER) {
                        throw new BadElementException(errorID + ": unsupported JPEG marker: " + marker);
                    }
                    else if (markertype != NOPARAM_MARKER) {
                        Utilities.skip(is, getShort(is) - 2);
                    }
                }
            }
        }
        finally {
            if (is != null) {
                is.close();
            }
        }
        plainWidth = getWidth();
        plainHeight = getHeight();
        if (icc != null) {
            int total = 0;
            for (int k = 0; k < icc.length; ++k) {
                if (icc[k] == null) {
                    icc = null;
                    return;
                }
                total += icc[k].length - 14;
            }
            byte[] ficc = new byte[total];
            total = 0;
            for (int k = 0; k < icc.length; ++k) {
                System.arraycopy(icc[k], 14, ficc, total, icc[k].length - 14);
                total += icc[k].length - 14;
            }
            try {
            	ICC_Profile icc_prof = ICC_Profile.getInstance(ficc);
            	tagICC(icc_prof);
            }
            catch(IllegalArgumentException e) {
            	// ignore ICC profile if it's invalid.
            }
            icc = null;
        }
    }
1048546
public void saveImages( Element form )
                            throws IOException {
        List<Element> images = DomUtils.getElementsByTagName( form, "img" );
        int imageCount = 1;
        for ( Element image : images ) {
            if ( image.hasAttribute( "src" ) ) {
                String src = image.getAttribute( "src" );
                String imageFormat = parseImageFormat( src );
                String testName = System.getProperty( "TestName" );
                String imgName = parseImageName( testName );
                URL url = new URL( src );
                BufferedImage img = ImageIO.read( url );
                File file = createImageFile( imageCount, imageFormat, imgName );
                if ( !file.exists() ) {
                    file.getParentFile().mkdirs();
                }
                ImageIO.write( img, imageFormat, file );
                imageCount++;
            }
        }
    }
21791
void validate() throws IOException {
		validate(platform, "platform");
		validate(jdk, "JDK");
		validate(executable, "executable name");
		validate(mainClass, "main class");
		validate(outDir, "output folder");

		if (outDir.exists()) {
			if (new File(".").equals(outDir)) {
				throw new IOException("Output directory equals working directory, aborting");
			}
			if (new File("/").equals(outDir)) {
				throw new IOException("Output directory points to root folder.");
			}
		}

		if (classpath.isEmpty()) {
			throw new IOException("Empty class path. Please check your commandline or configuration.");
		}
	}
62341
private void processParameters() throws IOException {
        type = JPEG2000;
        originalType = ORIGINAL_JPEG2000;
        inp = null;
        try {
            if (rawData == null){
                inp = url.openStream();
            }
            else{
                inp = new java.io.ByteArrayInputStream(rawData);
            }
            boxLength = cio_read(4);
            if (boxLength == 0x0000000c) {
                boxType = cio_read(4);
                if (JP2_JP != boxType) {
                    throw new IOException("Expected JP Marker");
                }
                if (0x0d0a870a != cio_read(4)) {
                    throw new IOException("Error with JP Marker");
                }

                jp2_read_boxhdr();
                if (JP2_FTYP != boxType) {
                    throw new IOException("Expected FTYP Marker");
                }
                Utilities.skip(inp, boxLength - 8);
                jp2_read_boxhdr();
                do {
                    if (JP2_JP2H != boxType) {
                        if (boxType == JP2_JP2C) {
                            throw new IOException("Expected JP2H Marker");
                        }
                        Utilities.skip(inp, boxLength - 8);
                        jp2_read_boxhdr();
                    }
                } while(JP2_JP2H != boxType);
                jp2_read_boxhdr();
                if (JP2_IHDR != boxType) {
                    throw new IOException("Expected IHDR Marker");
                }
                scaledHeight = cio_read(4);
                setTop(scaledHeight);
                scaledWidth = cio_read(4);
                setRight(scaledWidth);
                bpc = -1;
            }
            else if (boxLength == 0xff4fff51) {
                Utilities.skip(inp, 4);
                int x1 = cio_read(4);
                int y1 = cio_read(4);
                int x0 = cio_read(4);
                int y0 = cio_read(4);
                Utilities.skip(inp, 16);
                colorspace = cio_read(2);
                bpc = 8;
                scaledHeight = y1 - y0;
                setTop(scaledHeight);
                scaledWidth = x1 - x0;
                setRight(scaledWidth);
            }
            else {
                throw new IOException("Not a valid Jpeg2000 file");
            }
        }
        finally {
            if (inp != null) {
                try{inp.close();}catch(Exception e){}
                inp = null;
            }
        }
        plainWidth = getWidth();
        plainHeight = getHeight();
    }
1161559
public static boolean isKnownByteFormat( BufferedImage image ) {
		int type = image.getType();
		return type != BufferedImage.TYPE_BYTE_INDEXED &&
				type != BufferedImage.TYPE_BYTE_BINARY &&
				type != BufferedImage.TYPE_CUSTOM;
	}
922585
private void processImage() {
		final List<Point2D_F64> leftPts = new ArrayList<>();
		final List<Point2D_F64> rightPts = new ArrayList<>();
		final List<TupleDesc> leftDesc = new ArrayList<>();
		final List<TupleDesc> rightDesc = new ArrayList<>();

		final ProgressMonitor progressMonitor = new ProgressMonitor(this,
				"Compute Feature Information",
				"", 0, 4);
		extractImageFeatures(progressMonitor, 0, imageLeft, leftDesc, leftPts);
		extractImageFeatures(progressMonitor, 2, imageRight, rightDesc, rightPts);

		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				progressMonitor.close();
				scorePanel.setScorer(controlPanel.getSelected());
				scorePanel.setLocation(leftPts, rightPts, leftDesc, rightDesc);
				repaint();
			}
		});
	}
75794
protected void validate() {
    Preconditions.checkState(
        (mMultiImageRequests == null) || (mImageRequest == null),
        "Cannot specify both ImageRequest and FirstAvailableImageRequests!");
    Preconditions.checkState(
        (mDataSourceSupplier == null) ||
            (mMultiImageRequests == null && mImageRequest == null && mLowResImageRequest == null),
        "Cannot specify DataSourceSupplier with other ImageRequests! Use one or the other.");
  }
567745
public Image getImage() throws BadElementException {
        paintCode();
        byte g4[] = CCITTG4Encoder.compress(outBits, bitColumns, codeRows);
        return Image.getInstance(bitColumns, codeRows, false, Image.CCITTG4, (options & PDF417_INVERT_BITMAP) == 0 ? 0 : Image.CCITT_BLACKIS1, g4, null);
    }
90434
private void processImageOuter( ImageBase image ) {
		long startTime = System.currentTimeMillis();

		// this image is owned by only this process and no other. So no need to lock it while
		// processing
		processImage(image);

		// If an old image finished being processes after a more recent one it won't be visualized
		if( !visualizeOnlyMostRecent || startTime > timeOfLastUpdated ) {
			timeOfLastUpdated = startTime;

			// Copy this frame
			renderBitmapImage(bitmapMode,image);

			// Update the visualization
			runOnUiThread(() -> displayView.invalidate());
		}

		// Put the image into the stack if the image type has not changed
		synchronized (boofImage.imageLock) {
			if( boofImage.imageType.isSameType(image.getImageType()))
				boofImage.stackImages.add(image);
		}
	}
1202265
function processImage()
    {
        $destinationImageObject = $this->imageObjectInternal();
        $bbox = $this->textBoundingBox();
        $this->clear();
        $font = $this->font();
        $this->drawText( $font, $this->textColor(), $this->text(), $bbox[6], -$bbox[7], $this->textAngle(),
                         $destinationImageObject );
        return true;
    }
215528
private void createImageValidation(File imageFile) throws IOException {
    synchronized (imageValidatorLock) {
      InjectionHandler.processEvent(InjectionEvent.STANDBY_VALIDATE_CREATE);
      if (!running) {
        // fails the checkpoint
        InjectionHandler.processEvent(InjectionEvent.STANDBY_VALIDATE_CREATE_FAIL);
        throw new IOException("Standby: standby is quiescing");
      }
      imageValidator = new ImageValidator(imageFile);
      imageValidator.start();
    }
  }
1290207
private Set<String> validateJobImage(final String image) {
    final Set<String> errors = Sets.newHashSet();

    if (image == null) {
      errors.add("Image was not specified.");
    } else {
      // Validate image name
      validateImageReference(image, errors);
    }

    return errors;
  }
192860
private void CheckRGBImage(IfdTags metadata, int n) {
    // Samples per Pixel
    long samples = metadata.get(TiffTags.getTagId("SamplesPerPixel")).getFirstNumericValue();
    if (samples < 3)
      validation.addError("Invalid Samples per Pixel", "IFD" + n, samples);

    // Compression
    long comp = metadata.get(TiffTags.getTagId("Compression")).getFirstNumericValue();
    // if (comp != 1 && comp != 32773)
    if (comp < 1)
      validation.addError("Invalid Compression", "IFD" + n, comp);
  }
455134
public synchronized void setBufferedImage(BufferedImage image) {
		// assume the image was initially set before the GUI was invoked
		if( checkEventDispatch && this.img != null ) {
			if( !SwingUtilities.isEventDispatchThread() )
				throw new RuntimeException("Changed image when not in GUI thread?");
		}

		this.img = image;
		if( image != null )
			updateSize(image.getWidth(),image.getHeight());
	}
1071598
private void imageApiUsage() throws ApiException, IOException {
        LOG.info("The Image API usage.");
        Images api = retinaApisInstance.imageApi();
        
        
        LOG.info("Image API: getImageForExpression");
        try (ByteArrayInputStream inputStream = api.getImage(TEXT_1)) {
            //get image's stream;
            if (inputStream.read() == 0) {
                throw new IllegalStateException("A image stream cannot be received.");
            }
        }
        
        LOG.info("Image API: getOverlayImage");
        try (ByteArrayInputStream inputStream = api.compare(TEXT_1, TEXT_2)) {
            //get image's stream;
            if (inputStream.read() == 0) {
                throw new IllegalStateException("A image stream cannot be received.");
            }
        }
        
        LOG.info("Image API: getImageForBulkExpressions");
        List<Image> images = api.getImageBulk(TEXT_1, TERM_1);
        for (Image image : images) {
            LOG.info("Image: imageData size: " + image.getImageData().length);
        }
    }
298434
public function validate() {
        if (!$this->_rules) {
            return true;
        }

        if (!$this->_file) {
            throw new IoException('No file present for validation');
        }

        foreach ($this->_rules as $rule) {
            $method = $rule['method'];

            if (!method_exists($this, $method)) {
                throw new BadMethodCallException(sprintf('Validation method %s does not exist', $method));
            }

            if (!call_user_func_array(array($this, $method), $rule['params'])) {
                throw new ValidationException($rule['message']);
            }
        }

        return true;
    }
179206
@Override
	public void getImageBytes(ByteBuffer buffer) {
		final BufferedImage bi = getImage();
		if (bi != null) {
			buffer.put(ImageUtils.imageToBytes(bi));
		}
	}