View Single Post
Old 30th November 2007, 05:30 AM   #1
lisa
Senior Member
Professional user
 
lisa's Avatar
 
Join Date: Mar 2005
Location: Phoenix, AZ
Posts: 917
Default ac_image_GET_data

Function I wish I had:

bool ac_image_get_data(ACImage *i, unsigned char *data, size_t maxlen);

Where:

i - Image I want to retrieve the pixels for
data - pointer to a buffer I have pre-allocated to receive the pixel data
maxlen - the size of my destination buffer in bytes

Returns:

True if success, false if destination buffer size is too small. Correct buffer size can be calculate with ac_image_get_dim.

This would be the matching pair to ac_image_SET_data.

I don't know if AC3D keeps the pixel data around, or if it discards it after generating a surface for GL. I know reading pixels back from a surface is a no-no on some hardware. Alternatively, if this is the case, a variation of add_new_texture_opt that returned the image pixel data as a buffer instead of loading it to a texture would also work.

My goal is to access the texture data without having to re-implement the existing texture importers... I can work around it by getting the file name from AC3D and reloading the texture data myself, but then I don't get the benefit of all the nice image importers that have already been written, so I can't support all the formats that AC3D can.

Potential applications for this method:
- Texture baking
- Fur or other geometry generators that use input textures for color or density
- Displacement mapping
- Exporters that also perform image conversion
- Many more!

Ideas or more elegant work-arounds appreciated!
lisa is offline   Reply With Quote