bufferedimage

The type of the expression must be an array type but it resolved to BufferedImage

我的梦境 提交于 2019-12-11 01:12:53
问题 It's being really weird, the error is at textures[x] . The type of the expression must be an array type but it resolved to BufferedImage What is wrong with the code here? static BufferedImage textures[][] = new BufferedImage[20][20]; public static void loadTextures() { try { //Loads The Image BufferedImage textures = ImageIO.read(new URL("textures.png")); for (int x = 0; x < 1280; x += 1) { for (int y = 0; y < 1280; y += 1) { textures[x][y] = textures.getSubimage(x*64, y*64, 64, 64); } } }

java huge BufferedImage in JScrollPane

你。 提交于 2019-12-11 01:06:43
问题 I need to fit a huge image (BufferedImage to access colors etc) into a JScrollPane derived class. Nothing very hard until there. The image is a JPG scan of an A3 sample of material, its size is 13030x20840 pixels, 24bits, and weights 12MB on disk -> about 800MB in RAM. I embedded the BufferedImage into a Jpanel, which lies as the Scrollpane's view. When I try to scroll/drag my image, it takes seconds to respond, so it is not very handy. I need your help in order to know what I should do to

How to draw an Image underneath an open Menu

时光怂恿深爱的人放手 提交于 2019-12-11 00:41:32
问题 I'm implementing my own double-buffering for a BufferedImage in a JPanel so that I can display the mouse location in the BufferedImage without repainting every object back onto it on mousemovement. When a JMenu in the parent JFrame is open, the BufferedImage gets repainted on top of the JMenu. This class is not complete, and has only the necessary methods, public class Foo extends JPanel implements ComponentListener { BufferedImage bufferedImage; long mousePosX; long mousePoxY; protected void

Converting GDCM Image to Java BufferedImage

人走茶凉 提交于 2019-12-10 23:04:41
问题 I am using GDCM to read in DICOM images. Is there an easy way to read in a dicom file with GDCM, and then convert it to a Java BufferedImage? So far I have the following String filename = "C:\\test.dcm"; gdcm.ImageReader reader = new gdcm.ImageReader(); reader.SetFileName(filename); reader.Read(); gdcm.Image image = reader.GetImage(); BufferedImage bufferedImage = new BufferedImage((int)image.GetRows(, (int)image.GetColumns(), BufferedImage.TYPE_USHORT_GRAY); // How do I populate

Convert com.lowagie.text.Image to BufferedImage

笑着哭i 提交于 2019-12-10 22:49:02
问题 How can I convert com.lowagie.text.Image to BufferedImage successfully. Please help me. com.lowagie.text.Image itemImg=getHeaderImage(true); ByteArrayOutputStream bas = new ByteArrayOutputStream(); ImageIO.write((RenderedImage) itemImg,"png", bas); byte[] data = bas.toByteArray(); InputStream in = new ByteArrayInputStream(data); BufferedImage image = ImageIO.read(in); Now I get the exception "java.lang.ClassCastException: com.lowagie.text.ImgRaw cannot be cast to java.awt.image.RenderedImage"

How to write PNG files in java using pixel RGB values 0 to 1?

梦想与她 提交于 2019-12-10 22:06:26
问题 I am writing a ray tracer in java and I am trying to figure out how to write my generated image to a PNG file. So far, all the examples I have found demonstrate the use of BufferedImage to create a PNG, but they all use RGB values 0 to 255. In my code I represent each pixel colour value between 0 and 1, so for example magenta is (1, 0, 1). How can I go about writing a PNG with such values? Thanks 回答1: If you multiply your value between 0 and 1 with 255, you'll get a number between 0 and 255.

Why is my BufferedImage receiving a null value from ImageIO.read()

假装没事ソ 提交于 2019-12-10 20:58:30
问题 BufferedImage = ImageIO.read(getClass().getResourceAsStream("/Images/player.gif")); First of all, yes I did add the image folder to my classpath. For this I receive the error java.lang.IllegalArgumentException: input == null! I don't understand why the above code doesn't work. From everything I read, I don't see why it wouldn't. I've been told I should be using FileInputStream instead of GetResourceAsStream , but, as I just said, I don't see why. I've read documentation on the methods and

Performing setRGB on BufferedImage changes pixel to black instead of color

帅比萌擦擦* 提交于 2019-12-10 20:47:56
问题 ** Important update, see below! ** I am creating a program that changes the pixels of a BufferedImage to a certain color when that pixel fulfills a set of conditions in Java. However, when I write the image to disk, the pixels that should be colored are instead black. First I define the color, using RGB codes: Color purple = new Color(82, 0, 99); int PURPLE = purple.getRGB(); Then I read the image I want to alter from a File into a BufferedImage called "blank": BufferedImage blank = ImageIO

Trying to paint image to JFrame with Java BufferedImage, Graphics

有些话、适合烂在心里 提交于 2019-12-10 17:39:14
问题 I'm trying to capture the screen and then paint the image to a JFrame recursively while scaling the image (to create that effect you get when you look at a mirror in a mirror). I'm having trouble with my code - it doesn't paint any graphics. What am I doing wrong? import java.awt.AWTException; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.Graphics; import java.awt.HeadlessException; import java.awt.Image; import java.awt.Rectangle; import java.awt.Robot; import java

Guidance on the BufferedImage.getSubimage(int x, int y, int w, int h) method?

╄→尐↘猪︶ㄣ 提交于 2019-12-10 15:56:37
问题 I'm currently attempting to split an image, and I ran into a snitch and I have no idea why it's happening. Here's a quick pseudo code breakdown of my function Read in the image using the ImageIO.read(File file) method Split the images up using the getSubimage() method as follows: bufferedImage.getSubimage(300, 300, bufferedImage.getWidth() / columns, bufferedImage.getHeight() / rows); Write it to the images directory using the ImageIO.write() method. The problem is that the int x and int y