javax.imageio

How to convert a binary image data to a jpg file in Java where every 10bits in the binary data represent a pixel?

折月煮酒 提交于 2019-12-13 09:56:06
问题 I am receiving a stream of bits over the Ethernet . I am collecting the bits in a byte[] array in Java (I am collecting them in a byte[] because I think its relevant).The stream is a digitized image where every 10 bits represent a pixel. There are 1280*1024 pixels. Every pixel is represented by 10 bits. Hence, 1280*1024*10 = 13107200 bits = 1638400 bytes is the image size. 回答1: here's the solution - but if the 10 bits represent actually 8 bits with some 'nonsense' in the other two bits its

PNG metadata read and write

谁说胖子不能爱 提交于 2019-12-13 09:02:22
问题 I am using a piece of code posted on stackover flow to write custom metadata to PNG image and read it. The write function seems to work fine but when i try to read data that i had written it throws NullPointerException. Can someone tell me what is wrong? Here is code for writing metadata try{ image=ImageIO.read(new FileInputStream("input.png")); writeCustomData(image, "software", "FRDDC"); ImageIO.write(image, "png", new File("output.png")); } catch(Exception e){ e.printStackTrace(); } Method

java.util.ServiceConfigurationError: Provider could not be instantiated

走远了吗. 提交于 2019-12-13 07:23:16
问题 I have a .jp2 image file that I want to convert to .jpg . BufferedImage background = ImageIO.read(new File("images\\" + randNum + ".jp2")); ImageIO.write(background, "jpg", new File("images\\" + randNum + ".jpg")); I have got this exception : java.util.ServiceConfigurationError: javax.imageio.spi.ImageWriterSpi: Provider com.github.jaiimageio.jpeg2000.impl.J2KImageWriterSpi could not be instantiated ... Caused by: java.lang.NoClassDefFoundError: com/github/jaiimageio/impl/common/PackageUtil .

Using ImageIO to convert from JPEG2000 to PNG

自作多情 提交于 2019-12-13 07:14:57
问题 I'm trying to convert a JPEG2000 (.jp2) image to other formats (JPEG or PNG), so I try to use write method of javax.imageio package. This works fine for other formats (eg. JPEG to PNG), but when it comes to JPEG2000 (or TIFF) it throws an exception. Could anyone tell me what are the possible formats of the input image? Exception in thread "main" java.lang.IllegalArgumentException: im == null! at javax.imageio.ImageIO.write(ImageIO.java:1457) at javax.imageio.ImageIO.write(ImageIO.java:1565)

Netbeans & Java - using getResource() - returning null

本小妞迷上赌 提交于 2019-12-13 06:08:17
问题 I am trying to load a background to my JFrame using the following code: image = ImageIO.read(getClass().getResourceAsStream(s)); where for s I have tried: /res/Background/bg_menu.gif Background/bg_menu.gif /Background/bg_menu.gif res/Background/bg_menu.gif My res folder is in the project root like so: Game -- src -- res I have done the following: Project Properties -> Sources -> Add Folder -> res The error I'm getting returned is: java.lang.IllegalArgumentException: input == null! at javax

javax.ImageIO methods fail silently

你说的曾经没有我的故事 提交于 2019-12-13 04:45:24
问题 If my java code makes a call to any javax.ImageIO method, it throws a silent error. e.g. File screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); try { BufferedImage fullImg = ImageIO.read(screenshot); } catch(Exception e) { e.printStackTrace(); } no error message is produced, but the code halts at that point. I tried calling ImageIO.getReaderFormatNames() just to see, but it also throws a silent error. This problem occurs in Ubuntu with oracle jre (java version "1.8.0_60

Serialize Obj with 2 BufferedImage transient fields, second image won't be read

一个人想着一个人 提交于 2019-12-13 04:34:08
问题 before explaining my thing i want to mention that i haven't tried-search any alternate solutions (which i am pretty confident something will be found). I am just pretty curious to know why this is happening. So...I have an object that has 2 transient buffered images fields (firstimage and second image like the following example). Since bufferedimage does not implement serializable, one way to serialize them (i found in SO) is this. I did the exact same thing and everything worked perfect for

Serializing/Deserializing buffered images

爱⌒轻易说出口 提交于 2019-12-13 03:16:47
问题 I have a collection of buffered images that I want to serialize and then deserialize. For example I have an arrayList full of buffered images which are iterated through and written to a ObjectOutputStream for (BufferedImages i : images{ ImageIO.write(i,"png",ImageIO.createImageOutputStream(output)); } When I go to re-serialize the images, I tried to use BufferedImage image =ImageIO.read(ImageIO.createImageInputStream(input)); but it only reads in one image. Whats the correct way to re

Saving colorspace in jpeg

别说谁变了你拦得住时间么 提交于 2019-12-12 22:01:54
问题 I have a servlet to convert and cache smaller versions of photographs. It is implemented using java.awt.image + javax.imageio and a third party resample filter. The originals are all uploaded with an sRGB color profile. When I resample them and save them again they still are in sRGB however this is not recorded in the saved file. How can I make sure this information is saved in the file? In case you wondered it makes a difference, images without a profile are much more saturated on my screen

Java 8 ImageIO reads JPEG incorrectly in Linux

爷,独闯天下 提交于 2019-12-12 10:47:24
问题 I'm trying to read user-uploaded JPEG image (arbitrary) to create thumbnail in server app. System works just fine in Windows7 / Oracle Java 8u11 but I have problem with color model under CentOS on server: original image is: http://studio-st.ru/media/portfolio/image/45 resulting thumbnail on development workstation under Windows is absolutely correct result under Linux is color-shifted (reddish on Java 8u05, color-shifted on Java 8u11). Not presented here because original example was on site,