Examples of Gray8Image


Examples of jjil.core.Gray8Image

              null,
              null);
        }
        RgbImage rgb = (RgbImage) image;
        int[] rgbData = rgb.getData();
        Gray8Image gray = new Gray8Image(image.getWidth(), image.getHeight());
        byte[] grayData = gray.getData();
        for (int i=0; i<image.getWidth() * image.getHeight(); i++) {
            /* get individual r, g, and b values, unmasking them from the
             * ARGB word. The r, g, and b values are signed values
             * from -128 to 127.
             */
 
View Full Code Here

Examples of net.sourceforge.jiu.data.Gray8Image

    MissingParameterException,
    WrongParameterException
  {
    PixelImage in = getInputImage();
    prepare(in);
    Gray8Image out = (Gray8Image)getOutputImage();
    if (in instanceof BilevelImage)
    {
      process((BilevelImage)in, out);
    }
  }
View Full Code Here

Examples of net.sourceforge.jiu.data.Gray8Image

  private void process(Paletted8Image in) throws
    MissingParameterException,
    WrongParameterException
  {
    PixelImage image = getOutputImage();
    Gray8Image out = null;
    if (image == null)
    {
      out = new MemoryGray8Image(in.getWidth(), in.getHeight());
    }
    else
    {
      if (!(image instanceof Gray8Image))
      {
        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++)
    {
      for (int x = 0; x < WIDTH; x++)
      {
        try
        {
          out.putSample(0, x, y, lut[in.getSample(0, x, y)]);
        }
        catch (ArrayIndexOutOfBoundsException aioobe)
        {
        }
      }
View Full Code Here

Examples of net.sourceforge.jiu.data.Gray8Image

    outputImage = out;
  }

  private void createGray8FromGray16(Gray16Image in)
  {
    Gray8Image out = new MemoryGray8Image(in.getWidth(), in.getHeight());
    for (int y = 0; y < in.getHeight(); y++)
    {
      for (int x = 0; x < in.getWidth(); x++)
      {
        out.putSample(0, x, y, in.getSample(0, x, y) & 0xff);
      }
      setProgress(y, in.getHeight());
    }
    outputImage = out;
  }
View Full Code Here

Examples of net.sourceforge.jiu.data.Gray8Image

      if (palette.isGray())
      {
        type = TYPE_GRAY8;
        if (doConvert)
        {
          Gray8Image out = new MemoryGray8Image(in.getWidth(), in.getHeight());
          createGray8FromPaletted8(in, out);
        }
      }
    }
    else
View Full Code Here

Examples of net.sourceforge.jiu.data.Gray8Image

  private IntegerImage createImage(int width, int height)
  {
    if (monochrome)
    {
      Gray8Image image = new MemoryGray8Image(width, height);
      int offset = 0;
      for (int y = 0; y < height; y++)
      {
        for (int x = 0; x < width; x++)
        {
          image.putByteSample(0, x, y, data[0][offset++]);
        }
      }
      return image;
    }
    else
    if (performColorConversion)
    {
      RGB24Image image = new MemoryRGB24Image(width, height);
      int offset = 0;
      for (int y = 0; y < height; y++)
      {
        for (int x = 0; x < width; x++)
        {
          image.putByteSample(RGB24Image.INDEX_RED, x, y, data[0][offset]);
          image.putByteSample(RGB24Image.INDEX_GREEN, x, y, data[1][offset]);
          image.putByteSample(RGB24Image.INDEX_BLUE, x, y, data[2][offset]);
          offset++;
        }
      }
      return image;
    }
View Full Code Here

Examples of net.sourceforge.jiu.data.Gray8Image

      }
    }
    else
    if (image instanceof Gray8Image)
    {
      Gray8Image grayImage = (Gray8Image)image;
      grayImage.getByteSamples(0, getBoundsX1(), y, getBoundsWidth(), 1, row, offs);
    }
    else
    if (image instanceof Paletted8Image)
    {
      Paletted8Image palImage = (Paletted8Image)image;
View Full Code Here

Examples of net.sourceforge.jiu.data.Gray8Image

        }
        break;
      }
      case(2):
      {
        Gray8Image grayImage = (Gray8Image)image;
        ArrayConverter.convertPacked2BitIntensityTo8Bit(buffer, 0, dest, 0, numPackedBytes);
        while (x <= x2)
        {
          if (x >= x1)
          {
            grayImage.putByteSample(x - x1, y, dest[offset]);
          }
          x += incr;
          offset++;
        }
        break;
      }
      case(4):
      {
        Gray8Image grayImage = (Gray8Image)image;
        ArrayConverter.convertPacked4BitIntensityTo8Bit(buffer, 0, dest, 0, numPackedBytes);
        while (x <= x2)
        {
          if (x >= x1)
          {
            grayImage.putByteSample(x - x1, y, dest[offset]);
          }
          x += incr;
          offset++;
        }
        break;
      }
      case(8):
      {
        Gray8Image grayImage = (Gray8Image)image;
        while (x <= x2)
        {
          if (x >= x1)
          {
            grayImage.putSample(x - x1, y, buffer[offset]);
          }
          x += incr;
          offset++;
        }
        break;
      }
      case(16):
      {
        Gray16Image grayImage = (Gray16Image)image;
        while (x <= x2)
        {
          if (x >= x1)
          {
            int sample = (buffer[offset] & 0xff) << 8;
            sample |= (buffer[offset + 1] & 0xff);
            grayImage.putSample(x, y, sample);
          }
          x += incr;
          offset += 2;
        }
        break;
View Full Code Here

Examples of net.sourceforge.jiu.data.Gray8Image

    int offset = 0;
    switch(precision)
    {
      case(8):
      {
        Gray8Image grayImage = (Gray8Image)image;
        while (x <= x2)
        {
          if (x >= x1)
          {
            grayImage.putSample(x - x1, y, buffer[offset]);
            // alpha
          }
          x += incr;
          offset += 2;
        }
        break;
      }
      case(16):
      {
        Gray16Image grayImage = (Gray16Image)image;
        while (x <= x2)
        {
          if (x >= x1)
          {
            int sample = (buffer[offset] & 0xff) << 8;
            sample |= (buffer[offset + 1] & 0xff);
            grayImage.putSample(x, y, sample);
            // store alpha
          }
          x += incr;
          offset += 4;
        }
View Full Code Here

Examples of net.sourceforge.jiu.data.Gray8Image

        bilevelImage.putPackedBytes(0, y, getBoundsWidth(), buffer, x1 / 8, x1 % 8);
        break;
      }
      case(2):
      {
        Gray8Image grayImage = (Gray8Image)image;
        byte[] dest = new byte[width + 3];
        ArrayConverter.convertPacked2BitIntensityTo8Bit(buffer, 0, dest, 0, buffer.length);
        grayImage.putByteSamples(0, 0, y, getBoundsWidth(), 1, dest, getBoundsX1());
        break;
      }
      case(4):
      {
        Gray8Image grayImage = (Gray8Image)image;
        byte[] dest = new byte[width + 1];
        ArrayConverter.convertPacked4BitIntensityTo8Bit(buffer, 0, dest, 0, buffer.length);
        grayImage.putByteSamples(0, 0, y, getBoundsWidth(), 1, dest, getBoundsX1());
        break;
      }
      case(8):
      {
        Gray8Image grayImage = (Gray8Image)image;
        int offset = getBoundsX1();
        int x = 0;
        int k = getBoundsWidth();
        while (k > 0)
        {
          grayImage.putSample(0, x++, y, buffer[offset++]);
          k--;
        }
        break;
      }
      case(16):
      {
        Gray16Image grayImage = (Gray16Image)image;
        int offset = getBoundsX1();
        int x = 0;
        int k = getBoundsWidth();
        while (k > 0)
        {
          int sample = (buffer[offset++] & 0xff) << 8;
          sample |= (buffer[offset++] & 0xff);
          grayImage.putSample(x++, y, sample);
          k--;
        }
        break;
      }
    }
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.