Package net.sourceforge.jiu.data

Examples of net.sourceforge.jiu.data.Palette


  {
    if (out == null)
    {
      out = (Paletted8Image)in.createCompatibleImage(in.getWidth(), in.getHeight());
    }
    Palette palette = out.getPalette();
    int numSamples = palette.getNumEntries();
    final int[] LUT = createLookupTable(numSamples, brightness);
    for (int c = 0; c < 3; c++)
    {
      for (int i = 0; i < palette.getNumEntries(); i++)
      {
        palette.putSample(c, i, LUT[palette.getSample(c, i)]);
      }
    }
    for (int y = 0; y < in.getHeight(); y++)
    {
      for (int x = 0; x < in.getWidth(); x++)
View Full Code Here


    {
      paletteSize = numUniqueColors;
    }
    RGBColorList list = new RGBColorList(hist);
    list.sortByCounter(0, list.getNumEntries() - 1);
    Palette result = new Palette(paletteSize);
    int paletteIndex = paletteSize - 1;
    int listIndex = list.getNumEntries() - 1;
    while (paletteIndex >= 0)
    {
      RGBColor color = list.getColor(listIndex--);
      result.put(paletteIndex--,
        color.getSample(RGBIndex.INDEX_RED),
        color.getSample(RGBIndex.INDEX_GREEN),
        color.getSample(RGBIndex.INDEX_BLUE)
      );
    }
View Full Code Here

  public Palette createPalette()
  {
    if (palette == null)
    {
      int numValues = assignPaletteIndexValues(root, 0);
      palette = new Palette(numValues);
      initPalette(root, palette);
      redValues = new int[numValues];
      greenValues = new int[numValues];
      blueValues = new int[numValues];
      for (int i = 0; i < numValues; i++)
View Full Code Here

  }

  private void mapImage()
  {
    RGB24Image in = (RGB24Image)getInputImage();
    Palette palette = createPalette();
    Paletted8Image out = new MemoryPaletted8Image(in.getWidth(), in.getHeight(), palette);
    int[] origRgb = new int[3];
    int[] quantizedRgb = new int[3];
    for (int y = 0; y < in.getHeight(); y++)
    {
View Full Code Here

    }
  }

  public PixelImage createCompatibleImage(int width, int height)
  {
    Palette newPalette = null;
    Palette myPalette = getPalette();
    if (myPalette != null)
    {
      newPalette = (Palette)myPalette.clone();
    }
    return new MemoryPaletted8Image(width, height, newPalette);
  }
View Full Code Here

  }

  public long getAllocatedMemory()
  {
    long result = super.getAllocatedMemory();
    Palette myPalette = getPalette();
    if (myPalette != null)
    {
      result += myPalette.getAllocatedMemory();
    }
    return result;
  }
View Full Code Here

            throw new InvalidFileStructureException("Cannot " +
              "load image. The size of the colormap is " +
              "invalid: " + size);
          }
          int numColors = size / 3;
          palette = new Palette(numColors, 255);
          for (int i = 0; i < numColors; i++)
          {
            palette.putSample(Palette.INDEX_RED, i, in.readByte() & 0xff);
            palette.putSample(Palette.INDEX_GREEN, i, in.readByte() & 0xff);
            palette.putSample(Palette.INDEX_BLUE, i, in.readByte() & 0xff);
View Full Code Here

    if (palette == null)
    {
      return;
    }
    int numPaletteEntries = palette.getNumEntries();
    Palette tempPalette = new Palette(numPaletteEntries * 2, 255);
    for (int i = 0; i < numPaletteEntries; i++)
    {
      int red = palette.getSample(Palette.INDEX_RED, i);
      tempPalette.putSample(Palette.INDEX_RED, numPaletteEntries + i, red);
      tempPalette.putSample(Palette.INDEX_RED, i, (red / 2) & 0xf0);
      int green = palette.getSample(Palette.INDEX_GREEN, i);
      tempPalette.putSample(Palette.INDEX_GREEN, numPaletteEntries + i, red);
      tempPalette.putSample(Palette.INDEX_GREEN, i, (green / 2) & 0xf0);
      int blue = palette.getSample(Palette.INDEX_BLUE, i);
      tempPalette.putSample(Palette.INDEX_BLUE, numPaletteEntries + i, blue);
      tempPalette.putSample(Palette.INDEX_BLUE, i, (blue / 2) & 0xf0);
    }
    palette = tempPalette;
  }
View Full Code Here

    }
    if (numEntries > 256)
    {
      throw new InvalidFileStructureException("Number of palette entries larger than 256: " + numEntries);
    }
    palette = new Palette((int)numEntries);
    int index = 0;
    do
    {
      palette.putSample(Palette.INDEX_RED, index, in.read() & 0xff);
      palette.putSample(Palette.INDEX_GREEN, index, in.read() & 0xff);
View Full Code Here

    if (colorType != COLOR_TYPE_INDEXED)
    {
      return;
    }
    Paletted8Image image = (Paletted8Image)getImage();
    Palette pal = image.getPalette();
    int numEntries = pal.getNumEntries();
    byte[] data = new byte[numEntries * 3];
    for (int i = 0, j = 0; i < numEntries; i++, j += 3)
    {
      data[j] = (byte)pal.getSample(RGBIndex.INDEX_RED, i);
      data[j + 1] = (byte)pal.getSample(RGBIndex.INDEX_GREEN, i);
      data[j + 2] = (byte)pal.getSample(RGBIndex.INDEX_BLUE, i);
    }
    saveChunk(CHUNK_TYPE_PLTE, data.length, data);
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.jiu.data.Palette

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.