void interpolate_cmap(flam3_palette cmap, double blend, int index0, double hue0, int index1, double hue1) { flam3_palette p0,p1; int i, j; flam3_get_palette(index0, p0, hue0); flam3_get_palette(index1, p1, hue1); for (i = 0; i < 256; i++) { double t[5], s[5]; rgb2hsv(p0[i].color, s); rgb2hsv(p1[i].color, t); s[3] = p0[i].color[3]; t[3] = p1[i].color[3]; s[4] = p0[i].index; t[4] = p1[i].index; for (j = 0; j < 5; j++) t[j] = ((1.0-blend) * s[j]) + (blend * t[j]); hsv2rgb(t, cmap[i].color); cmap[i].color[3] = t[3]; cmap[i].index = t[4]; } }
void PaletteEditor::buildPaletteSelector() { // only do this once, but it takes a while, so only when asked static bool built = false; if (built) return; built = true; logInfo("PaletteEditor::buildPaletteSelector : generating palettes"); QSize s = m_palettesView->iconSize(); for (int n = 0 ; n < PaletteCount ; n++) { flam3_palette p; flam3_get_palette(n, p, 0.0); QImage palette(s.width(), s.height(), QImage::Format_RGB32); QPainter painter(&palette); for (int i = 0 ; i < 256 ; i++) { painter.setPen(QColor::fromRgbF(p[i].color[0], p[i].color[1], p[i].color[2])); painter.drawLine(i, 0, i, s.height()); } m_flamPalettes.addGradient(QPixmap::fromImage(palette)); } if (!m_lastBrowseDir.isEmpty()) { // restore p_stops for the initial call to resetGradientAction GradientStops tmp(p_stops); openGradientAction(true); p_stops = tmp; } }
void PaletteEditor::loadPalette(int palette_idx) { flam3_get_palette(palette_idx, p, 0.0); }