@Override
public void run() {
while (!stop) {
Canvas canvas = holder.lockCanvas();
int[] colors = ffmpeg4Buffer.getRGB();
if (colors != null) {
canvas.drawBitmap(colors, 0, 704, 0, 0, width, height, false, null);
}
holder.unlockCanvasAndPost(canvas);
}
}
使用继承SurfaceView,并实现SurfaceHolder.Callback接口
即可显示。
我解码后是RGB24 类型为byte[]; int[] colors = new int[width * height * numBands];
for(int i = 0; i < width * height * numBands -1; i++)
{
colors[i] = byteArray[i];
}
if (colors != null) {
canvas.drawBitmap(colors, 0, width, 0, 0, width, height, false, null);
}