Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
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  
  Fetching an Image  (Read 1124 times)
0 Members and 1 Guest are viewing this topic.
Offline Vision_Thing

Senior Newbie




Java games rock!


« Posted 2003-05-26 04:50:24 »

Hi, long time no see.
I've been really busy with my software 3D engine and it is turning out to be a nice system Wink

I have one question about Images though... Is there any other way to fetch the pixels from an Image than with a PixelGrabber? First, it's slow and secondly if a game has a high framerate and getPixels() is called like 60 times/second the program will eventually crash as it cannot fetch the pixels fast enough. The implementation doesn't allow the pixels to be cached as a new image can be supplied at any time asynchronously, so this is the only way. Right now I've solved it by forcing the user to fetch the pixels by himself and give the pixel array as an argument to my method, but it feels somewhat of a hack. Any ideas?

This is all for now,
laters dudes =)
Offline HeartOfGold

JGO Visitor



Java games rock!


« Reply #1 - Posted 2003-05-26 06:30:57 »

How about reading the pixels data from a file to an array (maybe using your own format) and using java.awt.image.MemoryImageSource to create a java.awt.Image? You can have immedeate access to the pixel array aswell as to the image.
Offline Vision_Thing

Senior Newbie




Java games rock!


« Reply #2 - Posted 2003-05-26 07:47:41 »

Quote
How about reading the pixels data from a file to an array (maybe using your own format) and using java.awt.image.MemoryImageSource to create a java.awt.Image? You can have immedeate access to the pixel array aswell as to the image.


Hi.
That's what I am doing now, but I want to have a method, drawImage(Image, width, height etc...) in my own rasteriser. I try to keep a high abstraction level so the user won't have to fetch the image pixels himself and calling the current drawImage(int[] pixels, width, height etc...). Hope you understand what I mean.
Laters.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Abuse

JGO Coder


Medals: 2


falling into the abyss of reality


« Reply #3 - Posted 2003-05-26 13:08:34 »

Quote


Hi.
That's what I am doing now, but I want to have a method, drawImage(Image, width, height etc...) in my own rasteriser. I try to keep a high abstraction level so the user won't have to fetch the image pixels himself and calling the current drawImage(int[] pixels, width, height etc...). Hope you understand what I mean.
Laters.


Then the answer is no.

I suggest you create a wrapper for the int [] way of doing it, and then simply provide a drawImage(YourImageClass,x,y,etc)

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here!
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #4 - Posted 2003-05-26 14:02:22 »

If you use a BufferedImage then you should be able to get at the pixel data through the Raster object.

Offline Abuse

JGO Coder


Medals: 2


falling into the abyss of reality


« Reply #5 - Posted 2003-05-26 15:18:50 »

Quote
If you use a BufferedImage then you should be able to get at the pixel data through the Raster object.


I think hes sticking to 1.1.
Atleast, thats the assumption I made when I said 'no'.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here!
Offline Vision_Thing

Senior Newbie




Java games rock!


« Reply #6 - Posted 2003-05-27 01:45:37 »

Quote


I think hes sticking to 1.1.
Atleast, thats the assumption I made when I said 'no'.



Correct, Java1.1 here =)
Thanks for the help though, now I can leave this behind me and focus on other things.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

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

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (84 views)
2013-05-17 21:29:12

alaslipknot (92 views)
2013-05-16 21:24:48

gouessej (123 views)
2013-05-16 00:53:38

gouessej (115 views)
2013-05-16 00:17:58

theagentd (127 views)
2013-05-15 15:01:13

theagentd (114 views)
2013-05-15 15:00:54

StreetDoggy (158 views)
2013-05-14 15:56:26

kutucuk (180 views)
2013-05-12 17:10:36

kutucuk (180 views)
2013-05-12 15:36:09

UnluckyDevil (187 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.07 seconds with 20 queries.