Java 类java.awt.image.MemoryImageSource 实例源码

项目:SpotSpotter    文件:BMPReader.java   
protected static Image readImage24(FileInputStream fs, BitmapHeader bh) throws IOException {
    Image image;
    if (bh.iSizeimage == 0) {
        bh.iSizeimage = ((((bh.iWidth * bh.iBitcount) + 31) & ~31) >> 3);
        bh.iSizeimage *= bh.iHeight;
    }
    final int npad = (bh.iSizeimage / bh.iHeight) - bh.iWidth * 3;
    final int ndata[] = new int[bh.iHeight * bh.iWidth];
    final byte brgb[] = new byte[(bh.iWidth + npad) * 3 * bh.iHeight];
    fs.read(brgb, 0, (bh.iWidth + npad) * 3 * bh.iHeight);
    int nindex = 0;
    for (int j = 0; j < bh.iHeight; j++) {
        for (int i = 0; i < bh.iWidth; i++) {
            ndata[bh.iWidth * (bh.iHeight - j - 1) + i] = constructInt3(brgb, nindex);
            nindex += 3;
        }
        nindex += npad;
    }
    image = Toolkit.getDefaultToolkit()
            .createImage(new MemoryImageSource(bh.iWidth, bh.iHeight, ndata, 0, bh.iWidth));
    fs.close();
    return (image);
}
项目:SpotSpotter    文件:BMPReader.java   
protected static Image readImage32(FileInputStream fs, BitmapHeader bh) throws IOException {
    Image image;
    final int ndata[] = new int[bh.iHeight * bh.iWidth];
    final byte brgb[] = new byte[bh.iWidth * 4 * bh.iHeight];
    fs.read(brgb, 0, bh.iWidth * 4 * bh.iHeight);
    int nindex = 0;
    for (int j = 0; j < bh.iHeight; j++) {
        for (int i = 0; i < bh.iWidth; i++) {
            ndata[bh.iWidth * (bh.iHeight - j - 1) + i] = constructInt3(brgb, nindex);
            nindex += 4;
        }
    }
    image = Toolkit.getDefaultToolkit()
            .createImage(new MemoryImageSource(bh.iWidth, bh.iHeight, ndata, 0, bh.iWidth));
    fs.close();
    return (image);
}
项目:OpenJSharp    文件:XYZApp.java   
private void Setup() {
    balls = new Image[nBalls];
    byte red[] = new byte[256];
    red[0] = (byte) bgGrey;
    byte green[] = new byte[256];
    green[0] = (byte) bgGrey;
    byte blue[] = new byte[256];
    blue[0] = (byte) bgGrey;
    for (int r = 0; r < nBalls; r++) {
        float b = (float) (r + 1) / nBalls;
        for (int i = maxr; i >= 1; --i) {
            float d = (float) i / maxr;
            red[i] = (byte) blend(blend(Rl, 255, d), bgGrey, b);
            green[i] = (byte) blend(blend(Gl, 255, d), bgGrey, b);
            blue[i] = (byte) blend(blend(Bl, 255, d), bgGrey, b);
        }
        IndexColorModel model = new IndexColorModel(8, maxr + 1,
                red, green, blue, 0);
        balls[r] = applet.createImage(
                new MemoryImageSource(R * 2, R * 2, model, data, 0, R * 2));
    }
}
项目:jdk8u-jdk    文件:XYZApp.java   
private void Setup() {
    balls = new Image[nBalls];
    byte red[] = new byte[256];
    red[0] = (byte) bgGrey;
    byte green[] = new byte[256];
    green[0] = (byte) bgGrey;
    byte blue[] = new byte[256];
    blue[0] = (byte) bgGrey;
    for (int r = 0; r < nBalls; r++) {
        float b = (float) (r + 1) / nBalls;
        for (int i = maxr; i >= 1; --i) {
            float d = (float) i / maxr;
            red[i] = (byte) blend(blend(Rl, 255, d), bgGrey, b);
            green[i] = (byte) blend(blend(Gl, 255, d), bgGrey, b);
            blue[i] = (byte) blend(blend(Bl, 255, d), bgGrey, b);
        }
        IndexColorModel model = new IndexColorModel(8, maxr + 1,
                red, green, blue, 0);
        balls[r] = applet.createImage(
                new MemoryImageSource(R * 2, R * 2, model, data, 0, R * 2));
    }
}
项目:jdk8u-jdk    文件:ImageTransferTest.java   
private static Image createImage() {
    int w = 100;
    int h = 100;
    int[] pix = new int[w * h];

    int index = 0;
    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            int red = 127;
            int green = 127;
            int blue = y > h / 2 ? 127 : 0;
            int alpha = 255;
            if (x < w / 4 && y < h / 4) {
                alpha = 0;
                red = 0;
            }
            pix[index++] = (alpha << 24) | (red << 16) | (green << 8) | blue;
        }
    }
    return Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(w, h, pix, 0, w));
}
项目:openjdk-jdk10    文件:XYZApp.java   
private void Setup() {
    balls = new Image[nBalls];
    byte red[] = new byte[256];
    red[0] = (byte) bgGrey;
    byte green[] = new byte[256];
    green[0] = (byte) bgGrey;
    byte blue[] = new byte[256];
    blue[0] = (byte) bgGrey;
    for (int r = 0; r < nBalls; r++) {
        float b = (float) (r + 1) / nBalls;
        for (int i = maxr; i >= 1; --i) {
            float d = (float) i / maxr;
            red[i] = (byte) blend(blend(Rl, 255, d), bgGrey, b);
            green[i] = (byte) blend(blend(Gl, 255, d), bgGrey, b);
            blue[i] = (byte) blend(blend(Bl, 255, d), bgGrey, b);
        }
        IndexColorModel model = new IndexColorModel(8, maxr + 1,
                red, green, blue, 0);
        balls[r] = applet.createImage(
                new MemoryImageSource(R * 2, R * 2, model, data, 0, R * 2));
    }
}
项目:openjdk-jdk10    文件:ImageTransferTest.java   
private static Image createImage() {
    int w = 100;
    int h = 100;
    int[] pix = new int[w * h];

    int index = 0;
    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            int red = 127;
            int green = 127;
            int blue = y > h / 2 ? 127 : 0;
            int alpha = 255;
            if (x < w / 4 && y < h / 4) {
                alpha = 0;
                red = 0;
            }
            pix[index++] = (alpha << 24) | (red << 16) | (green << 8) | blue;
        }
    }
    return Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(w, h, pix, 0, w));
}
项目:openjdk9    文件:XYZApp.java   
private void Setup() {
    balls = new Image[nBalls];
    byte red[] = new byte[256];
    red[0] = (byte) bgGrey;
    byte green[] = new byte[256];
    green[0] = (byte) bgGrey;
    byte blue[] = new byte[256];
    blue[0] = (byte) bgGrey;
    for (int r = 0; r < nBalls; r++) {
        float b = (float) (r + 1) / nBalls;
        for (int i = maxr; i >= 1; --i) {
            float d = (float) i / maxr;
            red[i] = (byte) blend(blend(Rl, 255, d), bgGrey, b);
            green[i] = (byte) blend(blend(Gl, 255, d), bgGrey, b);
            blue[i] = (byte) blend(blend(Bl, 255, d), bgGrey, b);
        }
        IndexColorModel model = new IndexColorModel(8, maxr + 1,
                red, green, blue, 0);
        balls[r] = applet.createImage(
                new MemoryImageSource(R * 2, R * 2, model, data, 0, R * 2));
    }
}
项目:openjdk9    文件:ImageTransferTest.java   
private static Image createImage() {
    int w = 100;
    int h = 100;
    int[] pix = new int[w * h];

    int index = 0;
    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            int red = 127;
            int green = 127;
            int blue = y > h / 2 ? 127 : 0;
            int alpha = 255;
            if (x < w / 4 && y < h / 4) {
                alpha = 0;
                red = 0;
            }
            pix[index++] = (alpha << 24) | (red << 16) | (green << 8) | blue;
        }
    }
    return Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(w, h, pix, 0, w));
}
项目:itext2    文件:BarcodeDatamatrix.java   
/**
 * Creates a <CODE>java.awt.Image</CODE>. A successful call to the method <CODE>generate()</CODE>
 * before calling this method is required.
 * @param foreground the color of the bars
 * @param background the color of the background
 * @return the image
 */    
public java.awt.Image createAwtImage(Color foreground, Color background) {
    if (image == null)
        return null;
    int f = foreground.getRGB();
    int g = background.getRGB();
    Canvas canvas = new Canvas();

    int w = width + 2 * ws;
    int h = height + 2 * ws;
    int pix[] = new int[w * h];
    int stride = (w + 7) / 8;
    int ptr = 0;
    for (int k = 0; k < h; ++k) {
        int p = k * stride;
        for (int j = 0; j < w; ++j) {
            int b = image[p + (j / 8)] & 0xff;
            b <<= j % 8;
            pix[ptr++] = (b & 0x80) == 0 ? g : f;
        }
    }
    java.awt.Image img = canvas.createImage(new MemoryImageSource(w, h, pix, 0, w));
    return img;
}
项目:audiveris    文件:TestImage.java   
public static Image decodeImage (String[] rows)
{
    final int width = rows[0].length();
    final int height = rows.length;
    int[] pix = new int[width * height];
    int index = 0;

    for (String row : rows) {
        for (int x = 0; x < width; x++) {
            pix[index++] = decodeARGB(row.charAt(x));
        }
    }

    // Create the proper image icon
    Toolkit tk = Toolkit.getDefaultToolkit();

    return tk.createImage(new MemoryImageSource(width, height, pix, 0, width));
}
项目:yajsw    文件:HelloWorld.java   
private static void startTray()
{
    SystemTray tray = SystemTray.getSystemTray();
    int w = 80;
    int[] pix = new int[w * w];
    for (int i = 0; i < w * w; i++)
        pix[i] = (int) (Math.random() * 255);
    ImageProducer producer = new MemoryImageSource(w, w, pix, 0, w);
    Image image = Toolkit.getDefaultToolkit().createImage(producer);
    TrayIcon trayIcon = new TrayIcon(image);
    trayIcon.setImageAutoSize(true);
    startWindow();
    try
    {
        tray.add(trayIcon);
        System.out.println("installed tray");
    }
    catch (AWTException e)
    {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
项目:OpenNFMM    文件:xtGraphics.java   
static private Image bressed(final Image image) {
    final int i = image.getHeight(null);
    final int i340 = image.getWidth(null);
    final int[] is = new int[i340 * i];
    final PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, i340, i, is, 0, i340);
    try {
        pixelgrabber.grabPixels();
    } catch (final InterruptedException ignored) {

    }
    final Color color = new Color(247, 255, 165);
    for (int i341 = 0; i341 < i340 * i; i341++)
        if (is[i341] != is[i340 * i - 1]) {
            is[i341] = color.getRGB();
        }
    return xt.createImage(new MemoryImageSource(i340, i, is, 0, i340));
}
项目:OpenNFMM    文件:xtGraphics.java   
static private Image pressed(final Image image) {
    final int i = image.getHeight(null);
    final int i337 = image.getWidth(null);
    final int[] is = new int[i337 * i];
    final PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, i337, i, is, 0, i337);
    try {
        pixelgrabber.grabPixels();
    } catch (final InterruptedException ignored) {

    }
    for (int i338 = 0; i338 < i337 * i; i338++)
        if (is[i338] != is[i337 * i - 1]) {
            is[i338] = -16777216;
        }
    return xt.createImage(new MemoryImageSource(i337, i, is, 0, i337));
}
项目:jdk8u_jdk    文件:XYZApp.java   
private void Setup() {
    balls = new Image[nBalls];
    byte red[] = new byte[256];
    red[0] = (byte) bgGrey;
    byte green[] = new byte[256];
    green[0] = (byte) bgGrey;
    byte blue[] = new byte[256];
    blue[0] = (byte) bgGrey;
    for (int r = 0; r < nBalls; r++) {
        float b = (float) (r + 1) / nBalls;
        for (int i = maxr; i >= 1; --i) {
            float d = (float) i / maxr;
            red[i] = (byte) blend(blend(Rl, 255, d), bgGrey, b);
            green[i] = (byte) blend(blend(Gl, 255, d), bgGrey, b);
            blue[i] = (byte) blend(blend(Bl, 255, d), bgGrey, b);
        }
        IndexColorModel model = new IndexColorModel(8, maxr + 1,
                red, green, blue, 0);
        balls[r] = applet.createImage(
                new MemoryImageSource(R * 2, R * 2, model, data, 0, R * 2));
    }
}
项目:jdk8u_jdk    文件:ImageTransferTest.java   
private static Image createImage() {
    int w = 100;
    int h = 100;
    int[] pix = new int[w * h];

    int index = 0;
    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            int red = 127;
            int green = 127;
            int blue = y > h / 2 ? 127 : 0;
            int alpha = 255;
            if (x < w / 4 && y < h / 4) {
                alpha = 0;
                red = 0;
            }
            pix[index++] = (alpha << 24) | (red << 16) | (green << 8) | blue;
        }
    }
    return Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(w, h, pix, 0, w));
}
项目:lookaside_java-1.8.0-openjdk    文件:XYZApp.java   
private void Setup() {
    balls = new Image[nBalls];
    byte red[] = new byte[256];
    red[0] = (byte) bgGrey;
    byte green[] = new byte[256];
    green[0] = (byte) bgGrey;
    byte blue[] = new byte[256];
    blue[0] = (byte) bgGrey;
    for (int r = 0; r < nBalls; r++) {
        float b = (float) (r + 1) / nBalls;
        for (int i = maxr; i >= 1; --i) {
            float d = (float) i / maxr;
            red[i] = (byte) blend(blend(Rl, 255, d), bgGrey, b);
            green[i] = (byte) blend(blend(Gl, 255, d), bgGrey, b);
            blue[i] = (byte) blend(blend(Bl, 255, d), bgGrey, b);
        }
        IndexColorModel model = new IndexColorModel(8, maxr + 1,
                red, green, blue, 0);
        balls[r] = applet.createImage(
                new MemoryImageSource(R * 2, R * 2, model, data, 0, R * 2));
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:ImageTransferTest.java   
private static Image createImage() {
    int w = 100;
    int h = 100;
    int[] pix = new int[w * h];

    int index = 0;
    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            int red = 127;
            int green = 127;
            int blue = y > h / 2 ? 127 : 0;
            int alpha = 255;
            if (x < w / 4 && y < h / 4) {
                alpha = 0;
                red = 0;
            }
            pix[index++] = (alpha << 24) | (red << 16) | (green << 8) | blue;
        }
    }
    return Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(w, h, pix, 0, w));
}
项目:javify    文件:DefaultHSBChooserPanel.java   
/**
 * This method updates the gradient image with a new one taking the Hue
 * value as the constant.
 */
private void updateHLockImage()
{
  int index = 0;
  int[] pix = new int[imgWidth * imgHeight];
  float hValue = ((Number) hSpinner.getValue()).intValue() / 360f;

  for (int j = 0; j < imgHeight; j++)
    for (int i = 0; i < imgWidth; i++)
      pix[index++] = Color.HSBtoRGB(hValue, (imgWidth - i * 1f) / imgWidth,
                                    (imgHeight - j * 1f) / imgHeight)
                     | (255 << 24);

  gradientImage = createImage(new MemoryImageSource(imgWidth, imgHeight,
                                                    pix, 0, imgWidth));
}
项目:javify    文件:DefaultHSBChooserPanel.java   
/**
 * This method updates the gradient image with a new one taking the
 * Brightness value as the constant.
 */
private void updateBLockImage()
{
  int[] pix = new int[imgWidth * imgHeight];
  float bValue = ((Number) bSpinner.getValue()).intValue() / 100f;

  int index = 0;
  for (int j = 0; j < imgHeight; j++)
    for (int i = 0; i < imgWidth; i++)
      pix[index++] = Color.HSBtoRGB(i * 1f / imgWidth,
                                    (imgHeight - j * 1f) / imgHeight, bValue)
                     | (255 << 24);

  gradientImage = createImage(new MemoryImageSource(imgWidth, imgHeight,
                                                    pix, 0, imgWidth));
}
项目:javify    文件:DefaultHSBChooserPanel.java   
/**
 * This method updates the track gradient image if the Saturation value is
 * allowed to change (according to the JRadioButtons).
 */
private void updateSTrack()
{
  int[] trackPix = new int[trackWidth * imgHeight];

  float hValue = ((Number) hSpinner.getValue()).intValue() / 360f;
  float bValue = ((Number) bSpinner.getValue()).intValue() / 100f;

  int trackIndex = 0;
  for (int j = 0; j < imgHeight; j++)
    for (int i = 0; i < trackWidth; i++)
      trackPix[trackIndex++] = Color.HSBtoRGB(hValue,
                                              (imgHeight - j * 1f) / imgHeight,
                                              bValue) | (255 << 24);

  trackImage = createImage(new MemoryImageSource(trackWidth, imgHeight,
                                                 trackPix, 0, trackWidth));
}
项目:javify    文件:DefaultHSBChooserPanel.java   
/**
 * This method updates the track gradient image if the Brightness value is
 * allowed to change (according to the JRadioButtons).
 */
private void updateBTrack()
{
  int[] trackPix = new int[trackWidth * imgHeight];

  float hValue = ((Number) hSpinner.getValue()).intValue() / 360f;
  float sValue = ((Number) sSpinner.getValue()).intValue() / 100f;

  int trackIndex = 0;
  for (int j = 0; j < imgHeight; j++)
    for (int i = 0; i < trackWidth; i++)
      trackPix[trackIndex++] = Color.HSBtoRGB(hValue, sValue,
                                              (imgHeight - j * 1f) / imgHeight)
                               | (255 << 24);

  trackImage = createImage(new MemoryImageSource(trackWidth, imgHeight,
                                                 trackPix, 0, trackWidth));
}
项目:javify    文件:GtkImage.java   
/**
 * Returns the source of this image.
 */
public ImageProducer getSource ()
{
  if (!isLoaded)
    return null;

  int[] pixels;
  synchronized (pixbufLock)
    {
      if (!errorLoading)
        pixels = getPixels();
      else
        return null;
    }
  return new MemoryImageSource(width, height, nativeModel, pixels,
                               0, width);
}
项目:sdrtrunk    文件:WaterfallPanel.java   
/**
 * Resets the memory image source and byte backing array when the DFT point
 * size has changed
 */
private void reset()
{
    mPixels = new byte[ mDFTSize * mImageHeight ];

    mMemoryImageSource = new MemoryImageSource( mDFTSize, 
            mImageHeight,
            mColorModel,
            mPixels,
            0,
            mDFTSize );

       mMemoryImageSource.setAnimated( true );

       mWaterfallImage = createImage( mMemoryImageSource );

       repaint();
}
项目:cmoct-sourcecode    文件:CCITTG4Image.java   
@Override
public Object getImageProducer()
{

    // DEBUG System.out.println("CCITTG4Image::getImage()");

    byte rawImage[] = getRawImage();
    if (bitsPerSample == 8 && rawImage != null)
    {
        ColorModel cm = makeColorModel();
        return new MemoryImageSource(imageWidth, imageHeight, cm,
                imageBytes, 0, imageWidth);
    }

    return null;
}
项目:cmoct-sourcecode    文件:CodedImage.java   
public Object getImageProducer()
{

    ColorModel cm = makeColorModel();
    int[] pixels;
    imageWidth = 256;
    imageHeight = 256;

    pixels = new int[imageWidth * imageHeight];
    for (int y = 0; y < pixels.length; y += imageWidth)
    {
        for (int x = 0; x < imageWidth; x++)
        {
            pixels[x + y] = (x & 0xff);
        }
    }

    return new MemoryImageSource(imageWidth, imageHeight, pixels, 0,
            imageWidth);
}
项目:cmoct-sourcecode    文件:ImageOperations.java   
/**
 * Ints must be maskable by red 0xff0000, <br>
 * green 0xff00, <br>
 * blue 0xff, <alpha> 0xff000000
 * 
 * @param pixels
 * @param width
 * @param height
 * @return
 */
public static BufferedImage pixelsToImage(int[] pixels, int width,
        int height) {
    DirectColorModel directColorModel = new DirectColorModel(32, 0xff0000,
            0xff00, 0xff, 0xff000000);
    MemoryImageSource memoryImageSource = new MemoryImageSource(width,
            height, directColorModel, pixels, 0, width);
    SampleModel sampleModel = directColorModel.createCompatibleSampleModel(
            width, height);
    DataBufferInt dataBufferInt = new DataBufferInt(pixels, width * height);

    WritableRaster writableRaster = Raster.createWritableRaster(
            sampleModel, dataBufferInt, new Point(0, 0));
    BufferedImage bufferedImage = new BufferedImage(directColorModel,
            writableRaster, false, null);

    return bufferedImage;
}
项目:mars-sim    文件:StarRater.java   
/**
 * Converts a byte array to an image that has previously been converted with imageToCompressedByteArray(Image image).
 * The image is not recognizable as image from standard tools.
 *
 * @param data  The image.
 * @return  The image.
 */
public static Image compressedByteArrayToImage(byte[] data) {
  try {
    // unzip data
    ByteArrayInputStream byteStream = new ByteArrayInputStream(data);
    GZIPInputStream zippedStream = new GZIPInputStream(byteStream);
    ObjectInputStream objectStream = new ObjectInputStream(zippedStream);
    int width = objectStream.readShort();
    int height = objectStream.readShort();
    int[] imageSource = (int[])objectStream.readObject();
    objectStream.close();

    // create image
    MemoryImageSource mis = new MemoryImageSource(width, height, imageSource, 0, width);
    return Toolkit.getDefaultToolkit().createImage(mis);
  }
  catch (Exception e) {
    return null;
  }
}
项目:jvm-stm    文件:DefaultHSBChooserPanel.java   
/**
  * This method updates the gradient image with a new one taking the Hue
  * value as the constant.
  */
 private void updateHLockImage()
 {
   int index = 0;
   int[] pix = new int[imgWidth * imgHeight];
   float hValue = ((Number) hSpinner.getValue()).intValue() / 360f;

   for (int j = 0; j < imgHeight; j++)
     for (int i = 0; i < imgWidth; i++)
pix[index++] = Color.HSBtoRGB(hValue, (imgWidth - i * 1f) / imgWidth,
                              (imgHeight - j * 1f) / imgHeight)
               | (255 << 24);

   gradientImage = createImage(new MemoryImageSource(imgWidth, imgHeight,
                                                     pix, 0, imgWidth));
 }
项目:jvm-stm    文件:DefaultHSBChooserPanel.java   
/**
  * This method updates the gradient image with a new one taking the
  * Brightness value as the constant.
  */
 private void updateBLockImage()
 {
   int[] pix = new int[imgWidth * imgHeight];
   float bValue = ((Number) bSpinner.getValue()).intValue() / 100f;

   int index = 0;
   for (int j = 0; j < imgHeight; j++)
     for (int i = 0; i < imgWidth; i++)
pix[index++] = Color.HSBtoRGB(i * 1f / imgWidth,
                              (imgHeight - j * 1f) / imgHeight, bValue)
               | (255 << 24);

   gradientImage = createImage(new MemoryImageSource(imgWidth, imgHeight,
                                                     pix, 0, imgWidth));
 }
项目:jvm-stm    文件:DefaultHSBChooserPanel.java   
/**
  * This method updates the track gradient image if the Saturation value is
  * allowed to change (according to the JRadioButtons).
  */
 private void updateSTrack()
 {
   int[] trackPix = new int[trackWidth * imgHeight];

   float hValue = ((Number) hSpinner.getValue()).intValue() / 360f;
   float bValue = ((Number) bSpinner.getValue()).intValue() / 100f;

   int trackIndex = 0;
   for (int j = 0; j < imgHeight; j++)
     for (int i = 0; i < trackWidth; i++)
trackPix[trackIndex++] = Color.HSBtoRGB(hValue,
                                        (imgHeight - j * 1f) / imgHeight,
                                        bValue) | (255 << 24);

   trackImage = createImage(new MemoryImageSource(trackWidth, imgHeight,
                                                  trackPix, 0, trackWidth));
 }
项目:jvm-stm    文件:DefaultHSBChooserPanel.java   
/**
  * This method updates the track gradient image if the Brightness value is
  * allowed to change (according to the JRadioButtons).
  */
 private void updateBTrack()
 {
   int[] trackPix = new int[trackWidth * imgHeight];

   float hValue = ((Number) hSpinner.getValue()).intValue() / 360f;
   float sValue = ((Number) sSpinner.getValue()).intValue() / 100f;

   int trackIndex = 0;
   for (int j = 0; j < imgHeight; j++)
     for (int i = 0; i < trackWidth; i++)
trackPix[trackIndex++] = Color.HSBtoRGB(hValue, sValue,
                                        (imgHeight - j * 1f) / imgHeight)
                         | (255 << 24);

   trackImage = createImage(new MemoryImageSource(trackWidth, imgHeight,
                                                  trackPix, 0, trackWidth));
 }
项目:jvm-stm    文件:GtkImage.java   
/**
 * Returns the source of this image.
 */
public ImageProducer getSource ()
{
  if (!isLoaded)
    return null;

  int[] pixels;
  synchronized (pixbufLock)
    {
      if (!errorLoading)
        pixels = getPixels();
      else
        return null;
    }
  return new MemoryImageSource(width, height, nativeModel, pixels, 
                               0, width);
}
项目:OpenNFMM    文件:xtGraphics.java   
static private Image bressed(final Image image) {
    final int i = image.getHeight(null);
    final int i340 = image.getWidth(null);
    final int[] is = new int[i340 * i];
    final PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, i340, i, is, 0, i340);
    try {
        pixelgrabber.grabPixels();
    } catch (final InterruptedException ignored) {

    }
    final Color color = new Color(247, 255, 165);
    for (int i341 = 0; i341 < i340 * i; i341++)
        if (is[i341] != is[i340 * i - 1]) {
            is[i341] = color.getRGB();
        }
    return xt.createImage(new MemoryImageSource(i340, i, is, 0, i340));
}
项目:OpenNFMM    文件:xtGraphics.java   
static private Image pressed(final Image image) {
    final int i = image.getHeight(null);
    final int i337 = image.getWidth(null);
    final int[] is = new int[i337 * i];
    final PixelGrabber pixelgrabber = new PixelGrabber(image, 0, 0, i337, i, is, 0, i337);
    try {
        pixelgrabber.grabPixels();
    } catch (final InterruptedException ignored) {

    }
    for (int i338 = 0; i338 < i337 * i; i338++)
        if (is[i338] != is[i337 * i - 1]) {
            is[i338] = -16777216;
        }
    return xt.createImage(new MemoryImageSource(i337, i, is, 0, i337));
}
项目:HTML5_WebSite    文件:MandelbrotPlot.java   
private Image drawMandelbrot() {
        final int width=getSize().width;
        final int height=getSize().height;
        final MandelbrotSet set=new MandelbrotSet();
        double x,y;
        int pixels[]=new int[width*height];
        int index=0;
        for(int j=0;j<height;j++) {
                for(int i=0;i<width;i++) {
                        x=i*3.0/width-2.0;
                        y=1.25-j*2.5/height;
                        pixels[index++]=colorLookup(set.isMember(x,y,N));
                }
        }
        return createImage(new MemoryImageSource(width,height,pixels,0,width));
}
项目:HTML5_WebSite    文件:MandelbrotPlot.java   
private Image drawJulia(Complex z) {
        final int width=getSize().width;
        final int height=getSize().height;
        final JuliaSet set=new JuliaSet(z);
        double x,y;
        int pixels[]=new int[width*height];
        int index=0;
        for(int j=0;j<height;j++) {
                for(int i=0;i<width;i++) {
                        x=i*4.0/width-2.0;
                        y=1.25-j*2.5/height;
                        pixels[index++]=colorLookup(set.isMember(x,y,N));
                }
        }
        return createImage(new MemoryImageSource(width,height,pixels,0,width));
}
项目:ct-sim    文件:MapComponent.java   
/**
 * Speichert die Karte als png-Bild
 * @param file Dateiname
 * @throws IOException 
 */
public void saveImage(File file) throws IOException {       
    /* Grosse der Map berechnen */
    final int width = max_x + (SECTION_SIZE - 1) - min_x + 1;
    final int height = max_y + (SECTION_SIZE * 2 - 1) - min_y + 1;

    /* belegten Teil in neues Bild kopieren */
    BufferedImage bimg = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
    Graphics g = bimg.createGraphics();
    g.setColor(new Color(128, 128, 128, 255)); // "Map-Wert 0"
    g.fillRect(0, 0, width, height);

    /* Pixel kopieren */
    int[] map = new int[width * height];
    for (int y = min_y + 1; y < max_y + SECTION_SIZE * 2; ++y) { // Zeilen
        System.arraycopy(pixels, min_x + 1 + y * WIDTH, map, (y - min_y - 1) * width, width); // alle Spalten einer Zeile
    }

    /* Bild zeichnen und als png speichern */
    g.drawImage(Toolkit.getDefaultToolkit().createImage(
        new MemoryImageSource(width, height, map, 0, width)), 0, 0, null);
    g.dispose();
    ImageIO.write(bimg, "png", file);
}
项目:Advanced-Trigoplex    文件:XYZApp.java   
private void Setup() {
    balls = new Image[nBalls];
    byte red[] = new byte[256];
    red[0] = (byte) bgGrey;
    byte green[] = new byte[256];
    green[0] = (byte) bgGrey;
    byte blue[] = new byte[256];
    blue[0] = (byte) bgGrey;
    for (int r = 0; r < nBalls; r++) {
        float b = (float) (r + 1) / nBalls;
        for (int i = maxr; i >= 1; --i) {
            float d = (float) i / maxr;
            red[i] = (byte) blend(blend(Rl, 255, d), bgGrey, b);
            green[i] = (byte) blend(blend(Gl, 255, d), bgGrey, b);
            blue[i] = (byte) blend(blend(Bl, 255, d), bgGrey, b);
        }
        IndexColorModel model = new IndexColorModel(8, maxr + 1,
                red, green, blue, 0);
        balls[r] = applet.createImage(
                new MemoryImageSource(R * 2, R * 2, model, data, 0, R * 2));
    }
}
项目:infobip-open-jdk-8    文件:XYZApp.java   
private void Setup() {
    balls = new Image[nBalls];
    byte red[] = new byte[256];
    red[0] = (byte) bgGrey;
    byte green[] = new byte[256];
    green[0] = (byte) bgGrey;
    byte blue[] = new byte[256];
    blue[0] = (byte) bgGrey;
    for (int r = 0; r < nBalls; r++) {
        float b = (float) (r + 1) / nBalls;
        for (int i = maxr; i >= 1; --i) {
            float d = (float) i / maxr;
            red[i] = (byte) blend(blend(Rl, 255, d), bgGrey, b);
            green[i] = (byte) blend(blend(Gl, 255, d), bgGrey, b);
            blue[i] = (byte) blend(blend(Bl, 255, d), bgGrey, b);
        }
        IndexColorModel model = new IndexColorModel(8, maxr + 1,
                red, green, blue, 0);
        balls[r] = applet.createImage(
                new MemoryImageSource(R * 2, R * 2, model, data, 0, R * 2));
    }
}