Package quicktime.app.view

Source Code of quicktime.app.view.QTImageProducer

/*     */ package quicktime.app.view;
/*     */
/*     */ import java.awt.Dimension;
/*     */ import java.awt.image.ColorModel;
/*     */ import java.awt.image.DirectColorModel;
/*     */ import java.awt.image.ImageConsumer;
/*     */ import java.awt.image.ImageProducer;
/*     */ import java.util.Enumeration;
/*     */ import java.util.Hashtable;
/*     */ import java.util.Vector;
/*     */ import quicktime.QTException;
/*     */ import quicktime.app.time.Timeable;
/*     */ import quicktime.jdirect.QTNative;
/*     */ import quicktime.qd.PixMap;
/*     */ import quicktime.qd.QDGraphics;
/*     */ import quicktime.qd.QDRect;
/*     */ import quicktime.qd.Region;
/*     */ import quicktime.util.RawEncodedImage;
/*     */
/*     */ public class QTImageProducer
/*     */   implements ImageProducer
/*     */ {
/*     */   private static final boolean debug = false;
/*  54 */   private static long msecs = 0L;
/*     */   private static final boolean profile = false;
/*     */   private Dimension size;
/*     */   private int rowInts;
/*     */   private QDGraphics gw;
/*     */   private PixMap pm;
/*     */   private int[] pixels;
/*     */   private Presentable qtSource;
/* 125 */   private ColorModel cm = new DirectColorModel(32, 16711680, 65280, 255, 0);
/* 126 */   private Hashtable props = new Hashtable();
/* 127 */   private Vector consumers = new Vector();
/*     */   private boolean doesRedraw;
/*     */   private boolean singleFrame;
/*     */
/*     */   private static boolean requiresRedrawing(Presentable paramPresentable)
/*     */   {
/*  58 */     return ((paramPresentable instanceof Timeable)) || (!paramPresentable.isSingleFrame());
/*     */   }
/*     */
/*     */   public QTImageProducer(MoviePlayer paramMoviePlayer, Dimension paramDimension)
/*     */     throws QTException
/*     */   {
/*  71 */     this(paramMoviePlayer, paramDimension);
/*     */   }
/*     */
/*     */   public QTImageProducer(GraphicsImporterDrawer paramGraphicsImporterDrawer, Dimension paramDimension)
/*     */     throws QTException
/*     */   {
/*  83 */     this(paramGraphicsImporterDrawer, paramDimension);
/*     */   }
/*     */
/*     */   QTImageProducer(Presentable paramPresentable, Dimension paramDimension) throws QTException {
/*  87 */     this.qtSource = paramPresentable;
/*  88 */     setRedrawing(requiresRedrawing(paramPresentable));
/*  89 */     this.singleFrame = (!isRedrawing());
/*  90 */     this.size = paramDimension;
/*  91 */     this.gw = new QDGraphics(new QDRect(this.size));
/*  92 */     paramPresentable.setDisplayBounds(new QDRect(this.size));
/*  93 */     paramPresentable.setGWorld(this.gw);
/*  94 */     this.pm = this.gw.getPixMap();
/*  95 */     this.rowInts = (this.pm.getRowBytes() / 4);
/*  96 */     this.pixels = new int[this.rowInts * this.size.height];
/*  97 */     paramPresentable.redraw(null);
/*  98 */     copyPixels();
/*     */
/* 102 */     if (isSingleFrame()) {
/* 103 */       this.gw.disposeQTObject();
/* 104 */       this.gw = null;
/* 105 */       this.pm = null;
/* 106 */       this.qtSource = null;
/*     */     }
/*     */   }
/*     */
/*     */   public QDGraphics getGWorld()
/*     */   {
/* 115 */     return this.gw;
/*     */   }
/*     */
/*     */   public boolean isSingleFrame()
/*     */   {
/* 137 */     return this.singleFrame;
/*     */   }
/*     */
/*     */   public synchronized void addConsumer(ImageConsumer paramImageConsumer)
/*     */   {
/* 151 */     if (isConsumer(paramImageConsumer)) return;
/*     */
/*     */     try
/*     */     {
/* 156 */       this.consumers.addElement(paramImageConsumer);
/* 157 */       paramImageConsumer.setDimensions(this.size.width, this.size.height);
/*     */
/* 160 */       if (isConsumer(paramImageConsumer)) {
/* 161 */         paramImageConsumer.setProperties(this.props);
/*     */       }
/*     */       else {
/* 164 */         return;
/*     */       }
/* 166 */       if (isConsumer(paramImageConsumer)) {
/* 167 */         paramImageConsumer.setColorModel(this.cm);
/*     */       }
/*     */       else {
/* 170 */         return;
/*     */       }
/* 172 */       if (isConsumer(paramImageConsumer)) {
/* 173 */         int i = 14;
/* 174 */         if (isSingleFrame())
/* 175 */           i |= 16;
/* 176 */         paramImageConsumer.setHints(i);
/*     */       }
/*     */     }
/*     */     catch (Exception localException) {
/* 180 */       if (isConsumer(paramImageConsumer))
/* 181 */         paramImageConsumer.imageComplete(1);
/*     */     }
/*     */   }
/*     */
/*     */   public synchronized boolean isConsumer(ImageConsumer paramImageConsumer)
/*     */   {
/* 194 */     return this.consumers.contains(paramImageConsumer);
/*     */   }
/*     */
/*     */   public synchronized void removeConsumer(ImageConsumer paramImageConsumer)
/*     */   {
/* 208 */     this.consumers.removeElement(paramImageConsumer);
/*     */   }
/*     */
/*     */   public void startProduction(ImageConsumer paramImageConsumer)
/*     */   {
/* 222 */     synchronized (QTNative.globalsLock) {
/* 223 */       synchronized (this)
/*     */       {
/*     */         try {
/* 226 */           addConsumer(paramImageConsumer);
/* 227 */           if (isConsumer(paramImageConsumer)) {
/* 228 */             paramImageConsumer.setPixels(0, 0, this.size.width, this.size.height, this.cm, this.pixels, 0, this.rowInts);
/*     */           }
/*     */           else {
/* 231 */             return;
/*     */           }
/* 233 */           if (isConsumer(paramImageConsumer))
/* 234 */             if (isSingleFrame()) {
/* 235 */               paramImageConsumer.imageComplete(3);
/* 236 */               if (isConsumer(paramImageConsumer)) {
/* 237 */                 paramImageConsumer.imageComplete(1);
/* 238 */                 removeConsumer(paramImageConsumer);
/*     */               }
/*     */             } else {
/* 241 */               paramImageConsumer.imageComplete(2);
/*     */             }
/*     */         }
/*     */         catch (Exception localException)
/*     */         {
/* 246 */           if (isConsumer(paramImageConsumer))
/* 247 */             paramImageConsumer.imageComplete(1);
/*     */         }
/*     */       }
/*     */     }
/*     */   }
/*     */
/*     */   public void requestTopDownLeftRightResend(ImageConsumer paramImageConsumer)
/*     */   {
/*     */   }
/*     */
/*     */   private synchronized void copyPixels()
/*     */     throws QTException
/*     */   {
/* 281 */     RawEncodedImage localRawEncodedImage = this.pm.getPixelData();
/* 282 */     localRawEncodedImage.copyToArray(0, this.pixels, 0, this.pixels.length);
/*     */   }
/*     */
/*     */   public synchronized void redraw(Region paramRegion)
/*     */     throws QTException
/*     */   {
/* 305 */     if ((!this.consumers.isEmpty()) || (!isSingleFrame()))
/*     */     {
/* 311 */       this.qtSource.redraw(null);
/*     */     }
/* 313 */     else return;
/*     */
/* 315 */     updateConsumers(paramRegion);
/*     */   }
/*     */
/*     */   public synchronized void updateConsumers(Region paramRegion)
/*     */     throws QTException
/*     */   {
/* 328 */     if (!isSingleFrame())
/* 329 */       copyPixels();
/* 330 */     int m = 0;
/*     */     int i;
/*     */     int j;
/*     */     int k;
/* 331 */     if (paramRegion != null) {
/* 332 */       localObject = paramRegion.getRgnBBox();
/* 333 */       i = ((QDRect)localObject).getX();
/* 334 */       j = ((QDRect)localObject).getY();
/* 335 */       k = ((QDRect)localObject).getWidth();
/* 336 */       m = ((QDRect)localObject).getHeight();
/*     */     } else {
/* 338 */       i = 0;
/* 339 */       j = 0;
/* 340 */       k = this.size.width;
/* 341 */       m = this.size.height;
/*     */     }
/*     */
/* 345 */     Object localObject = this.consumers.elements();
/* 346 */     while (((Enumeration)localObject).hasMoreElements()) {
/* 347 */       ImageConsumer localImageConsumer = (ImageConsumer)((Enumeration)localObject).nextElement();
/* 348 */       localImageConsumer.setPixels(i, j, k, m, this.cm, this.pixels, 0, this.rowInts);
/*     */
/* 351 */       if (isConsumer(localImageConsumer)) {
/* 352 */         localImageConsumer.imageComplete(2);
/*     */       }
/*     */     }
/*     */
/* 356 */     this.pixels[0] = 0;
/*     */   }
/*     */
/*     */   public synchronized void setRedrawing(boolean paramBoolean)
/*     */   {
/* 370 */     this.doesRedraw = paramBoolean;
/*     */   }
/*     */
/*     */   public boolean isRedrawing()
/*     */   {
/* 379 */     return this.doesRedraw;
/*     */   }
/*     */
/*     */   public Dimension getSize() {
/* 383 */     return new Dimension(this.size);
/*     */   }
/*     */ }

/* Location:           Z:\System\Library\Java\Extensions\QTJava.zip
* Qualified Name:     quicktime.app.view.QTImageProducer
* JD-Core Version:    0.6.2
*/
TOP

Related Classes of quicktime.app.view.QTImageProducer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.