Package java.awt.image

Examples of java.awt.image.DataBuffer


       
        // And its ColorModel
        ColorModel colorModel = rdrdImage.getColorModel();
        Raster raster = rdrdImage.getData();
        SampleModel sampleModel = raster.getSampleModel();
        DataBuffer dataBuffer = raster.getDataBuffer();
       
        if (colorModel == null) {
            colorModel = ColorModel.getRGBdefault();
        }
        int minX = raster.getMinX();
View Full Code Here


    }
    else
    bi = convert(image);
    }
   
    final DataBuffer dataBuffer = bi.getRaster().getDataBuffer();
   
    final Object pixels;
    final int pixelsLength;
    final Class dataType;
   
View Full Code Here

//                        sofnSegment.width, sofnSegment.height);
            }
            else
                throw new ImageReadException(sofnSegment.numberOfComponents +
                        " components are invalid or unsupported");
            DataBuffer dataBuffer = raster.getDataBuffer();

           
            for (int y1 = 0; y1 < vSize*yMCUs; y1 += vSize)
            {
                for (int x1 = 0; x1 < hSize*xMCUs; x1 += hSize)
                {
                    readMCU(bitInputStream, preds, mcu);
                    rescaleMCU(mcu, hSize, vSize, scaledMCU);
                    int srcRowOffset = 0;
                    int dstRowOffset = y1*sofnSegment.width + x1;
                    for (int y2 = 0; y2 < vSize && y1 + y2 < sofnSegment.height; y2++)
                    {
                        for (int x2 = 0; x2 < hSize && x1 + x2 < sofnSegment.width; x2++)
                        {
                            if (scaledMCU.length == 3)
                            {
                                int Y = scaledMCU[0].samples[srcRowOffset + x2];
                                int Cb = scaledMCU[1].samples[srcRowOffset + x2];
                                int Cr = scaledMCU[2].samples[srcRowOffset + x2];
                                int rgb = YCbCrConverter.convertYCbCrToRGB(Y, Cb, Cr);
                                dataBuffer.setElem(dstRowOffset + x2, rgb);
                            }
                            else if (mcu.length == 1)
                            {
                                int Y = scaledMCU[0].samples[srcRowOffset + x2];
                                dataBuffer.setElem(dstRowOffset + x2,
                                        (Y << 16) | (Y << 8) | Y);
                            }
                            else
                                throw new ImageReadException("Unsupported JPEG with " +
                                        mcu.length + " components");
View Full Code Here

    }

    public void processImage(BufferedImage bi) throws ImageReadException,
            IOException
    {
        DataBuffer db = bi.getRaster().getDataBuffer();

        int count = 0;
        int width = bhi.width;
        int height = bhi.height;
        int x = 0, y = height - 1;
View Full Code Here

            int rowsInPass1 = (height + 7) / 8;
            int rowsInPass2 = (height + 3) / 8;
            int rowsInPass3 = (height + 1) / 4;
            int rowsInPass4 = (height) / 2;

            DataBuffer db = result.getRaster().getDataBuffer();

            for (int row = 0; row < height; row++)
            {
                int y;
                if (id.interlaceFlag)
                {
                    int the_row = row;
                    if (the_row < rowsInPass1)
                        y = the_row * 8;
                    else
                    {
                        the_row -= rowsInPass1;
                        if (the_row < (rowsInPass2))
                            y = 4 + (the_row * 8);
                        else
                        {
                            the_row -= rowsInPass2;
                            if (the_row < (rowsInPass3))
                                y = 2 + (the_row * 4);
                            else
                            {
                                the_row -= rowsInPass3;
                                if (the_row < (rowsInPass4))
                                    y = 1 + (the_row * 2);
                                else
                                    throw new ImageReadException(
                                            "Gif: Strange Row");
                            }
                        }
                    }
                } else
                    y = row;

                for (int x = 0; x < width; x++)
                {
                    int index = 0xff & id.imageData[counter++];
                    int rgb = colorTable[index];

                    if (transparentIndex == index)
                        rgb = 0x00;

                    db.setElem(y * width + x, rgb);
                }

            }
        }

View Full Code Here

public abstract class DataParser
{
    public final void parseData(int data[][][], BufferedImage bi,
            ImageContents imageContents)
    {
        DataBuffer buffer = bi.getRaster().getDataBuffer();

        PSDHeaderInfo header = imageContents.header;
        int width = header.Columns;
        int height = header.Rows;

        for (int y = 0; y < height; y++)
            for (int x = 0; x < width; x++)
            {
                int rgb = getRGB(data, x, y, imageContents);
                buffer.setElem(y * width + x, rgb);
            }

    }
View Full Code Here

            bpp = 32;
        }

        BufferedImage image = new BufferedImage(colorModel, raster,
                colorModel.isAlphaPremultiplied(), new Properties());
        DataBuffer dataBuffer = raster.getDataBuffer();
        StringBuilder row = new StringBuilder();
        boolean hasMore = true;
        for (int y = 0; y < xpmHeader.height; y++)
        {
            row.setLength(0);
            hasMore = parseNextString(cParser, row);
            if (y < (xpmHeader.height - 1) && !hasMore)
                throw new ImageReadException("Parsing XPM file failed, " +
                        "insufficient image rows in file");
            int rowOffset = y*xpmHeader.width;
            for (int x = 0; x < xpmHeader.width; x++)
            {
                String index = row.substring(x*xpmHeader.numCharsPerPixel,
                        (x + 1)*xpmHeader.numCharsPerPixel);
                PaletteEntry paletteEntry = (PaletteEntry) xpmHeader.palette.get(index);
                if (paletteEntry == null) {
                    throw new ImageReadException("No palette entry was defined " +
                            "for " + index);
                }
                if (bpp <= 16)
                    dataBuffer.setElem(rowOffset + x, paletteEntry.index);
                else
                    dataBuffer.setElem(rowOffset + x, paletteEntry.getBestARGB());
            }
        }

        while (hasMore)
        {
View Full Code Here

        // is = new BufferedInputStream(is);
        // int count = 0;
        //
        // try
        // {
        DataBuffer buffer = bi.getRaster().getDataBuffer();

        if (!RAWBITS)
        {
            WhiteSpaceReader wsr = new WhiteSpaceReader(is);

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    int rgb = getRGB(wsr);

                    buffer.setElem(y * width + x, rgb);
                    // count++;
                }
                newline();
            }
        } else
        {
            for (int y = 0; y < height; y++)
            {
                // System.out.println("y: " + y);
                for (int x = 0; x < width; x++)
                {
                    int rgb = getRGB(is);
                    buffer.setElem(y * width + x, rgb);
                    // count++;
                }
                newline();
            }
        }
View Full Code Here

                final int width = image.getWidth();
                final int height = image.getHeight();

                byte[] buf = new byte[3 * width * height];

                final DataBuffer buffer = image.getData().getDataBuffer();

                for (int y = 0; y < height; y++){
                 
                    for (int x = 0; x < width; x++) {
                        final int rgb = buffer.getElem(y * width + x);
                        final int offset = 3 * (y * width + x);

                        buf[offset + 0] = (byte) (rgb & 0xFF);
                        buf[offset + 1] = (byte) ((rgb >> 8) & 0xFF);
                        buf[offset + 2] = (byte) ((rgb >> 16) & 0xFF);
View Full Code Here

      final int width = image.getWidth();
      final int height = image.getHeight();

      byte[] buf = new byte[3 * width * height];

      final DataBuffer buffer = image.getData().getDataBuffer();

      for (int y = 0; y < height; y++)
      {
        for (int x = 0; x < width; x++)
        {
          final int rgb = buffer.getElem(y * width + x);
          final int offset = 3 * (y * width + x);

          buf[offset + 0] = (byte) (rgb & 0xFF);
          buf[offset + 1] = (byte) ((rgb >> 8) & 0xFF);
          buf[offset + 2] = (byte) ((rgb >> 16) & 0xFF);
View Full Code Here

TOP

Related Classes of java.awt.image.DataBuffer

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.