从 AWT 和 JAI 转换为 Android
我在将 java 项目转换为 android 项目时遇到问题。是什么让 我混淆相当于 SampleModel、ColorModel、WritableRaster, 和 Android 的 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[] 作为输入的图像,并平铺 每个像素为 4x4 框,宽度为 numXTiles*4,高度为 numYTiles*4。
有人可以帮忙吗?非常感谢:)
I have a problem about converting java project to android. What makes
me confuse is the equivalent to SampleModel, ColorModel, WritableRaster,
and TiledImage for android? Here is the snipped code:
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");
This code is for creating an image with int[] as the input, and tiling
each pixel to 4x4 box which width is numXTiles*4 and height is
numYTiles*4.
Can anyone help? many thx :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论