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


Java TypedArrays.createUint8Array方法代码示例

本文整理汇总了Java中com.google.gwt.typedarrays.shared.TypedArrays.createUint8Array方法的典型用法代码示例。如果您正苦于以下问题:Java TypedArrays.createUint8Array方法的具体用法?Java TypedArrays.createUint8Array怎么用?Java TypedArrays.createUint8Array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.typedarrays.shared.TypedArrays的用法示例。


在下文中一共展示了TypedArrays.createUint8Array方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: putMethod

import com.google.gwt.typedarrays.shared.TypedArrays; //导入方法依赖的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.TypedArrays; //导入方法依赖的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: BSInputStream

import com.google.gwt.typedarrays.shared.TypedArrays; //导入方法依赖的package包/类
/**
  * Creates a new BSInputStream object.
* @param bsInputStream 
  */
 public BSInputStream(BSInputStream toCopy) {
  this.zp = new ZPCodec(toCopy.zp);
  for (int i = 0; i < toCopy.ctx.length; i++) {
	  if (toCopy.ctx[i] != null) {
		  ctx[i] = new BitContext((short) (toCopy.ctx[i].get() & 0xFF));
	  }
  }
  if (toCopy.data != null) {
	  data = TypedArrays.createUint8Array(toCopy.data.length());
	  data.set(toCopy.data);
  }
  eof = toCopy.eof;
  blocksize = toCopy.blocksize;
  bptr = toCopy.bptr;
  size = toCopy.size;
 }
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:21,代码来源:BSInputStream.java

示例4: doSend

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

示例5: convertBytes

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

示例6: getTypedArray

import com.google.gwt.typedarrays.shared.TypedArrays; //导入方法依赖的package包/类
/**
 * Returns the typed array of the given native buffer. Set byteSize to -1 to use remaining().
 */
private ArrayBufferView getTypedArray(Buffer buffer, int type, int byteSize) {
  if (!(buffer instanceof HasArrayBufferView)) {
    throw new RuntimeException("Native buffer required " + buffer);
  }
  HasArrayBufferView arrayHolder = (HasArrayBufferView) buffer;
  int bufferElementSize = arrayHolder.getElementSize();

  ArrayBufferView webGLArray = arrayHolder.getTypedArray();
  if (byteSize == -1) {
    byteSize = buffer.remaining() * bufferElementSize;
  }
  if (byteSize == buffer.capacity() * bufferElementSize && type == arrayHolder.getElementType()) {
    return webGLArray;
  }

  int byteOffset = webGLArray.byteOffset() + buffer.position() * bufferElementSize;

  switch (type) {
    case FLOAT:
      return TypedArrays.createFloat32Array(webGLArray.buffer(), byteOffset, byteSize / 4);
    case UNSIGNED_BYTE:
      return TypedArrays.createUint8Array(webGLArray.buffer(), byteOffset, byteSize);
    case UNSIGNED_SHORT:
      return TypedArrays.createUint16Array(webGLArray.buffer(), byteOffset, byteSize / 2);
    case INT:
      return TypedArrays.createInt32Array(webGLArray.buffer(), byteOffset, byteSize / 4);
    case SHORT:
      return TypedArrays.createInt16Array(webGLArray.buffer(), byteOffset, byteSize / 2);
    case BYTE:
      return TypedArrays.createInt8Array(webGLArray.buffer(), byteOffset, byteSize);
    default:
      throw new IllegalArgumentException("Type: " + type);
  }
}
 
开发者ID:playn,项目名称:playn,代码行数:38,代码来源:HtmlGL20.java

示例7: doSend

import com.google.gwt.typedarrays.shared.TypedArrays; //导入方法依赖的package包/类
@Override
public void doSend(byte[] data) {
    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:dsaved,项目名称:africhat-platform-0.1,代码行数:12,代码来源:WebSocketConnection.java

示例8: convertArray

import com.google.gwt.typedarrays.shared.TypedArrays; //导入方法依赖的package包/类
private Uint8Array convertArray(byte[] bytes) {
	Uint8Array result = TypedArrays.createUint8Array(bytes.length);
	for (int i = 0; i < bytes.length; i++)
		result.set(i, bytes[i]);
	return result;
}
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:7,代码来源:DjVuText.java

示例9: getPixmap

import com.google.gwt.typedarrays.shared.TypedArrays; //导入方法依赖的package包/类
/**
 * DOCUMENT ME!
 *
 * @return DOCUMENT ME!
 */
public GPixmap getPixmap()
{
  if(ymap == null)
  {
    return null;
  }

  final int w      = ymap.iw;
  final int h      = ymap.ih;
  final int pixsep = 4;
  final int rowsep = w * pixsep;
  Uint8Array bytes = TypedArrays.createUint8Array(h * rowsep);

  ymap.image(0, bytes, rowsep, pixsep, false);

  if((crmap != null) && (cbmap != null) && (crcb_delay >= 0))
  {
    cbmap.image(1, bytes, rowsep, pixsep, crcb_half);
    crmap.image(2, bytes, rowsep, pixsep, crcb_half);
  }

  // Convert image to RGB
  final GPixmap         ppm   =
    new GPixmap().init(bytes, h, w);
  final GPixelReference pixel = ppm.createGPixelReference(0);

  for(int i = 0; i < h;)
  {
    pixel.setOffset(i++, 0);

    if((crmap != null) && (cbmap != null) && (crcb_delay >= 0))
    {
      pixel.YCC_to_RGB(w);
    }
    else
    {
      for(int x = w; x-- > 0; pixel.incOffset())
      {
        pixel.setGray(127 - pixel.getBlue());
      }
    }
  }

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

示例10: createImageData

import com.google.gwt.typedarrays.shared.TypedArrays; //导入方法依赖的package包/类
protected void createImageData(int columns, int rows) {
  data = TypedArrays.createUint8Array(columns * rows * BYTES_PER_PIXEL);
  dataBuffer = data.buffer();
  dataWidth = columns;
  dataHeight = rows;
}
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:7,代码来源:GMap.java


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