我有两份申请。一个应用程序充当服务器,它是在java中创建的,并使用以下代码连续发送桌面屏幕截图。
public void screenCap() throws IOException, AWTException{
Rectangle captureSize = new Rectangle(lastXpos, lastYpos, 500, 500);
img = robot.createScreenCapture(captureSize);
Robot robot=new Robot();
OutputStream os = null;
BufferedImage image = robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
ImageIO.write(image, "jpg", os);
}第二个应用程序是Android应用程序,它充当客户端应用程序,必须从inputstream中连续读取上面的图像流。
请帮助我从客户端应用程序中读取inputstream中的图像。
发布于 2012-08-27 18:49:19
使用BitmapFactory类的Bitmap decodeStream()方法。
public static Bitmap decodeStream (InputStream is)
Since: API Level 1将输入流解码为位图。流的位置将是在读取编码数据之后所在的位置。
示例:
String urlOfBitmap = ""; // Url of inputstream
Bitmap bitmap = null;
try {
InputStream in = new java.net.URL(urlOfBitmap).openStream();
bitmap = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}发布于 2012-08-27 18:50:14
FileInputStream in;
in = ...;
bitmap = BitmapFactory.decodeStream(in);https://stackoverflow.com/questions/12140529
复制相似问题