Package net.sourceforge.jiu.data

Examples of net.sourceforge.jiu.data.Palette


  private void process(Paletted8Image in, RGB48Image 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);
        int red = PAL.getSample(RGBIndex.INDEX_RED, value);
        int green = PAL.getSample(RGBIndex.INDEX_GREEN, value);
        int blue = PAL.getSample(RGBIndex.INDEX_BLUE, value);
        out.putSample(RGBIndex.INDEX_RED, x, y, red | red << 8);
        out.putSample(RGBIndex.INDEX_GREEN, x, y, green | green << 8);
        out.putSample(RGBIndex.INDEX_BLUE, x, y, blue | blue << 8);
      }
      setProgress(y, HEIGHT);
View Full Code Here


    if (numPixels > 256)
    {
      // too many pixels
      return null;
    }
    Palette result = new Palette(numPixels, 255);
    int index = 0;
    for (int y = 0; y < image.getHeight(); y++)
    {
      for (int x = 0; x < image.getWidth(); x++)
      {
        result.put(index++, image.getSample(INDEX_RED, x, y),
          image.getSample(INDEX_GREEN, x, y),
          image.getSample(INDEX_BLUE, x, y));
      }
    }
    return result;
View Full Code Here

        throw new WrongParameterException("Specified output image must be of type Gray8Image for input image of type Paletted8Image.");
      }
      out = (Gray8Image)image;
      ensureImagesHaveSameResolution();
    }
    Palette palette = in.getPalette();
    int[] lut = new int[palette.getNumEntries()];
    for (int i = 0; i < lut.length; i++)
    {
      int red = palette.getSample(RGBIndex.INDEX_RED, i);
      int green = palette.getSample(RGBIndex.INDEX_GREEN, i);
      int blue = palette.getSample(RGBIndex.INDEX_BLUE, i);
      lut[i] = (int)(red * redWeight + green * greenWeight + blue * blueWeight);
    }
    final int WIDTH = in.getWidth();
    final int HEIGHT = in.getHeight();
    for (int y = 0; y < HEIGHT; y++)
View Full Code Here

  {
    if (out == null)
    {
      out = (Paletted8Image)in.createCompatibleImage(in.getWidth(), in.getHeight());
    }
    Palette palette = out.getPalette();
    int numSamples = palette.getMaxValue() + 1;
    final int[] LUT = createLookupTable(numSamples, contrast);
    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

    }
  }

  private void process(Paletted8Image in, Paletted8Image out)
  {
    Palette inPal = in.getPalette();
    Palette outPal = out.getPalette();
    int[] orig = new int[3];
    int[] adjusted = new int[3];
    final int MAX = inPal.getMaxValue();
    final int WIDTH = in.getWidth();
    final int HEIGHT = in.getHeight();
    for (int i = 0; i < inPal.getNumEntries(); i++)
    {
      orig[INDEX_RED] = inPal.getSample(INDEX_RED, i);
      orig[INDEX_GREEN] = inPal.getSample(INDEX_GREEN, i);
      orig[INDEX_BLUE] = inPal.getSample(INDEX_BLUE, i);
      adjust(orig, adjusted, MAX);
      outPal.putSample(INDEX_RED, i, adjusted[INDEX_RED]);
      outPal.putSample(INDEX_GREEN, i, adjusted[INDEX_GREEN]);
      outPal.putSample(INDEX_BLUE, i, adjusted[INDEX_BLUE]);
    }
    for (int y = 0; y < HEIGHT; y++)
    {
      for (int x = 0; x < WIDTH; x++)
      {
View Full Code Here

    outputImage = out;
  }

  private void createBilevelFromPaletted(Paletted8Image in)
  {
    Palette palette = in.getPalette();
    MemoryBilevelImage out = new MemoryBilevelImage(in.getWidth(), in.getHeight());
    out.clear(BilevelImage.BLACK);
    for (int y = 0; y < in.getHeight(); y++)
    {
      for (int x = 0; x < in.getWidth(); x++)
      {
        if (palette.getSample(RGBIndex.INDEX_RED, in.getSample(0, x, y)) != 0)
        {
          out.putWhite(x, y);
        }
      }
      setProgress(y, in.getHeight());
View Full Code Here

  }

  // assumes that in fact has a palette with gray colors only
  private void createGray8FromPaletted8(Paletted8Image in, Gray8Image out)
  {
    Palette palette = in.getPalette();
    for (int y = 0; y < in.getHeight(); y++)
    {
      for (int x = 0; x < in.getWidth(); x++)
      {
        out.putSample(0, x, y, palette.getSample(0, in.getSample(0, x, y)));
      }
      setProgress(y, in.getHeight());
    }
    outputImage = out;
  }
View Full Code Here

    if (out == null)
    {
      out = (Paletted8Image)in.createCompatibleImage(in.getWidth(), in.getHeight());
      setOutputImage(out);
    }
    Palette palette = out.getPalette();
    int numSamples = palette.getMaxValue() + 1;
    final int[] LUT = createLookupTable(numSamples);
    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

  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

  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

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.