BlinkenArea - GitList
Repositories
Blog
Wiki
BlinkenSimJava
Code
Commits
Branches
Tags
Search
Tree:
16048cb
Branches
Tags
master
v0.1
v0.1.1
v0.2
BlinkenSimJava
Frame.java
BlinkenSimJava v.0.1 (2004-06-29)
Christian Heimke
commited
16048cb
at 2011-07-15 09:12:42
Frame.java
Blame
History
Raw
public class Frame { private int height; private int width; private int channels; private byte[][][] data; Frame( int height, int width, int channels ) { this.height = height; this.width = width; this.channels = channels; data = new byte[height][width][channels]; } Frame( Frame frame ) { height = frame.height; width = frame.width; channels = frame.channels; data = (byte[][][])frame.data.clone( ); } public void setData( int maxval, byte[] rawData, int startIndex ) { int i, h, w, c; for( i = startIndex, h = 0; h < height; h++ ) for( w = 0; w < width; w++ ) for( c = 0; c < channels; c++, i++ ) if( rawData[i] > maxval ) data[h][w][c] = (byte)255; else data[h][w][c] = (byte)((rawData[i] & 0xFF) * 255 / maxval); } public int getHeight( ) { return height; } public int getWidth( ) { return width; } public int getChannels( ) { return channels; } public byte[][][] getData( ) { return data; } public String toString( ) { String str = ""; int h, w, c, val; for( h = 0; h < height; h++ ) { for( w = 0; w < width; w++ ) { val = 0; for( val = 0, c = 0; c < channels; c++ ) val += (data[h][w][c] & 0xFF); val /= channels * 32; str = str + " -+*%#&@".substring( val, val + 1); } str = str + "\n"; } return str; } }