Puedes pasar ByteBuffer mutable o inmutable. Sin embargo, una vez que se pasa ByteBuffer, no debes modificar el contenido para mantener la integridad de los datos.
public
ByteBufferMlImageBuilder(ByteBuffer byteBuffer, ancho int, altura int, imageFormat)
Crea el compilador con el ByteBuffer obligatorio y la imagen representada.
Validaremos el tamaño de byteBuffer con width, height y imageFormat determinados.
También llama a setRotation(int) para establecer las propiedades opcionales. Si no se configura, los valores
se establecerán con la configuración predeterminada:
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Falta la información que necesito","missingTheInformationINeed","thumb-down"],["Muy complicado o demasiados pasos","tooComplicatedTooManySteps","thumb-down"],["Desactualizado","outOfDate","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Problema con las muestras o los códigos","samplesCodeIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 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|-------------------------------------------------------------------------------------------------------------|-------------------------------------------------|"]]