There
are lots of things you can try. The first thing is to use the ImageIO
library to load the image (ImageIO.read(filename)). Another thing you can
try is to use JDK 1.4s ability to memory map files and map your image directly
into memory. This means your map could be in interleaved ARGB format
already, or you can have it compressed but map the file for faster
loading. We don't use the texture loader utility anymore because we wanted
finer control over what it does. If you don't want to write the code to
create the tetxure itself from the image, you can load the buffered image via
ImagIO or some other library and then call textureloader(bufferedimage) to make
the texture, but if the texture loader thinks that the underlying format of the
image does not match the imagecomponent needs then it will rebuild it, which
takes time. Another thing to realize is that if you are not using YUP and
BYREF then it will copy your buffered image yet again! And if you are
mipmapping then it will laboriously make those scaled
copies.
The
abolutely fastest way to read your image would be to do the
following:
1. pre
build your images and store them on disk. Build all map map levels and
store it in RGB or ARGB interlaced format on the disk file.
2. Use
NIO to create a bytebuffer and load the entire file in one call into your byte
buffer.
3. Map
the buffer as a int buffer, construct your image and use setpixels to slam the
data in.
4.
load each level
5.
build image componants using by ref and yup
6.
build your texture object and assign your cimage components.
You
could probably load a 2k x 2k image in under a second with this
approach.
Dave
Yazel
-----Original Message-----
From: hammad [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 05, 2003 12:58 AM
To: [EMAIL PROTECTED]
Subject: [JAVA3D] Texture loading problem for big files ...I am trying to load a map within my 3D Universe via TextureLoader utility.. The problem which i am facing is that is eats a hell lot of time ....I have tried differenent file formats like gif, bmp and jpg ..... the.bmp files loads the fastest that is around 40 secs ... which is a 12MB file ....Is there any more elegant way to load such huge files quicker ... I am P4 system with GForce4 3D card ... so processing is not an issue out here .. and the map is in the order of 2 so the loading should be efficent in that case as wellI am using it like thisTexture texture = new TextureLoader(mapPath,null).getTexture();Any ideas ...Hammad
Do you Yahoo!?
Free online calendar with sync to Outlook(TM).
