Java tutorial
//package com.java2s; /* * Copyright Samuel Halliday 2009 * * This file 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 3 of the License, or (at your option) any later version. * * This file 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 file. * If not, see <http://www.gnu.org/licenses/>. */ import com.google.common.base.Preconditions; import java.awt.Color; import java.util.Arrays; import java.util.Collections; import java.util.List; public class Main { private static List<Color> buildPalette(int[] raw) { Preconditions.checkArgument(raw.length == 256 * 3); Color[] pal = new Color[256]; for (int i = 0; i < pal.length; i++) { pal[i] = new Color(raw[i * 3], raw[i * 3 + 1], raw[i * 3 + 2]); } return Collections.unmodifiableList(Arrays.asList(pal)); } }