richarddlu / jmonkeyengine

Automatically exported from code.google.com/p/jmonkeyengine
0 stars 0 forks source link

Capability to access and modify image data without regard to format #521

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
At the moment it is hard to modify arbitrary jME3 images, as there are many 
formats supported. Users are expected to access the image's ByteBuffer directly 
and modify the bytes. 
A more convinient method should be available. For example, an "ImageReadWrite" 
class could be created, taking as argument a jME3 image object. 
It would have two methods:

// Reads a pixel on the image into the given color argument.
void readPixel(int x, int y, ColorRGBA store);

// Writes the given color into the image at the pixel location.
void writePixel(int x, int y, ColorRGBA color);

The input color (in single precision floating point) would be converted to the 
target precision as needed. E.g. for RGBA8, each component would be converted 
from float 0.0 - 1.0 to unsigned byte 0 - 255. If a component is not available, 
it is set to 1.0. For example reading from Alpha8 image would set the ColorRGBA 
R, G and B components to 1.0.

Original issue reported on code.google.com by ShadowIs...@gmail.com on 15 Jul 2012 at 11:38

GoogleCodeExporter commented 8 years ago
i agree jme3tools.optimize.TextureAtlas class uses pixel manipulation methods 
but they are hardcoded private not allowing to be reused.

This forces users like me, to use BufferedImage in order to move pixel data,
creating ungly code that cant run on android.

I propose to create this Utilities class.

Offending Code:
jme3tools.optimize.TextureAtlas.drawImage

Sugggested methods:
1) draw pixel at desired position.
2) get pixel from desired position.
3) draw whole image on desired position.

Original comment by tralalol...@gmail.com on 31 Jul 2012 at 10:52

GoogleCodeExporter commented 8 years ago

Original comment by ShadowIs...@gmail.com on 6 Sep 2012 at 6:09