Examples of Palette


Examples of net.sourceforge.jiu.data.Palette

  private void createPaletted8FromRgb24(RGB24Image in)
  {
    // create palette from histogram
    int uniqueColors = hist.getNumUsedEntries();
    Palette palette = new Palette(uniqueColors, 255);
    int index = 0;
    for (int r = 0; r < 256; r++)
    {
      for (int g = 0; g < 256; g++)
      {
        for (int b = 0; b < 256; b++)
        {
          if (hist.getEntry(r, g, b) != 0)
          {
            hist.setEntry(r, g, b, index);
            palette.putSample(RGBIndex.INDEX_RED, index, r);
            palette.putSample(RGBIndex.INDEX_GREEN, index, g);
            palette.putSample(RGBIndex.INDEX_BLUE, index, b);
            index++;
          }
        }
      }
    }
View Full Code Here

Examples of net.sourceforge.jiu.data.Palette

  private void createPaletted8FromRgb48(RGB48Image in)
  {
    // create palette from histogram
    int uniqueColors = hist.getNumUsedEntries();
    Palette palette = new Palette(uniqueColors, 255);
    int index = 0;
    for (int r = 0; r < 256; r++)
    {
      for (int g = 0; g < 256; g++)
      {
        for (int b = 0; b < 256; b++)
        {
          if (hist.getEntry(r, g, b) != 0)
          {
            hist.setEntry(r, g, b, index);
            palette.putSample(RGBIndex.INDEX_RED, index, r);
            palette.putSample(RGBIndex.INDEX_GREEN, index, g);
            palette.putSample(RGBIndex.INDEX_BLUE, index, b);
            index++;
          }
        }
      }
    }
View Full Code Here

Examples of net.sourceforge.jiu.data.Palette

    else
    // PALETTED8
    if (inputImage instanceof Paletted8Image)
    {
      Paletted8Image in = (Paletted8Image)inputImage;
      Palette palette = in.getPalette();
      if (palette.isBlackAndWhite())
      {
        type = TYPE_BILEVEL;
        if (doConvert)
        {
          createBilevelFromPaletted(in);
        }
      }
      else
      if (palette.isGray())
      {
        type = TYPE_GRAY8;
        if (doConvert)
        {
          Gray8Image out = new MemoryGray8Image(in.getWidth(), in.getHeight());
View Full Code Here

Examples of net.sourceforge.jiu.data.Palette

   * @return palette with all representative colors
   */
  public Palette createPalette()
  {
    MedianCutNode[] leaves = createLeafList();
    Palette result = new Palette(leaves.length);
    for (int i = 0; i < leaves.length; i++)
    {
      int[] reprColor = leaves[i].getRepresentativeColor();
      result.putSample(INDEX_RED, i, reprColor[INDEX_RED]);
      result.putSample(INDEX_GREEN, i, reprColor[INDEX_GREEN]);
      result.putSample(INDEX_BLUE, i, reprColor[INDEX_BLUE]);
    }
    return result;
  }
View Full Code Here

Examples of net.sourceforge.jiu.data.Palette

      }
      mapImage((RGB24Image)in, (RGB24Image)out);
    }
    else
    {
      Palette palette = createPalette();
      if (out == null)
      {
        out = new MemoryPaletted8Image(in.getWidth(), in.getHeight(), palette);
        setOutputImage(out);
      }
View Full Code Here

Examples of net.sourceforge.jiu.data.Palette

  {
    // prepare(PixelImage) has made sure that we have a compatible output image
    Paletted8Image out = (Paletted8Image)getOutputImage();

    // invert palette of output image
    Palette pal = out.getPalette();
    final int MAX = pal.getMaxValue();
    for (int entryIndex = 0; entryIndex < pal.getNumEntries(); entryIndex++)
    {
      for (int channelIndex = 0; channelIndex < 3; channelIndex++)
      {
        pal.putSample(channelIndex, entryIndex, MAX - pal.getSample(channelIndex, entryIndex));
      }
    }

    // copy image content
    final int WIDTH = in.getWidth();
View Full Code Here

Examples of net.sourceforge.jiu.data.Palette

   * Creates a new palette with the 216 websafe colors.
   * @return new palette object
   */
  public static Palette create()
  {
    Palette result = new Palette(216, 255);
    int index = 0;
    for (int r = 0; r < 6; r++)
    {
      for (int g = 0; g < 6; g++)
      {
        for (int b = 0; b < 6; b++)
        {
          result.put(index++, SAMPLES[r], SAMPLES[g], SAMPLES[b]);
        }
      }
    }
    return result;
  }
View Full Code Here

Examples of net.sourceforge.jiu.data.Palette

  {
    if (in == null)
    {
      throw new MissingParameterException("Missing input image.");
    }
    Palette palette = null;
    if (in instanceof BilevelImage)
    {
      palette = new Palette(2, 255);
      palette.put(0, 0, 0, 0);
      palette.put(1, 255, 255, 255);
    }
    else
    if (in instanceof Gray8Image)
    {
      palette = new Palette(256, 255);
      for (int i = 0; i < 256; i++)
      {
        palette.put(i, i, i, i);
      }
    }
    else
    {
      throw new WrongParameterException("Unsupported input image type: " + in.getClass().getName());
View Full Code Here

Examples of net.sourceforge.jiu.data.Palette

  private void process(Paletted8Image in, RGB24Image out)
  {
    final int WIDTH = in.getWidth();
    final int HEIGHT = in.getHeight();
    final Palette PAL = in.getPalette();
    for (int y = 0; y < HEIGHT; y++)
    {
      for (int x = 0; x < WIDTH; x++)
      {
        int value = in.getSample(0, x, y);
        out.putSample(RGBIndex.INDEX_RED, x, y, PAL.getSample(RGBIndex.INDEX_RED, value));
        out.putSample(RGBIndex.INDEX_GREEN, x, y, PAL.getSample(RGBIndex.INDEX_GREEN, value));
        out.putSample(RGBIndex.INDEX_BLUE, x, y, PAL.getSample(RGBIndex.INDEX_BLUE, value));
      }
      setProgress(y, HEIGHT);
    }
  }
View Full Code Here

Examples of net.sourceforge.jiu.data.Palette

  private Palette readPalette() throws
    InvalidFileStructureException,
    java.io.IOException
  {
    Palette result = new Palette(256, 255);
    for (int channel = 0; channel < 3; channel++)
    {
      int channelIndex = -1;
      switch(channel)
      {
        case(0):
        {
          channelIndex = Palette.INDEX_RED;
          break;
        }
        case(1):
        {
          channelIndex = Palette.INDEX_GREEN;
          break;
        }
        case(2):
        {
          channelIndex = Palette.INDEX_BLUE;
          break;
        }
      }
      for (int i = 0; i < numColors; i++)
      {
        int value = in.readUnsignedByte();
        if (value == -1)
        {
          throw new InvalidFileStructureException("Unexpected end " +
            "of file when reading Sun RAS palette.");
        }
        result.putSample(channelIndex, i, value);
      }
    }
    return result;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.