java-2d

Java create anaglyph (red/blue image)

六月ゝ 毕业季﹏ 提交于 2019-12-22 05:28:10
问题 I'm writing a Java game engine (http://victoryengine.org) and I've been experimenting with generating "3d" images with depth that you can see with those red/blue glasses. I'm using Java2D for graphics. I've created something that works, but is very slow (by manually copying pixel values and stuff like that). What I need to is take two BufferedImages (one for the left eye, one for the right) and combine them into one (either another buffer or directly to screen). For one I just want the red

AffineTransform without transforming Stroke?

感情迁移 提交于 2019-12-22 03:20:08
问题 When using the Graphics2D scale() function with two different parameters (scaling by different ratios in x- and y-direction), everything drawn later on this Graphics2D object is scaled too. This has the strange effect that lines drawn in one direction are thicker than those in another direction. The following program produces this effect, it shows this window: public class StrokeExample extends JPanel { public void paintComponent(Graphics context) { super.paintComponent(context); Graphics2D g

Scala library for image creation

邮差的信 提交于 2019-12-21 21:27:26
问题 Is there any good Scala or Java library for image manipulation? For simple tasks like composing an image with some others then generating a thumb? 回答1: they're all a bit old school, and maybe inconvenient, but java.awt, java.awt.image, and javax.imageio has everything you need to blend and rescale images. You can find some blending example code e.g. here http://www.curious-creature.org/2006/09/20/new-blendings-modes-for-java2d/ you can find some examples of rescaling and generating image

How do I load an enormous image to Java via BufferedImage?

无人久伴 提交于 2019-12-21 12:42:14
问题 I want to load large images (18000 x 18000) to my application. If i use BufferedImage with type int_rgb , I need around 1235mb of heap memory to load. This is a very high amount of memory, and end users will likely have less ram (1GB or less). On my development PC, when I load the image from MyEclipse IDE, it throws an out of memory Exception . When i pack my code to an executable jar and run it on my PC external of Eclipse, it still throws an exception. How do I load such a large image into

Hardware accelerate bitmap drawing in java

时光毁灭记忆、已成空白 提交于 2019-12-21 06:57:14
问题 I want to be able to draw consecutive bitmaps (of type BufferedImage.TYPE_INT_RGB) of a video as quickly as possible in java. I want to know the best method in doing so. Does anyone have any advice where I should start? From what I've read, 2 options are: 1) Use GDI/GDI+ routines in a JNI dll working with JAWT (Im on Windows) 2) Use Java3D and apply Textures to a Box's face and rotate it to the camera Im interesting in any advice on these topics as well as any others. I have done a decent

understanding difficulties java swing

萝らか妹 提交于 2019-12-20 07:31:31
问题 im trying to paint random (not yet) circles on a JPanel through click on a JMenu. Im using a JTextField (and have to keep this) for some output. Here is my Class: class RandomDrawer extends JPanel implements ActionListener { @Override public void actionPerformed(ActionEvent e) { //double x = Math.random(); //double y = Math.random(); Random generator = new Random(); int x = generator.nextInt(100)+1; int y = generator.nextInt(100)+1; //System.out.printf("x = %d y = %d\n", x, y); status.setText

Slow Java2D Drawing on Integrated Graphics

China☆狼群 提交于 2019-12-20 06:31:33
问题 I'm working on a simple 2D game, rendering via the Java2D API. I've noticed that when I try to draw on integrated graphics card the performance crashes. I've tested this game on both my main rig with a newer ATI Radeon and my 5 year old laptop which also has an (incredibly antiquated) Radeon. On both I get good FPS, but when I try to use my Intel i5's onboard HD 4000 graphics, it crawls at around 20 FPS. I'm using Full Screen Exclusive mode. At any given moment, I am rendering approximately

Slow Java2D Drawing on Integrated Graphics

北城余情 提交于 2019-12-20 06:30:58
问题 I'm working on a simple 2D game, rendering via the Java2D API. I've noticed that when I try to draw on integrated graphics card the performance crashes. I've tested this game on both my main rig with a newer ATI Radeon and my 5 year old laptop which also has an (incredibly antiquated) Radeon. On both I get good FPS, but when I try to use my Intel i5's onboard HD 4000 graphics, it crawls at around 20 FPS. I'm using Full Screen Exclusive mode. At any given moment, I am rendering approximately

want to drawLine additionally when Timer generates Events

拟墨画扇 提交于 2019-12-20 04:55:10
问题 As I wrote in title, I want to drawLine additionally when Timer generates events. Line will be draw like first time; ㅡ second time; ㅡ ㅡ I want line will be added on before's maintained situation If first purpose cannot be done, (because I'm not good at Java yet, that's just my idea) I want to draw N line in Nth events then i redraw new N+1 line in (N+1)th events. Which could be done in Java? P.S. How to stop the Swing Timer ? 回答1: You'll basically have to (not in order): Build an event to

Draw an infinite line through 2 points?

落爺英雄遲暮 提交于 2019-12-20 02:29:44
问题 I'm looking for a way to draw an infinite line (a line with no end, also known as a ray) through 2 points. I can draw a line between 2 points with Line2D, no problem here. Next the infinite part needed a look. With my simple mind I thought, lets multiply the x and y coordinates from the second point with 100 and redraw the line. This works, but only in simple cases. For example here is a case in which it produces lines with different angles: g.setColor(Color.red); g2.setStroke(new BasicStroke