blob: 5eef75d1531be7024133002b7bac061c27617da9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
package com.javispedro.vndroid;
import android.content.Context;
import android.graphics.PixelFormat;
import android.hardware.display.DisplayManager;
import android.media.ImageReader;
import android.util.Log;
public class ScreenVirtualGrabber extends ScreenGrabber {
private static final String TAG = ScreenVirtualGrabber.class.getSimpleName();
public ScreenVirtualGrabber(Context context) {
super(context);
}
@Override
public void start() {
if (reader != null || display != null) {
Log.w(TAG, "already started");
return;
}
int width = 1024;
int height = 768;
int dpi = 96;
Log.d(TAG, "starting virtual display with width " + width + " height: " + height + " dpi: " + dpi);
reader = ImageReader.newInstance(width, height, PixelFormat.RGBA_8888, MAX_IMAGES);
reader.setOnImageAvailableListener(new ImageReaderCallback(), null);
DisplayManager manager = getSystemService(DisplayManager.class);
display = manager.createVirtualDisplay("vndroid",
width, height, dpi, reader.getSurface(),
DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC | DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY,
new VirtualDisplayCallback(), null);
}
}
|