*NV21 to RGB
http://www.41post.com/3470/programming/android-retrieving-the-camera-preview-as-a-pixel-array
Android: Retrieving Camera preview as a Pixel Array | 41 Post
Posted by Dimitri | Mar 24th, 2011 | Filed under Featured, Programming This post explains how to take the live images created by Android’s camera preview feature and return them as a RGB array, that can be used to all sorts of things, like custom effects
www.41post.com
*intArray to byteArray
https://stackoverflow.com/questions/1086054/how-to-convert-int-to-byte
How to convert int[] to byte[]
I have an array of integers which represent a RGB image and would like to convert it to a byte array and save it to a file. What's the best way to convert an array of integers to the array of byte...
stackoverflow.com
*RGB to BGR
Java RGB Color Convert To rgbToBgr(final byte[] pixels)
Java RGB Color Convert To rgbToBgr(final byte[] pixels) Here you can find the source of rgbToBgr(final byte[] pixels) HOMEJavaRRGB Color Convert TorgbToBgr(final byte[] pixels)
www.java2s.com
//nv21 -> RGB
byte[] decodeYUV420SP(int[] rgb, byte[] yuv420sp, int width, int height) {
final int frameSize = width * height;
for (int j = 0, yp = 0; j < height; j++) {
int uvp = frameSize + (j >> 1) * width, u = 0, v = 0;
for (int i = 0; i < width; i++, yp++) {
int y = (0xff & ((int) yuv420sp[yp])) - 16;
if (y < 0)
y = 0;
if ((i & 1) == 0) {
v = (0xff & yuv420sp[uvp++]) - 128;
u = (0xff & yuv420sp[uvp++]) - 128;
}
int y1192 = 1192 * y;
int r = (y1192 + 1634 * v);
int g = (y1192 - 833 * v - 400 * u);
int b = (y1192 + 2066 * u);
if (r < 0) r = 0;
else if (r > 262143)
r = 262143;
if (g < 0) g = 0;
else if (g > 262143)
g = 262143;
if (b < 0) b = 0;
else if (b > 262143)
b = 262143;
rgb[yp] = 0xff000000 | ((r << 6) & 0xff0000) | ((g >> 2) & 0xff00) | ((b >> 10) & 0xff);
}
}
//int[] to byte[]
ByteBuffer byteBuffer = ByteBuffer.allocate(rgb.length * 4);
IntBuffer intBuffer = byteBuffer.asIntBuffer();
intBuffer.put(rgb);
byte[] array = byteBuffer.array();
return rgbToBgr(array);
}
//RGB -> BGR
public static byte[] rgbToBgr(final byte[] pixels) {
final byte[] pixels_publish = new byte[pixels.length];
int idx = 0;
for (int i = 0; i < pixels.length / 3; i++) {
pixels_publish[idx] = pixels[idx + 2];
pixels_publish[idx + 1] = pixels[idx + 1];
pixels_publish[idx + 2] = pixels[idx];
idx += 3;
}
return pixels_publish;
}
*byte[] to int[]
http://www.java2s.com/Code/Java/Collections-Data-Structure/bytearraytointarray.htm
byte array to int array : Array Convert « Collections Data Structure « Java
byte array to int array : Array Convert « Collections Data Structure « Java JavaCollections Data StructureArray Convert byte array to int array /* * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and a
www.java2s.com
'+)기록 > 과제' 카테고리의 다른 글
정리사항 35 - 스레드 runOnUiThread사용 / 뒤로가기 버튼 막기(onBackPressed()) (0) | 2023.03.23 |
---|---|
정리사항 34 - 스레드 동기화 (0) | 2023.03.21 |
정리사항 32 - int[] to byte[] (0) | 2023.03.20 |
정리사항 31 - NV21이미지 회전 (0) | 2023.03.16 |
정리사항 30 - 스레드, 핸들러 / 바이트배열 -> 비트맵 / NV21 회전 (0) | 2023.03.15 |