É possível transmitir ByteBuffer mutáveis ou imutáveis. No entanto, depois que ByteBuffer for transmitido, para manter a integridade dos dados, não modifique o conteúdo dele.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-07-24 UTC."],[],[],null,["# ByteBufferMlImageBuilder\n\npublic class **ByteBufferMlImageBuilder** \nBuilds a [MlImage](/edge/api/tflite/java/com/google/android/odml/image/MlImage) from a [ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer.html).\n\nYou can pass in either mutable or immutable [ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer.html). However once [ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer.html) is passed in, to keep data integrity you shouldn't modify content in it.\n\nUse [ByteBufferExtractor](/edge/api/tflite/java/com/google/android/odml/image/ByteBufferExtractor) to get [ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer.html) you passed in.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n### Public Constructors\n\n|---|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | [ByteBufferMlImageBuilder](/edge/api/tflite/java/com/google/android/odml/image/ByteBufferMlImageBuilder#ByteBufferMlImageBuilder(java.nio.ByteBuffer,%20int,%20int,%20int))([ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer.html) byteBuffer, int width, int height, int imageFormat) Creates the builder with mandatory [ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer.html) and the represented image. |\n\n### Public Methods\n\n|----------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [MlImage](/edge/api/tflite/java/com/google/android/odml/image/MlImage) | [build](/edge/api/tflite/java/com/google/android/odml/image/ByteBufferMlImageBuilder#build())() Builds an [MlImage](/edge/api/tflite/java/com/google/android/odml/image/MlImage) instance. |\n| [ByteBufferMlImageBuilder](/edge/api/tflite/java/com/google/android/odml/image/ByteBufferMlImageBuilder) | [setRotation](/edge/api/tflite/java/com/google/android/odml/image/ByteBufferMlImageBuilder#setRotation(int))(int rotation) Sets value for [MlImage.getRotation()](/edge/api/tflite/java/com/google/android/odml/image/MlImage#getRotation()). |\n\n### Inherited Methods\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|\n| boolean | equals([Object](https://developer.android.com/reference/java/lang/Object.html) arg0) |\n| final [Class](https://developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](https://developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Constructors\n-------------------\n\n#### public\n**ByteBufferMlImageBuilder**\n([ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer.html) byteBuffer, int width, int height, int imageFormat)\n\nCreates the builder with mandatory [ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer.html) and the represented image.\n\nWe will validate the size of the `byteBuffer` with given `width`, `height`\nand `imageFormat`.\n\nAlso calls [setRotation(int)](/edge/api/tflite/java/com/google/android/odml/image/ByteBufferMlImageBuilder#setRotation(int)) to set the optional properties. If not set, the values\nwill be set with default:\n\n- rotation: 0\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| byteBuffer | image data object. |\n| width | the width of the represented image. |\n| height | the height of the represented image. |\n| imageFormat | how the data encode the image. |\n|-------------|--------------------------------------|\n\nPublic Methods\n--------------\n\n#### public [MlImage](/edge/api/tflite/java/com/google/android/odml/image/MlImage)\n**build**\n()\n\nBuilds an [MlImage](/edge/api/tflite/java/com/google/android/odml/image/MlImage) instance. \n\n#### public [ByteBufferMlImageBuilder](/edge/api/tflite/java/com/google/android/odml/image/ByteBufferMlImageBuilder)\n**setRotation**\n(int rotation)\n\nSets value for [MlImage.getRotation()](/edge/api/tflite/java/com/google/android/odml/image/MlImage#getRotation()). \n\n##### Parameters\n\n| rotation | |\n|----------|---|\n\n##### Throws\n\n| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html) | if the rotation value is not 0, 90, 180 or 270. |\n|-------------------------------------------------------------------------------------------------------------|-------------------------------------------------|"]]