This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void draw(float[] cameraView, float[] cameraPerspective) { | |
if (done || !prepared) { | |
return; | |
} | |
synchronized (this) { | |
if (frameAvailable) { | |
videoTexture.updateTexImage(); | |
frameAvailable = false; | |
if (videoTexture != null) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class VideoRenderer implements SurfaceTexture.OnFrameAvailableListener { | |
private SurfaceTexture videoTexture; | |
private int mTextureId; | |
private static final int TEXCOORDS_PER_VERTEX = 2; | |
private static final int COORDS_PER_VERTEX = 3; | |
private String TAG = VideoRenderer.class.getSimpleName(); | |
private int mQuadProgram; | |
private final Object lock = new Object(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HelloArActivity extends AppCompatActivity implements GLSurfaceView.Renderer { | |
private static final String TAG = HelloArActivity.class.getSimpleName(); | |
// Rendering. The Renderers are created here, and initialized when the GL surface is created. | |
private GLSurfaceView surfaceView; | |
private boolean installRequested; | |
private final VideoRenderer videoRenderer = new VideoRenderer(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val listener = ImageDecoder.OnHeaderDecodedListener { decoder, imageinfo, source -> | |
decoder.setTargetSize(100, 100) | |
//you can use setTargetSampleSize(2) to create a image with half of original height and width | |
} | |
val drawable = ImageDecoder.decodeDrawable(source, listener); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val source = ImageDecoder.createSource(assets, "image.jpg") | |
val listener = ImageDecoder.OnHeaderDecodedListener { decoder, info, src -> | |
decoder.setPostProcessor { canvas -> | |
// This will create rounded corners. | |
val path = Path() | |
path.fillType = Path.FillType.INVERSE_EVEN_ODD | |
val width = canvas.width | |
val height = canvas.height | |
path.addRoundRect(0f, 0f, width.toFloat(), height.toFloat(), width / 2.toFloat(), height / 2.toFloat(), Path.Direction.CW) | |
val paint = Paint() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainActivity : AppCompatActivity() { | |
val TAG = MainActivity::class.java.simpleName | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) | |
val handler = Handler(Looper.getMainLooper()) | |
Log.d(TAG, "Before post delayed:${System.currentTimeMillis()}") | |
handler.postDelayed( | |
{ |
OlderNewer