Skip to content

Instantly share code, notes, and snippets.

@LiorA1
LiorA1 / gist:14263af979ca2fb4cf3d05dc1a19bec3
Last active May 11, 2020 20:48
RenderScript: Save YUV_420_888 from Camera2 API to png file in the most efficient way [Uses ScriptIntrinsicYuvToRGB]
// Goal: Save YUV_420_888 from Camera2 API to png file in the most efficient way [Uses ScriptIntrinsicYuvToRGB]
// The following currently produce black image.
// a quick solution will be to use bitmap.
private void saveRenderScript(Image newImage, Context i_Context)
{
final Image image = newImage;
byte[] RGBBytes = ImageUtil.YUV_420_888_toRGBBytesIntrinsics(newImage, i_Context);
@LiorA1
LiorA1 / isPermissionGranted.java
Created May 11, 2020 20:47
isPermissionGranted basic example
public boolean isPermissionGranted()
{
boolean res = false;
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED
&& ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
&& ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED
/*&& ContextCompat.checkSelfPermission(this, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED*/)
{
res = true;
}