Package java.awt.image

Examples of java.awt.image.DirectColorModel


    static BufferedImage toImage(int[] pixels, int w, int h)
    {
        DataBuffer db = new DataBufferInt(pixels, w * h);
        WritableRaster raster = Raster.createPackedRaster(db,
                w, h, w, new int[]{0xff0000, 0xff00, 0xff}, null);
        ColorModel cm = new DirectColorModel(24, 0xff0000, 0xff00, 0xff);
        return new BufferedImage(cm, raster, false, null);
    }
View Full Code Here


  public static void writeShort(int val, OutputStream out) throws IOException {
    // TODO: this
  }

  public static Image readRawImage(InputStream in, int twidth, int theight) throws IOException {
    DirectColorModel cm = new DirectColorModel(16, 0xF800, 0x07E0, 0x001F);

    int[] pixels = new int[twidth * theight + 1];
    int i, j;

    for (i = 0; i < theight; i++) {
View Full Code Here

            if (!isRGB(b) && !isBGR(b)) {
                return null;
            }
            int masks[] = { b.rMask, b.gMask, b.bMask };
            int buffer[] = (int [])b.buffer;
            cm = new DirectColorModel(24, b.rMask, b.gMask, b.bMask);
            wr = Raster.createPackedRaster(
                    new DataBufferInt(buffer, buffer.length),
                    b.width, b.height, b.stride,
                    masks, null);

        } else  if (b.bits == 24 && b.buffer instanceof byte[]) {
            int bits[] = { 8, 8, 8 };
            int offsets[];
            if (isRGB(b)) {
                offsets = new int[] { 0, 1, 2 };
            } else if (isBGR(b)) {
                offsets = new int[] { 2, 1, 0 };
            } else {
                return null;
            }
            byte buffer[] = (byte [])b.buffer;
            cm = new ComponentColorModel(
                    ColorSpace.getInstance(ColorSpace.CS_sRGB),
                    bits, false, false,
                    Transparency.OPAQUE,
                    DataBuffer.TYPE_BYTE);

            wr = Raster.createInterleavedRaster(
                    new DataBufferByte(buffer, buffer.length),
                    b.width, b.height, b.stride, 3, offsets, null);

        } else if ((b.bits == 16 || b.bits == 15)
                && b.buffer instanceof short[]) {
            int masks[] = { b.rMask, b.gMask, b.bMask };
            short buffer[] = (short [])b.buffer;
            cm = new DirectColorModel(b.bits, b.rMask, b.gMask, b.bMask);
            wr = Raster.createPackedRaster(
                    new DataBufferUShort(buffer, buffer.length),
                    b.width, b.height, b.stride,
                    masks, null);
        }
View Full Code Here

        } else if (sm instanceof SinglePixelPackedSampleModel) {
            SinglePixelPackedSampleModel sppsm;
            sppsm = (SinglePixelPackedSampleModel)sm;
            int masks [] = sppsm.getBitMasks();
            if (bands == 4)
                return new DirectColorModel
                    (cs, bits, masks[0], masks[1], masks[2], masks[3],
                     preMult, dt);
            else if (bands == 3)
                return new DirectColorModel
                    (cs, bits, masks[0], masks[1], masks[2], 0x0,
                     preMult, dt);
            else
                throw new IllegalArgumentException
                    ("Incompatible number of bands out for ColorModel");
View Full Code Here

        } else {
            BufferedImage srcBI;
            srcBI = new BufferedImage(cm, wr, cm.isAlphaPremultiplied(), null);

            // Construct a linear sRGB cm without alpha...
            cm = new DirectColorModel(ColorSpace.getInstance
                                      (ColorSpace.CS_LINEAR_RGB), 24,
                                      0x00FF0000, 0x0000FF00,
                                      0x000000FF, 0x0, false,
                                      DataBuffer.TYPE_INT);
View Full Code Here

        for (int i=0; i < b-1; i++)
            masks[i] = 0xFF0000 >> (8*i);
        masks[3] = 0xFF << (8*(b-1));
        ColorSpace cs = cm.getColorSpace();

        return new DirectColorModel(cs, 8*b, masks[0], masks[1],
                                    masks[2], masks[3],
                                    true, DataBuffer.TYPE_INT);
    }
View Full Code Here

        default:
            throw new IllegalArgumentException
                ("GaussianBlurRed8Bit only supports one to four band images");
        }
        ColorSpace cs = cm.getColorSpace();
        return new DirectColorModel(cs, 8*b, masks[0], masks[1],
                                    masks[2], masks[3],
                                    true, DataBuffer.TYPE_INT);
    }
View Full Code Here

            int [] masks = new int[4];
            for (int i=0; i < b-1; i++)
                masks[i] = 0xFF0000 >> (8*i);
            masks[3] = 0xFF << (8*(b-1));

            return new DirectColorModel(cs, 8*b, masks[0], masks[1],
                                        masks[2], masks[3],
                                        true, DataBuffer.TYPE_INT);
        }

        int [] bits = new int[b];
View Full Code Here

        } else if (sm instanceof SinglePixelPackedSampleModel) {
            SinglePixelPackedSampleModel sppsm;
            sppsm = (SinglePixelPackedSampleModel)sm;
            int masks [] = sppsm.getBitMasks();
            if (bands == 4)
                return new DirectColorModel
                    (cs, bits, masks[0], masks[1], masks[2], masks[3],
                     preMult, dt);
            else if (bands == 3)
                return new DirectColorModel
                    (cs, bits, masks[0], masks[1], masks[2], 0x0,
                     preMult, dt);
            else
                throw new IllegalArgumentException
                    ("Incompatible number of bands out for ColorModel");
View Full Code Here

        initLattice(seed);

        ColorModel cm;
        if (alpha)
            cm = new DirectColorModel
                (cs, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000,
                 false, DataBuffer.TYPE_INT);
        else
            cm = new DirectColorModel
                (cs, 24, 0x00FF0000, 0x0000FF00, 0x000000FF, 0x0,
                 false, DataBuffer.TYPE_INT);

        int tileSize = AbstractTiledRed.getDefaultTileSize();
        init((CachableRed)null, devRect, cm,
View Full Code Here

TOP

Related Classes of java.awt.image.DirectColorModel

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.