/*** 红外照片转RGB888图片* @param sourceFilePath 本地源文件* @return*/
public static BoolResult convertToRGB888File(String sourceFilePath) {//1.红外图片二进制数据try {FileInputStream fis0 = new FileInputStream(sourceFilePath);if (dirpHandle != null) {tsdkLibrary.dirp_destroy(dirpHandle.getPointer(0));}//创建句柄dirpHandle = new Memory(fis0.available());byte[] buffer = new byte[(int) fis0.available()];int read = fis0.read(buffer, 0, fis0.available());// 指针分配tsdkLibrary.dirp_create_from_rjpeg(buffer, buffer.length, dirpHandle);fis0.close();// 获取分辨率dirp_resolution_t resolution = new dirp_resolution_t();tsdkLibrary.dirp_get_rjpeg_resolution(dirpHandle.getPointer(0), resolution);int imageSize2 = resolution.width * resolution.height * 3;byte[] bytes6 = new byte[imageSize2];int i1 = tsdkLibrary.dirp_process(dirpHandle.getPointer(0), bytes6, imageSize2);System.out.println("i1 = " + i1);// 创建BufferedImage对象BufferedImage image = new BufferedImage(resolution.width, resolution.height, BufferedImage.TYPE_INT_RGB);// 将字节数据写入BufferedImageint index = 0;for (int y = 0; y < resolution.height; y++) {for (int x = 0; x < resolution.width; x++) {// 读取RGB值(每个像素3个字节)int r = bytes6[index++] & 0xFF;int g = bytes6[index++] & 0xFF;int b = bytes6[index++] & 0xFF;// 组合成RGB颜色值int rgb = (r << 16) | (g << 8) | b;// 设置像素颜色image.setRGB(x, y, rgb);}}//修改文件名称String finalRawJPGObjectName = sourceFilePath.replace(".jpeg", "_raw.bmp");// 保存图片到文件ImageIO.write(image, "bmp", new File(finalRawJPGObjectName));return new BoolResult(true);} catch (Exception exception) {exception.printStackTrace();return new BoolResult(false).setData("操作失败!");}}