Here you can find the source of saveColorTable(final float[][] table, final File file)
public static boolean saveColorTable(final float[][] table, final File file)
//package com.java2s; /*// www.ja va2 s .com * #%L * VisBio application for visualization of multidimensional biological * image data. * %% * Copyright (C) 2002 - 2014 Board of Regents of the University of * Wisconsin-Madison. * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 2 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-2.0.html>. * #L% */ import java.io.DataOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { /** Color table file length. */ protected static final int LUT_LEN = 768; /** * Saves the given color table into the specified file. * * @return true if file was saved successfully */ public static boolean saveColorTable(final float[][] table, final File file) { if (file == null || table == null || table.length != 3) return false; // convert LUT data to binary format final int len = LUT_LEN / 3; final int[] b = new int[LUT_LEN]; int count = 0; for (int i = 0; i < 3; i++) { if (table[i].length != len) return false; for (int j = 0; j < len; j++) b[count++] = (int) (255 * table[i][j]); } // write out LUT data try { final DataOutputStream fout = new DataOutputStream(new FileOutputStream(file)); for (int i = 0; i < LUT_LEN; i++) fout.writeByte(b[i]); fout.close(); } catch (final IOException exc) { return false; } return true; } }