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


Java IntBuffer.wrap方法代碼示例

本文整理匯總了Java中java.nio.IntBuffer.wrap方法的典型用法代碼示例。如果您正苦於以下問題:Java IntBuffer.wrap方法的具體用法?Java IntBuffer.wrap怎麽用?Java IntBuffer.wrap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.nio.IntBuffer的用法示例。


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

示例1: majorVersionBuffer

import java.nio.IntBuffer; //導入方法依賴的package包/類
/**
 * Return an IntBuffer that accesses the major version number.
 * This is used to create a Monitor object for this value.
 *
 * @return IntBuffer - a ByteBuffer that accesses the major version number
 *                     in the instrumentation buffer header.
 */
public IntBuffer majorVersionBuffer() {
    int[] holder = new int[1];
    holder[0] = getMajorVersion();
    IntBuffer ib = IntBuffer.wrap(holder);
    ib.limit(1);
    return ib;
  }
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:AbstractPerfDataBufferPrologue.java

示例2: minorVersionBuffer

import java.nio.IntBuffer; //導入方法依賴的package包/類
/**
 * Return an IntBuffer that accesses the minor version number.
 * This is used to create a Monitor object for this value.
 *
 * @return IntBuffer - a ByteBuffer that accesses the minor version number
 *                     in the instrumentation buffer header.
 */
public IntBuffer minorVersionBuffer() {
    int[] holder = new int[1];
    holder[0] = getMinorVersion();
    IntBuffer ib = IntBuffer.wrap(holder);
    ib.limit(1);
    return ib;
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:15,代碼來源:AbstractPerfDataBufferPrologue.java

示例3: initBuffer

import java.nio.IntBuffer; //導入方法依賴的package包/類
@Override
public IntBuffer initBuffer(int width, int height) {
    int[] pixels = new int[width * height];
    IntBuffer intBuffer = IntBuffer.wrap(pixels);
    intBuffer.position(0);
    return intBuffer;
}
 
開發者ID:uestccokey,項目名稱:EZFilter,代碼行數:8,代碼來源:BitmapOutput.java

示例4: Texture

import java.nio.IntBuffer; //導入方法依賴的package包/類
public Texture(/*final String aName,*/ final Image aImage/*, final int aRepeatMode, final int aMagfilter*/)
{
    m_Name = aImage.getName();

    Debug.log("Texture::Texture(const std::string &aTextureFileName, GFXuint repeatmode, GFXuint magfilter)\n");
    Debug.log("Loading texture: "+m_Name);
    
    //load texture      
    int width = aImage.getData().getWidth(),height = aImage.getData().getHeight();
        
    Debug.log("Dimensons: {"+width+", "+width+"}");

    //.if DESKTOP
    //|int[] data;
    //|data = aImage.getData().getRGB(0, 0, width, height, (int[])null, 0, width);
    //|
    //|//Change from BGRA to RGBA
    //|for(int i = 0, pixel,r,g,b,a; i < data.length; i++)
    //|{
    //|    pixel = data[i];
    //|    a = (pixel >> 24) & 0xff;
    //|    r = (pixel >> 16) & 0xff;
    //|    g = (pixel >> 8) & 0xff;
    //|       b = (pixel >> 0) & 0xff;
    //|    pixel = (b<<16) | (g<<8) | (r<<0) | (a<<24);
    //|    data[i] = pixel;
    //|
    //|}
    //|IntBuffer pngbuffer = IntBuffer.wrap(data);
    //.elseif ANDROID
    //IntBuffer pngbuffer = IntBuffer.allocate(aImage.getData().getHeight()*aImage.getData().getRowBytes());
    //aImage.getData().copyPixelsToBuffer(pngbuffer);

    int x = aImage.getData().getWidth();
    int y = aImage.getData().getHeight();
    int[] data = new int[x * y];
    aImage.getData().getPixels(data, 0, x, 0, 0, x, y);

    for(int i = 0, pixel,r,g,b,a; i < data.length; i++)
    {
        pixel = data[i];
        a = (pixel >> 24) & 0xff;
        r = (pixel >> 16) & 0xff;
        g = (pixel >> 8) & 0xff;
        b = (pixel >> 0) & 0xff;

        pixel = (b<<16) | (g<<8) | (r<<0) | (a<<24);
        data[i] = pixel;

    }

    IntBuffer pngbuffer = IntBuffer.wrap(data);

    //.endif

    Debug.log("This is how long the intbuffer is: "    + pngbuffer.array().length );
    Debug.log("This is the size of a {RGBA} in bits: " + Integer.SIZE             );
        
    //push texture data to video memory
    IntBuffer texturehandle = IntBuffer.allocate(1);
            
    int textureFormat = GL.GL_RGBA;
        
    //Put the texture data in video memory
    GL.glGenTextures( 1, texturehandle );
    GL.glActiveTexture( GL.GL_TEXTURE0 );
    GL.glBindTexture( GL.GL_TEXTURE_2D, texturehandle.get(0) );
    GL.glTexImage2D( GL.GL_TEXTURE_2D, 0, textureFormat, width, height, 0, textureFormat, GL.GL_UNSIGNED_BYTE, pngbuffer );
        
    //Apply parameters
    GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST );
    GL.glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST );
        
    m_TextureHandle = texturehandle.get(0);
    
    Debug.log("Handle is: "+m_TextureHandle);
    
    GL.glBindTexture( GL.GL_TEXTURE_2D,0);//clear the binding

}
 
開發者ID:jfcameron,項目名稱:G2Dj,代碼行數:81,代碼來源:Texture.java

示例5: tensorInt

import java.nio.IntBuffer; //導入方法依賴的package包/類
/**
 * Creates a TensorFlow Tensor containing data from the given int image.
 * <p>
 * Note that this does _not_ adjust any dimensions. This means that
 * the resulting Tensor will have a shape corresponding to the reversed
 * dimensions of the image.
 * </p><p>
 * Also note that this will use the backing RAI's primitive array when one is
 * available. Otherwise a copy will be made.
 * </p>
 * @param image The image which should be put into the Tensor.
 * @return A Tensor containing the data of the image.
 */
public static Tensor tensorInt(
	final RandomAccessibleInterval<IntType> image)
{
	final int[] value = intArray(image);
	IntBuffer buffer = IntBuffer.wrap(value);
	return Tensor.create(shape(image), buffer);
}
 
開發者ID:imagej,項目名稱:imagej-tensorflow,代碼行數:21,代碼來源:Tensors.java


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