當前位置: 首頁>>代碼示例>>Java>>正文


Java DataBufferInt類代碼示例

本文整理匯總了Java中java.awt.image.DataBufferInt的典型用法代碼示例。如果您正苦於以下問題:Java DataBufferInt類的具體用法?Java DataBufferInt怎麽用?Java DataBufferInt使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DataBufferInt類屬於java.awt.image包,在下文中一共展示了DataBufferInt類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: write

import java.awt.image.DataBufferInt; //導入依賴的package包/類
/**
 * Write a tile image to a stream.
 *
 * @param tile the image
 * @param out the stream
 *
 * @throws ImageIOException if the write fails
 */
public static void write(BufferedImage tile, OutputStream out)
                                                         throws IOException {
  ByteBuffer bb;

  // write the header
  bb = ByteBuffer.allocate(18);

  bb.put("VASSAL".getBytes())
    .putInt(tile.getWidth())
    .putInt(tile.getHeight())
    .putInt(tile.getType());

  out.write(bb.array());

  // write the tile data
  final DataBufferInt db = (DataBufferInt) tile.getRaster().getDataBuffer();
  final int[] data = db.getData();

  bb = ByteBuffer.allocate(4*data.length);
  bb.asIntBuffer().put(data);

  final GZIPOutputStream zout = new GZIPOutputStream(out);
  zout.write(bb.array());
  zout.finish();
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:34,代碼來源:TileUtils.java

示例2: initImageMem

import java.awt.image.DataBufferInt; //導入依賴的package包/類
private cl_mem initImageMem(BufferedImage img) {
    cl_image_format imageFormat = new cl_image_format();
    imageFormat.image_channel_order = CL_RGBA;
    imageFormat.image_channel_data_type = CL_UNSIGNED_INT8;
    
    // Create the memory object for the input image
    DataBufferInt dataBufferSrc = (DataBufferInt)img.getRaster().getDataBuffer();
    int dataSrc[] = dataBufferSrc.getData();

    cl_mem inputImageMem = CL.clCreateImage2D(
        context, CL_MEM_READ_ONLY | CL_MEM_USE_HOST_PTR,
        new cl_image_format[]{imageFormat}, img.getWidth(), img.getHeight(),
        img.getWidth() * Sizeof.cl_uint, Pointer.to(dataSrc), null);
    
    return  inputImageMem;
}
 
開發者ID:iapafoto,項目名稱:DicomViewer,代碼行數:17,代碼來源:OpenCLWithJOCL.java

示例3: run

import java.awt.image.DataBufferInt; //導入依賴的package包/類
@Override
  public void run() {
    FrameRate framerate = new FrameRate();
    int[] pixels = ((DataBufferInt) ps3eye_frame.getRaster().getDataBuffer()).getData();
//    ps3eye.waitAvailable(false);
    while (true) {
      
//      if(ps3eye.isAvailable()){
        ps3eye.getFrame(pixels);
        repaint();
        jframe.setTitle(""+framerate.update());
//      }
        
//      try {
//        Thread.sleep(0);
//      } catch (InterruptedException e) {
//        e.printStackTrace();
//      }
    }
    
  }
 
開發者ID:diwi,項目名稱:PS3Eye,代碼行數:22,代碼來源:PS3Eye_Basic.java

示例4: fix_tRNS

import java.awt.image.DataBufferInt; //導入依賴的package包/類
protected BufferedImage fix_tRNS(Reference<BufferedImage> ref,
                                 int tRNS, int type) throws ImageIOException {
  BufferedImage img = ref.obj;

  // Ensure that we are working with integer ARGB data. Whether it's
  // premultiplied doesn't matter, since fully transparent black pixels
  // are the same in both.
  if (img.getType() != BufferedImage.TYPE_INT_ARGB &&
      img.getType() != BufferedImage.TYPE_INT_ARGB_PRE) {

    // If the requested type is not an ARGB one, then we convert to ARGB
    // for applying this fix.
    if (type != BufferedImage.TYPE_INT_ARGB &&
        type != BufferedImage.TYPE_INT_ARGB_PRE) {
      type = BufferedImage.TYPE_INT_ARGB;
    }

    img = null;
    img = tconv.convert(ref, type);
  }

  // NB: This unmanages the image.
  final DataBufferInt db = (DataBufferInt) img.getRaster().getDataBuffer();
  final int[] data = db.getData();

  // Set all pixels of the transparent color to have alpha 0.
  for (int i = 0; i < data.length; ++i) {
    if (data[i] == tRNS) data[i] = 0x00000000;
  }

  return img;
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:33,代碼來源:ImageIOImageLoader.java

示例5: fix_YCbCr

import java.awt.image.DataBufferInt; //導入依賴的package包/類
protected BufferedImage fix_YCbCr(Reference<BufferedImage> ref, int type)
                                                    throws ImageIOException {
  BufferedImage img = ref.obj;

  // Ensure that we are working with RGB or ARGB data.
  if (img.getType() != BufferedImage.TYPE_INT_RGB &&
      img.getType() != BufferedImage.TYPE_INT_ARGB) {

    if (type != BufferedImage.TYPE_INT_RGB &&
        type != BufferedImage.TYPE_INT_ARGB) {
      type = BufferedImage.TYPE_INT_ARGB;
    }

    img = null;
    img = tconv.convert(ref, type);
  }

  // NB: This unmanages the image.
  final DataBufferInt db = (DataBufferInt) img.getRaster().getDataBuffer();
  final int[] data = db.getData();

  for (int i = 0; i < data.length; ++i) {
    final int y  =  (data[i] >> 16) & 0xFF;
    final int pb = ((data[i] >>  8) & 0xFF) - 128;
    final int pr = ( data[i]        & 0xFF) - 128;

    final int a  = (data[i] >> 24) & 0xFF;
    final int r = (int) Math.round(y + 1.402*pr);
    final int g = (int) Math.round(y - 0.34414*pb - 0.71414*pr);
    final int b = (int) Math.round(y + 1.772*pb);

    data[i] = (a << 24) |
              ((r < 0 ? 0 : (r > 0xFF ? 0xFF : r)) << 16) |
              ((g < 0 ? 0 : (g > 0xFF ? 0xFF : g)) <<  8) |
               (b < 0 ? 0 : (b > 0xFF ? 0xFF : b));
  }

  return img;
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:40,代碼來源:ImageIOImageLoader.java

示例6: convertImage

import java.awt.image.DataBufferInt; //導入依賴的package包/類
/**
 * Converts the given image to the stream deck format.<br>
 * Format is:<br>
 * Color Schema: BGR<br>
 * Image size: 72 x 72 pixel<br>
 * Stored in an array with each byte stored seperatly (Size of each array is
 * 72 x 72 x 3 = 15_552).
 * 
 * @param img
 *            Image to be converted
 * @return Byte arraythat contains the given image, ready to be sent to the
 *         stream deck
 */
public static byte[] convertImage(BufferedImage img) {
	img = IconHelper.createResizedCopy(IconHelper.fillBackground(IconHelper.rotate180(img), Color.BLACK));
	if (APPLY_FRAME) {
		BufferedImage frame = getImageFromResource("/resources/frame.png");
		if (frame != null) {
			Graphics2D g = img.createGraphics();
			g.drawImage(frame, 0, 0, null);
			g.dispose();
		}
	}
	int[] pixels = ((DataBufferInt) img.getRaster().getDataBuffer()).getData();
	byte[] imgData = new byte[StreamDeck.ICON_SIZE * StreamDeck.ICON_SIZE * 3];
	int imgDataCount = 0;
	// remove the alpha channel
	for (int i = 0; i < StreamDeck.ICON_SIZE * StreamDeck.ICON_SIZE; i++) {
		// RGB -> BGR
		imgData[imgDataCount++] = (byte) ((pixels[i] >> 16) & 0xFF);
		imgData[imgDataCount++] = (byte) (pixels[i] & 0xFF);
		imgData[imgDataCount++] = (byte) ((pixels[i] >> 8) & 0xFF);
	}
	return imgData;
}
 
開發者ID:WElRD,項目名稱:StreamDeckCore,代碼行數:36,代碼來源:IconHelper.java

示例7: toImage

import java.awt.image.DataBufferInt; //導入依賴的package包/類
/**
 * Turns gl to BufferedImage with fixed format
 *
 * @param gl
 * @param w
 * @param h
 * @return
 */
protected BufferedImage toImage(GL2 gl, int w, int h) {

    gl.glReadBuffer(GL.GL_FRONT); // or GL.GL_BACK
    ByteBuffer glBB = Buffers.newDirectByteBuffer(4 * w * h);
    gl.glReadPixels(0, 0, w, h, GL2.GL_BGRA, GL.GL_BYTE, glBB);

    BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_BGR);
    int[] bd = ((DataBufferInt) bi.getRaster().getDataBuffer()).getData();

    for (int y = 0; y < h; y++) {
        for (int x = 0; x < w; x++) {
            int b = 2 * glBB.get();
            int g = 2 * glBB.get();
            int r = 2 * glBB.get();
            int a = glBB.get(); // not using

            bd[(h - y - 1) * w + x] = (b << 16) | (g << 8) | r | 0xFF000000;
        }
    }

    return bi;
}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:31,代碼來源:AbstractAviWriter.java

示例8: toImage

import java.awt.image.DataBufferInt; //導入依賴的package包/類
private BufferedImage toImage(DvsFramerSingleFrame subSampler) {
    BufferedImage bi = new BufferedImage(dvsFrame.getWidth(), dvsFrame.getHeight(), BufferedImage.TYPE_INT_BGR);
    int[] bd = ((DataBufferInt) bi.getRaster().getDataBuffer()).getData();

    for (int y = 0; y < dvsFrame.getHeight(); y++) {
        for (int x = 0; x < dvsFrame.getWidth(); x++) {
            int b = (int) (255 * subSampler.getValueAtPixel(x, y));
            int g = b;
            int r = b;
            int idx = (dvsFrame.getHeight() - y - 1) * dvsFrame.getWidth() + x;
            if (idx >= bd.length) {
                throw new RuntimeException(String.format("index %d out of bounds for x=%d y=%d", idx, x, y));
            }
            bd[idx] = (b << 16) | (g << 8) | r | 0xFF000000;
        }
    }

    return bi;

}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:21,代碼來源:DvsSliceAviWriter.java

示例9: makeImage

import java.awt.image.DataBufferInt; //導入依賴的package包/類
public Image makeImage(TestEnvironment env, int w, int h) {
    BufferedImage img = new BufferedImage(w, h, type);
    if (unmanaged) {
        DataBuffer db = img.getRaster().getDataBuffer();
        if (db instanceof DataBufferInt) {
            ((DataBufferInt)db).getData();
        } else if (db instanceof DataBufferShort) {
            ((DataBufferShort)db).getData();
        } else if (db instanceof DataBufferByte) {
            ((DataBufferByte)db).getData();
        } else {
            try {
                img.setAccelerationPriority(0.0f);
            } catch (Throwable e) {}
        }
    }
    return img;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:ImageTests.java

示例10: syncCopyBuffer

import java.awt.image.DataBufferInt; //導入依賴的package包/類
private void syncCopyBuffer(boolean reset, int x, int y, int w, int h, int scale) {
    content.paintLock();
    try {
        int[] srcBuffer = ((DataBufferInt)bbImage.getRaster().getDataBuffer()).getData();
        if (reset) {
            copyBuffer = new int[srcBuffer.length];
        }
        int linestride = bbImage.getWidth();

        x *= scale;
        y *= scale;
        w *= scale;
        h *= scale;

        for (int i=0; i<h; i++) {
            int from = (y + i) * linestride + x;
            System.arraycopy(srcBuffer, from, copyBuffer, from, w);
        }
    } finally {
        content.paintUnlock();
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:JLightweightFrame.java

示例11: createBuffer

import java.awt.image.DataBufferInt; //導入依賴的package包/類
/**
  * Create a data buffer of a particular type.
  *
  * @param dataType the desired data type of the buffer.
  * @param size the size of the data buffer bank
  * @param numBanks the number of banks the buffer should have
  */
 public static DataBuffer createBuffer(int dataType, int size, int numBanks)
 {
   switch (dataType)
     {
     case DataBuffer.TYPE_BYTE:
return new DataBufferByte(size, numBanks);
     case DataBuffer.TYPE_SHORT:
return new DataBufferShort(size, numBanks);
     case DataBuffer.TYPE_USHORT:
return new DataBufferUShort(size, numBanks);
     case DataBuffer.TYPE_INT:
return new DataBufferInt(size, numBanks);
     case DataBuffer.TYPE_FLOAT:
return new DataBufferFloat(size, numBanks);
     case DataBuffer.TYPE_DOUBLE:
return new DataBufferDouble(size, numBanks);
     default:
throw new UnsupportedOperationException();
     }
 }
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:28,代碼來源:Buffers.java

示例12: createBufferFromData

import java.awt.image.DataBufferInt; //導入依賴的package包/類
/**
  * Create a data buffer of a particular type.
  *
  * @param dataType the desired data type of the buffer
  * @param data an array containing the data
  * @param size the size of the data buffer bank
  */
 public static DataBuffer createBufferFromData(int dataType, Object data,
					int size)
 {
   switch (dataType)
     {
     case DataBuffer.TYPE_BYTE:
return new DataBufferByte((byte[]) data, size);
     case DataBuffer.TYPE_SHORT:
return new DataBufferShort((short[]) data, size);
     case DataBuffer.TYPE_USHORT:
return new DataBufferUShort((short[]) data, size);
     case DataBuffer.TYPE_INT:
return new DataBufferInt((int[]) data, size);
     case DataBuffer.TYPE_FLOAT:
return new DataBufferFloat((float[]) data, size);
     case DataBuffer.TYPE_DOUBLE:
return new DataBufferDouble((double[]) data, size);
     default:
throw new UnsupportedOperationException();
     }
 }
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:29,代碼來源:Buffers.java

示例13: allocateRgbImage

import java.awt.image.DataBufferInt; //導入依賴的package包/類
/**
 * @param windowWidth
 * @param windowHeight
 * @param pBuffer
 * @param windowSize
 * @param backgroundTransparent
 * @return an Image
 */
static Object allocateRgbImage(int windowWidth, int windowHeight,
                               int[] pBuffer, int windowSize,
                               boolean backgroundTransparent) {
  //backgroundTransparent not working with antialiasDisplay. I have no idea why. BH 9/24/08
  /* DEAD CODE   if (false && backgroundTransparent)
        return new BufferedImage(
            rgbColorModelT,
            Raster.createWritableRaster(
                new SinglePixelPackedSampleModel(
                    DataBuffer.TYPE_INT,
                    windowWidth,
                    windowHeight,
                    sampleModelBitMasksT), 
                new DataBufferInt(pBuffer, windowSize),
                null),
            false, 
            null);
  */
  return new BufferedImage(rgbColorModel, Raster.createWritableRaster(
      new SinglePixelPackedSampleModel(DataBuffer.TYPE_INT, windowWidth,
          windowHeight, sampleModelBitMasks), new DataBufferInt(pBuffer,
          windowSize), null), false, null);
}
 
開發者ID:etomica,項目名稱:etomica,代碼行數:32,代碼來源:Image.java

示例14: makeUnmanagedBI

import java.awt.image.DataBufferInt; //導入依賴的package包/類
private static BufferedImage makeUnmanagedBI(GraphicsConfiguration gc,
                                             int type) {
    BufferedImage img = gc.createCompatibleImage(SIZE, SIZE, type);
    Graphics2D g2d = img.createGraphics();
    g2d.setColor(RGB);
    g2d.fillRect(0, 0, SIZE, SIZE);
    g2d.dispose();
    final DataBuffer db = img.getRaster().getDataBuffer();
    if (db instanceof DataBufferInt) {
        ((DataBufferInt) db).getData();
    } else if (db instanceof DataBufferShort) {
        ((DataBufferShort) db).getData();
    } else if (db instanceof DataBufferByte) {
        ((DataBufferByte) db).getData();
    } else {
        try {
            img.setAccelerationPriority(0.0f);
        } catch (final Throwable ignored) {
        }
    }
    return img;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:23,代碼來源:IncorrectAlphaConversionBicubic.java

示例15: makeUnmanagedBI

import java.awt.image.DataBufferInt; //導入依賴的package包/類
private static BufferedImage makeUnmanagedBI(final int type) {
    final BufferedImage img = new BufferedImage(SIZE, SIZE, type);
    final DataBuffer db = img.getRaster().getDataBuffer();
    if (db instanceof DataBufferInt) {
        ((DataBufferInt) db).getData();
    } else if (db instanceof DataBufferShort) {
        ((DataBufferShort) db).getData();
    } else if (db instanceof DataBufferByte) {
        ((DataBufferByte) db).getData();
    } else {
        try {
            img.setAccelerationPriority(0.0f);
        } catch (final Throwable ignored) {
        }
    }
    return img;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:18,代碼來源:UnmanagedDrawImagePerformance.java


注:本文中的java.awt.image.DataBufferInt類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。