Javax.imageio.iioexception: Can't Read Input File! At Javax.imageio.imageio.read(Unknown Source)e
Coffee Lawmaking Examples for javax.imageio.ImageIO
The following code examples are extracted from open up source projects. You can click to vote upward the examples that are useful to yous.
Instance 1
From project activiti-explorer, under directory /src/chief/java/org/activiti/explorer/util/.
Source file: ImageUtil.java
22
/** * Resizes the given image (passed as {@link InputStream}. If the image is smaller then the given maximum width or height, the epitome volition be proportionally resized. */ public static InputStream smallify(InputStream imageInputStream,String mimeType,int maxWidth,int maxHeight){ try { BufferedImage image=ImageIO.read(imageInputStream); int width=Math.min(image.getWidth(),maxWidth); int height=Math.min(image.getHeight(),maxHeight); Style mode=Way.Automated; if (paradigm.getHeight() > maxHeight) { manner=Mode.FIT_TO_HEIGHT; } if (width != epitome.getWidth() || height != paradigm.getHeight()) { paradigm=Scalr.resize(image,mode,width,height); } ByteArrayOutputStream bos=new ByteArrayOutputStream(); ImageIO.write(image,Constants.MIMETYPE_EXTENSION_MAPPING.get(mimeType),bos); render new ByteArrayInputStream(bos.toByteArray()); } catch ( IOException e) { LOGGER.log(Level.SEVERE,"Exception while resizing image",e); return zero; } } Example ii
From project JaamSim, under directory /com/eteks/sweethome3d/j3d/.
Source file: DAELoader.java
21
/** * Handles the end tag of elements children of "image". */ private void handleImageElementsEnd(Cord name) throws SAXException { if ("init_from".equals(name)) { try { URL textureImageUrl=new URL(baseUrl,getCharacters()); BufferedImage textureImage=ImageIO.read(textureImageUrl); if (textureImage != nix) { TextureLoader textureLoader=new TextureLoader(textureImage); Texture texture=textureLoader.getTexture(); texture.setUserData(textureImageUrl); this.textures.put(this.imageId,texture); } } catch ( IOException ex) { InputAgent.logWarning("%s: \"%s: %s\"",this.baseUrl,ex,getCharacters()); } } else if ("information".equals(name)) { throw new SAXException("<data> not supported"); } } Example 3
From project 16Blocks, under directory /src/chief/java/de/minestar/sixteenblocks/Number/.
Source file: NumberUnit.java
twenty
individual void loadFromBitmap(){ endeavor { BufferedImage img=ImageIO.read(new File(Cadre.getInstance().getDataFolder(),"numbers.png")); int startX=this.number * seven; Color thisColor; int thisWidth=0; for (int y=0; y < img.getHeight(); y++) { int nowX=0; for (int x=startX; x < startX + seven; x++) { thisColor=new Colour(img.getRGB(x,y)); if (y == 0) { if (thisColor.getRed() != 255) { thisWidth++; } } if (thisColor.getGreen() == 255) { this.addBlock(-nowX,img.getHeight() - y - ane,35,(byte)15); } else if (thisColor.getBlue() == 255) { this.addBlock(-nowX,img.getHeight() - y - one,35,(byte)8); } nowX++; if (thisColor.getRed() == 255) { nowX--; } } } this.setWidth(thisWidth); } catch ( Exception e) { e.printStackTrace(); } } Example 4
From project ajah, nether directory /ajah-image/src/main/java/com/ajah/image/.
Source file: AutoCrop.coffee
19
/** * Crops an image based on the value of the top left pixel. * @param information The image data. * @param fuzziness The fuzziness immune for minor deviations (~v is recommended). * @return The new image information, cropped. * @throws IOException If the image could not exist read. */ public static byte[] autoCrop(final byte[] data,final int fuzziness) throws IOException { concluding BufferedImage image=ImageIO.read(new ByteArrayInputStream(information)); final BufferedImage cropped=autoCrop(prototype,fuzziness); final ByteArrayOutputStream out=new ByteArrayOutputStream(); ImageIO.write(cropped,"png",out); return out.toByteArray(); } Case 5
From project android-joedayz, under directory /Proyectos/spring-rest-servidor/src/main/java/com/mycompany/remainder/controller/.
Source file: PersonController.coffee
nineteen
@RequestMapping(value="/person/{id}",method=RequestMethod.Become,headers="Take=paradigm/jpeg, image/jpg, epitome/png, image/gif") public @ResponseBody byte[] getPhoto(@PathVariable("id") Long id){ try { InputStream is=this.getClass().getResourceAsStream("/bella.jpg"); BufferedImage img=ImageIO.read(is); ByteArrayOutputStream bao=new ByteArrayOutputStream(); ImageIO.write(img,"jpg",bao); logger.debug("Retrieving photograph as byte array prototype"); return bao.toByteArray(); } catch ( IOException eastward) { logger.mistake(e); throw new RuntimeException(e); } } Case 6
From project ANNIS, under directory /annis-gui/src/main/java/annis/gui/visualizers/iframe/tree/.
Source file: TigerTreeVisualizer.java
19
@Override public void writeOutput(VisualizerInput input,OutputStream outstream){ this.input=input; AnnisResult result=input.getResult(); List<AbstractImageGraphicsItem> layouts=new LinkedList<AbstractImageGraphicsItem>(); double width=0; double maxheight=0; for ( DirectedGraph<AnnisNode,Edge> m : graphtools.getSyntaxGraphs(input)) { ConstituentLayouter<AbstractImageGraphicsItem> cl=new ConstituentLayouter<AbstractImageGraphicsItem>(m,backend,labeler,styler,input); AbstractImageGraphicsItem item=cl.createLayout(new LayoutOptions(VerticalOrientation.TOP_ROOT,AnnisGraphTools.detectLayoutDirection(result.getGraph()))); Rectangle2D treeSize=detail.getBounds(); maxheight=Math.max(maxheight,treeSize.getHeight()); width+=treeSize.getWidth(); layouts.add(item); } BufferedImage paradigm=new BufferedImage((int)(width + (layouts.size() - 1) * TREE_DISTANCE + 2 * SIDE_MARGIN),(int)(maxheight + 2 * TOP_MARGIN),BufferedImage.TYPE_INT_ARGB); Graphics2D canvas=createCanvas(image); double xOffset=SIDE_MARGIN; for ( AbstractImageGraphicsItem item : layouts) { AffineTransform t=sail.getTransform(); Rectangle2D premises=item.getBounds(); canvas.translate(xOffset,TOP_MARGIN + maxheight - bounds.getHeight()); renderTree(detail,canvas); xOffset+=bounds.getWidth() + TREE_DISTANCE; sheet.setTransform(t); } try { ImageIO.write(epitome,"png",outstream); } catch ( IOException e) { throw new RuntimeException(eastward); } } Instance vii
public Image changeImage(File file,Epitome image) throws IOException { String hash=MD5.asHex(MD5.getHash(file)); if (isBlank(hash)) { throw new IOException("Could not get hash from " + file.getAbsolutePath()); } Epitome existingImage=imageService.getImageByHash(hash); if (existingImage != zero) { log.info("Imported existing Paradigm: {} from the user",existingImage.toString()); file.delete(); return existingImage; } else { image.setHash(hash); BufferedImage rendImage=ImageIO.read(file); paradigm.setHeight(rendImage.getHeight()); epitome.setWidth(rendImage.getWidth()); epitome.setFileSize(file.length()); FileUtils.copyFile(file,new File(imageDirectory + "/" + epitome.getUrl())); file.delete(); log.debug("Imported Image: {} from {}",image.toString(),file.getAbsolutePath()); return imageService.saveOrUpdate(image); } } Example 8
From project arquillian-graphene, nether directory /graphene-selenium/graphene-selenium-impl/src/main/java/org/jboss/arquillian/ajocado/framework/.
Source file: TypedSeleniumImpl.java
19
private BufferedImage decodeBase64Screenshot(Cord screenshotInBase64){ byte[] screenshotPng=Base64.decodeBase64(screenshotInBase64); ByteArrayInputStream inputStream=new ByteArrayInputStream(screenshotPng); BufferedImage result; try { result=ImageIO.read(inputStream); } catch ( IOException e) { throw new RuntimeException(east); } render result; } Instance nine
From project arquillian-rusheye, under directory /rusheye-impl/src/main/java/org/jboss/rusheye/.
Source file: CommandCompare.java
19
public void writeDifferenceImage(){ try { ImageIO.write(result.getDiffImage(),"PNG",output); } take hold of ( Exception eastward) { printErrorMessage(east); System.go out(three); } } Example 10
@Override public void setNode(Node selectedNode){ this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); endeavor { if (selectedNode != zero) { endeavour { Content content=selectedNode.getLookup().lookup(Content.class); byte[] dataSource=new byte[(int)content.getSize()]; int bytesRead=content.read(dataSource,0,content.getSize()); if (bytesRead > 0) { InputStream is=new ByteArrayInputStream(dataSource); Image image=ImageIO.read(is); if (image != null) this.picLabel.setIcon(new javax.swing.ImageIcon(image)); } } catch ( TskException ex) { Logger.getLogger(this.className).log(Level.WARNING,"Fault while trying to display the picture content.",ex); } take hold of ( Exception ex) { Logger.getLogger(this.className).log(Level.WARNING,"Mistake while trying to display the picture content.",ex); } } } finally { this.setCursor(zip); } } Example 11
From project b3log-latke, under directory /latke/src/principal/coffee/org/b3log/latke/image/local/.
Source file: LocalImageService.java
nineteen
@Override public Image makeImage(last List<Image> images){ if (null == images || images.isEmpty()) { return cipher; } effort { final Image firstImage=images.get(0); BufferedImage tmp=ImageIO.read(new ByteArrayInputStream(firstImage.getData())); for (int i=1; i < images.size(); i++) { final Paradigm image=images.get(i); final byte[] data=epitome.getData(); terminal BufferedImage awtImage=ImageIO.read(new ByteArrayInputStream(information)); tmp=splice(tmp,awtImage); } last Image ret=new Image(); final ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream(); ImageIO.write(tmp,"PNG",byteArrayOutputStream); final byte[] information=byteArrayOutputStream.toByteArray(); ret.setData(data); return ret; } grab ( last IOException due east) { throw new RuntimeException(e); } } Example 12
From project BioMAV, under directory /Behavior/src/nl/ru/ai/projects/parrot/tools/.
Source file: TwitterAccess.java
nineteen
/** * Uploads an prototype * @param prototype The paradigm to upload * @param tweet The text of the tweet that needs to be posted with the image */ public void uploadImage(byte[] image,String tweet){ if (!enabled) return; ByteArrayOutputStream baos=new ByteArrayOutputStream(); RenderedImage img=getImageFromCamera(image); try { ImageIO.write(img,"jpg",baos); URL url=new URL("http://api.imgur.com/ii/upload.json"); Cord data=URLEncoder.encode("paradigm","UTF-8") + "=" + URLEncoder.encode(Base64.encodeBase64String(baos.toByteArray()),"UTF-eight"); data+="&" + URLEncoder.encode("key","UTF-8") + "="+ URLEncoder.encode("f9c4861fc0aec595e4a64dd185751d28","UTF-8"); URLConnection conn=url.openConnection(); conn.setDoOutput(true); OutputStreamWriter wr=new OutputStreamWriter(conn.getOutputStream()); wr.write(data); wr.flush(); StringBuffer buffer=new StringBuffer(); InputStreamReader isr=new InputStreamReader(conn.getInputStream()); Reader in=new BufferedReader(isr); int ch; while ((ch=in.read()) > -1) buffer.suspend((char)ch); String imgURL=processJSON(buffer.toString()); setStatus(tweet + " " + imgURL,100); } take hold of ( IOException e1) { e1.printStackTrace(); } } Example 13
From project blogs, under directory /asking-mappers/src/chief/java/com/wicketinaction/requestmappers/resources/images/.
Source file: ImageResourceReference.java
19
/** * Generates an image with a label. For existent life application this method will read the paradigm bytes from external source. * @param characterization the paradigm text to return * @return */ individual byte[] getImageAsBytes(String characterization){ BufferedImage image=new BufferedImage(800,600,BufferedImage.TYPE_INT_RGB); Graphics2D k=(Graphics2D)prototype.getGraphics(); thou.setColor(Color.BLACK); one thousand.setBackground(Color.WHITE); g.clearRect(0,0,image.getWidth(),image.getHeight()); chiliad.setFont(new Font("SansSerif",Font.PLAIN,48)); chiliad.drawString(label,50,50); chiliad.dispose(); Iterator<ImageWriter> writers=ImageIO.getImageWritersByFormatName("jpg"); ImageWriter writer=writers.adjacent(); if (writer == goose egg) { throw new RuntimeException("JPG not supported?!"); } terminal ByteArrayOutputStream out=new ByteArrayOutputStream(); byte[] imageBytes=zippo; try { ImageOutputStream imageOut=ImageIO.createImageOutputStream(out); writer.setOutput(imageOut); writer.write(image); imageOut.shut(); imageBytes=out.toByteArray(); } catch ( IOException e) { e.printStackTrace(); } return imageBytes; } Example 14
From project brut.apktool, under directory /apktool-lib/src/main/java/brut/androlib/res/decoder/.
Source file: Res9patchStreamDecoder.java
xix
public void decode(InputStream in,OutputStream out) throws AndrolibException { try { byte[] data=IOUtils.toByteArray(in); BufferedImage im=ImageIO.read(new ByteArrayInputStream(information)); int westward=im.getWidth(), h=im.getHeight(); BufferedImage im2=new BufferedImage(due west + 2,h + 2,BufferedImage.TYPE_4BYTE_ABGR); if (im.getType() == BufferedImage.TYPE_4BYTE_ABGR) { im2.getRaster().setRect(1,one,im.getRaster()); } else { im2.getGraphics().drawImage(im,i,1,null); } NinePatch np=getNinePatch(data); drawHLine(im2,h + ane,np.padLeft + 1,w - np.padRight); drawVLine(im2,w + 1,np.padTop + i,h - np.padBottom); int[] xDivs=np.xDivs; for (int i=0; i < xDivs.length; i+=2) { drawHLine(im2,0,xDivs[i] + 1,xDivs[i + i]); } int[] yDivs=np.yDivs; for (int i=0; i < yDivs.length; i+=ii) { drawVLine(im2,0,yDivs[i] + 1,yDivs[i + 1]); } ImageIO.write(im2,"png",out); } catch ( IOException ex) { throw new AndrolibException(ex); } } Example 15
From project capedwarf-bluish, under directory /images/src/main/java/org/jboss/capedwarf/images/util/.
Source file: ImageUtils.java
19
public static byte[] getByteArray(RenderedImage image,String formatName){ endeavor { ByteArrayOutputStream byteArrayOutputStream=new ByteArrayOutputStream(); ImageIO.write(image,formatName,byteArrayOutputStream); render byteArrayOutputStream.toByteArray(); } take hold of ( IOException e) { throw new RuntimeException(eastward); } } Case xvi
From project Carolina-Digital-Repository, under directory /djatoka-cdr/src/gov/lanl/adore/djatoka/io/author/.
Source file: PNGWriter.java
nineteen
/** * Write a BufferedImage instance using implementation to the provided OutputStream. * @param bi a BufferedImage instance to exist serialized * @param os OutputStream to output the image to * @throws FormatIOException */ public void write(BufferedImage bi,OutputStream os) throws FormatIOException { if (bi != null) { BufferedOutputStream bos=zippo; endeavour { bos=new BufferedOutputStream(bone); ImageIO.write(bi,"png",bos); } grab ( IOException eastward) { logger.error(e,e); } } } Example 17
private static BufferedImage loadImage(String imageFilePath){ attempt { return ImageIO.read(new File(imageFilePath)); } take hold of ( IOException e) { return null; } } Example 18
From project charts4j, under directory /src/test/java/com/googlecode/charts4j/example/.
Source file: SwingExample.java
19
/** * Display the nautical chart in a swing window. * @param urlString the url string to display. * @throws IOException */ private static void displayUrlString(terminal String urlString) throws IOException { JFrame frame=new JFrame(); JLabel label=new JLabel(new ImageIcon(ImageIO.read(new URL(urlString)))); frame.getContentPane().add(characterization,BorderLayout.CENTER); frame.pack(); frame.setVisible(truthful); } Instance xix
From project Chess_1, under directory /src/chess/gui/.
Source file: ImageDisplay.java
19
/** * Constructs an object that knows how to display an epitome. Looks for the named file showtime in the jar file, then in the current directory. * @param imageFilename proper name of file containing image */ public ImageDisplay(Form cl) throws IOException { this.cl=cl; imageFilename=cl.getName().supersede('.','/'); URL url=cl.getClassLoader().getResource(imageFilename + imageExtension); if (url == null) throw new FileNotFoundException(imageFilename + imageExtension + " not found."); tintedVersions.put("",ImageIO.read(url)); } Example xx
From project ChkBugReport, under directory /src/com/sonyericsson/chkbugreport/plugins/logs/event/.
Source file: AMChart.java
xix
public Cord cease(Module br){ if (mLastState != STATE_UNKNOWN) { drawState(Due west); } if (mUsed == 0) { return null; } Cord fn="amchart_" + hashCode() + ".png"; try { ImageIO.write(mImg,"png",new File(br.getBaseDir() + fn)); } grab ( IOException east) { eastward.printStackTrace(); } render fn; } Example 21
From project chukwa, under directory /src/main/java/org/apache/hadoop/chukwa/hicc/.
Source file: ImageSlicer.java
19
public BufferedImage prepare(String filename){ try { src=ImageIO.read(new File(filename)); } catch ( IOException due east) { log.error("Image file does not exist:" + filename + ", can not render image."); } XYData fullSize=new XYData(1,1); while (fullSize.getX() < src.getWidth() || fullSize.getY() < src.getHeight()) { fullSize.set(fullSize.getX() * 2,fullSize.getY() * 2); } float scaleX=(float)fullSize.getX() / src.getWidth(); float scaleY=(float)fullSize.getY() / src.getHeight(); log.info("Image size: (" + src.getWidth() + ","+ src.getHeight()+ ")"); log.info("Scale size: (" + scaleX + ","+ scaleY+ ")"); AffineTransform at=AffineTransform.getScaleInstance(scaleX,scaleY); AffineTransformOp op=new AffineTransformOp(at,AffineTransformOp.TYPE_BILINEAR); BufferedImage dest=op.filter(src,zippo); return dest; } Example 22
From projection CIShell, under directory /cadre/org.cishell.utilities/src/org/cishell/utilities/.
Source file: FileUtilities.java
19
public static File writeBufferedImageIntoTemporaryDirectory(BufferedImage bufferedImage,String imageType) throws IOException, Exception { String temporaryDirectoryPath=getDefaultTemporaryDirectory(); File temporaryImageFile=createTemporaryFileInTemporaryDirectory(temporaryDirectoryPath,"image-",imageType); if (!ImageIO.write(bufferedImage,imageType,temporaryImageFile)) { throw new Exception("No valid epitome writer was institute for the paradigm type " + imageType); } render temporaryImageFile; } Example 23
From projection citrus-sample, nether directory /archetype-webx-quickstart/src/principal/resource/archetype-resources/src/chief/java/app1/module/screen/unproblematic/.
Source file: SayHiImage.java
nineteen
private void writeImage(OutputStream out) throws IOException { BufferedImage img=new BufferedImage(800,600,BufferedImage.TYPE_INT_RGB); Graphics2D g2d=img.createGraphics(); g2d.setPaint(Colour.crimson); g2d.setFont(new Font("Serif",Font.Assuming,36)); g2d.drawString("Hullo there, how are you doing today?",5,g2d.getFontMetrics().getHeight()); g2d.dispose(); ImageIO.write(img,"jpg",out); } Example 24
From project Clotho-Core, under directory /ClothoApps/WikiEditorPanel/src/org/clothocad/wikieditorpanel/.
Source file: WikiEditorPanel.java
19
private void createEmptyHTMLPage(){ File file=new File(Attachment.cacheDir.getAbsolutePath() + File.separator + "pencilandpaper.png"); if (!file.exists()) { BufferedImage img=(BufferedImage)ImageUtilities.loadImage("org/clothocad/wikieditorpanel/pencilandpaper.png",false); if (img != aught) { effort { ImageIO.write(img,"png",file); } grab ( IOException ex) { } } } String imagelink=file.getAbsolutePath(); JEditorPane pane=new JEditorPane("text/html","<html>\n<body>\due north<p marshal=\"middle\"> </p>\n<p align=\"center\"> </p>\n<p align=\"center\"><img src=\"file:\\" + File.separator + imagelink+ "\" width=\"110\" height=\"87\" alt=\"doubleClick\" /></p>\n<p align=\"centre\"> </p>\n<p marshal=\"middle\" class=\"style1\">Double click to add together text.</p>\due north</body>\northward</html>"); pane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES,Boolean.Truthful); pane.setFont(new Font("Arial",Font.Plainly,12)); pane.setBackground(htmlEmpty); pane.setForeground(new Color(255,255,255)); emptyHTMLPage=(HTMLDocument)pane.getDocument(); } Example 25
public static void initialize(){ if (!checkGetSystemClassLoaderAccess()) { LOGGER.warn("Admission to system course loader restricted - AWTInitializer won't be run"); return; } Thread thread=Thread.currentThread(); ClassLoader initialTCCL=thread.getContextClassLoader(); ImageInputStream testStream=nix; effort { ClassLoader systemCL=ClassLoader.getSystemClassLoader(); thread.setContextClassLoader(systemCL); ImageIO.setUseCache(faux); testStream=ImageIO.createImageInputStream(new ByteArrayInputStream(new byte[0])); Toolkit.getDefaultToolkit().getSystemEventQueue(); } take hold of ( IOException e) { LOGGER.fault(e.getMessage(),due east); } finally { if (testStream != null) { try { testStream.close(); } catch ( IOException e) { LOGGER.error(e.getMessage(),e); } } thread.setContextClassLoader(initialTCCL); } } Example 26
From project CraftMania, under directory /CraftMania/src/org/craftmania/game/.
Source file: TextureStorage.java
19
public static Texture loadStichedTexture(String id,Cord resource0,Cord resource1) throws IOException { BufferedImage img0=ImageIO.read(getTextureFile(resource0)); BufferedImage img1=ImageIO.read(getTextureFile(resource1)); if (img0.getWidth() != img1.getWidth()) { throw new IOException("Images exercise not have the same width"); } BufferedImage img=new BufferedImage(img0.getWidth(),img0.getHeight() + img1.getHeight(),img0.getType()); Graphics2D g=img.createGraphics(); g.drawImage(img0,0,0,null); g.drawImage(img1,0,img0.getHeight(),null); g.dispose(); render loadTexture(id,img); } Example 27
From project Custom-Salem, under directory /src/haven/.
Source file: LocalMiniMap.java
19
private void store(BufferedImage img,Coord cg){ if (!Config.store_map) { render; } Coord c=cg.sub(sp); String fileName=String.format("%south/map/%southward/tile_%d_%d.png",Config.userhome,session,c.10,c.y); File outputfile=new File(fileName); endeavour { ImageIO.write(img,"png",outputfile); } catch ( IOException due east) { } } Instance 28
From project dawn-common, under directory /org.dawb.hdf5/src/ncsa/hdf/view/.
Source file: Tools.java
19
/** * Relieve a BufferedImage into an image file. * @param image the BufferedImage to save. * @param file the image file. * @param type the image type. */ public static void saveImageAs(BufferedImage image,File file,String blazon) throws Exception { if (image == null) { throw new NullPointerException("The source image is null."); } ImageIO.write(prototype,blazon,file); } Example 29
From project dawn-ui, under directory /org.dawb.workbench.plotting/src/org/dawb/workbench/plotting/press/.
Source file: PlotExportPrintUtil.java
nineteen
private static void savePostScript(File imageFile,Image image) throws FileNotFoundException { ByteArrayOutputStream os=new ByteArrayOutputStream(); RenderedImage awtImage=convertToAWT(image.getImageData()); try { ImageIO.write(awtImage,"png",os); } catch ( IOException e) { logger.error("Could not write to OutputStream",e); } try { ByteArrayInputStream inputStream=new ByteArrayInputStream(os.toByteArray()); InputStream is=new BufferedInputStream(inputStream); OutputStream fos=new BufferedOutputStream(new FileOutputStream(imageFile.getAbsolutePath())); DocFlavor flavor=DocFlavor.INPUT_STREAM.GIF; StreamPrintServiceFactory[] factories=StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor,DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType()); if (factories.length > 0) { StreamPrintService service=factories[0].getPrintService(fos); DocPrintJob job=service.createPrintJob(); Dr. doctor=new SimpleDoc(is,flavour,null); PrintJobWatcher pjDone=new PrintJobWatcher(chore); task.print(dr.,null); pjDone.waitUntilDone(); } is.close(); fos.close(); } catch ( PrintException e) { logger.error("Could not print to PostScript",e); } take hold of ( IOException e) { logger.mistake("IO fault",e); } } Instance 30
From project drools-planner, nether directory /drools-planner-benchmark/src/main/java/org/drools/planner/benchmark/core/statistic/.
Source file: AbstractProblemStatistic.coffee
19
protected File writeChartToImageFile(JFreeChart chart,String fileNameBase){ BufferedImage chartImage=chart.createBufferedImage(1024,768); File chartFile=new File(problemBenchmark.getProblemReportDirectory(),fileNameBase + ".png"); OutputStream out=null; try { out=new FileOutputStream(chartFile); ImageIO.write(chartImage,"png",out); } catch ( IOException e) { throw new IllegalArgumentException("Problem writing chartFile: " + chartFile,eastward); } finally { IOUtils.closeQuietly(out); } return chartFile; } Case 31
From project drugis-common, under directory /mutual-extra/src/master/java/org/drugis/common/gui/.
Source file: ImageExporter.java
xix
private static void writePNG(String filename,BufferedImage b){ try { ImageIO.write(b,"png",new File(filename)); } take hold of ( IOException east) { throw new RuntimeException(due east); } } Example 32
From projection edg-examples, under directory /chunchun/src/jbossas/coffee/com/jboss/datagrid/chunchun/jsf/.
Source file: InitializeCache.java
19
private BufferedImage loadImageFromFile(Cord fileName){ BufferedImage prototype=null; endeavour { image=ImageIO.read(this.getClass().getClassLoader().getResourceAsStream(fileName)); render image; } grab ( IOException e) { throw new RuntimeException("Unable to load image from file " + fileName); } } Example 33
From project en4j, under directory /NBPlatformApp/NoteContentViewModule/src/main/coffee/com/rubenlaguna/en4j/NoteContentViewModule/.
Source file: ENMLReplacedElementFactory.java
xix
private ReplacedElement loadImage(LayoutContext context,String hash){ ReplacedElement toReturn=nil; InputStream is=getImage(hash); Image image=null; if (is == null) { render brokenImage(context,100,100); } endeavour { image=ImageIO.read(is); } catch ( IOException due east) { LOG.log(Level.Warning,"exception defenseless:",e); } finally { try { is.close(); } catch ( IOException east) { } } if (image == null) { render brokenImage(context,100,100); } ImageIcon icon=new ImageIcon(image); JLabel cc=new JLabel(icon); cc.setSize(cc.getPreferredSize()); FSCanvas canvas=context.getCanvas(); if (canvass instanceof JComponent) { ((JComponent)canvas).add together(cc); } toReturn=new SwingReplacedElement(cc){ public boolean isRequiresInteractivePaint(){ return false; } } ; render toReturn; } Instance 34
From project encog-coffee-core, under directory /src/main/coffee/org/encog/ca/program/generic/.
Source file: GenericIO.java
xix
public static void salvage(CARunner runner,File f){ attempt { EncogDirectoryPersistence.saveObject(new File(FileUtil.forceExtension(f.toString(),"eg")),runner.getUniverse()); SerializeObject.save(new File(FileUtil.forceExtension(f.toString(),"bin")),(Serializable)runner.getPhysics()); BasicCAVisualizer visualizer=new BasicCAVisualizer(runner.getUniverse()); Image img=visualizer.visualize(); ImageIO.write((RenderedImage)img,"png",new File(FileUtil.forceExtension(f.toString(),"png"))); } catch ( IOException ex) { throw new CellularAutomataError(ex); } } Example 35
From project encog-java-examples, under directory /src/chief/java/org/encog/examples/neural/image/.
Source file: ImageNeuralNetwork.java
19
private void processNetwork() throws IOException { Organization.out.println("Downsampling images..."); for ( concluding ImagePair pair : this.imageList) { final MLData ideal=new BasicMLData(this.outputCount); final int idx=pair.getIdentity(); for (int i=0; i < this.outputCount; i++) { if (i == idx) { platonic.setData(i,1); } else { ideal.setData(i,-1); } } final Image img=ImageIO.read(pair.getFile()); terminal ImageMLData information=new ImageMLData(img); this.training.add(data,ideal); } final String strHidden1=getArg("hidden1"); final String strHidden2=getArg("hidden2"); this.training.downsample(this.downsampleHeight,this.downsampleWidth); final int hidden1=Integer.parseInt(strHidden1); concluding int hidden2=Integer.parseInt(strHidden2); this.network=EncogUtility.simpleFeedForward(this.preparation.getInputSize(),hidden1,hidden2,this.training.getIdealSize(),true); System.out.println("Created network: " + this.network.toString()); } Instance 36
From projection encog-java-workbench, under directory /src/primary/java/org/encog/workbench/tabs/files/.
Source file: ImageFileTab.java
19
public ImageFileTab(ProjectFile file){ super(file); try { this.paradigm=ImageIO.read(file.getFile()); } take hold of ( IOException e) { EncogWorkBench.displayError("Error Loading Prototype",east); } } Example 37
From project engine, under directory /main/com/midtro/platform/modules/assets/types/.
Source file: ImageAssembler.java
nineteen
/** * {@inheritDoc} */ @Override public void assemble(Cord assetName,Cord fileName,AssetConfig config,Map<Cord,Asset<?>> store) throws Exception { Image img=nix; switch (config.getMountType()) { instance FILE: img=ImageIO.read(new File(config.getFileLocation() + fileName.supercede('/',File.separatorChar))); break; case CACHE: img=ImageIO.read(new File(config.getCacheLocation() + fileName.supplant('/',File.separatorChar))); break; case URL: img=ImageIO.read(new URL(config.getUrlLocation() + fileName)); break; default : throw new IllegalStateException("Unknown mount type"); } store.put("image." + assetName,new ImageAsset(assetName,img)); } Example 38
From project entando-core-engine, under directory /src/main/java/com/agiletec/plugins/jacms/aps/organization/services/resource/model/imageresizer/.
Source file: DefaultImageResizer.java
xix
@Override public void saveResizedImage(ImageIcon imageIcon,String filePath,ImageResourceDimension dimension) throws ApsSystemException { Paradigm paradigm=imageIcon.getImage(); double scale=this.computeScale(image.getWidth(null),image.getHeight(null),dimension.getDimx(),dimension.getDimy()); int scaledW=(int)(scale * paradigm.getWidth(zip)); int scaledH=(int)(scale * image.getHeight(null)); BufferedImage outImage=new BufferedImage(scaledW,scaledH,BufferedImage.TYPE_INT_RGB); AffineTransform tx=new AffineTransform(); tx.scale(scale,scale); Graphics2D g2d=outImage.createGraphics(); g2d.setRenderingHint(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY); g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,RenderingHints.VALUE_COLOR_RENDER_QUALITY); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); g2d.drawImage(image,tx,nil); g2d.dispose(); try { File file=new File(filePath); ImageIO.write(outImage,this.getFileExtension(filePath),file); } take hold of ( Throwable t) { String msg=this.getClass().getName() + ": saveImageResized: " + t.toString(); ApsSystemUtils.getLogger().throwing(this.getClass().getName(),"saveImageResized",t); throw new ApsSystemException(msg,t); } } Instance 39
From project faces, nether directory /Proyectos/showcase/src/chief/java/org/primefaces/examples/view/.
Source file: DynamicImageController.java
19
public DynamicImageController(){ try { BufferedImage bufferedImg=new BufferedImage(100,25,BufferedImage.TYPE_INT_RGB); Graphics2D g2=bufferedImg.createGraphics(); g2.drawString("This is a text",0,10); ByteArrayOutputStream os=new ByteArrayOutputStream(); ImageIO.write(bufferedImg,"png",os); graphicText=new DefaultStreamedContent(new ByteArrayInputStream(os.toByteArray()),"epitome/png"); JFreeChart jfreechart=ChartFactory.createPieChart("Turkish Cities",createDataset(),truthful,true,imitation); File chartFile=new File("dynamichart"); ChartUtilities.saveChartAsPNG(chartFile,jfreechart,375,300); chart=new DefaultStreamedContent(new FileInputStream(chartFile),"paradigm/png"); File barcodeFile=new File("dynamicbarcode"); BarcodeImageHandler.saveJPEG(BarcodeFactory.createCode128("PRIMEFACES"),barcodeFile); barcode=new DefaultStreamedContent(new FileInputStream(barcodeFile),"image/jpeg"); } take hold of ( Exception eastward) { e.printStackTrace(); } } Instance 40
From project FBReaderJ, under directory /obsolete/swing/src/org/geometerplus/zlibrary/ui/swing/image/.
Source file: ZLSwingImageManager.coffee
19
public ZLSwingImageData getImageData(ZLImage image){ if (image instanceof ZLSingleImage) { if ("image/palm".equals(((ZLSingleImage)image).mimeType())) { return new ZLSwingImageData(convertFromPalmImageFormat(((ZLSingleImage)image).byteData())); } try { final BufferedImage awtImage=ImageIO.read(new ByteArrayInputStream(((ZLSingleImage)paradigm).byteData())); return new ZLSwingImageData(awtImage); } catch ( IOException e) { render zilch; } } else { return null; } } Example 41
From project flyingsaucer, under directory /flight-saucer-core/src/main/java/org/xhtmlrenderer/swing/.
Source file: ImageResourceLoader.coffee
19
public static ImageResource loadImageResourceFromUri(concluding Cord uri){ StreamResource sr=new StreamResource(uri); InputStream is; ImageResource ir=null; attempt { sr.connect(); is=sr.bufferedStream(); endeavour { BufferedImage img=ImageIO.read(is); if (img == null) { throw new IOException("ImageIO.read() returned nix"); } ir=createImageResource(uri,img); } catch ( FileNotFoundException e) { XRLog.exception("Can't read epitome file; image at URI '" + uri + "' not found"); } catch ( IOException east) { XRLog.exception("Can't read image file; unexpected problem for URI '" + uri + "'",due east); } finally { sr.close(); } } catch ( IOException e) { XRLog.exception("Can't open stream for URI '" + uri + "': "+ east.getMessage()); } if (ir == null) { ir=createImageResource(uri,zip); } return ir; } Example 42
public BufferedImage loadImageFromTexturePack(RenderEngine renderEngine,String path) throws IOException { InputStream paradigm=customer.field_71418_C.func_77292_e().func_77532_a(path); if (image == nix) { throw new RuntimeException(String.format("The requested image path %south is not found",path)); } BufferedImage effect=ImageIO.read(paradigm); if (consequence == null) { throw new RuntimeException(Cord.format("The requested image path %s appears to exist corrupted",path)); } render effect; } Example 43
@Override public Image fromURL(terminal URL url) throws IOException { if (repository != zero && repository.exists()) { if (logger.isDebugEnabled()) { logger.debug("Getting Image from cache [" + repository.getAbsolutePath() + "]"); } File file=getFileFromURL(url,0,0); if (file.exists()) { if (logger.isDebugEnabled()) { logger.debug("Getting Prototype [" + file.getName() + "] from cache"); } BufferedImage buf=ImageIO.read(file); Image paradigm=new Image(buf); image.setUrl(url); return image; } else { Image image=super.fromURL(url); image.setUrl(url); ImageIO.write(image.getBufferedImage(),Image.ContentType.PNG.getSuffix(),file); if (logger.isDebugEnabled()) { logger.debug("Wrote Epitome (original) [" + file.getName() + ", "+ image.getWidth()+ "px past "+ prototype.getHeight()+ "px] to cache"); } return image; } } logger.warn("Failed to enshroud Image [" + url + "], returning without caching!"); return super.fromURL(url); } Example 44
From project freemind, nether directory /freemind/accessories/plugins/.
Source file: ExportToImage.java
xix
/** * Export paradigm. */ public boolean exportToImage(BufferedImage paradigm,String type,String description){ File chosenFile=chooseFile(type,description,null); if (chosenFile == null) { render faux; } try { getController().getFrame().setWaitingCursor(true); FileOutputStream out=new FileOutputStream(chosenFile); ImageIO.write(epitome,type,out); out.close(); } catch ( IOException e1) { freemind.main.Resource.getInstance().logException(e1); } getController().getFrame().setWaitingCursor(false); return truthful; } Case 45
From projection GAIL, nether directory /src/gail/filigree/.
Source file: Resources.coffee
19
/** * Loads image resources inside the .jar packege. For instance, if "paradigm.jpg" is into the foo.bar bundle, the string to load information technology would exist "/foo/bar/epitome.jpg". * @param resourceLocation * @return */ public static BufferedImage loadImageResource(String resourceLocation){ URL url=Resource.class.getResource(resourceLocation); BufferedImage img=nothing; try { img=ImageIO.read(url); } catch ( IOException ex) { Logger.getLogger(Resources.course.getName()).log(Level.SEVERE,aught,ex); } render img; } Example 46
From project Game_3, under directory /java/src/playn/java/.
Source file: JavaAssets.coffee
19
@Override protected Image doGetImage(String path){ JavaGraphics graphics=platform.graphics(); Exception error=nada; for ( Calibration.ScaledResource rsrc : graphics.ctx().calibration.getScaledResources(pathPrefix + path)) { try { return graphics.createStaticImage(ImageIO.read(requireResource(rsrc.path)),rsrc.scale); } catch ( FileNotFoundException fnfe) { error=fnfe; } catch ( Exception e) { error=east; break; } } PlayN.log().warn("Could not load paradigm: " + pathPrefix + path,mistake); return graphics.createErrorImage(mistake != null ? error : new FileNotFoundException(path)); } Case 47
From project GeoBI, under directory /impress/src/master/java/org/mapfish/print/output/.
Source file: ImageOutputFactory.java
19
private void drawImage(OutputStream out,List<? extends RenderedImage> images) throws IOException { ParameterBlock pbMosaic=new ParameterBlock(); float tiptop=0; bladder width=0; int i=0; for ( RenderedImage source : images) { i++; LOGGER.debug("Adding page epitome " + i + " bounds: ["+ 0+ ","+ summit+ " "+ source.getWidth()+ ","+ (height + source.getHeight())+ "]"); ParameterBlock pbTranslate=new ParameterBlock(); pbTranslate.addSource(source); pbTranslate.add together(0f); pbTranslate.add(height); RenderedOp translated=JAI.create("translate",pbTranslate); pbMosaic.addSource(translated); elevation+=source.getHeight() + MARGIN; if (width < source.getWidth()) width=source.getWidth(); } TileCache cache=JAI.createTileCache((long)(height * width * 400)); RenderingHints hints=new RenderingHints(JAI.KEY_TILE_CACHE,cache); RenderedOp mosaic=JAI.create("mosaic",pbMosaic,hints); ImageIO.write(mosaic,"TIFF",out); } Example 48
From project geolatte-maprenderer, under directory /src/master/coffee/org/geolatte/maprenderer/sld/graphics/.
Source file: ExternalGraphicsRepository.java
xix
/** * Retrieves prototype or SVG from path and stores information technology in the cache (svg or image cache) * @param uri * @param path * @throws IOException */ private void retrieveAndStore(Cord uri,String path) throws IOException { InputStream inputStream=getResourceAsInputStream(path); if (inputStream == zero) { throw new IOException(String.format("Graphics file %s not found on classpath.",path)); } BufferedImage img=ImageIO.read(inputStream); if (img != zippo) { storeInCache(new ImageKey(uri),img); return; } inputStream=getResourceAsInputStream(path); SVGDocument svg=SVGDocumentIO.read(uri,inputStream); if (svg != null) { storeInSvgCache(uri,svg); return; } throw new IOException("File " + path + " is neither image nor svg."); } Instance 49
From project geolatte-mapserver, nether directory /src/main/coffee/org/geolatte/mapserver/img/.
Source file: JAIImaging.java
19
/** * {@inheritDoc} */ @Override public TileImage read(InputStream is,int x,int y,boolean forceArgb) throws IOException { BufferedImage bi=ImageIO.read(is); if (forceArgb) { BufferedImage rgbImage=new BufferedImage(bi.getWidth(),bi.getHeight(),BufferedImage.TYPE_INT_ARGB); rgbImage.createGraphics().drawImage(bi,0,0,null,null); bi=rgbImage; } RenderedOp op=TranslateDescriptor.create(bi,(float)x,(float)y,null,zip); PlanarImage prototype=op.createInstance(); render new JAITileImage(image); } Example 50
From project geronimo-javamail, under directory /geronimo-javamail_1.iv/geronimo-javamail_1.4_provider/src/principal/java/org/apache/geronimo/javamail/handlers/.
Source file: AbstractImageHandler.coffee
19
public Object getContent(DataSource ds) throws IOException { Iterator i=ImageIO.getImageReadersByMIMEType(flavour.getMimeType()); if (!i.hasNext()) { throw new UnsupportedDataTypeException("Unknown image blazon " + season.getMimeType()); } ImageReader reader=(ImageReader)i.next(); ImageInputStream iis=ImageIO.createImageInputStream(ds.getInputStream()); reader.setInput(iis); render reader.read(0); } Example 51
From project gitblit, under directory /src/com/gitblit/build/.
Source file: BuildThumbnails.java
nineteen
/** * Return the dimensions of the specified image file. * @param file * @render dimensions of the epitome * @throws IOException */ public static Dimension getImageDimensions(File file) throws IOException { ImageInputStream in=ImageIO.createImageInputStream(file); try { final Iterator<ImageReader> readers=ImageIO.getImageReaders(in); if (readers.hasNext()) { ImageReader reader=readers.side by side(); endeavor { reader.setInput(in); return new Dimension(reader.getWidth(0),reader.getHeight(0)); } finally { reader.dispose(); } } } finally { if (in != nada) { in.close(); } } return null; } Example 52
From project glg2d, under directory /src/test/java/glg2d/.
Source file: StressTest.java
19
@Exam public void imageTest() throws Exception { concluding int numimages=1000; final Image prototype=ImageIO.read(StressTest.grade.getClassLoader().getResource("duke.gif")); TimedPainter painter=new TimedPainter(){ @Override protected void pigment( Graphics2D g2d){ int x=300; int y=400; for (int i=0; i < numimages; i++) { g2d.drawImage(image,rand.nextInt(x),rand.nextInt(y),rand.nextInt(x),rand.nextInt(y),null); } } } ; tester.setPainter(painter); painter.waitAndLogTimes("images"); } Instance 53
From projection Gmote, under directory /gmoteserver/src/org/gmote/server/.
Source file: GmoteHttpServer.java
19
private void sendImage(File originalImagePath,BufferedOutputStream dataOut) throws InterruptedException, ImageFormatException, IOException { LOGGER.info("Converting paradigm to smaller calibration"); Image epitome=Toolkit.getDefaultToolkit().getImage(originalImagePath.getAbsolutePath()); MediaTracker mediaTracker=new MediaTracker(new Container()); mediaTracker.addImage(image,0); mediaTracker.waitForID(0); int imageWidth=prototype.getWidth(null); int imageHeight=image.getHeight(null); int thumbWidth=imageWidth; int thumbHeight=imageHeight; int MAX_SIZE=500; if (imageWidth > MAX_SIZE || imageHeight > MAX_SIZE) { double imageRatio=(double)imageWidth / (double)imageHeight; if (imageWidth > imageHeight) { thumbWidth=MAX_SIZE; thumbHeight=(int)(thumbWidth / imageRatio); } else { thumbHeight=MAX_SIZE; thumbWidth=(int)(thumbHeight * imageRatio); } } BufferedImage thumbImage; thumbImage=new BufferedImage(thumbWidth,thumbHeight,BufferedImage.TYPE_INT_RGB); Graphics2D graphics2D=thumbImage.createGraphics(); graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BILINEAR); graphics2D.drawImage(image,0,0,thumbWidth,thumbHeight,null); if (PlatformUtil.isLinux()) { ImageIO.write(thumbImage,"JPEG",dataOut); } else { JPEGImageEncoder encoder=JPEGCodec.createJPEGEncoder(dataOut); JPEGEncodeParam param=encoder.getDefaultJPEGEncodeParam(thumbImage); bladder quality=80; param.setQuality(quality / 100.0f,false); encoder.encode(thumbImage,param); } dataOut.close(); LOGGER.info("Done sending image"); } Example 54
From projection GraphLab, under directory /src/graphlab/graph/graph/.
Source file: GraphModel.java
19
public void setBackgroundImageFile(File imageFile){ backgroundImageFile=imageFile; try { backgroundImage=ImageIO.read(imageFile); } catch ( Exception e) { System.out.println("Fault loading prototype file"); } fireGraphChange(REPAINT_GRAPH_GRAPH_CHANGE,aught,aught); } Example 55
From project greenhouse, under directory /src/main/coffee/com/springsource/greenhouse/utils/.
Source file: ImageUtils.coffee
19
/** * Scale the image stored in the byte assortment to a specific width. */ public static byte[] scaleImageToWidth(byte[] originalBytes,int scaledWidth) throws IOException { BufferedImage originalImage=ImageIO.read(new ByteArrayInputStream(originalBytes)); int originalWidth=originalImage.getWidth(); if (originalWidth <= scaledWidth) { render originalBytes; } int scaledHeight=(int)(originalImage.getHeight() * ((float)scaledWidth / (bladder)originalWidth)); BufferedImage scaledImage=new BufferedImage(scaledWidth,scaledHeight,BufferedImage.TYPE_INT_RGB); Graphics2D one thousand=scaledImage.createGraphics(); g.drawImage(originalImage,0,0,scaledWidth,scaledHeight,null); g.dispose(); ByteArrayOutputStream byteStream=new ByteArrayOutputStream(); ImageIO.write(scaledImage,"jpeg",byteStream); return byteStream.toByteArray(); } Example 56
From projection gridland, nether directory /src/org/grid/server/.
Source file: Field.coffee
19
private static Dimension loadImage(File f,Set<Position>[] flags,Position[] hqs,Vector<Position> walls) throws IOException { BufferedImage src=ImageIO.read(f); for (int j=0; j < src.getHeight(); j++) { for (int i=0; i < src.getWidth(); i++) { Color colour=new Color(src.getRGB(i,j)); if (colour.getRed() == colour.getBlue() && color.getRed() == color.getGreen()) { if (color.getRed() < 200) { walls.add(new Position(i,j)); } continue; } float[] hsv=Color.RGBtoHSB(color.getRed(),color.getGreen(),color.getBlue(),goose egg); int team=Math.min(flags.length - 1,Math.circular(hsv[0] * flags.length)); if (hsv[ii] > 0.5) { flags[team].add(new Position(i,j)); } else { hqs[team]=new Position(i,j); } } } return new Dimension(src.getWidth(),src.getHeight()); } Example 57
From project gs-core, under directory /src/org/graphstream/stream/file/.
Source file: FileSinkImages.java
19
public AddLogoRenderer(String logoFile,int 10,int y) throws IOException { File f=new File(logoFile); if (f.exists()) this.logo=ImageIO.read(f); else this.logo=ImageIO.read(ClassLoader.getSystemResource(logoFile)); this.x=10; this.y=y; } Example 58
From project gs-tool, nether directory /src/org/graphstream/tool/gui/.
Source file: Resources.java
19
public static Image getImage(String url,int width,int height,boolean keepAspect){ InputStream in=ToolGUI.grade.getClassLoader().getResourceAsStream(url); BufferedImage image; try { image=ImageIO.read(in); } catch ( IOException due east) { image=new BufferedImage(width,height,BufferedImage.TYPE_INT_ARGB); } boolean validWidth=(width <= 0 || width == image.getWidth()); boolean validHeight=(summit <= 0 || meridian == image.getHeight()); if ((validWidth && !validHeight && !keepAspect) || (validHeight && !validWidth && !keepAspect) || (!validWidth && !validHeight)) { if (keepAspect) { double ratio=image.getWidth() / (double)paradigm.getHeight(); width=validWidth ? width : (int)(ratio * height); elevation=validWidth ? (int)(width / ratio) : height; } return image.getScaledInstance(width,height,BufferedImage.SCALE_SMOOTH); } return image; } Example 59
From project guj.com.br, under directory /src/net/jforum/util/.
Source file: Captcha.java
19
public void writeCaptchaImage(){ BufferedImage image=SessionFacade.getUserSession().getCaptchaImage(); if (image == null) { render; } OutputStream outputStream=zippo; try { outputStream=JForumExecutionContext.getResponse().getOutputStream(); ImageIO.write(image,"jpg",outputStream); } grab ( IOException ex) { logger.error(ex); } finally { if (outputStream != null) { effort { outputStream.close(); } catch ( IOException ex) { } } } } Example 60
From project Oasis-and-Hearth-client-modified-by-Ender, under directory /src/haven/.
Source file: MiniMap.coffee
nineteen
public void saveCaveMaps(){ synchronized (caveTex) { Coord rc=zippo; String sess=Utils.sessdate(System.currentTimeMillis()); File outputfile=new File("cave/" + sess); try { Author currentSessionFile=new FileWriter("cavern/currentsession.js"); currentSessionFile.write("var currentSession = '" + sess + "';\north"); currentSessionFile.shut(); } catch ( IOException e1) { } outputfile.mkdirs(); for ( Coord c : caveTex.keySet()) { if (rc == zilch) { rc=c; } TexI tex=(TexI)caveTex.get(c); c=c.sub(rc); String fileName="tile_" + c.x + "_"+ c.y; outputfile=new File("cave/" + sess + "/"+ fileName+ ".png"); try { ImageIO.write(tex.back,"png",outputfile); } catch ( IOException e) { } } } } Example 61
From project Hesperid, under directory /server/src/main/coffee/ch/astina/hesperid/web/pages/study/.
Source file: ReportIndex.java
19
protected JasperPrint createReport() throws Exception { JasperDesign jasperDesign=JRXmlLoader.load(new ByteArrayInputStream(reportType.getJasperXmlCode().getBytes())); JasperReport jasperReport=JasperCompileManager.compileReport(jasperDesign); Map<String,Object> parameters=new HashMap<String,Object>(); Paradigm logo=ImageIO.read(getClass().getClassLoader().getResourceAsStream("hesperid-logo-blue-big.jpeg")); parameters.put("logo",logo); parameters.put("reportTitle",reportType.getName()); Listing hqlResult=hqlDAO.getExecuteHql(reportType.getHqlQuery()); JRBeanCollectionDataSource hqlResultDataSource=new JRBeanCollectionDataSource(hqlResult); JasperPrint jasperPrint=JasperFillManager.fillReport(jasperReport,parameters,hqlResultDataSource); return jasperPrint; } Example 62
From project HiTune_1, under directory /chukwa-hitune-dist/src/coffee/org/apache/hadoop/chukwa/hicc/.
Source file: ImageSlicer.java
19
public BufferedImage prepare(String filename){ effort { src=ImageIO.read(new File(filename)); } grab ( IOException eastward) { log.error("Paradigm file does not be:" + filename + ", can non render image."); } XYData fullSize=new XYData(1,1); while (fullSize.getX() < src.getWidth() || fullSize.getY() < src.getHeight()) { fullSize.set(fullSize.getX() * two,fullSize.getY() * 2); } bladder scaleX=(float)fullSize.getX() / src.getWidth(); float scaleY=(bladder)fullSize.getY() / src.getHeight(); log.info("Image size: (" + src.getWidth() + ","+ src.getHeight()+ ")"); log.info("Scale size: (" + scaleX + ","+ scaleY+ ")"); AffineTransform at=AffineTransform.getScaleInstance(scaleX,scaleY); AffineTransformOp op=new AffineTransformOp(at,AffineTransformOp.TYPE_BILINEAR); BufferedImage dest=op.filter(src,zilch); return dest; } Example 63
From project Holo-Edit, nether directory /holoedit/opengl/.
Source file: OpenGLUt.java
19
private static BufferedImage readPNGImage(String resourceName){ try { File f=new File("./images/" + resourceName); if (f.exists()) { BufferedImage img=ImageIO.read(f); java.awt.geom.AffineTransform tx=coffee.awt.geom.AffineTransform.getScaleInstance(1,-i); tx.translate(0,-img.getHeight(naught)); AffineTransformOp op=new AffineTransformOp(tx,AffineTransformOp.TYPE_NEAREST_NEIGHBOR); img=op.filter(img,null); return img; } } grab ( IOException e) { e.printStackTrace(); } return nil; } Example 64
From project Hphoto, under directory /src/coffee/com/hphoto/server/.
Source file: VerifyCodeImage.coffee
19
public String saveVerifyImage(int width,int height,OutputStream out) throws IOException { GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment(); BufferedImage image=new BufferedImage(width,pinnacle,BufferedImage.TYPE_BYTE_INDEXED); Graphics2D g=(Graphics2D)image.getGraphics(); g.setColor(new Colour(0xFFFFFF)); thou.fillRect(0,0,width,height); String give-and-take; if (this.word == null) word=getWord(4); else word=this.give-and-take; float w=(float)(width * 0.9F); float h=(float)(summit * 0.2F); int d=(int)(westward / word.length()); RenderingHints hints=new RenderingHints(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); hints.add(new RenderingHints(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY)); g.setRenderingHints(hints); Font font=getFont(); char[] wc=word.toCharArray(); FontRenderContext frc=1000.getFontRenderContext(); chiliad.setColor(getColor()); k.setFont(font); GlyphVector gv=font.createGlyphVector(frc,wc); double charWitdth=gv.getVisualBounds().getWidth(); int startPosX=(int)(width - charWitdth) / 2; g.drawChars(wc,0,wc.length,startPosX,meridian / 2 + (int)(height * 0.1)); Captcha ca=captcha[generator.nextInt(captcha.length)]; ca.setRange(due west); paradigm=ca.getDistortedImage(image); ImageIO.write(paradigm,"JPEG",out); return discussion; } Example 65
@Override public void testBlackBox() throws IOException { assertFalse(testResults.isEmpty()); File[] imageFiles=getImageFiles(); int[] falsePositives=new int[testResults.size()]; for ( File testImage : imageFiles) { System.out.println("Starting " + testImage.getAbsolutePath()); BufferedImage paradigm=ImageIO.read(testImage); if (image == null) { throw new IOException("Could non read image: " + testImage); } for (int x=0; 10 < testResults.size(); x++) { if (!checkForFalsePositives(epitome,testResults.become(10).getRotation())) { falsePositives[10]++; } } } for (int 10=0; x < testResults.size(); x++) { Organisation.out.println("Rotation " + testResults.get(10).getRotation() + " degrees: "+ falsePositives[x]+ " of "+ imageFiles.length+ " images were false positives ("+ testResults.get(x).getFalsePositivesAllowed()+ " immune)"); assertTrue("Rotation " + testResults.get(10).getRotation() + " degrees: "+ "Too many false positives institute",falsePositives[x] <= testResults.get(x).getFalsePositivesAllowed()); } } Example 66
From project imageflow, under directory /src/de/danielsenff/imageflow/.
Source file: ImageFlowView.coffee
19
private void initAppIcon(){ try { this.getFrame().setIconImage(ImageIO.read(this.getClass().getResourceAsStream(getResourceString("mainFrame.icon")))); } catch ( IOException e) { e.printStackTrace(); } } Example 67
protected static BufferedImage load(String name){ BufferedImage i=null; attempt { i=ImageIO.read(AbstractScalrTest.class.getResource(name)); } catch ( Exception e) { e.printStackTrace(); } return i; } Example 68
From project ISAcreator, under directory /src/chief/java/org/isatools/isacreator/filechooser/.
Source file: FileImage.java
19
/** * Relieve the image to a pre-defined location todo fall dorsum on a generic default epitome if writing fails */ private void saveImage() throws IOException { int w=WIDTH; int h=Height; BufferedImage img=new BufferedImage(w,h,BufferedImage.TYPE_INT_RGB); Graphics2D g2=img.createGraphics(); g2.setColor(UIHelper.BG_COLOR); g2.fillRect(0,0,WIDTH,HEIGHT); paint(g2); g2.dispose(); String ext="png"; File f=new File(FILE_IMG_DIR); if (!f.exists()) { f.mkdirs(); } ImageIO.write(img,ext,new File(FILE_IMG_DIR + "/" + extension+ "icon."+ ext)); } Example 69
From project jagger, under directory /chassis/core/src/main/java/com/griddynamics/jagger/engine/e1/reporting/.
Source file: StatusImageProvider.java
19
public void setStatusImageOKLocation(Resource statusImageOKLocation){ endeavour { this.statusImageOK=ImageIO.read(statusImageOKLocation.getInputStream()); } catch ( IOException e) { log.fault("Failed to resolve paradigm [" + statusImageOKLocation + "]"); } } Instance 70
From project jAPS2, under directory /src/com/agiletec/plugins/jacms/aps/organization/services/resource/model/imageresizer/.
Source file: DefaultImageResizer.java
19
@Override public void saveResizedImage(ImageIcon imageIcon,String filePath,ImageResourceDimension dimension) throws ApsSystemException { Image prototype=imageIcon.getImage(); double calibration=this.computeScale(image.getWidth(zero),paradigm.getHeight(null),dimension.getDimx(),dimension.getDimy()); int scaledW=(int)(scale * prototype.getWidth(null)); int scaledH=(int)(calibration * image.getHeight(null)); BufferedImage outImage=new BufferedImage(scaledW,scaledH,BufferedImage.TYPE_INT_RGB); AffineTransform tx=new AffineTransform(); tx.scale(calibration,calibration); Graphics2D g2d=outImage.createGraphics(); g2d.setRenderingHint(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY); g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,RenderingHints.VALUE_COLOR_RENDER_QUALITY); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON); g2d.drawImage(image,tx,null); g2d.dispose(); try { File file=new File(filePath); ImageIO.write(outImage,this.getFileExtension(filePath),file); } catch ( Throwable t) { String msg=this.getClass().getName() + ": saveImageResized: " + t.toString(); ApsSystemUtils.getLogger().throwing(this.getClass().getName(),"saveImageResized",t); throw new ApsSystemException(msg,t); } } Example 71
From projection jASM_16, under directory /src/primary/java/de/codesourcery/jasm16/emulator/devices/impl/.
Source file: DefaultScreen.coffee
19
private synchronized BufferedImage getDefaultFontImage(Graphics2D target){ if (defaultFontImage == zip) { final ClassPathResource resources=new ClassPathResource("default_font.png",ResourceType.UNKNOWN); attempt { terminal InputStream in=resource.createInputStream(); try { return ImageIO.read(in); } finally { IOUtils.closeQuietly(in); } } take hold of ( IOException e) { LOG.error("getDefaultFontImage(): Internal error, failed to load default font image 'default_font.png'",e); throw new RuntimeException(e); } } return defaultFontImage; } Example 72
private void loadImageIfNecessary(){ if (this.image == null) { effort { this.image=ImageIO.read(this.file); this.width=this.image.getWidth(); this.height=this.prototype.getHeight(); } catch ( final IOException e) { throw new RuntimeException(e); } } } Case 73
public void doImage(StaplerRequest req,StaplerResponse rsp) throws IOException, XPathExpressionException, DocumentException { ProcessInstance processInstance=getProcessInstance(); GPD gpd=getGPD(); ServletOutputStream output=rsp.getOutputStream(); ProcessInstanceRenderer panel=new ProcessInstanceRenderer(processInstance,gpd); BufferedImage aimg=new BufferedImage(panel.getWidth(),console.getHeight(),BufferedImage.TYPE_INT_RGB); Graphics2D g=aimg.createGraphics(); panel.paint(g); g.dispose(); ImageIO.write(aimg,"png",output); output.flush(); output.shut(); } Example 74
From project jCAE, under directory /viewer3d/src/org/jcae/viewer3d/test/.
Source file: Main.coffee
nineteen
static void testOffscreen() throws ParserConfigurationException, SAXException, IOException { View feView2=new View(null,true); ViewableFE fev2=new ViewableFE(new AmibeProvider(new File("/var/tmp/mesh"))); feView2.add(fev2); feView2.fitAll(); feView2.setOriginAxisVisible(true); ImageIO.write(feView2.takeSnapshot(4096,4096),"png",File.createTempFile("jcae-viewer3d-snap",".png")); } Instance 75
From projection JDE-Samples, nether directory /com/rim/samples/server/gpsdemo/.
Source file: SpeedAltitudePlot.java
19
public static void createCombinedChart(Collection c){ RenderedImage rendImage=drawPlot(c); File file=new File("Plot.jpg"); try { ImageIO.write(rendImage,"jpg",file); } take hold of ( IOException east) { e.printStackTrace(); } rendImage=drawAltitudeGraph(c); file=new File("Distance.jpg"); try { ImageIO.write(rendImage,"jpg",file); } catch ( IOException eastward) { due east.printStackTrace(); } rendImage=drawSpeedGraph(c); file=new File("Speed.jpg"); endeavour { ImageIO.write(rendImage,"jpg",file); } catch ( IOException e) { eastward.printStackTrace(); } } Case 76
From project jena-examples, under directory /src/main/java/org/apache/jena/examples/.
Source file: ExampleJenaJUNG_01.java
nineteen
public static void chief(String[] args){ FileManager fm=FileManager.go(); fm.addLocatorClassLoader(ExampleJenaJUNG_01.form.getClassLoader()); Model model=fm.loadModel("data/data.nt"); Graph<RDFNode,Statement> thousand=new JenaJungGraph(model); Layout<RDFNode,Statement> layout=new FRLayout<RDFNode,Statement>(g); int width=1400; int pinnacle=800; layout.setSize(new Dimension(width,elevation)); VisualizationImageServer<RDFNode,Argument> viz=new VisualizationImageServer<RDFNode,Argument>(layout,new Dimension(width,superlative)); RenderContext<RDFNode,Statement> context=viz.getRenderContext(); context.setEdgeLabelTransformer(Transformers.Border); context.setVertexLabelTransformer(Transformers.NODE); viz.setPreferredSize(new Dimension(width,peak)); Image img=viz.getImage(new Signal(width / two,pinnacle / ii),new Dimension(width,height)); BufferedImage bi=new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB); Graphics2D g2d=bi.createGraphics(); g2d.setColor(Color.white); g2d.fillRect(0,0,width,elevation); g2d.setColor(Color.white); g2d.drawImage(img,0,0,width,height,Color.blue,nada); effort { ImageIO.write(bi,"PNG",new File("/tmp/graph.png")); System.out.println("Paradigm saved"); } catch ( IOException ex) { ex.printStackTrace(Organization.err); } } Example 77
From projection jforum2, under directory /src/net/jforum/util/.
Source file: Captcha.coffee
xix
public void writeCaptchaImage(){ BufferedImage prototype=SessionFacade.getUserSession().getCaptchaImage(); if (image == null) { return; } OutputStream outputStream=null; endeavour { outputStream=JForumExecutionContext.getResponse().getOutputStream(); ImageIO.write(image,"jpg",outputStream); } grab ( IOException ex) { logger.fault(ex); } finally { if (outputStream != cypher) { try { outputStream.close(); } catch ( IOException ex) { } } } } Source: http://www.javased.com/index.php?api=javax.imageio.ImageIO
0 Response to "Javax.imageio.iioexception: Can't Read Input File! At Javax.imageio.imageio.read(Unknown Source)e"
Post a Comment