Desperate plea for help: access to raw image data
Folks,
I need to convert images stores as JPEG, BMP, etc. files to OpenGL
textures. I spent a few days trying to load my images using various
methods. According to the docs LispWorks uses image decoding libraries
internally and I would like to use this capability. I would be
duplicating code and introducing /perhaps/ unneeded dependencies if I
were to go with a C library and write my texture loading code in C.
To load a texture OpenGL expects an array of RGB, RGBA, etc. raw data.
The only way to create this data now is by using the gp:image-access
api, extract the individual pixels, unconvert the color and extract
the float color values. You will then need to either multiply the
color values by 255 when storing into a byte array or store them into
a float array.
I wrote code that uses CL-JPEG (CLJL, external JPEG decompressor
written in Lisp) to load my textures as well as code that uses the the
gp:image-access apis. I'm storing raw data into a float array. The
results in both cases are killing me. And I some of my images are BMP
so I'll need yet another decoder if I am to go with the faster
solution.
Take a look at these results but don't pay attention to the speed too
much. I was running iTunes to simulate normal machine load and had
lots of memory taken by a PDF viewer, web browser, etc. #1 takes 14x
more memory and runs almost 4 times slower than #2!
1. This is the version that uses gp:image-access apis
Timing the evaluation of (LOAD1 V)
user time = 5.200
system time = 0.050
Elapsed time = 0:00:07
Allocation = 146926864 bytes
3976 Page faults
2. This is the version that uses CL-JPEG
Timing the evaluation of (LOAD2 V)
user time = 2.100
system time = 0.080
Elapsed time = 0:00:03
Allocation = 10384964 bytes
4966 Page faults
The GP code that loads images from disk is very fast and all the time
is spent extracting pixels. How can I get hold of the raw image bytes
after loading the image? I assume that the GP apis need to store this
data someplace. Is there some kind of an undocumented function? I
would be in haven if there was and would, it's all I need and I that
I'm asking for!
Thanks, Joel
--
http://wagerlabs.com/
New generation of poker room software