Package net.sourceforge.jiu.data

Examples of net.sourceforge.jiu.data.RGB48Image


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


  private void loadColorImage() throws InvalidFileStructureException, IOException
  {
    RGBIntegerImage image = null;
    RGB24Image image24 = null;
    RGB48Image image48 = null;
    if (maxSample <= 255)
    {
      image24 = new MemoryRGB24Image(width, height);
      image = image24;
      setImage(image);
    }
    else
    {
      image48 = new MemoryRGB48Image(width, height);
      image = image48;
      setImage(image);
    }
    for (int y = 0, destY = - getBoundsY1(); y < height; y++, destY++)
    {
      if (getAscii().booleanValue())
      {
        for (int x = 0; x < width; x++)
        {
          int red = loadAsciiNumber();
          if (red < 0 || red > maxSample)
          {
            throw new InvalidFileStructureException("Invalid " +
              "sample value " + red + " for red sample at " +
              "(x=" + x + ", y=" + y + ").");
          }
          image.putSample(RGBIndex.INDEX_RED, x, y, red);

          int green = loadAsciiNumber();
          if (green < 0 || green > maxSample)
          {
            throw new InvalidFileStructureException("Invalid " +
              "sample value " + green + " for green sample at " +
              "(x=" + x + ", y=" + y + ").");
          }
          image.putSample(RGBIndex.INDEX_GREEN, x, y, green);

          int blue = loadAsciiNumber();
          if (blue < 0 || blue > maxSample)
          {
            throw new InvalidFileStructureException("Invalid " +
              "sample value " + blue + " for blue sample at " +
              "(x=" + x + ", y=" + y + ").");
          }
          image.putSample(RGBIndex.INDEX_BLUE, x, y, blue);
        }
      }
      else
      {
        if (image24 != null)
        {
          for (int x = 0; x < width; x++)
          {
            int red = in.read();
            if (red == -1)
            {
              throw new InvalidFileStructureException("Unexpected " +
                "end of file while reading red sample for pixel " +
                "x=" + x + ", y=" + y + ".");
            }
            image24.putByteSample(RGBIndex.INDEX_RED, x, y, (byte)(red & 0xff));
            int green = in.read();
            if (green == -1)
            {
              throw new InvalidFileStructureException("Unexpected " +
                "end of file while reading green sample for pixel " +
                "x=" + x + ", y=" + y + ".");
            }
            image24.putByteSample(RGBIndex.INDEX_GREEN, x, y, (byte)(green & 0xff));
            int blue = in.read();
            if (blue == -1)
            {
              throw new InvalidFileStructureException("Unexpected " +
                "end of file while reading blue sample for pixel " +
                "x=" + x + ", y=" + y + ".");
            }
            image24.putByteSample(RGBIndex.INDEX_BLUE, x, y, (byte)(blue & 0xff));
          }
        }
        else if (image48 != null)
        {
          for (int x = 0; x < width; x++)
          {
            int red = read16BitBinaryValue();
            if (red == -1)
            {
              throw new InvalidFileStructureException("Unexpected " +
                "end of file while reading red sample for pixel " +
                "x=" + x + ", y=" + y + ".");
            }
            image48.putShortSample(RGBIndex.INDEX_RED, x, y, (short)(red & 0xffff));
            int green = read16BitBinaryValue();
            if (green == -1)
            {
              throw new InvalidFileStructureException("Unexpected " +
                "end of file while reading green sample for pixel " +
                "x=" + x + ", y=" + y + ".");
            }
            image48.putShortSample(RGBIndex.INDEX_GREEN, x, y, (short)(green & 0xffff));
            int blue = read16BitBinaryValue();
            if (blue == -1)
            {
              throw new InvalidFileStructureException("Unexpected " +
                "end of file while reading blue sample for pixel " +
                "x=" + x + ", y=" + y + ".");
            }
            image48.putShortSample(RGBIndex.INDEX_BLUE, x, y, (short)(blue & 0xffff));
          }
        }
      }
      setProgress(y, getBoundsHeight());
    }
View Full Code Here

      }
    }
    else
    if (image instanceof RGB48Image)
    {
      RGB48Image rgbImage = (RGB48Image)image;
      while (w-- > 0)
      {
        short sample = rgbImage.getShortSample(RGBIndex.INDEX_RED, x1, y);
        ArrayConverter.setShortBE(row, offs, sample);
        offs += 2;

        sample = rgbImage.getShortSample(RGBIndex.INDEX_GREEN, x1, y);
        ArrayConverter.setShortBE(row, offs, sample);
        offs += 2;

        sample = rgbImage.getShortSample(RGBIndex.INDEX_BLUE, x1, y);
        ArrayConverter.setShortBE(row, offs, sample);
        offs += 2;

        x1++;
      }
View Full Code Here

      }
    }
    else
    if (precision == 16)
    {
      RGB48Image rgbImage = (RGB48Image)image;
      while (x <= x2)
      {
        if (x >= x1)
        {
          int red = (buffer[offset] & 0xff) << 8;
          red |= buffer[offset + 1] & 0xff;
          rgbImage.putSample(RGB24Image.INDEX_RED, x, y, red);
 
          int green = (buffer[offset + 2] & 0xff) << 8;
          green |= buffer[offset + 3] & 0xff;
          rgbImage.putSample(RGB24Image.INDEX_GREEN, x, y, green);
   
          int blue = (buffer[offset + 4] & 0xff) << 8;
          blue |= buffer[offset + 5] & 0xff;
          rgbImage.putSample(RGB24Image.INDEX_BLUE, x, y, blue);
        }
        x += incr;
        offset += 6;
      }
    }
View Full Code Here

      }
    }
    else
    if (precision == 16)
    {
      RGB48Image rgbImage = (RGB48Image)image;
      while (x <= x2)
      {
        if (x >= x1)
        {
          int red = (buffer[offset] & 0xff) << 8;
          red |= buffer[offset + 1] & 0xff;
          rgbImage.putSample(RGB24Image.INDEX_RED, x, y, red);
 
          int green = (buffer[offset + 2] & 0xff) << 8;
          green |= buffer[offset + 3] & 0xff;
          rgbImage.putSample(RGB24Image.INDEX_GREEN, x, y, green);
   
          int blue = (buffer[offset + 4] & 0xff) << 8;
          blue |= buffer[offset + 5] & 0xff;
          rgbImage.putSample(RGB24Image.INDEX_BLUE, x, y, blue);
         
          // store alpha
        }
        x += incr;
        offset += 8;
View Full Code Here

      }
    }
    else
    if (precision == 16)
    {
      RGB48Image rgbImage = (RGB48Image)image;
      int offset = getBoundsX1() * 6;
      int x = 0;
      int k = getBoundsWidth();
      while (k > 0)
      {
        int red = (buffer[offset++] & 0xff) << 8;
        red |= buffer[offset++] & 0xff;
        rgbImage.putSample(RGB24Image.INDEX_RED, x, y, red);

        int green = (buffer[offset++] & 0xff) << 8;
        green |= buffer[offset++] & 0xff;
        rgbImage.putSample(RGB24Image.INDEX_GREEN, x, y, green);
 
        int blue = (buffer[offset++] & 0xff) << 8;
        blue |= buffer[offset++] & 0xff;
        rgbImage.putSample(RGB24Image.INDEX_BLUE, x, y, blue);
 
        x++;
        k--;
      }
    }
View Full Code Here

        }
        break;
      }
      case(16):
      {
        RGB48Image rgbImage = (RGB48Image)image;
        int offset = getBoundsX1() * 8;
        int x = 0;
        int k = getBoundsWidth();
        while (k > 0)
        {
          int red = (buffer[offset++] & 0xff) << 8;
          red |= buffer[offset++] & 0xff;
          rgbImage.putSample(RGB24Image.INDEX_RED, x, y, red);
   
          int green = (buffer[offset++] & 0xff) << 8;
          green |= buffer[offset++] & 0xff;
          rgbImage.putSample(RGB24Image.INDEX_GREEN, x, y, green);
   
          int blue = (buffer[offset++] & 0xff) << 8;
          blue |= buffer[offset++] & 0xff;
          rgbImage.putSample(RGB24Image.INDEX_BLUE, x, y, blue);
   
          offset += 2; // skip alpha; TODO: store in TransparencyInformation object
          x++;
          k--;
        }
View Full Code Here

TOP

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

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.