Tesseract  3.02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
com.google.scrollview.ui.SVImageHandler Class Reference

Static Public Member Functions

static void createImage (String name, int width, int height, int bitsPerPixel)
 
static void openImage (String location)
 
static PImage getImage (String name)
 
static void parseData (String inputLine)
 
static boolean getReadImageData ()
 
static int getMissingRemainingBytes ()
 

Detailed Description

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 26 of file SVImageHandler.java.

Member Function Documentation

static void com.google.scrollview.ui.SVImageHandler.createImage ( String  name,
int  width,
int  height,
int  bitsPerPixel 
)
inlinestatic

Starts creation of a new image.

Definition at line 146 of file SVImageHandler.java.

147  {
148  // Create buffered image that does not support transparency
149  bpp = bitsPerPixel;
150  if (bpp == 1) {
151  bytePerPixel = 1;
152  } else if (bpp == 8) {
153  bytePerPixel = 2;
154  } else if (bpp == 32) {
155  bytePerPixel = 7;
156  } else {
157  throw new IllegalArgumentException(
158  "bpp should be 1 (binary), 8 (gray) or 32 (argb), is " + bpp);
159  }
160  if (imageName != null) {
161  throw new IllegalArgumentException("Image " + imageName + " already opened!");
162  }
163  else {
164  imageName = name;
165  bytesRead = 0;
166  readImageData = true;
167  SVImageHandler.height = height;
168  SVImageHandler.width = width;
169  pictureArray = new int[width * height];
170  }
171 
172  System.out.println("Processing Image with " + bpp + " bpp, size " + width + "x" + height);
173  }
static PImage com.google.scrollview.ui.SVImageHandler.getImage ( String  name)
inlinestatic

Find the image corresponding to a given name

Definition at line 189 of file SVImageHandler.java.

189  {
190  return images.get(name);
191  }
static int com.google.scrollview.ui.SVImageHandler.getMissingRemainingBytes ( )
inlinestatic

Computes how many bytes of the image data are still missing

Definition at line 225 of file SVImageHandler.java.

225  {
226  return (height * width * bytePerPixel) - bytesRead;
227  }
static boolean com.google.scrollview.ui.SVImageHandler.getReadImageData ( )
inlinestatic

Returns whether we a currently reading image data or not

Definition at line 220 of file SVImageHandler.java.

220  {
221  return readImageData;
222  }
static void com.google.scrollview.ui.SVImageHandler.openImage ( String  location)
inlinestatic

Opens an Image from location. This means the image does not have to be actually transfered over the network. Thus, it is a lot faster than using the createImage method.

Parameters
locationThe (local) location from where to open the file. This is also the internal name associated with the image (if you want to draw it).

Definition at line 183 of file SVImageHandler.java.

183  {
184  PImage img = new PImage(location);
185  images.put(location, img);
186  }
static void com.google.scrollview.ui.SVImageHandler.parseData ( String  inputLine)
inlinestatic

Gets called while currently reading image data. Decides, how to process it (which image type, whether all data is there).

Definition at line 197 of file SVImageHandler.java.

197  {
198  int[] data = null;
199 
200  if (bpp == 1) {
201  data = processBinaryImage(inputLine);
202  } else if (bpp == 8) {
203  data = processGrayImage(inputLine);
204  } else if (bpp == 32) {
205  data = process32bppImage(inputLine);
206  } else {
207  System.out.println("Unsupported Bit Type: " + bpp);
208  }
209 
210  System.arraycopy(data, 0, pictureArray, bytesRead, data.length);
211  bytesRead += data.length;
212 
213  // We have read all image data - close the image
214  if (bytesRead == (height * width)) {
215  closeImage();
216  }
217  }

The documentation for this class was generated from the following file: