bufferedimage

Pipe series of images from java application to ffmpeg subprocess

て烟熏妆下的殇ゞ 提交于 2020-01-03 13:07:29
问题 I am looking for a way to stream series of images (jpegs) from java application into FFMpeg STDIN pipe. FFMpeg should process these images and create a video file as an output. FFMpeg is executed as sub process of java application with the following command "ffmpeg.exe -i pipe:0 out.avi" When i run "ffmpeg -i input.jpg out.avi" command in the console, i get the "out.avi" file as expected But when i use the following tester code in my java application, i got an error. Code in Java application:

Pipe series of images from java application to ffmpeg subprocess

倖福魔咒の 提交于 2020-01-03 13:07:28
问题 I am looking for a way to stream series of images (jpegs) from java application into FFMpeg STDIN pipe. FFMpeg should process these images and create a video file as an output. FFMpeg is executed as sub process of java application with the following command "ffmpeg.exe -i pipe:0 out.avi" When i run "ffmpeg -i input.jpg out.avi" command in the console, i get the "out.avi" file as expected But when i use the following tester code in my java application, i got an error. Code in Java application:

Convert List<BufferedImage> to Image

混江龙づ霸主 提交于 2020-01-03 04:32:15
问题 I have the following .ico image, read using image4j library: List<BufferedImage> BI = ICODecoder.read("aImage.ico"); Next I want to set this image as a frame icon: myFrame.setIconImage((Image)BI); Error: java.lang.ClassCastException I need to convert the type List<\BufferedImage> to the type Image. Any help would be appreciated. 回答1: You could consider using... myFrame.setIconImage(BI.get(0)); List is a list of stuff (or technically Object s, in your case, BufferedImage s), where as

Load a PNG image into Java as BufferedImage through JNI C code

我的未来我决定 提交于 2020-01-02 11:14:06
问题 I have the following problem. I have C code that acquires a PNG image as basically raw data and keeps it in memory. I would like this raw data to be translated to a BufferedImage in Java, through the use of JNI. Does anyone know any way of doing this or has done this before? 回答1: I'll assume you know the basics of how to call functions with JNI. It's not that complicated, although it can be a pain in the ass. If you want to get it done quickly, just write the PNG to a temp file, pass the file

How to make bmp image from pixel byte array in java

懵懂的女人 提交于 2020-01-02 06:11:50
问题 I have a byte array containing pixel values from a .bmp file. It was generated by doing this: BufferedImage readImage = ImageIO.read(new File(fileName)); byte imageData[] = ((DataBufferByte)readImage.getData().getDataBuffer()).getData(); Now I need to recreate the .bmp image. I tried to make a BufferedImage and set the pixels of the WritableRaster by calling the setPixels method. But there I have to provide an int[], float[] or double[] array. Maybe I need to convert the byte array into one

How to make bmp image from pixel byte array in java

﹥>﹥吖頭↗ 提交于 2020-01-02 06:09:52
问题 I have a byte array containing pixel values from a .bmp file. It was generated by doing this: BufferedImage readImage = ImageIO.read(new File(fileName)); byte imageData[] = ((DataBufferByte)readImage.getData().getDataBuffer()).getData(); Now I need to recreate the .bmp image. I tried to make a BufferedImage and set the pixels of the WritableRaster by calling the setPixels method. But there I have to provide an int[], float[] or double[] array. Maybe I need to convert the byte array into one

JavaFX: Fastest way to write pixels to PixelWriter

空扰寡人 提交于 2020-01-02 05:15:13
问题 I'm looking for the fastest way to write pixels on javafx.scene.image.Image . Writing to BufferedImage 's backing array is much faster. At least on the test image I made it took only ~20ms for BufferedImage , WritableImage on the other hand took ~100ms. I already tried SwingFXUtils but no luck. Code for BufferedImage (faster): BufferedImage bi = createCompatibleImage( width, height ); WritableRaster raster = bi.getRaster(); DataBufferInt dataBuffer = (DataBufferInt) raster.getDataBuffer();

In Java converting an image to sRGB makes the image too bright

℡╲_俬逩灬. 提交于 2020-01-01 17:03:21
问题 I have multiple images with a custom profile embedded in them and want to convert the image to sRGB in order to serve it up to a browser. I have seen code like the following: BufferedImage image = ImageIO.read(fileIn); ColorSpace ics = ColorSpace.getInstance(ColorSpace.CS_sRGB); ColorConvertOp cco = new ColorConvertOp(ics, null); BufferedImage result = cco.filter(image, null); ImageIO.write(result, "PNG", fileOut); where fileIn and fileOut are File objects representing the input file and

Why does a BufferedImage require so much memory beyond the size of its data array?

女生的网名这么多〃 提交于 2020-01-01 12:36:10
问题 I'm trying to determine how much heap any given TYPE_INT_ARGB BufferedImage will use so that, for a program which is doing some image processing, I can set a reasonable max heap based on the size of image we feed it. I wrote the following program as a test, which I then used to determine the least maximum heap under which it would run without an OutOfMemoryError : import java.awt.image.BufferedImage; public class Test { public static void main(String[] args) { final int w = Integer.parseInt

Working in a BufferedImage's int[] pixels array

只愿长相守 提交于 2020-01-01 05:25:08
问题 When working with BufferedImage using the setRGB and getRGB methods, I noticed two things: the setRGB and getRGB methods can be incredibly slow on some systems (as much as two orders of magnitude slower than modifiyng the int[] array). there are no guarantee that a getRGB following a setRGB will give back the same pixel you passed This last point is basically pretty clear from the JavaDoc of setRGB , which states: ...For images with an IndexColorModel, the index with the nearest color is