Examples of Palette


Examples of net.sourceforge.jiu.data.Palette

    }
    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

Examples of net.sourceforge.jiu.data.Palette

    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

Examples of net.sourceforge.jiu.data.Palette

    {
      return null;
    }
    int width = image.getWidth();
    int height = image.getHeight();
    Palette palette = image.getPalette();
    if (width < 1 || height < 1 || palette == null)
    {
      return null;
    }
    int[] red = new int[palette.getNumEntries()];
    int[] green = new int[palette.getNumEntries()];
    int[] blue = new int[palette.getNumEntries()];
    for (int i = 0; i < palette.getNumEntries(); i++)
    {
      red[i] = palette.getSample(RGBIndex.INDEX_RED, i);
      green[i] = palette.getSample(RGBIndex.INDEX_GREEN, i);
      blue[i] = palette.getSample(RGBIndex.INDEX_BLUE, i);
    }
    int[] pixels = new int[width * height];
    byte[] data = new byte[width];
    int destOffset = 0;
    for (int y = 0; y < height; y++)
View Full Code Here

Examples of net.sourceforge.jiu.data.Palette

    setBoundsIfNecessary(width, height);
    width = getBoundsWidth();
    height = getBoundsHeight();
    if (image instanceof Paletted8Image)
    {
      Palette palette = ((Paletted8Image)image).getPalette();
      int numEntries = palette.getNumEntries();
      if (numEntries < 1 || numEntries > 256)
      {
        throw new WrongParameterException("Palette of image to be saved must have 1..256 entries.");
      }
      bitsPerPixel = 8;
View Full Code Here

Examples of net.sourceforge.jiu.data.Palette

  private void writePalette() throws IOException
  {
    PixelImage image = getImage();
    if (image instanceof Paletted8Image)
    {
      Palette palette = ((Paletted8Image)image).getPalette();
      int numEntries = 1 << bitsPerPixel;
      for (int i = 0; i < numEntries; i++)
      {
        if (i < palette.getNumEntries())
        {
          out.write(palette.getSample(RGBIndex.INDEX_RED, i));
          out.write(palette.getSample(RGBIndex.INDEX_GREEN, i));
          out.write(palette.getSample(RGBIndex.INDEX_BLUE, i));
        }
        else
        {
          out.write(0);
          out.write(0);
View Full Code Here

Examples of net.sourceforge.jiu.data.Palette

      if (bytesToSkip < 0)
      {
        throw new InvalidFileStructureException("Not enough space in header for palette with " +
          numPaletteEntries + "entries.");
      }
      palette = new Palette(numPaletteEntries);
      for (int index = 0; index < numPaletteEntries; index++)
      {
        int blue = in.readUnsignedByte();
        int green = in.readUnsignedByte();
        int red = in.readUnsignedByte();
View Full Code Here

Examples of net.sourceforge.jiu.data.Palette

    }
    if (pi instanceof Paletted8Image)
    {
      // always write 256 entries; if there aren't enough
      // in the palette, fill it up to 256 with (0, 0, 0, 0)
      Palette palette = ((Paletted8Image)pi).getPalette();
      for (int i = 0; i < 256; i++)
      {
        if (i < palette.getNumEntries())
        {
          out.write(palette.getSample(RGBIndex.INDEX_BLUE, i));
          out.write(palette.getSample(RGBIndex.INDEX_GREEN, i));
          out.write(palette.getSample(RGBIndex.INDEX_RED, i));
          out.write(0);
        }
        else
        {
          out.writeInt(0); // writes four 0 bytes
View Full Code Here

Examples of net.sourceforge.jiu.data.Palette

  private int version;
  private int width;

  private static Palette createPalette(short[][] data)
  {
    Palette result = new Palette(data.length);
    for (int i = 0; i < data.length; i++)
    {
      result.put(i, data[i][0], data[i][1], data[i][2]);
    }
    return result;
  }
View Full Code Here

Examples of net.sourceforge.jiu.data.Palette

    int numEntries = in.readShort() & 0xffff;
    if (numEntries < 1 || numEntries > 256)
    {
      throw new WrongFileFormatException("Not a Palm image file, invalid number of palette entries: "  + numEntries);
    }
    palette = new Palette(numEntries, 255);
    for (int i = 0; i < numEntries; i++)
    {
      //int reserved = in.readUnsignedByte();
      in.readUnsignedByte();
      int red = in.readUnsignedByte();
View Full Code Here

Examples of net.sourceforge.jiu.data.Palette

    saveFinalCompressedSize(out);
  }

  private void save(DataOutput out, Paletted8Image image) throws IOException
  {
    Palette palette = image.getPalette();
    boolean system256Palette = isPalmSystemPalette256(palette);
    boolean system16GrayPalette = isPalmSystemPaletteGray16(palette);
    boolean system16ColorPalette = isPalmSystemPaletteColor16(palette);
    boolean system4GrayPalette = isPalmSystemPaletteGray4(palette);
    boolean customPalette = !(system256Palette || system16GrayPalette || system16ColorPalette || system4GrayPalette);
    if (customPalette)
    {
      flags |= FLAG_COLOR_TABLE;
    }
    // determine bits per pixel, bytesPerRow
    if (palette.getNumEntries() <= 4)
    {
      bitsPerPixel = 2;
      bytesPerRow = (width + 3) / 4;
    }
    else
    if (palette.getNumEntries() <= 16)
    {
      bitsPerPixel = 4;
      bytesPerRow = (width + 1) / 2;
    }
    else
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.