[tfls.util.image] Fix bug in Buffer->Bitmap conversion.
PiperOrigin-RevId: 304529665 Change-Id: Id844bd6822a2f60556963a9373b0066fc5f3184d
This commit is contained in:
parent
4503a089f0
commit
394b6bb711
@ -16,6 +16,7 @@ limitations under the License.
|
||||
package org.tensorflow.lite.support.image;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import java.util.Arrays;
|
||||
import org.tensorflow.lite.DataType;
|
||||
import org.tensorflow.lite.support.tensorbuffer.TensorBuffer;
|
||||
@ -68,10 +69,10 @@ class ImageConversions {
|
||||
int[] intValues = new int[w * h];
|
||||
int[] rgbValues = buffer.getIntArray();
|
||||
for (int i = 0, j = 0; i < intValues.length; i++) {
|
||||
byte r = (byte) rgbValues[j++];
|
||||
byte g = (byte) rgbValues[j++];
|
||||
byte b = (byte) rgbValues[j++];
|
||||
intValues[i] = ((r << 16) | (g << 8) | b);
|
||||
int r = rgbValues[j++];
|
||||
int g = rgbValues[j++];
|
||||
int b = rgbValues[j++];
|
||||
intValues[i] = Color.rgb(r, g, b);
|
||||
}
|
||||
bitmap.setPixels(intValues, 0, w, 0, 0, w, h);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user