当前位置: 首页>>代码示例>>Java>>正文


Java MemoryImageSource类代码示例

本文整理汇总了Java中java.awt.image.MemoryImageSource的典型用法代码示例。如果您正苦于以下问题:Java MemoryImageSource类的具体用法?Java MemoryImageSource怎么用?Java MemoryImageSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MemoryImageSource类属于java.awt.image包,在下文中一共展示了MemoryImageSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createImage

import java.awt.image.MemoryImageSource; //导入依赖的package包/类
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));
}
 
开发者ID:JetBrains,项目名称:jdk8u_jdk,代码行数:22,代码来源:ImageTransferTest.java

示例2: readImage24

import java.awt.image.MemoryImageSource; //导入依赖的package包/类
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);
}
 
开发者ID:zylo117,项目名称:SpotSpotter,代码行数:24,代码来源:BMPReader.java

示例3: readImage32

import java.awt.image.MemoryImageSource; //导入依赖的package包/类
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);
}
 
开发者ID:zylo117,项目名称:SpotSpotter,代码行数:18,代码来源:BMPReader.java

示例4: Setup

import java.awt.image.MemoryImageSource; //导入依赖的package包/类
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));
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:XYZApp.java

示例5: createAwtImage

import java.awt.image.MemoryImageSource; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:31,代码来源:BarcodeDatamatrix.java

示例6: decodeImage

import java.awt.image.MemoryImageSource; //导入依赖的package包/类
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));
}
 
开发者ID:Audiveris,项目名称:audiveris,代码行数:19,代码来源:TestImage.java

示例7: startTray

import java.awt.image.MemoryImageSource; //导入依赖的package包/类
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();
	}
}
 
开发者ID:yajsw,项目名称:yajsw,代码行数:24,代码来源:HelloWorld.java

示例8: bressed

import java.awt.image.MemoryImageSource; //导入依赖的package包/类
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));
}
 
开发者ID:uwx,项目名称:OpenNFMM,代码行数:18,代码来源:xtGraphics.java

示例9: pressed

import java.awt.image.MemoryImageSource; //导入依赖的package包/类
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));
}
 
开发者ID:uwx,项目名称:OpenNFMM,代码行数:17,代码来源:xtGraphics.java

示例10: updateHLockImage

import java.awt.image.MemoryImageSource; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:vilie,项目名称:javify,代码行数:20,代码来源:DefaultHSBChooserPanel.java

示例11: updateBLockImage

import java.awt.image.MemoryImageSource; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:vilie,项目名称:javify,代码行数:20,代码来源:DefaultHSBChooserPanel.java

示例12: updateSTrack

import java.awt.image.MemoryImageSource; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:vilie,项目名称:javify,代码行数:22,代码来源:DefaultHSBChooserPanel.java

示例13: updateBTrack

import java.awt.image.MemoryImageSource; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:vilie,项目名称:javify,代码行数:22,代码来源:DefaultHSBChooserPanel.java

示例14: getSource

import java.awt.image.MemoryImageSource; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:vilie,项目名称:javify,代码行数:20,代码来源:GtkImage.java

示例15: reset

import java.awt.image.MemoryImageSource; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:DSheirer,项目名称:sdrtrunk,代码行数:22,代码来源:WaterfallPanel.java


注:本文中的java.awt.image.MemoryImageSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。