• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Uint8ArrayNative类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: glReadPixels

import com.google.gwt.typedarrays.client.Uint8ArrayNative; //导入依赖的package包/类
@Override
public void glReadPixels (int x, int y, int width, int height, int format, int type, Buffer pixels) {
	// verify request
	if ((format != WebGLRenderingContext.RGBA) || (type != WebGLRenderingContext.UNSIGNED_BYTE)) {
		throw new GdxRuntimeException("Only format RGBA and type UNSIGNED_BYTE are currently supported for glReadPixels(...).");
	}
	if (!(pixels instanceof ByteBuffer)) {
		throw new GdxRuntimeException("Inputed pixels buffer needs to be of type ByteBuffer for glReadPixels(...).");
	}

	// create new ArrayBufferView (4 bytes per pixel)
	int size = 4 * width * height;
	Uint8Array buffer = Uint8ArrayNative.create(size);

	// read bytes to ArrayBufferView
	gl.readPixels(x, y, width, height, format, type, buffer);

	// copy ArrayBufferView to our pixels array
	ByteBuffer pixelsByte = (ByteBuffer)pixels;
	for (int i = 0; i < size; i++) {
		pixelsByte.put((byte)(buffer.get(i) & 0x000000ff));
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:24,代码来源:GwtGL20.java


示例2: glTexImage2D

import com.google.gwt.typedarrays.client.Uint8ArrayNative; //导入依赖的package包/类
@Override
public void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type,
	Buffer pixels) {
       if (pixels.limit() > 1) {
           HasArrayBufferView arrayHolder = (HasArrayBufferView) pixels;

           ArrayBufferView webGLArray = arrayHolder.getTypedArray();
           int remainingBytes = pixels.remaining() * 4;

           int byteOffset = webGLArray.byteOffset() + pixels.position() * 4;

           Uint8Array buffer = Uint8ArrayNative.create(webGLArray.buffer(), byteOffset, remainingBytes);

           gl.texImage2D(target, level, internalformat, width, height, border, format, type, buffer);
       } else {
           Pixmap pixmap = Pixmap.pixmaps.get(((IntBuffer)pixels).get(0));
           gl.texImage2D(target, level, internalformat, format, type, pixmap.getCanvasElement());
       }
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:20,代码来源:GwtGL20.java


示例3: glTexSubImage2D

import com.google.gwt.typedarrays.client.Uint8ArrayNative; //导入依赖的package包/类
@Override
public void glTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format, int type,
	Buffer pixels) {
       if (pixels.limit() > 1) {
           HasArrayBufferView arrayHolder = (HasArrayBufferView) pixels;

           ArrayBufferView webGLArray = arrayHolder.getTypedArray();
           int remainingBytes = pixels.remaining() * 4;

           int byteOffset = webGLArray.byteOffset() + pixels.position() * 4;

           Uint8Array buffer = Uint8ArrayNative.create(webGLArray.buffer(), byteOffset, remainingBytes);

           gl.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, buffer);
       } else {
           Pixmap pixmap = Pixmap.pixmaps.get(((IntBuffer) pixels).get(0));
           gl.texSubImage2D(target, level, xoffset, yoffset, width, height, pixmap.getCanvasElement());
       }
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:20,代码来源:GwtGL20.java


示例4: glReadPixels

import com.google.gwt.typedarrays.client.Uint8ArrayNative; //导入依赖的package包/类
@Override
public void glReadPixels (int x, int y, int width, int height, int format, int type, Buffer pixels) {
    // verify request
    if ((format != WebGLRenderingContext.RGBA) || (type != WebGLRenderingContext.UNSIGNED_BYTE)) {
        throw new GdxRuntimeException("Only format RGBA and type UNSIGNED_BYTE are currently supported for glReadPixels(...).");
    }
    if (!(pixels instanceof ByteBuffer)) {
        throw new GdxRuntimeException("Inputed pixels buffer needs to be of type ByteBuffer for glReadPixels(...).");
    }

    // create new ArrayBufferView (4 bytes per pixel)
    int size = 4 * width * height;
    Uint8Array buffer = Uint8ArrayNative.create(size);

    // read bytes to ArrayBufferView
    gl.readPixels(x, y, width, height, format, type, buffer);

    // copy ArrayBufferView to our pixels array
    ByteBuffer pixelsByte = (ByteBuffer)pixels;
    for (int i = 0; i < size; i++) {
        pixelsByte.put((byte)(buffer.get(i) & 0x000000ff));
    }
}
 
开发者ID:neuroradiology,项目名称:TinyVoxel,代码行数:24,代码来源:GwtGL20.java


示例5: glTexImage2D

import com.google.gwt.typedarrays.client.Uint8ArrayNative; //导入依赖的package包/类
@Override
public void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type,
                          Buffer pixels) {
    if (pixels.limit() > 1) {
        HasArrayBufferView arrayHolder = (HasArrayBufferView) pixels;

        ArrayBufferView webGLArray = arrayHolder.getTypedArray();
        int remainingBytes = pixels.remaining() * 4;

        int byteOffset = webGLArray.byteOffset() + pixels.position() * 4;

        Uint8Array buffer = Uint8ArrayNative.create(webGLArray.buffer(), byteOffset, remainingBytes);

        gl.texImage2D(target, level, internalformat, width, height, border, format, type, buffer);
    } else {
        // Put this back later
        Pixmap pixmap = Pixmap.pixmaps.get(((IntBuffer)pixels).get(0));
        gl.texImage2D(target, level, internalformat, format, type, pixmap.getCanvasElement());
    }
}
 
开发者ID:neuroradiology,项目名称:TinyVoxel,代码行数:21,代码来源:GwtGL20.java


示例6: glTexSubImage2D

import com.google.gwt.typedarrays.client.Uint8ArrayNative; //导入依赖的package包/类
@Override
public void glTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format, int type,
                             Buffer pixels) {
    if (pixels.limit() > 1) {
        HasArrayBufferView arrayHolder = (HasArrayBufferView) pixels;

        ArrayBufferView webGLArray = arrayHolder.getTypedArray();
        int remainingBytes = pixels.remaining() * 4;

        int byteOffset = webGLArray.byteOffset() + pixels.position() * 4;

        Uint8Array buffer = Uint8ArrayNative.create(webGLArray.buffer(), byteOffset, remainingBytes);

        gl.texSubImage2D(target, level, xoffset, yoffset, width, height, format, type, buffer);
    } else {
        // Put this back later
        Pixmap pixmap = Pixmap.pixmaps.get(((IntBuffer) pixels).get(0));
        gl.texSubImage2D(target, level, xoffset, yoffset, width, height, pixmap.getCanvasElement());
    }
}
 
开发者ID:neuroradiology,项目名称:TinyVoxel,代码行数:21,代码来源:GwtGL20.java


示例7: glTexImage2D

import com.google.gwt.typedarrays.client.Uint8ArrayNative; //导入依赖的package包/类
@Override
public void glTexImage2D(int target, int level, int internalFormat, int width, int height, int border, int format, int type, DirectBuffer pixels)
{
    ArrayBufferView arrayBufferView = null;

    switch (type)
    {
        case GL_FLOAT:
            arrayBufferView = Float32ArrayNative.create(((ArrayBufferView) pixels.nativeBuffer()).buffer());
            break;

        case GL_UNSIGNED_BYTE:
            arrayBufferView = Uint8ArrayNative.create(((ArrayBufferView) pixels.nativeBuffer()).buffer());
            break;
    }

    WebGL10.glTexImage2D(target, level, internalFormat, width, height, border, format, type, arrayBufferView);
}
 
开发者ID:sriharshachilakapati,项目名称:SilenceEngine,代码行数:19,代码来源:GwtGraphicsDevice.java


示例8: read

import com.google.gwt.typedarrays.client.Uint8ArrayNative; //导入依赖的package包/类
public static PixelImage read(ArrayBuffer arrayBuffer, ImageType type) throws IOException {
	Uint8ArrayNative u8array = Uint8ArrayNative.create(arrayBuffer);
	byte [] buffer = new byte[u8array.length()];
	for(int i=0; i<buffer.length; i++) {
		buffer[i] = (byte)u8array.get(i);
	}
	return read(buffer, type);
}
 
开发者ID:npedotnet,项目名称:npe-image-library,代码行数:9,代码来源:GwtImageReader.java


示例9: createCanvas

import com.google.gwt.typedarrays.client.Uint8ArrayNative; //导入依赖的package包/类
public static Canvas createCanvas(ArrayBuffer arrayBuffer, ImageType type) throws IOException {
	Uint8ArrayNative u8array = Uint8ArrayNative.create(arrayBuffer);
	byte [] buffer = new byte[u8array.length()];
	for(int i=0; i<buffer.length; i++) {
		buffer[i] = (byte)u8array.get(i);
	}
	return createCanvas(buffer, type);
}
 
开发者ID:npedotnet,项目名称:npe-image-library,代码行数:9,代码来源:GwtImageReader.java


示例10: dataImageAsBlob

import com.google.gwt.typedarrays.client.Uint8ArrayNative; //导入依赖的package包/类
/**
 * Creates a Blob instance for the raw image data-uri value.
 * @param data The image uri data.
 * @param mimeType The media type for the generated blob.
 */
public static Blob dataImageAsBlob(final String data,
                                   final String mimeType) {
    final String byteString = Window.atob(data);
    final ArrayBuffer buffer = ArrayBufferNative.create(byteString.length());
    final Uint8Array ia = Uint8ArrayNative.create(buffer);
    for (int i = 0; i < byteString.length(); i++) {
        ia.set(i,
               byteString.charAt(i));
    }
    return new BlobImpl(new Object[]{ia},
                        BlobPropertyBag.create(mimeType));
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:18,代码来源:ImageFileExport.java


示例11: addTGACanvas

import com.google.gwt.typedarrays.client.Uint8ArrayNative; //导入依赖的package包/类
private void addTGACanvas(String url) {
	XMLHttpRequest request = XMLHttpRequest.create();
	request.open("GET", url);
	request.setResponseType(ResponseType.ArrayBuffer);
	request.setOnReadyStateChange(new ReadyStateChangeHandler() {
		@Override
		public void onReadyStateChange(XMLHttpRequest xhr) {
			if(xhr.getReadyState() == XMLHttpRequest.DONE) {
				if(xhr.getStatus() >= 400) {
					// error
					System.out.println("Error");
				}
				else {
					try {
						ArrayBuffer arrayBuffer = xhr.getResponseArrayBuffer();
						Uint8ArrayNative u8array = Uint8ArrayNative.create(arrayBuffer);
						byte [] buffer = new byte[u8array.length()];
						for(int i=0; i<buffer.length; i++) {
							buffer[i] = (byte)u8array.get(i);
						}
						int pixels [] = TGAReader.read(buffer, TGAReader.ABGR);
						int width = TGAReader.getWidth(buffer);
						int height = TGAReader.getHeight(buffer);
						
						Canvas canvas = createImageCanvas(pixels, width, height);
						panel.add(canvas);
					}
					catch(Exception e) {
						e.printStackTrace();
					}
				}
			}
		}
	});
	request.send();
}
 
开发者ID:npedotnet,项目名称:TGAReader,代码行数:37,代码来源:ImageCanvasTest.java


示例12: sendRequest

import com.google.gwt.typedarrays.client.Uint8ArrayNative; //导入依赖的package包/类
public void sendRequest(MapTile tile, final UrlTileDataSource dataSource) {

		String url = mTileSource.getTileUrl(tile);

		mHttpRequest = XMLHttpRequest.create();
		mHttpRequest.open("GET", url);
		mHttpRequest.setResponseType(ResponseType.ArrayBuffer);

		mResponseHandler = new ReadyStateChangeHandler() {

			@Override
			public void onReadyStateChange(XMLHttpRequest xhr) {
				int state = xhr.getReadyState();
				//log.debug(mCurrentUrl + "response " + status + "/" + state);

				if (state == XMLHttpRequest.DONE) {
					if (xhr.getStatus() == 200) {
						Uint8Array buf = Uint8ArrayNative.create(xhr.getResponseArrayBuffer());
						dataSource.process(new Buffer(buf));
					} else {
						dataSource.process(null);
					}
					mHttpRequest = null;
				}
			}
		};

		mHttpRequest.setOnReadyStateChange(mResponseHandler);
		mHttpRequest.send();
	}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:31,代码来源:LwHttp.java


示例13: glTexImage2D

import com.google.gwt.typedarrays.client.Uint8ArrayNative; //导入依赖的package包/类
@Override
public void glTexImage2D(int target, int level, int internalformat, int width, int height,
        int border, int format, int type, Buffer pixels) {

	if (pixels == null) {
		gl.texImage2D(target, level, internalformat,
		              width, height, border, format,
		              type, null);
		return;
	}

	Pixmap pixmap = Pixmap.pixmaps.get(((IntBuffer) pixels).get(0));
	if (pixmap != null) {
		gl.texImage2D(target, level, internalformat, format, type, pixmap.getCanvasElement());
	} else if (format == GL.ALPHA) {
		int tmp[] = new int[(width * height) >> 2];
		((IntBuffer) pixels).get(tmp);

		Uint8ArrayNative v = com.google.gwt.typedarrays.client.Uint8ArrayNative.create(width
		        * height);

		for (int i = 0, n = (width * height) >> 2; i < n; i++) {
			v.set(i * 4 + 3, (tmp[i] >> 24) & 0xff);
			v.set(i * 4 + 2, (tmp[i] >> 16) & 0xff);
			v.set(i * 4 + 1, (tmp[i] >> 8) & 0xff);
			v.set(i * 4 + 0, (tmp[i]) & 0xff);
		}
		gl.texImage2D(target, level, internalformat, width, height, 0, format, type, v);
	}
}
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:31,代码来源:GdxGL.java


示例14: loadTexture

import com.google.gwt.typedarrays.client.Uint8ArrayNative; //导入依赖的package包/类
void loadTexture(String url, int index) {
	final int i = index;
    XMLHttpRequest request = XMLHttpRequest.create();
    request.open("GET", url);
    request.setResponseType(ResponseType.ArrayBuffer);
    request.setOnReadyStateChange(new ReadyStateChangeHandler() {
        @Override
        public void onReadyStateChange(XMLHttpRequest xhr) {
            if(xhr.getReadyState() == XMLHttpRequest.DONE) {
                if(xhr.getStatus() >= 400) {
                    // error
                    System.out.println("Error");
                }
                else {
                	try {
	                	ArrayBuffer arrayBuffer = xhr.getResponseArrayBuffer();
	    				Uint8ArrayNative u8array = Uint8ArrayNative.create(arrayBuffer);
	    				byte [] buffer = new byte[u8array.length()];
	    				for(int i=0; i<buffer.length; i++) {
	    					buffer[i] = (byte)u8array.get(i);
	    				}
	    				
	    				int [] pixels = TGAReader.read(buffer, TGAReader.ABGR);
	    				int width = TGAReader.getWidth(buffer);
	    				int height = TGAReader.getHeight(buffer);
	    				
	    				Canvas canvas = createImageCanvas(pixels, width, height);
	    				
	    				WebGLTexture texture = gl.createTexture();
	    				gl.enable(TEXTURE_2D);
	    				gl.bindTexture(TEXTURE_2D, texture);
	    				
	    				gl.texImage2D(TEXTURE_2D, 0, RGBA, RGBA, UNSIGNED_BYTE, canvas.getElement());

	    				gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);
	    				gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);
	    				gl.texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, LINEAR);
	    				gl.texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, LINEAR);
	    				
	    				textures[i] = texture;
	    				draw();
                	}
                	catch(Exception e) {
                		e.printStackTrace();
                	}
                }
            }
        }
    });
    request.send();
}
 
开发者ID:npedotnet,项目名称:TGAReader,代码行数:52,代码来源:TexturedCube.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FBDanmaku类代码示例发布时间:2022-05-23
下一篇:
Java SessionAddress类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap