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


Java Uint8Array类代码示例

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


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

示例1: putMethod

import com.google.gwt.typedarrays.shared.Uint8Array; //导入依赖的package包/类
@Override
public Promise<HTTPResponse> putMethod(String url, byte[] contents) {
    return new Promise<>(resolver -> {
        JsHttpRequest request = JsHttpRequest.create();
        request.open("PUT", url);
        request.setRequestHeader("Content-Type", "application/octet-stream");
        request.setOnLoadHandler(request1 -> {
            if (request1.getReadyState() == 4) {
                if (request1.getStatus() >= 200 && request1.getStatus() < 300) {
                    resolver.result(new HTTPResponse(request1.getStatus(), null));
                } else {
                    resolver.error(new HTTPError(request1.getStatus()));
                }
            }
        });
        Uint8Array push = TypedArrays.createUint8Array(contents.length);
        for (int i = 0; i < contents.length; i++) {
            push.set(i, contents[i]);
        }
        request.send(push.buffer());
    });
}
 
开发者ID:wex5,项目名称:dangchat-sdk,代码行数:23,代码来源:JsHttpProvider.java

示例2: send

import com.google.gwt.typedarrays.shared.Uint8Array; //导入依赖的package包/类
@Override
public void send(ByteBuffer data) {
  int len = data.limit();
  // TODO(haustein) Sending the view directly does not work for some reason.
  // May be a chrome issue...?
  //  Object trick = data;
  // ArrayBufferView ta = ((HasArrayBufferView) trick).getTypedArray();
  // Int8Array view = Int8Array.create(ta.getBuffer(), ta.getByteOffset(), len)
  // ws.send(view);
  ArrayBuffer buf = TypedArrays.createArrayBuffer(len);
  Uint8Array view = TypedArrays.createUint8Array(buf);
  for (int i = 0; i < len; i++) {
    view.set(i, data.get(i));
  }
  ws.send(buf);
}
 
开发者ID:playn,项目名称:playn,代码行数:17,代码来源:HtmlWebSocket.java

示例3: setTile

import com.google.gwt.typedarrays.shared.Uint8Array; //导入依赖的package包/类
public void setTile(TileInfo tileInfo, GMap bufferGMap) {
	if (bufferImageData == null || bufferImageData.getWidth() != bufferGMap.getDataWidth()
			|| bufferImageData.getHeight() != bufferGMap.getDataHeight()) {
		bufferImageData = bufferCanvas.getContext2d()
				.createImageData(bufferGMap.getDataWidth(), bufferGMap.getDataHeight());
	}
	Uint8Array imageArray = bufferImageData.getData().cast();
	imageArray.set(bufferGMap.getImageData());
	bufferCanvas.getContext2d().putImageData(bufferImageData, -bufferGMap.getBorder(), 0);

	CanvasElement tile = tiles.get(tileInfo);
	if (tile == null) {
		tile = createImage(bufferGMap.getDataWidth() - bufferGMap.getBorder(), bufferGMap.getDataHeight());
		tiles.put(new TileInfo(tileInfo), tile);
	}
	Context2d c = tile.getContext2d();
	c.setFillStyle("white");
	c.fillRect(0, 0, tileSize, tileSize);
	c.drawImage(bufferCanvas, 0, 0);
	for (Consumer<Integer> listener : tileListeners)
		listener.accept(tileInfo.page);
}
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:23,代码来源:DataStore.java

示例4: nextChar

import com.google.gwt.typedarrays.shared.Uint8Array; //导入依赖的package包/类
private static int nextChar(
  Uint8Array byteArray,
  int    pos)
{
  if(pos < byteArray.length())
  {
    while(++pos < byteArray.length())
    {
      if((byteArray.get(pos) & 0xc0) != 0x80)
      {
        return pos;
      }
    }
  }

  return pos;
}
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:18,代码来源:DjVuText.java

示例5: firstEndSpace

import com.google.gwt.typedarrays.shared.Uint8Array; //导入依赖的package包/类
private int firstEndSpace(
  final Uint8Array byteArray,
  int          start,
  final int    length)
{
  for(int pos = start + length; --pos >= start;)
  {
    if(
      ((byteArray.get(pos) & 0xc0) != 0x80)
      && !isspace(getChar(byteArray, pos)))
    {
      return nextChar(byteArray, pos);
    }
  }

  return start;
}
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:18,代码来源:DjVuText.java

示例6: prevChar

import com.google.gwt.typedarrays.shared.Uint8Array; //导入依赖的package包/类
private static int prevChar(
  Uint8Array byteArray,
  int    pos)
{
  if(pos >= 0)
  {
    while(--pos >= 0)
    {
      if((byteArray.get(pos) & 0xc0) != 0x80)
      {
        return pos;
      }
    }
  }

  return pos;
}
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:18,代码来源:DjVuText.java

示例7: glReadPixels

import com.google.gwt.typedarrays.shared.Uint8Array; //导入依赖的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

示例8: glTexImage2D

import com.google.gwt.typedarrays.shared.Uint8Array; //导入依赖的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

示例9: glTexSubImage2D

import com.google.gwt.typedarrays.shared.Uint8Array; //导入依赖的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

示例10: glReadPixels

import com.google.gwt.typedarrays.shared.Uint8Array; //导入依赖的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

示例11: glTexImage2D

import com.google.gwt.typedarrays.shared.Uint8Array; //导入依赖的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

示例12: glTexSubImage2D

import com.google.gwt.typedarrays.shared.Uint8Array; //导入依赖的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

示例13: doSend

import com.google.gwt.typedarrays.shared.Uint8Array; //导入依赖的package包/类
@Override
public void doSend(byte[] data) {
    // Log.d(TAG, "doSend");
    if (isClosed) {
        return;
    }
    Uint8Array push = TypedArrays.createUint8Array(data.length);
    for (int i = 0; i < data.length; i++) {
        push.set(i, data[i]);
    }
    send(push);
}
 
开发者ID:wex5,项目名称:dangchat-sdk,代码行数:13,代码来源:WebSocketConnection.java

示例14: convertBytes

import com.google.gwt.typedarrays.shared.Uint8Array; //导入依赖的package包/类
public static byte[] convertBytes(ArrayBuffer buffer) {
    Uint8Array array = TypedArrays.createUint8Array(buffer);
    byte[] res = new byte[array.length()];
    for (int i = 0; i < res.length; i++) {
        res[i] = (byte) (array.get(i));
    }
    return res;
}
 
开发者ID:wex5,项目名称:dangchat-sdk,代码行数:9,代码来源:Conversion.java

示例15: read

import com.google.gwt.typedarrays.shared.Uint8Array; //导入依赖的package包/类
@Override
public Promise<FilePart> read(int fileOffset, int len) {
    return new Promise<>(resolver -> {
        JsFileReader fileReader = JsFileReader.create();
        fileReader.setOnLoaded(message -> {
            Uint8Array array = TypedArrays.createUint8Array(message);
            byte[] data = new byte[len];
            for (int i = 0; i < len; i++) {
                data[i] = (byte) (array.get(i));
            }
            resolver.result(new FilePart(fileOffset, len, data));
        });
        fileReader.readAsArrayBuffer(jsFile.slice(fileOffset, fileOffset + len));
    });
}
 
开发者ID:wex5,项目名称:dangchat-sdk,代码行数:16,代码来源:JsFileInput.java


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