本文整理汇总了Java中com.google.gwt.typedarrays.shared.Uint8Array.set方法的典型用法代码示例。如果您正苦于以下问题:Java Uint8Array.set方法的具体用法?Java Uint8Array.set怎么用?Java Uint8Array.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.typedarrays.shared.Uint8Array
的用法示例。
在下文中一共展示了Uint8Array.set方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
});
}
示例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);
}
示例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);
}
示例4: 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);
}
示例5: convertBytes
import com.google.gwt.typedarrays.shared.Uint8Array; //导入方法依赖的package包/类
public static ArrayBuffer convertBytes(byte[] data) {
Uint8Array push = TypedArrays.createUint8Array(data.length);
for (int i = 0; i < data.length; i++) {
push.set(i, data[i]);
}
return push.buffer();
}
示例6: dataImageAsBlob
import com.google.gwt.typedarrays.shared.Uint8Array; //导入方法依赖的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));
}
示例7: doSend
import com.google.gwt.typedarrays.shared.Uint8Array; //导入方法依赖的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);
}
示例8: convertArray
import com.google.gwt.typedarrays.shared.Uint8Array; //导入方法依赖的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;
}