create tiled image

Problems with Canvas, OpenGL, etc...

create tiled image

Postby amel » Thu Jul 28, 2011 11:09 am

i want to create a grayscale image from array of integer with defined height and width. it consist of 16 pixel that will be tilled into 4x4 pixels. how can i do this? i have the java project but i still confuse to porting it to android project. here is the snippet code of java project:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. SampleModel sampleModel = RasterFactory.createBandedSampleModel(
  2.                DataBuffer.TYPE_BYTE, 4 * numXTiles, 4* numYTiles, 1);
  3.    ColorModel colorModel = PlanarImage.createColorModel(sampleModel);
  4.    WritableRaster decWRaster = RasterFactory.createWritableRaster(
  5.                sampleModel, null);
  6.    for (int j = 0; j < numYTiles; j++) {
  7.             for (int i = 0; i < numXTiles; i++) {
  8.                int indexEnc = disEnc.readByte();
  9.                if (indexEnc < 0) indexEnc = indexEnc + 128;
  10.                System.out.print(indexEnc + " ");
  11.  
  12.                int[] codeWord = codeBook[indexEnc];
  13.                decWRaster.setPixels(i * 4, j * 4, 4, 4, codeWord);
  14.             }
  15.          }
  16.          TiledImage decTImage = new TiledImage(0, 0, 4 * numXTiles,
  17.                4 * numYTiles, 0, 0, sampleModel, colorModel);
  18.          decTImage.setData(decWRaster);
  19.          JAI.create("FileStore", decTImage, decPath + "test4.bmp",
  20. "BMP");
Parsed in 0.037 seconds, using GeSHi 1.0.8.4


anyone can help me?
thx :)
amel
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Jul 28, 2011 10:43 am

Top

Return to Android 2D/3D Graphics - OpenGL Problems

Who is online

Users browsing this forum: No registered users and 1 guest