mass rename and rebranding from xwt to ibex - fixed to use ixt files
[org.ibex.core.git] / src / org / ibex / plat / AWT.java
1 // Copyright 2004 Adam Megacz, see the COPYING file for licensing [GPL]
2 package org.ibex.plat;
3
4 import org.ibex.*;
5 import org.ibex.util.*;
6 import java.io.*;
7 import org.ibex.js.*;
8 import java.awt.*;
9 import java.awt.datatransfer.*;
10 import java.awt.image.*;
11 import java.awt.event.*;
12
13 /** Platform subclass for all VM's providing AWT 1.1 functionality */
14 public class AWT extends JVM {
15
16     protected String getDescriptiveName() { return "Generic JDK 1.1+ with AWT"; }
17     protected PixelBuffer _createPixelBuffer(int w, int h, Surface owner) { return new AWTPixelBuffer(w, h); }
18     protected Picture _createPicture(JS r) { return new AWTPicture(r); }
19     protected int _getScreenWidth() { return Toolkit.getDefaultToolkit().getScreenSize().width; }
20     protected int _getScreenHeight() { return Toolkit.getDefaultToolkit().getScreenSize().height; }
21     protected Surface _createSurface(Box b, boolean framed) { return new AWTSurface(b, framed); }
22
23     protected void postInit() {
24         if (Log.on) Log.diag(Platform.class, "               color depth = " +
25                             Toolkit.getDefaultToolkit().getColorModel().getPixelSize() + "bpp");
26     }
27
28     protected void _criticalAbort(String message) {
29         if (Log.on) Log.info(this, message);
30         final Dialog d = new Dialog(new Frame(), "Ibex Cannot Continue");
31         d.setLayout(new BorderLayout());
32         TextArea ta = new TextArea("Ibex cannot continue because:\n\n" + message, 10, 80);
33         ta.setEditable(false);
34         d.add(ta, "Center");
35         Button b = new Button("OK");
36         b.addActionListener(new ActionListener() {
37                 public void actionPerformed(ActionEvent e) {
38                     d.dispose();
39                 }
40             });
41         d.add(b, "South");
42         d.setModal(true);
43         d.pack();
44         d.show();
45         new Semaphore().block();
46     }
47
48     protected String _getClipBoard() {
49         Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
50         if (cb == null) return null;
51         Transferable clipdata = cb.getContents(null);
52         try { return (String)clipdata.getTransferData(DataFlavor.stringFlavor); } catch (Exception ex) { return null; }
53     }
54
55     protected void _setClipBoard(String s) {
56         Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
57         if (clipboard == null) return;
58         StringSelection clipString = new StringSelection(s);
59         clipboard.setContents(clipString, clipString);
60     }
61
62     /** some platforms (cough, cough, NetscapeVM) have totally broken modifier masks; they will need to override this */
63     protected static int modifiersToButtonNumber(int modifiers) {
64         if ((modifiers & InputEvent.BUTTON1_MASK) == InputEvent.BUTTON1_MASK) return 1;
65         if ((modifiers & InputEvent.BUTTON2_MASK) == InputEvent.BUTTON2_MASK) {
66             // ugh, MacOSX reports the right mouse button as BUTTON2_MASK...
67             if (System.getProperty("os.name", "").startsWith("Mac OS X")) return 2;
68             return 3;
69         }
70         if ((modifiers & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) {
71             // ugh, MacOSX reports the right mouse button as BUTTON2_MASK...
72             if (System.getProperty("os.name", "").startsWith("Mac OS X")) return 3;
73             return 2;
74         }
75         return 0;
76     }
77
78     static class FileDialogHelper extends FileDialog implements WindowListener, ComponentListener {
79         Semaphore s;
80         public FileDialogHelper(String suggestedFileName, Semaphore s, boolean write) {
81             super(new Frame(), write ? "Save" : "Open", write ? FileDialog.SAVE : FileDialog.LOAD);
82             this.s = s;
83             addWindowListener(this);
84             addComponentListener(this);
85             if (suggestedFileName.indexOf(File.separatorChar) == -1) {
86                 setFile(suggestedFileName);
87             } else {
88                 setDirectory(suggestedFileName.substring(0, suggestedFileName.lastIndexOf(File.separatorChar)));
89                 setFile(suggestedFileName.substring(suggestedFileName.lastIndexOf(File.separatorChar) + 1));
90             }
91             show();
92         }
93         public void windowActivated(WindowEvent e) { }
94         public void windowClosed(WindowEvent e) { s.release(); }
95         public void windowClosing(WindowEvent e) { }
96         public void windowDeactivated(WindowEvent e) { }
97         public void windowDeiconified(WindowEvent e) { }
98         public void windowIconified(WindowEvent e) { }
99         public void windowOpened(WindowEvent e) { }
100         public void componentHidden(ComponentEvent e) { s.release(); }
101         public void componentMoved(ComponentEvent e) { }
102         public void componentResized(ComponentEvent e) { }
103         public void componentShown(ComponentEvent e) { }
104     };
105
106     protected String _fileDialog(String suggestedFileName, boolean write) {
107         final Semaphore s = new Semaphore();
108         FileDialogHelper fd = new FileDialogHelper(suggestedFileName, s, write);
109         s.block();
110         return fd.getDirectory() == null ? null : (fd.getDirectory() + File.separatorChar + fd.getFile());
111     }
112
113
114     // Inner Classes /////////////////////////////////////////////////////////////////////////////////////
115
116     protected org.ibex.Font.Glyph _createGlyph(org.ibex.Font f, char c) { return new AWTGlyph(f, c); }
117     protected static class AWTGlyph extends org.ibex.Font.Glyph {
118         private Image i = null;
119         private static ColorModel cmodel = new DirectColorModel(32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
120
121         // this doesn't work on Win32 because the JVM is broken
122         /*
123         static final ColorModel cmodel = new ColorModel(8) {
124             public int getRed(int p) { return 0; }
125             public int getGreen(int p) { return 0; }
126             public int getBlue(int p) { return 0; }
127             public int getAlpha(int p) { return p & 0xFF; }
128         };
129         */
130
131         public AWTGlyph(org.ibex.Font f, char c) { super(f, c); }
132         Image getImage() {
133             if (i == null && isLoaded) {
134
135                 int[] data2 = new int[data.length];
136                 for(int i=0; i<data2.length; i++) data2[i] = ((data[i]) & 0xff) << 24;
137
138                 MemoryImageSource mis = new MemoryImageSource(width, height, cmodel, data2, 0, width);
139                 mis.setAnimated(true);
140                 i = Toolkit.getDefaultToolkit().createImage(mis);
141                 MediaTracker mediatracker = new MediaTracker(new Canvas());
142                 mediatracker.addImage(i, 1);
143                 try { mediatracker.waitForAll(); } catch (InterruptedException e) { }
144                 mediatracker.removeImage(i);
145                 synchronized(AWTPixelBuffer.class) { 
146                     if (AWTPixelBuffer.component == null) {
147                         AWTPixelBuffer.component = new Frame();
148                         AWTPixelBuffer.component.setVisible(false);
149                         AWTPixelBuffer.component.addNotify();
150                     }
151                 }
152                 data = null;
153             }
154             return i;
155         }
156     }
157
158     protected static class AWTPicture extends Picture {
159         public Image i = null;
160         private static ColorModel cmodel = new DirectColorModel(32, 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000);
161         
162         boolean initialized = false;
163         public AWTPicture(JS r) { super(r); }
164         public void init() {
165             if (initialized) return;
166             initialized = true;
167             MemoryImageSource mis = new MemoryImageSource(width, height, cmodel, data, 0, width);
168             mis.setAnimated(true);
169             i = Toolkit.getDefaultToolkit().createImage(mis);
170             MediaTracker mediatracker = new MediaTracker(new Canvas());
171             mediatracker.addImage(i, 1);
172             try { mediatracker.waitForAll(); } catch (InterruptedException e) { }
173             mediatracker.removeImage(i);
174             synchronized(AWTPixelBuffer.class) { 
175                 if (AWTPixelBuffer.component == null) {
176                     AWTPixelBuffer.component = new Frame();
177                     AWTPixelBuffer.component.setVisible(false);
178                     AWTPixelBuffer.component.addNotify();
179                 }
180             }
181         }
182     }
183     
184     protected static class AWTPixelBuffer extends PixelBuffer {
185         
186         protected Image i = null;
187         protected Graphics g = null;
188         
189         /** JDK1.1 platforms require that a component be associated with each off-screen buffer */
190         static Component component = null;
191
192         protected AWTPixelBuffer() { }
193         public AWTPixelBuffer(int w, int h) {
194             synchronized(AWTPixelBuffer.class) {
195                 if (component == null) {
196                     component = new Frame();
197                     component.setVisible(false);
198                     component.addNotify();
199                 }
200             }
201             i = component.createImage(w, h);
202             g = i.getGraphics();
203         }
204         
205         public int getHeight() { return i == null ? 0 : i.getHeight(null); }
206         public int getWidth() { return i == null ? 0 : i.getWidth(null); }
207
208         public void drawPicture(Picture source, int dx, int dy, int cx1, int cy1, int cx2, int cy2) {
209             ((AWTPicture)source).init();
210             g.setClip(cx1, cy1, cx2 - cx1, cy2 - cy1);
211             g.drawImage(((AWTPicture)source).i, dx, dy, null);
212             g.setClip(0, 0, i.getWidth(null), i.getHeight(null));
213         }
214
215         /** implemented with java.awt 1.1's setXORMode() */
216         public void drawGlyph(org.ibex.Font.Glyph source, int dx, int dy, int cx1, int cy1, int cx2, int cy2, int rgb) {
217
218             // XOR the target region
219             g.setXORMode(new Color((rgb & 0x00ff0000) >> 16, (rgb & 0x0000ff00) >> 8, rgb & 0x000000ff));
220             g.setColor(new Color(0x0, 0x0, 0x0));
221             g.fillRect(cx1, cy1, cx2 - cx1, cy2 - cy1);
222
223             // blacken the area we want the glyph to cover
224             g.setPaintMode();
225             g.setClip(cx1, cy1, cx2 - cx1, cy2 - cy1);
226             g.drawImage(((AWTGlyph)source).getImage(), dx, dy, null);
227             g.setClip(0, 0, i.getWidth(null), i.getHeight(null));
228
229             // XOR back, turning black into the chosen rgb color
230             g.setXORMode(new Color((rgb & 0x00ff0000) >> 16, (rgb & 0x0000ff00) >> 8, rgb & 0x000000ff));
231             g.setColor(new Color(0x0, 0x0, 0x0));
232             g.fillRect(cx1, cy1, cx2 - cx1, cy2 - cy1);
233
234             // restore the graphics context
235             g.setPaintMode();
236         }
237
238         // FIXME: try to use os acceleration
239         public void fillTrapezoid(int x1, int x2, int y1, int x3, int x4, int y2, int argb) {
240             g.setColor(new Color((argb & 0x00FF0000) >> 16, (argb & 0x0000FF00) >> 8, (argb & 0x000000FF)));
241             if (x1 == x3 && x2 == x4) {
242                 g.fillRect(x1, y1, x4 - x1, y2 - y1);
243             } else for(int y=y1; y<y2; y++) {
244                 int _x1 = (int)Math.floor((y - y1) * (x3 - x1) / (y2 - y1) + x1);
245                 int _y1 = (int)Math.floor(y);
246                 int _x2 = (int)Math.ceil((y - y1) * (x4 - x2) / (y2 - y1) + x2);
247                 int _y2 = (int)Math.floor(y) + 1;
248                 if (_x1 > _x2) { int _x0 = _x1; _x1 = _x2; _x2 = _x0; }
249                 g.fillRect(_x1, _y1, _x2 - _x1, _y2 - _y1);
250             }
251         }
252     }
253     
254     
255     protected static class AWTSurface extends Surface.DoubleBufferedSurface
256         implements MouseListener, MouseMotionListener, KeyListener, ComponentListener, WindowListener {
257
258         public void blit(PixelBuffer s, int sx, int sy, int dx, int dy, int dx2, int dy2) {
259             insets = (frame == null ? window : frame).getInsets();
260             window.getGraphics().drawImage(((AWTPixelBuffer)s).i,
261                                   dx + insets.left,
262                                   dy + insets.top,
263                                   dx2 + insets.left,
264                                   dy2 + insets.top,
265                                   sx, sy, sx + (dx2 - dx), sy + (dy2 - dy), null);
266         }
267         
268         /** if (component instanceof Frame) then frame == window else frame == null */
269         Frame frame = null;
270         Window window = null;
271         
272         /** our component's insets */
273         protected Insets insets = new Insets(0, 0, 0, 0);
274         
275         /** some JDKs let us recycle a single Dimension object when calling getSize() */
276         Dimension singleSize = new Dimension();
277         
278         public void toBack() { if (window != null) window.toBack(); }
279         public void toFront() { if (window != null) window.toFront(); }
280         public void setLocation() { window.setLocation(root.x, root.y); }
281         public void setTitleBarText(String s) { if (frame != null) frame.setTitle(s); }
282         public void setIcon(Picture i) { if (frame != null) frame.setIconImage(((AWTPicture)i).i); }
283         public void _setSize(int width, int height) { window.setSize(width + (insets.left + insets.right), height + (insets.top + insets.bottom)); }
284         public void setInvisible(boolean b) { window.setVisible(!b); }
285         protected void _setMinimized(boolean b) { if (Log.on) Log.info(this, "JDK 1.1 platforms cannot minimize or unminimize windows"); }
286         protected void _setMaximized(boolean b) {
287             if (!b) {
288                 if (Log.on) Log.info(this, "JDK 1.1 platforms cannot unmaximize windows");
289                 return;
290             }
291             window.setLocation(new Point(0, 0));
292             window.setSize(Toolkit.getDefaultToolkit().getScreenSize());
293         }
294
295         class InnerFrame extends Frame {
296             public InnerFrame() throws java.lang.UnsupportedOperationException { }
297             public Dimension getMinimumSize() {
298                 return new Dimension(root == null ? 0 : root.minwidth, root == null ? 0 : root.minheight); }
299             public void update(Graphics gr) { paint(gr); }
300             public void paint(Graphics gr) {
301                 Rectangle r = gr.getClipBounds();
302
303                 // ugly hack for Java1.4 dynamicLayout on Win32 -- this catches expansions during smooth resize
304                 int newwidth = Math.max(r.x - insets.left + r.width, root.width);
305                 int newheight = Math.max(r.y - insets.top + r.height, root.height);
306                 if (newwidth > root.width || newheight > root.height)
307                     componentResized(window.getWidth() - insets.left - insets.right,
308                                      window.getHeight() - insets.top - insets.bottom);
309
310                 Dirty(r.x - insets.left, r.y - insets.top, r.width, r.height);
311             }
312         }
313
314         class InnerWindow extends Window {
315             public InnerWindow() throws java.lang.UnsupportedOperationException { super(new Frame()); }
316             public Dimension getMinimumSize() {
317                 return new Dimension(root == null ? 0 : root.minwidth, root == null ? 0 : root.minheight); }
318             public void update(Graphics gr) { paint(gr); }
319             public void paint(Graphics gr) {
320                 Rectangle r = gr.getClipBounds();
321                 Dirty(r.x - insets.left, r.y - insets.top, r.width, r.height);
322             }
323         }
324
325         public void setMinimumSize(int minx, int miny, boolean resizable) { if (frame != null) frame.setResizable(resizable); }
326
327         public void render() {
328             // useful optimizatin;
329             window.setBackground((root.fillcolor & 0xFF000000) == 0 ?
330                                  Color.white :
331                                  new Color((root.fillcolor >> 16) & 0xff,
332                                            (root.fillcolor >> 8) & 0xff,
333                                            (root.fillcolor) & 0xff));
334             super.render();
335         }
336
337         AWTSurface(Box root, boolean framed) {
338             super(root);
339             try {
340                 if (framed) window = frame = new InnerFrame();
341                 else window = new InnerWindow();
342
343             // this is here to catch HeadlessException on jdk1.4
344             } catch (java.lang.UnsupportedOperationException e) {
345                 if (Log.on) Log.info(this, "Exception thrown in AWTSurface$InnerFrame() -- this should never happen");
346                 if (Log.on) Log.info(this, e);
347             }
348
349             insets = window.getInsets();
350             
351             window.addMouseListener(this);
352             window.addKeyListener(this);
353             window.addComponentListener(this);
354             window.addMouseMotionListener(this);
355             window.addWindowListener(this);
356
357             // IMPORTANT: this must be called before render() to ensure
358             // that our peer has been created
359             makeVisible();
360         }
361
362         protected void makeVisible() { window.setVisible(true); }
363         
364         public void _dispose() {
365             window.removeMouseListener(this);
366
367             // removed to work around a jdk1.3 bug
368             /* window.removeKeyListener(this); */
369
370             window.removeComponentListener(this);
371             window.removeMouseMotionListener(this);
372             window.removeWindowListener(this);
373             window.dispose();
374         }
375
376         public void syncCursor() {
377             if (cursor.equals("crosshair")) window.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));
378             else if (cursor.equals("east")) window.setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));
379             else if (cursor.equals("move")) window.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
380             else if (cursor.equals("north")) window.setCursor(Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR));
381             else if (cursor.equals("northeast")) window.setCursor(Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR));
382             else if (cursor.equals("northwest")) window.setCursor(Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR));
383             else if (cursor.equals("south")) window.setCursor(Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR));
384             else if (cursor.equals("southeast")) window.setCursor(Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR));
385             else if (cursor.equals("southwest")) window.setCursor(Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR));
386             else if (cursor.equals("text")) window.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
387             else if (cursor.equals("west")) window.setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR));
388             else if (cursor.equals("wait")) window.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
389             else if (cursor.equals("hand")) window.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
390             else window.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
391         }
392         
393         // AWT Message translation ////////////////////////////////////////////////////////////////
394         
395         // these functions are all executed in the AWT thread, not the
396         // MessageQueue thread. As a result, they must be *extremely*
397         // careful about invoking methods on instances of Box. Currently,
398         // they should only enqueue messages, use Box.whoIs()
399         // (unsynchronized but thought to be safe), and modify members of
400         // Surface.
401         
402         public void componentHidden(ComponentEvent e) { }
403         public void componentShown(ComponentEvent e) { }
404         public void windowOpened(WindowEvent e) { }
405         public void windowClosed(WindowEvent e) { }
406         public void windowClosing(WindowEvent e) { Close(); }
407         public void windowIconified(WindowEvent e) { Minimized(true); }
408         public void windowDeiconified(WindowEvent e) { dirty(0, 0, root.width, root.height); Minimized(false); }
409         public void windowActivated(WindowEvent e) { Focused(true); }
410         public void windowDeactivated(WindowEvent e) { Focused(false); }
411         public void componentMoved(ComponentEvent e) { PosChange(window.getLocation().x + insets.left, window.getLocation().y + insets.top); }
412
413         public void componentResized(ComponentEvent e) {
414             // we have to periodically do this; I don't know why
415             insets = window.getInsets();
416             componentResized(window.getWidth() - insets.left - insets.right, window.getHeight() - insets.top - insets.bottom);
417         }
418
419         public void componentResized(int newwidth, int newheight) { SizeChange(newwidth, newheight); }
420
421         public void keyTyped(KeyEvent k) { }
422         public void keyPressed(KeyEvent k) { KeyPressed(translateKey(k)); }
423         public void keyReleased(KeyEvent k) { KeyReleased(translateKey(k)); }
424         public void mouseExited(MouseEvent m) { mouseMoved(m); }
425         public void mouseEntered(MouseEvent m) { mouseMoved(m); }
426         public void mouseDragged(MouseEvent m) { mouseMoved(m); }
427         public void mouseMoved(MouseEvent m) {
428
429             // ugly hack for Java1.4 dynamicLayout on Win32 -- this catches contractions during smooth resize
430             int newwidth = window.getWidth() - insets.left - insets.right;
431             int newheight = window.getHeight() - insets.top - insets.bottom;
432             if (newwidth != root.width || newheight != root.height) componentResized(newwidth, newheight);
433             
434             Move(m.getX() - insets.left, m.getY() - insets.top);
435         }
436         public void mousePressed(MouseEvent m) { Press(modifiersToButtonNumber(m.getModifiers())); }
437         public void mouseReleased(MouseEvent m) { Release(modifiersToButtonNumber(m.getModifiers())); }
438         public void mouseClicked(MouseEvent m) {
439             if (m.getClickCount() == 2) DoubleClick(modifiersToButtonNumber(m.getModifiers()));
440             else Click(modifiersToButtonNumber(m.getModifiers()));
441         }
442         
443         String translateKey(KeyEvent k) {
444             switch (k.getKeyCode()) {
445             case KeyEvent.VK_ALT: return "alt";
446             case KeyEvent.VK_BACK_SPACE: return "back_space";
447             case KeyEvent.VK_CONTROL: return "control";
448             case KeyEvent.VK_DELETE: return "delete";
449             case KeyEvent.VK_DOWN: return "down";
450             case KeyEvent.VK_END: return "end";
451             case KeyEvent.VK_ENTER: return "enter";
452             case KeyEvent.VK_ESCAPE: return "escape";
453             case KeyEvent.VK_F1: return "f1";
454             case KeyEvent.VK_F10: return "f10";
455             case KeyEvent.VK_F11: return "f11";
456             case KeyEvent.VK_F12: return "f12";
457             case KeyEvent.VK_F2: return "f2";
458             case KeyEvent.VK_F3: return "f3";
459             case KeyEvent.VK_F4: return "f4";
460             case KeyEvent.VK_F5: return "f5";
461             case KeyEvent.VK_F6: return "f6"; 
462             case KeyEvent.VK_F7: return "f7";
463             case KeyEvent.VK_F8: return "f8";
464             case KeyEvent.VK_F9: return "f9";
465             case KeyEvent.VK_HOME: return "home";
466             case KeyEvent.VK_INSERT: return "insert";
467             case KeyEvent.VK_LEFT: return "left";
468             case KeyEvent.VK_META: return "alt";
469             case KeyEvent.VK_PAGE_DOWN: return "page_down";
470             case KeyEvent.VK_PAGE_UP: return "page_up";
471             case KeyEvent.VK_PAUSE: return "pause";
472             case KeyEvent.VK_PRINTSCREEN: return "printscreen";
473             case KeyEvent.VK_RIGHT: return "right";
474             case KeyEvent.VK_SHIFT: return "shift";
475             case KeyEvent.VK_TAB: return "tab";
476             case KeyEvent.VK_UP: return "up";
477             default:
478                 char c = k.getKeyChar();
479                 if (c >= 1 && c <= 26) c = (char)('a' + c - 1);
480                 return String.valueOf(c);
481             }
482         }
483     }
484
485     protected void _decodeJPEG(InputStream is, Picture p) {
486         try {
487             Image i = Toolkit.getDefaultToolkit().createImage(InputStreamToByteArray.convert(is));
488             MediaTracker mediatracker = new MediaTracker(new Canvas());
489             mediatracker.addImage(i, 1);
490             try { mediatracker.waitForAll(); } catch (InterruptedException e) { }
491             mediatracker.removeImage(i);
492             final int width = i.getWidth(null);
493             final int height = i.getHeight(null);
494             final int[] data = new int[width * height];
495             PixelGrabber pg = new PixelGrabber(i, 0, 0, width, height, data, 0, width);
496             pg.grabPixels();
497             if ((pg.getStatus() & ImageObserver.ABORT) != 0)
498                 Log.info(this, "PixelGrabber reported an error while decoding JPEG image");
499             p.width = width;
500             p.height = height;
501             p.data = data;
502         } catch (Exception e) {
503             Log.info(this, "Exception caught while decoding JPEG image");
504             Log.info(this, e);
505         }
506     }
507 }