2

我有一个关于将java项目转换为android的问题。让我感到困惑的是 android 的 SampleModel、ColorModel、WritableRaster 和 TiledImage 等价物?这是截断的代码:

SampleModel sampleModel = RasterFactory.createBandedSampleModel(
               DataBuffer.TYPE_BYTE, 4 * numXTiles, 4* numYTiles, 1);
   ColorModel colorModel = PlanarImage.createColorModel(sampleModel);
   WritableRaster decWRaster = RasterFactory.createWritableRaster(
               sampleModel, null);
   for (int j = 0; j < numYTiles; j++) {
            for (int i = 0; i < numXTiles; i++) {
               int indexEnc = disEnc.readByte();
               if (indexEnc < 0) indexEnc = indexEnc + 128;
               System.out.print(indexEnc + " ");

               int[] codeWord = codeBook[indexEnc];
               decWRaster.setPixels(i * 4, j * 4, 4, 4, codeWord);
            }
         }
         TiledImage decTImage = new TiledImage(0, 0, 4 * numXTiles,
               4 * numYTiles, 0, 0, sampleModel, colorModel);
         decTImage.setData(decWRaster);
         JAI.create("FileStore", decTImage, decPath + "test4.bmp",
"BMP");

此代码用于以 int[] 作为输入创建图像,并将每个像素平铺到宽度为 numXTiles*4 且高度为 numYTiles*4 的 4x4 框。

任何人都可以帮忙吗?很多谢谢 :)

4

0 回答 0