private BufferedImage readJPGFile(File srcFile) 
    	throws IOException {
    	
        // Find a JPEG reader which supports reading Rasters.
        Iterator<ImageReader> readers = ImageIO.getImageReadersByFormatName("JPEG");
        ImageReader reader = null;
        while (readers.hasNext()) {
            reader = (ImageReader) readers.next();
            if (reader.canReadRaster())
                break;
        }

        // Set the input.
        ImageInputStream input = ImageIO.createImageInputStream(srcFile);
        reader.setInput(input);

        // Create the image.
        BufferedImage image = null;
        try {
            // Try reading an image (including color conversion).
            image = reader.read(0);
        } catch(IIOException e) {
            // Try reading a Raster (no color conversion).
            Raster raster = reader.readRaster(0, null);

            // Arbitrarily select a BufferedImage type.
            int imageType;
            switch (raster.getNumBands()) {
                case 1:
                    imageType = BufferedImage.TYPE_BYTE_GRAY;
                    break;
                case 3:
                    imageType = BufferedImage.TYPE_3BYTE_BGR;
                    break;
                case 4:
                    imageType = BufferedImage.TYPE_4BYTE_ABGR;
                    break;
                default:
                    throw new UnsupportedOperationException();
            }

            // Create a BufferedImage.
            image = new BufferedImage(raster.getWidth(), raster.getHeight(), imageType);

            // Set the image data.
            image.getRaster().setRect(raster);
        }
        
        return image;
    }