javax.imageio

How to send images through sockets in java?

坚强是说给别人听的谎言 提交于 2019-12-28 12:16:29
问题 I am writing a client-server program and I want that to send an image. The code is the following: //RECEIVER while(true){ try{ socket = server.accept(); out = new ObjectOutputStream(socket.getOutputStream()); out.flush(); in = new ObjectInputStream(socket.getInputStream()); System.out.println("Connected to "+PORTA+"."); while(!socket.isClosed()){ System.out.println("\nPrint the action"); azione = reader.readLine(); if(azione.equals("screenshot")){ out.writeObject("screenshot"); out.flush();

How to send images through sockets in java?

陌路散爱 提交于 2019-12-28 12:14:20
问题 I am writing a client-server program and I want that to send an image. The code is the following: //RECEIVER while(true){ try{ socket = server.accept(); out = new ObjectOutputStream(socket.getOutputStream()); out.flush(); in = new ObjectInputStream(socket.getInputStream()); System.out.println("Connected to "+PORTA+"."); while(!socket.isClosed()){ System.out.println("\nPrint the action"); azione = reader.readLine(); if(azione.equals("screenshot")){ out.writeObject("screenshot"); out.flush();

How to return a PNG image from Jersey REST service method to the browser

蹲街弑〆低调 提交于 2019-12-28 02:24:04
问题 I have a web server running with Jersey REST resources up and I wonder how to get an image/png reference for the browsers img tag; after submitting a Form or getting an Ajax response. The image processing code for adding graphics is working, just need to return it somehow. Code: @POST @Path("{fullsize}") @Consumes(MediaType.MULTIPART_FORM_DATA) @Produces("image/png") // Would need to replace void public void getFullImage(@FormDataParam("photo") InputStream imageIS, @FormDataParam("submit")

Why do i get ImageIO errors in console?

拥有回忆 提交于 2019-12-25 04:23:23
问题 Why do i get error ImageIO: _CGImagePluginInitGIFmalformed GIF file (768 x 1024)? I am going crazy! This error shows up in XCode console when some of my .gif images need to show up in UIImageView. Images do not display(!) and I get that in console. That error is showing only for few images, not all! I tried to remove the images, add them again, clean, rebuild, but I still cant display those images! Everything was OK until I installed XCode 4.0.1, all images were working and displaying fine!

Decoding base64 image received as email on Google App Engine

流过昼夜 提交于 2019-12-25 03:01:58
问题 I want to decode a base64 encoded image received over email on Google App Engine(GAE). When I extract the image from MimeMessage I get a base64DecoderStream object. I initially assumed that this decoded data is byte array in ARGB format, but that doesn't seem to be the case here. I verified this by comparing the decoded byte array with the one got from running "ImageIO.read(ImageFile).getRGB()" and they didn't match. So I was wondering:- 1) Which image format data did I get after decoding the

Getting IllegalSrgumentException: input==null. When trying to load an image

孤人 提交于 2019-12-25 02:39:33
问题 i am trying to load an image to be used as a texture and i keep getting input==null errors; This is my code where i am trying to load the image and where most of the errors are pointing to. package com.mime.minefront.graphics; import java.awt.image.BufferedImage; import javax.imageio.ImageIO; public class Texture { public static Render floor = loadBitmap("/C:\\Users\\Danny\\Documents\\NetBeansProjects\\MyFirstgame\\src\\res\\textures\\floor.png"); public static Render loadBitmap(String

ImageIO.read() infinite loop

青春壹個敷衍的年華 提交于 2019-12-24 13:01:07
问题 ImageIO.read() just seems to be stuck in an infinite loop. My code: import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import javax.imageio.ImageIO; public class Texture { BufferedImage _img; public Texture(String path) { try { _img = ImageIO.read(new File(path)); } catch (final IOException e) { e.printStackTrace(); } } } Other class: private Texture _tex; _tex = new Texture("/res/img.png"); I have tried loading the image this URL and File, none works. I am

What does control caching means in ImageIO read

ぐ巨炮叔叔 提交于 2019-12-24 10:36:43
问题 My only fear of using BufferedImage object is that for a very large image of say 60000x32000 it will result in JVM shutting down with OOM on a limited JVM heap space. However, JavaDocs of ImageIO.read method says something about "control caching". What is control caching in this context? Does that mean ImageIO.read uses caching of image on disk for large image? Refer to JavaDocs and ImageIO.read method below: /** * Returns a <code>BufferedImage</code> as the result of decoding * a supplied

How to resize images in a directory?

我只是一个虾纸丫 提交于 2019-12-24 04:52:30
问题 This code attempts to resize images in a directory called "imgs". Unfortunately for some reason when I uncomment the listFiles(..) loop ImageIO.read(sourceImageFile) will return null. Yet processing the same file straightaway outside the loop ( res("imgs/foto_3.jpg") ) works. So apparently, this loop is preventing the files from being read. Solutions? import java.awt.image.*; import java.io.*; import javax.imageio.*; import static org.imgscalr.Scalr.*; public class App { public static void

How to prevent loss of image quality while using ImageIO.write() method?

寵の児 提交于 2019-12-24 04:31:47
问题 I am dealing with Images in java where I do read and write Images in my local disk. My Problem is while writing Images I am losing the quality of the actual Image I read. It reduces the quality by image file size from 6.19MB(actual image size) file to 1.22MB(written using ImageIO.write() which is drastic loss. How can I prevent this loss when i do use ImageIO.write(image, "jpg", os); for writing Image. Remember, I dont need any compression over here. Just I want to read the Image and write