bufferedimage

The image gets drawn at the wrong position

橙三吉。 提交于 2019-12-25 00:22:55
问题 This is the final output of my thread that takes screenshots and stores them in a vector. java.awt.Robot is used to take screenshots which are basically rasters of the screen and does not contain cursor position. As a way around, I use the MouseInfo class to get PointerInfo and then get a Point . Then draw an image at that point. All is cool if recording area is set to full screen resolution. However if I change the recording area, the cursor gets drawn at the wrong position. This black

How to load streamed data directly into a BufferedImage

跟風遠走 提交于 2019-12-25 00:18:55
问题 I am using the code provided by this accepted answer to send a list of files over a socket in Java. My goal is to be receiving a list of images. What I would like to do is read these images directly into memory as BufferedImages before writing them to disk. However, my first attempts, which was to use ImageIO.read(bis) (again, see the attached question) failed, as it attempted to continue reading beyond the end of the first image file. My current idea is to write the data from the socket to a

BufferedImage causes a program freeze on MacOs but not on Windows

蹲街弑〆低调 提交于 2019-12-24 23:53:26
问题 I'm using a piece of code to grab a screenshot of my application screen for a group project. On my Macbook Pro the code freezes the screen whereas on my teammates's PC's (all Windows) it runs just fine and exports a .png file in their root dir. The code public void screenShot(){ //Creating an rbg array of total pixels int[] pixels = new int[WIDTH * HEIGHT]; int bindex; // allocate space for RBG pixels ByteBuffer fb = ByteBuffer.allocateDirect(WIDTH * HEIGHT * 3); // grab a copy of the current

moving buffered image to specific coordinates

允我心安 提交于 2019-12-24 14:34:12
问题 I am trying to move the blue square around the grid by pressing the arrow keys. I already set up the KeyListener but when I repaint the frame, I have to move the frame around in order for it to update. How do I make it a smooth animation (moving the square from one coordinate to another)? Example: if (keyCode == KeyEvent.VK_LEFT){ x5=x5-xChange; frame.repaint(); } My images are buffered images and are all set to specific coordinates. Here is my graphics class: public static class

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

How to create a circular bufferedimage rather than creating a rectangular one in Java using Graphics

我只是一个虾纸丫 提交于 2019-12-24 12:37:02
问题 I need to create a bufferedimage (circular type) but I am able to create only rectangular type. Then I want to create a oval inside the bufferedimage with some configurations and finally i want to draw a rectangular icon inside the circular shape which should be inserted on the circular shape and not on the rectangular bufferedimage. Now i am able to do the following BufferedImage img = "SomeImage.png"; BufferedImage bfImage = new BufferedImage(200,200,BufferedImage.TYPE_INT_ARGB); Graphics2D

How to see BufferedImage in JPanel?

纵饮孤独 提交于 2019-12-24 12:34:21
问题 I'm building a PongClone but I encounter a bug. **I think the bug is cause by JPanel. I tried the Image instead of BufferedImage. I tried the drawImage outside the paintComponent method. I create to another panel and then add that panel inside a mainpanel. Menu Class package me.pong; import javax.swing.*; public class TestMenu { JFrame frame; public void createFrame () { TestMain main = new TestMain (); frame = new JFrame("TEST"); frame.setSize (800, 450); frame.setDefaultCloseOperation

How can I control the brightness of an Image?

我与影子孤独终老i 提交于 2019-12-24 12:29:29
问题 I have the following problem: I want to create a method to control the brightness of an Image. I think I have to convert it to a BufferedImage before. And if the Image has an alpha channel and I want to convert it with TYPE_INT_RGB the alpha pixels will be black. But it works fine with TYPE_INT_ARGB ... It doesn't work if the image doesn't have an alpha channel and I convert it with TYPE_INT_ARGB . Then not only the brightness changes, but also the color. When I make the image brighter it

DICOM image to BufferedImage on Windows 64

末鹿安然 提交于 2019-12-24 11:29:56
问题 I need a way to convert a DICOM file into a BufferedImage (or if the dicom file is mult-frame then a set of BufferedImages) on Windows 64. I am currently using dcm4che to do this, but am running into a problem because dcm4che uses JAI which thunks down to a native dll clib_jiio.dll which is not complied, and will not be compiled for Windows 64 (see here). Does anyone know of an open source library that can do this for me? Thanks 回答1: Several DICOM plugins are available for ImageJ. Addendum:

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