Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (741)
Games in Android Showcase (225)
games submitted by our members
Games in WIP (823)
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 14: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 17: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.
        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
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 14: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);
memImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
memGraphics = memImage.getGraphics();
pixelsSource =   new MemoryImageSource(width, height, colorModel, pixels, 0, width);
rawPixelsImage = Toolkit.getDefaultToolkit().createImage(pixelsSource);
Pages: [1]
xxMrPHDxx (12 views)
2017-11-21 16:21:00

xxMrPHDxx (10 views)
2017-11-21 16:14:31

xxMrPHDxx (10 views)
2017-11-21 16:10:57

Ecumene (113 views)
2017-09-30 02:57:34

theagentd (148 views)
2017-09-26 18:23:31

cybrmynd (246 views)
2017-08-02 12:28:51

cybrmynd (242 views)
2017-08-02 12:19:43

cybrmynd (242 views)
2017-08-02 12:18:09

Sralse (257 views)
2017-07-25 17:13:48

Archive (875 views)
2017-04-27 17:45:51
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51 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‑
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!