Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (535)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Obtain pixel from Image(Slick2D)  (Read 1141 times)
0 Members and 1 Guest are viewing this topic.
Offline P0jahn

Senior Member


Projects: 3



« Posted 2013-01-23 11:32:59 »

Using image.getColor is afaik performance killer. Is there any other options? Take note that this option should be compatible with rotated images.
Offline Mads

JGO Ninja


Medals: 26
Projects: 3
Exp: 6 years


One for all!


« Reply #1 - Posted 2013-01-23 11:52:05 »

Have you tried just doing what you suggested? I can't see why it should be a bottleneck. It looks like it's just a few calls to the pixel-array, and that operation is usually extremely fast.

EDIT: My bad.

Offline davedes
« Reply #2 - Posted 2013-01-23 18:12:36 »

getColor is indeed a performance killer, as it involves copying data from the GPU to CPU. Once cached, this isn't so bad, but if you are doing things like rendering to offscreen graphics, the data will be flushed and will need to be re-copied every frame. And it won't work with rotated images.

What are you trying to achieve? Maybe you need shaders.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline P0jahn

Senior Member


Projects: 3



« Reply #3 - Posted 2013-01-23 18:22:13 »

I am trying to create a fast pixel-perfect function. The only thing making it ineffective is grabbing the pixels from the Image.
I have made a piss solution, by associating every image with an int[][] array(that represent all the pixels in the image). This array is initiated at loading screen. The results performance wise is fantastic. But it turns my code into a mess, killing the readability. And its not working with rotation.
Offline davedes
« Reply #4 - Posted 2013-01-23 18:40:32 »

Using image data for pixel-perfect collision only works when you aren't changing the image (i.e. scaling or rotating it).

If you are really set on pixel-perfect, some occlusion queries may be a possibility. Instead for your purposes you should be using polygons. Here is a good book on the subject.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

E.R. Fleming (17 views)
2014-07-29 03:07:13

E.R. Fleming (6 views)
2014-07-29 03:06:25

pw (39 views)
2014-07-24 01:59:36

Riven (39 views)
2014-07-23 21:16:32

Riven (26 views)
2014-07-23 21:07:15

Riven (28 views)
2014-07-23 20:56:16

ctomni231 (59 views)
2014-07-18 06:55:21

Zero Volt (50 views)
2014-07-17 23:47:54

danieldean (42 views)
2014-07-17 23:41:23

MustardPeter (44 views)
2014-07-16 23:30:00
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!