javax.imageio

Java ImageIO is insanely slow

陌路散爱 提交于 2019-12-06 08:01:15
问题 I'm making a program that sends the clients screen to the server and displays it but it's being extremely slow. It's taking 2-3 seconds for one frame and the upload/download speed is not a problem. Is there anything I'm doing wrong/anything I can change to speed this up? Server: import java.awt.BorderLayout; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; import java.util.zip.GZIPInputStream; import javax.imageio.ImageIO;

Is there any way in Java to take image width and height without transfer or download?

核能气质少年 提交于 2019-12-06 06:35:45
问题 In order to get image's height we can use ImageIO.read(new URL("…")).getHeight() . My questions: Do I understand correctly that this method downloads the image to the local computer prior size calculation? If yes, to where exactly the image is downloaded — to some JVM's cache on HDD or directly to the RAM? Is there any way to take image's height without transfer or download? But with some kind of request to server? 回答1: First, your questions: Kind of. First of all, the ImageIO.read(...)

stitch images together in java

我是研究僧i 提交于 2019-12-06 05:18:23
I'm trying to stitch some images together using java. I have a bunch of images I'd like to stitch together and they are all the same dimensions so it's really just a question of lining them up next to each other I suppose. I have it working but it's very slow and probably very memory intensive. I'm wondering if there's an easier way: public static void main(String[] args) throws IOException { int dim = 256; BufferedImage merged = null; for(int y = 0; y<10;y++) { for(int x = 0; x<10;x++) { URL url = new URL(someURL); BufferedImage nextImage = ImageIO.read(url); if(merged==null) merged=nextImage

How to resize an image without loading into memory?

眉间皱痕 提交于 2019-12-06 02:36:21
问题 I'd like to check the dimensions of an image, and then size it down if the width exceeds a given threshold. When I load a 6MB JPEG image with ImageIO.read(), the BufferedImage allocates about 45MB of heap space. Is there a way to do a passthrough image resize without loading all the data into memory? I tried passing ImageIO.read() a File object, thinking it would stream the data from disk, but it doesn't help. 回答1: Check out im4java and JMagick. Both use an extremely efficient external tool

How to make ImageIO read from InputStream :Java

半城伤御伤魂 提交于 2019-12-06 01:18:04
问题 I have created executable jar file(using Eclipse) , there are a set of image (.png) files that is to be inculded in the jar. So I have added a source folder with all the images inside /images folder in the project . Code has to access these file to create BufferedImage using ImageIO.read(new File(path); Earlier, To get the path I used ClassName.class.getResource(/image/test.png).toURI(); On executing jar , it throw error URI is not hierarchical So now I am using ClassName.class

Java ImageIO Grayscale PNG Issue

。_饼干妹妹 提交于 2019-12-05 21:58:45
I have a grayscale image ("lena" actually) which I want to experiment with. I got it as a 512x512 PNG file with 216 shades of gray. What happens is, when I read it with Java ImageIO, like that: String name = args[0]; File fi = new File(name); BufferedImage img = ImageIO.read(fi); I get a BufferedImage with only 154 colours ! I only realized this, cause my processed images which looked sallow, lacking deep black. Even more irritating, when I use XnView convert the PNG to a GIF, which is a lossless procedure in this case, read the GIF with above code, I get all 216 colours in my BufferedImage.

Java: Detecting image format, resize (scale) and save as JPEG

白昼怎懂夜的黑 提交于 2019-12-05 19:02:49
问题 This is the code I have, it actually works, not perfectly but it does, the problem is that the resized thumbnails are not pasting on the white Drawn rectangle, breaking the images aspect ratio, here is the code, could someone suggest me a fix for it, please? Thank you import java.awt.Color; import java.awt.Graphics2D; import java.awt.Image; import java.awt.RenderingHints; import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; import java.io.BufferedInputStream; import java.io

Creating progressive jpeg on iOS with ImageIO produces blocky results on device

会有一股神秘感。 提交于 2019-12-05 16:30:10
问题 I'm trying to create a progressive jpeg from a UIImage object, this is the code i'm NSMutableData *data = [NSMutableData data]; NSString *path = [NSHomeDirectory() stringByAppendingPathComponent: @"Library/Caches/test.jpg"]; CFURLRef url = CFURLCreateWithString(NULL, (CFStringRef)[NSString stringWithFormat:@"file://%@", path], NULL); CGImageDestinationRef destination = CGImageDestinationCreateWithURL(url, kUTTypeJPEG, 1, NULL); CFRelease(url); NSDictionary *jfifProperties = [NSDictionary

Cannot run or jai_imageio or ImageIO.getImageReadersByFormatName cannot get Object

家住魔仙堡 提交于 2019-12-05 15:40:32
I'm running a program that using jai_imageio.jar and then validating if I can get ImageIO.getImageReadersByFormatName("tiff") for some reason the program is running on other server, But when I checkout / load it into my server it always cause an error java.util.NoSuchElementException at javax.imageio.spi.FilterIterator.next(Unknown Source) at javax.imageio.ImageIO$ImageReaderIterator.next(Unknown Source) at javax.imageio.ImageIO$ImageReaderIterator.next(Unknown Source) I've already spending half of my day with this.. but still can't figure it out. I hope someone can tell what's wrong with my

android Image encryption/decryption BufferedImage and ImageIO not resolved

落爺英雄遲暮 提交于 2019-12-05 08:16:23
问题 Code given below ,is not working with the android sdk "BufferdImage and ImageIO " not resolved . I've tried to implement "Bitmap" and "BitmapFactory", but it did not work.Please help me to do this at android application . Please correct in for an android application . public class stackoverflow { public static void main(String[] arg) throws Exception { Scanner scanner = new Scanner(System.in); byte[] salt = { (byte) 0xc7, (byte) 0x73, (byte) 0x21, (byte) 0x8c, (byte) 0x7e, (byte) 0xc8, (byte)