Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / Java 2D / Image Corruption from Graphics.copyArea on: 2007-07-13 16:12:02
I have a BufferedImage that I am drawing to.  All is good but when I call copyArea, the image gets corrupted.  It may be because there are multiple calls in a row (think window moves) for the copy and one copy doesn't finish before the next is called.  Does anyone know if this method is somehow threaded?  Is there a way to disable the threading if it is there?

Thanks in advance
2  Java Game APIs & Engines / Java 2D / Re: 2D Rendering Advice on: 2007-07-11 19:04:34
Not sure if this will help, but here's code for accessing pixel[] arrays in a BufferedImage quickly, so you don't have to copy from a MemoryImageSource.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
        int w = getWidth();
        int h = getHeight();
        int[] pixels = new int[w * h];
       
        DirectColorModel colorModel =
            new DirectColorModel(24, 0xff0000, 0x00ff00, 0x0000ff);

        SampleModel sampleModel = new SinglePixelPackedSampleModel(
            DataBuffer.TYPE_INT, w, h, new int[] { 0xff0000, 0x00ff00, 0x0000ff });
       
        DataBuffer dataBuffer = new DataBufferInt(pixels, w * h);
       
        WritableRaster raster = Raster.createWritableRaster(
            sampleModel, dataBuffer, new Point(0,0));
       
        awtImage = new BufferedImage(colorModel, raster, true, new Hashtable());



And does that end up being quicker than using the WritableRaster that is supplied by the BufferedImage automatically?  I tried
1  
int[] pixels = ((DataBufferInt)memImage.getRaster().getDataBuffer()).getData(0);

and it ends up being much slower than the version I have now
3  Java Game APIs & Engines / Java 2D / 2D Rendering Advice on: 2007-07-11 16:37:54
I am writing an application that decodes image data from a network stream and then renders it.  I need two rendering modes, one for on screen rendering and one for image rendering to disk.  Because the data is often raw pixels, I am currently using the code below to allow access to the pixel data directly and then copy the changed pixels to the regular BufferedImage.  When the data stream has a line or rectangle encoded, I draw directly to the BufferedImage.  Is there a faster/smarter way to do this?  I have tried accessing the pixels stored in the DataBufferInt rather than using the pixel[] below and performance is horrendous.

Thanks in advance for any suggestions.

pixels = new int[width * height];
memImageSrc = new MemoryImageSource(width, height, colorModel, pixels, 0, width);
memImageSrc.setAnimated(true);
      
memImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
memGraphics = memImage.getGraphics();
pixelsSource =   new MemoryImageSource(width, height, colorModel, pixels, 0, width);
pixelsSource.setAnimated(true);
rawPixelsImage = Toolkit.getDefaultToolkit().createImage(pixelsSource);
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (32 views)
2014-04-15 18:08:23

BurntPizza (29 views)
2014-04-15 03:46:01

UprightPath (44 views)
2014-04-14 17:39:50

UprightPath (27 views)
2014-04-14 17:35:47

Porlus (44 views)
2014-04-14 15:48:38

tom_mai78101 (65 views)
2014-04-10 04:04:31

BurntPizza (125 views)
2014-04-08 23:06:04

tom_mai78101 (225 views)
2014-04-05 13:34:39

trollwarrior1 (190 views)
2014-04-04 12:06:45

CJLetsGame (198 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!