Package com.google.gwt.typedarrays.shared

Examples of com.google.gwt.typedarrays.shared.Uint8Array


    String byteString = getByteString(strings[1], strings[0]);
    String mimeString = strings[0].split(":")[1].split(";")[0];

    int length = byteString.length();
    ArrayBuffer ab = ArrayBufferNative.create(length);
    Uint8Array ia = Uint8ArrayNative.create(ab);

    for (int i = 0; i < length; i++)
    {
      ia.set(i, StringUtils.charCodeAt(byteString, i));
    }

    return Blob.createIfSupported(ab, mimeString);
  }
View Full Code Here


    if (!TypedArrays.isSupported()) {
      // TODO: some way of showing test as skipped in this case?
      return;
    }
    JsArrayInteger src = getJsoArray();
    Uint8Array array = JsUtils.createUint8Array(src);
    validateArrayContents(array, 0);
  }
View Full Code Here

    if (!TypedArrays.isSupported()) {
      // TODO: some way of showing test as skipped in this case?
      return;
    }
    ArrayBuffer buf = TypedArrays.createArrayBuffer(12);
    Uint8Array array = TypedArrays.createUint8Array(buf);
    setFromJsArray(array, 0);
    validateArrayContents(array, 0);

    buf = TypedArrays.createArrayBuffer(12);
    array = TypedArrays.createUint8Array(buf);
View Full Code Here

      // TODO: some way of showing test as skipped in this case?
      return;
    }
    String str = "\u0001\u0000\u0080\u0081";
    ArrayBuffer buf = JsUtils.arrayBufferFromString(str);
    Uint8Array view = TypedArrays.createUint8Array(buf);
    assertEquals(4, buf.byteLength());
    assertEquals(1, view.get(0));
    assertEquals(0, view.get(1));
    assertEquals(128, view.get(2));
    assertEquals(129, view.get(3));
  }
View Full Code Here

  public void testToString() {
    if (!TypedArrays.isSupported()) {
      // TODO: some way of showing test as skipped in this case?
      return;
    }
    Uint8Array view = TypedArrays.createUint8Array(4);
    view.set(0, 1);
    view.set(1, 0);
    view.set(2, 128);
    view.set(3, 129);
    String str = JsUtils.stringFromArrayBuffer(view.buffer());
    assertEquals(4, str.length());
    assertEquals(1, str.charAt(0));
    assertEquals(0, str.charAt(1));
    assertEquals(128, str.charAt(2));
    assertEquals(129, str.charAt(3));
View Full Code Here

      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));
    }
  }
View Full Code Here

      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));
    }
  }
View Full Code Here

TOP

Related Classes of com.google.gwt.typedarrays.shared.Uint8Array

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.