|
static PImage | readImage (int size, BufferedReader in) |
|
The ScrollViewImageHandler is a helper class which takes care of image processing. It is used to construct an Image from the message-stream and basically consists of a number of utility functions to process the input stream.
- Author
- wanke.nosp@m.@goo.nosp@m.gle.c.nosp@m.om
Definition at line 29 of file SVImageHandler.java.
static PImage com.google.scrollview.ui.SVImageHandler.readImage |
( |
int |
size, |
|
|
BufferedReader |
in |
|
) |
| |
|
inlinestatic |
Reads size bytes from the stream in and interprets it as an image file, encoded as png, and then text-encoded as base 64, returning the decoded bitmap.
- Parameters
-
size | The size of the image file. |
in | The input stream from which to read the bytes. |
Definition at line 42 of file SVImageHandler.java.
43 char[] charbuffer =
new char[size];
45 while (numRead < size) {
48 newRead = in.read(charbuffer, numRead, size - numRead);
49 }
catch (IOException e) {
50 System.out.println(
"Failed to read image data from socket:" + e.getMessage());
58 if (numRead != size) {
59 System.out.println(
"Failed to read image data from socket");
63 byte[] binarydata = DatatypeConverter.parseBase64Binary(
new String(charbuffer));
65 ByteArrayInputStream byteStream =
new ByteArrayInputStream(binarydata);
67 PImage img =
new PImage(ImageIO.read(byteStream));
69 }
catch (IOException e) {
70 System.out.println(
"Failed to decode image data from socket" + e.getMessage());
The documentation for this class was generated from the following file: