本文整理汇总了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));
}
示例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);
}
示例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);
}
示例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));
}
}
示例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;
}
示例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));
}
示例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();
}
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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));
}
示例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);
}
示例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();
}