Package quicktime.qd

Source Code of quicktime.qd.Pict

/*     */ package quicktime.qd;
/*     */
/*     */ import java.io.File;
/*     */ import java.io.FileInputStream;
/*     */ import java.io.FileOutputStream;
/*     */ import java.io.IOException;
/*     */ import quicktime.QTException;
/*     */ import quicktime.QTObject;
/*     */ import quicktime.QTRuntimeException;
/*     */ import quicktime.QTSession;
/*     */ import quicktime.jdirect.QTNative;
/*     */ import quicktime.std.StdQTException;
/*     */ import quicktime.std.image.GraphicsExporter;
/*     */ import quicktime.std.image.GraphicsImporter;
/*     */ import quicktime.std.movies.Movie;
/*     */ import quicktime.std.movies.Track;
/*     */ import quicktime.std.qtcomponents.ImageCompressionDialog;
/*     */ import quicktime.std.sg.SequenceGrabber;
/*     */ import quicktime.streaming.Presentation;
/*     */ import quicktime.streaming.Stream;
/*     */ import quicktime.util.EndianOrder;
/*     */ import quicktime.util.QTHandleRef;
/*     */ import quicktime.util.RawEncodedImage;
/*     */
/*     */ public final class Pict extends QTHandleRef
/*     */   implements Cloneable
/*     */ {
/*  32 */   private static boolean apriori = QTSession.apriori();
/*     */
/*  40 */   private static int kNativeSize = 10;
/*  41 */   private static transient QDGraphics gw = null;
/*  42 */   private static final int[] savedPort = { 0 };
/*  43 */   private static final int[] savedDevice = { 0 };
/*     */
/*     */   public static Pict thumbnailFromQDGraphics(QDGraphics paramQDGraphics, QDRect paramQDRect, int paramInt)
/*     */     throws QTException
/*     */   {
/*  55 */     Pict localPict = new Pict(4, false);
/*  56 */     if (paramQDGraphics == null) {
/*  57 */       throw new StdQTException(-50);
/*     */     }
/*  59 */     int i = 0;
/*     */
/*  61 */     synchronized (QTNative.globalsLock) {
/*  62 */       if ((QTSession.isCurrentOS(1)) || (QTSession.isCurrentOS(4)))
/*  63 */         GetGWorld(savedPort, savedDevice);
/*  64 */       SetGWorld(QTObject.ID(paramQDGraphics), 0);
/*  65 */       int j = GetGWorldPixMap(QTObject.ID(paramQDGraphics));
/*  66 */       LockPixels(j);
/*  67 */       i = MakeThumbnailFromPixMap(j, paramQDRect.getRect(), (short)paramInt, QTObject.ID(localPict), 0);
/*     */
/*  72 */       if ((QTSession.isCurrentOS(1)) || (QTSession.isCurrentOS(4)))
/*  73 */         SetGWorld(savedPort[0], savedDevice[0]);
/*     */     }
/*  75 */     QDException.checkError(i);
/*  76 */     return localPict;
/*     */   }
/*     */
/*     */   public static Pict fromTrack(Track paramTrack, int paramInt)
/*     */     throws QTException
/*     */   {
/*  88 */     int i = GetTrackPict(QTObject.ID(paramTrack), paramInt);
/*  89 */     StdQTException.checkError(GetMoviesError());
/*  90 */     return new Pict(i);
/*     */   }
/*     */
/*     */   public static Pict fromMovie(Movie paramMovie, int paramInt)
/*     */     throws QTException
/*     */   {
/* 104 */     int i = GetMoviePict(QTObject.ID(paramMovie), paramInt);
/* 105 */     StdQTException.checkError(GetMoviesError());
/* 106 */     return new Pict(i);
/*     */   }
/*     */
/*     */   public static Pict fromMovie(Movie paramMovie)
/*     */     throws QTException
/*     */   {
/* 118 */     int i = GetMoviePosterPict(QTObject.ID(paramMovie));
/* 119 */     StdQTException.checkError(GetMoviesError());
/* 120 */     return new Pict(i);
/*     */   }
/*     */
/*     */   public static Pict fromPresentation(Presentation paramPresentation, Stream paramStream)
/*     */     throws QTException
/*     */   {
/* 133 */     int[] arrayOfInt = new int[1];
/* 134 */     StdQTException.checkError(QTSPresGetPicture(QTObject.ID(paramPresentation), QTObject.ID(paramStream), arrayOfInt));
/*     */
/* 136 */     return arrayOfInt[0] == 0 ? null : new Pict(arrayOfInt[0]);
/*     */   }
/*     */
/*     */   public static Pict fromSequenceGrabber(SequenceGrabber paramSequenceGrabber, QDRect paramQDRect, int paramInt1, int paramInt2)
/*     */     throws QTException
/*     */   {
/* 155 */     int[] arrayOfInt = new int[1];
/* 156 */     int i = SGGrabPict(QTObject.ID(paramSequenceGrabber), arrayOfInt, paramQDRect.getRect(), (short)paramInt1, paramInt2);
/*     */
/* 161 */     StdQTException.checkError(i);
/* 162 */     return arrayOfInt[0] == 0 ? null : new Pict(arrayOfInt[0]);
/*     */   }
/*     */
/*     */   public static Pict fromGraphicsImporter(GraphicsImporter paramGraphicsImporter)
/*     */     throws QTException
/*     */   {
/* 172 */     int[] arrayOfInt = { 0 };
/* 173 */     int i = GraphicsImportGetAsPicture(QTObject.ID(paramGraphicsImporter), arrayOfInt);
/* 174 */     StdQTException.checkError(i);
/* 175 */     return new Pict(arrayOfInt[0]);
/*     */   }
/*     */
/*     */   public static Pict fromGraphicsExporter(GraphicsExporter paramGraphicsExporter)
/*     */     throws QTException
/*     */   {
/* 186 */     int[] arrayOfInt = { 0 };
/* 187 */     int i = GraphicsExportGetInputPicture(QTObject.ID(paramGraphicsExporter), arrayOfInt);
/* 188 */     StdQTException.checkError(i);
/* 189 */     return new Pict(arrayOfInt[0]);
/*     */   }
/*     */
/*     */   public static Pict fromImageCompressionDialog(ImageCompressionDialog paramImageCompressionDialog, Pict paramPict)
/*     */     throws QTException
/*     */   {
/* 200 */     Pict localPict = new Pict(4, true);
/* 201 */     int i = SCCompressPicture(QTObject.ID(paramImageCompressionDialog), QTObject.ID(paramPict), QTObject.ID(localPict));
/* 202 */     if (i == 1) throw new StdQTException(-128);
/* 203 */     StdQTException.checkError(i);
/* 204 */     return localPict;
/*     */   }
/*     */
/*     */   public static Pict fromFile(File paramFile)
/*     */     throws QTException, IOException
/*     */   {
/* 214 */     FileInputStream localFileInputStream = new FileInputStream(paramFile);
/* 215 */     byte[] arrayOfByte = new byte[localFileInputStream.available() - 512];
/* 216 */     localFileInputStream.skip(512L);
/* 217 */     localFileInputStream.read(arrayOfByte, 0, arrayOfByte.length);
/* 218 */     localFileInputStream.close();
/* 219 */     Pict localPict = new Pict(arrayOfByte.length, false);
/* 220 */     localPict.copyFromArray(0, arrayOfByte, 0, arrayOfByte.length);
/* 221 */     return localPict;
/*     */   }
/*     */
/*     */   public static Pict open(QDGraphics paramQDGraphics, OpenCPicParams paramOpenCPicParams)
/*     */     throws QTException
/*     */   {
/* 234 */     if (gw != null) throw new QDException(-9);
/* 235 */     int i = 0;
/*     */
/* 237 */     synchronized (QTNative.globalsLock) {
/* 238 */       if ((QTSession.isCurrentOS(1)) || (QTSession.isCurrentOS(4)))
/* 239 */         GetGWorld(savedPort, savedDevice);
/* 240 */       SetGWorld(QTObject.ID(paramQDGraphics), 0);
/* 241 */       gw = paramQDGraphics;
/* 242 */       i = OpenCPicture(paramOpenCPicParams.getBytes());
/* 243 */       if ((QTSession.isCurrentOS(1)) || (QTSession.isCurrentOS(4)))
/* 244 */         SetGWorld(savedPort[0], savedDevice[0]);
/*     */       try {
/* 246 */         QDException.checkError(QDError());
/*     */       } catch (QTException localQTException) {
/* 248 */         gw = null;
/* 249 */         throw localQTException;
/*     */       }
/*     */     }
/* 252 */     if (i == 0)
/* 253 */       throw new QDException(-108);
/* 254 */     return new Pict(i);
/*     */   }
/*     */
/*     */   public Pict(byte[] paramArrayOfByte)
/*     */     throws QTException
/*     */   {
/* 264 */     super(paramArrayOfByte.length, false);
/* 265 */     copyFromArray(0, paramArrayOfByte, 0, paramArrayOfByte.length);
/*     */   }
/*     */
/*     */   private Pict(int paramInt)
/*     */     throws QTException
/*     */   {
/* 274 */     super(paramInt, null, false);
/*     */   }
/*     */
/*     */   private Pict(int paramInt, boolean paramBoolean)
/*     */     throws QTException
/*     */   {
/* 284 */     super(paramInt, paramBoolean);
/*     */   }
/*     */
/*     */   public QDRect getPictFrame()
/*     */   {
/* 289 */     byte[] arrayOfByte = new byte[8];
/* 290 */     getBytesAt(2, 8, arrayOfByte, 0);
/* 291 */     if ((QTSession.isCurrentOS(2)) || ((QTSession.isCurrentOS(4)) && (EndianOrder.isNativeLittleEndian()))) {
/* 292 */       for (int i = 0; i < 8; i += 2)
/* 293 */         setShortInArray(arrayOfByte, i, EndianOrder.flipNativeToBigEndian16(getShortFromArray(arrayOfByte, i)));
/*     */     }
/* 295 */     return QDRect.fromArray(arrayOfByte, 8);
/*     */   }
/*     */
/*     */   public boolean isOpen()
/*     */   {
/* 302 */     return gw != null;
/*     */   }
/*     */
/*     */   public void close()
/*     */     throws QDException
/*     */   {
/* 309 */     if (gw != null) {
/* 310 */       synchronized (QTNative.globalsLock) {
/* 311 */         if ((QTSession.isCurrentOS(1)) || (QTSession.isCurrentOS(4)))
/* 312 */           GetGWorld(savedPort, savedDevice);
/* 313 */         SetGWorld(QTObject.ID(gw), 0);
/* 314 */         ClosePicture();
/* 315 */         if ((QTSession.isCurrentOS(1)) || (QTSession.isCurrentOS(4)))
/* 316 */           SetGWorld(savedPort[0], savedDevice[0]);
/*     */       }
/*     */     }
/* 319 */     gw = null;
/*     */   }
/*     */
/*     */   public Pict compress(int paramInt1, int paramInt2)
/*     */     throws QTException
/*     */   {
/* 331 */     if (isOpen()) throw new QDException(-9);
/* 332 */     Pict localPict = new Pict(4, true);
/* 333 */     QDException.checkError(CompressPicture(_ID(), QTObject.ID(localPict), paramInt1, paramInt2));
/* 334 */     return localPict;
/*     */   }
/*     */
/*     */   public Pict fCompress(int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6)
/*     */     throws QTException
/*     */   {
/* 351 */     if (isOpen()) throw new QDException(-9);
/* 352 */     Pict localPict = new Pict(4, true);
/* 353 */     QDException.checkError(FCompressPicture(_ID(), QTObject.ID(localPict), (short)paramInt1, 0, paramInt2, (short)paramInt3, (short)paramInt4, 0, paramInt5, paramInt6));
/*     */
/* 356 */     return localPict;
/*     */   }
/*     */
/*     */   public void draw(QDGraphics paramQDGraphics, QDRect paramQDRect)
/*     */     throws QTException
/*     */   {
/* 366 */     if (isOpen())
/* 367 */       throw new QDException(-9);
/* 368 */     if (paramQDGraphics == null) {
/* 369 */       throw new StdQTException(-50);
/*     */     }
/* 371 */     synchronized (QTNative.globalsLock) {
/* 372 */       if ((QTSession.isCurrentOS(1)) || (QTSession.isCurrentOS(4)))
/* 373 */         GetGWorld(savedPort, savedDevice);
/* 374 */       SetGWorld(QTObject.ID(paramQDGraphics), 0);
/* 375 */       DrawPicture(_ID(), paramQDRect.getBytes());
/* 376 */       if ((QTSession.isCurrentOS(1)) || (QTSession.isCurrentOS(4)))
/* 377 */         SetGWorld(savedPort[0], savedDevice[0]);
/*     */     }
/* 379 */     QDException.checkError(QDError());
/*     */   }
/*     */
/*     */   public void drawTrimmed(QDGraphics paramQDGraphics, QDRect paramQDRect, Region paramRegion, int paramInt)
/*     */     throws QTException
/*     */   {
/* 392 */     if (isOpen())
/* 393 */       throw new QDException(-9);
/* 394 */     if (paramQDGraphics == null) {
/* 395 */       throw new StdQTException(-50);
/*     */     }
/* 397 */     int i = 0;
/* 398 */     synchronized (QTNative.globalsLock) {
/* 399 */       if ((QTSession.isCurrentOS(1)) || (QTSession.isCurrentOS(4)))
/* 400 */         GetGWorld(savedPort, savedDevice);
/* 401 */       SetGWorld(QTObject.ID(paramQDGraphics), 0);
/* 402 */       i = DrawTrimmedPicture(_ID(), paramQDRect.getBytes(), QTObject.ID(paramRegion), (short)paramInt, 0);
/* 403 */       if ((QTSession.isCurrentOS(1)) || (QTSession.isCurrentOS(4)))
/* 404 */         SetGWorld(savedPort[0], savedDevice[0]);
/*     */     }
/* 406 */     QDException.checkError(i);
/*     */   }
/*     */
/*     */   public Pict makeThumbnail(int paramInt)
/*     */     throws QTException
/*     */   {
/* 417 */     if (isOpen()) throw new QDException(-9);
/* 418 */     Pict localPict = new Pict(4, false);
/* 419 */     QDException.checkError(MakeThumbnailFromPicture(_ID(), (short)paramInt, QTObject.ID(localPict), 0));
/*     */
/* 422 */     return localPict;
/*     */   }
/*     */
/*     */   public RawEncodedImage toEncodedImage()
/*     */     throws QDException
/*     */   {
/* 430 */     if (isOpen()) throw new QDException(-9);
/* 431 */     return RawEncodedImage.fromQTHandle(this);
/*     */   }
/*     */
/*     */   public void writeToFile(File paramFile)
/*     */     throws QDException, IOException
/*     */   {
/* 439 */     if (isOpen()) throw new QDException(-9);
/* 440 */     FileOutputStream localFileOutputStream = new FileOutputStream(paramFile);
/* 441 */     localFileOutputStream.write(new byte[512]);
/* 442 */     byte[] arrayOfByte = getBytes();
/*     */
/* 444 */     localFileOutputStream.write(arrayOfByte, 0, arrayOfByte.length);
/* 445 */     localFileOutputStream.close();
/*     */   }
/*     */
/*     */   public String toString()
/*     */   {
/* 453 */     return super.toString() + "[pictFrame=" + getPictFrame() + ",isOpen=" + isOpen() + "]";
/*     */   }
/*     */
/*     */   protected void _dispose() {
/*     */     try {
/* 458 */       close();
/*     */     } catch (QDException localQDException) {
/* 460 */       QTRuntimeException.handleOrThrow(new QTRuntimeException(localQDException), this, "close");
/*     */     }
/*     */   }
/*     */
/*     */   private static native int GetGWorldPixMap(int paramInt);
/*     */
/*     */   private static native byte LockPixels(int paramInt);
/*     */
/*     */   private static native short MakeThumbnailFromPixMap(int paramInt1, byte[] paramArrayOfByte, short paramShort, int paramInt2, int paramInt3);
/*     */
/*     */   private static native void UnlockPixels(int paramInt);
/*     */
/*     */   private static native int GetTrackPict(int paramInt1, int paramInt2);
/*     */
/*     */   private static native short GetMoviesError();
/*     */
/*     */   private static native int GetMoviePict(int paramInt1, int paramInt2);
/*     */
/*     */   private static native int GetMoviePosterPict(int paramInt);
/*     */
/*     */   private static native int SGGrabPict(int paramInt1, int[] paramArrayOfInt, byte[] paramArrayOfByte, short paramShort, int paramInt2);
/*     */
/*     */   private static native int GraphicsImportGetAsPicture(int paramInt, int[] paramArrayOfInt);
/*     */
/*     */   private static native int SCCompressPicture(int paramInt1, int paramInt2, int paramInt3);
/*     */
/*     */   private static native int OpenCPicture(byte[] paramArrayOfByte);
/*     */
/*     */   private static native short QDError();
/*     */
/*     */   private static native void ClosePicture();
/*     */
/*     */   private static native short CompressPicture(int paramInt1, int paramInt2, int paramInt3, int paramInt4);
/*     */
/*     */   private static native short FCompressPicture(int paramInt1, int paramInt2, short paramShort1, int paramInt3, int paramInt4, short paramShort2, short paramShort3, int paramInt5, int paramInt6, int paramInt7);
/*     */
/*     */   private static native void DrawPicture(int paramInt, byte[] paramArrayOfByte);
/*     */
/*     */   private static native short DrawTrimmedPicture(int paramInt1, byte[] paramArrayOfByte, int paramInt2, short paramShort, int paramInt3);
/*     */
/*     */   private static native short MakeThumbnailFromPicture(int paramInt1, int paramInt2, int paramInt3, int paramInt4);
/*     */
/*     */   private static native int GraphicsExportGetInputPicture(int paramInt, int[] paramArrayOfInt);
/*     */
/*     */   private static native void SetGWorld(int paramInt1, int paramInt2);
/*     */
/*     */   private static native void GetGWorld(int[] paramArrayOfInt1, int[] paramArrayOfInt2);
/*     */
/*     */   private static native void setShortInArray(byte[] paramArrayOfByte, int paramInt, short paramShort);
/*     */
/*     */   private static native short getShortFromArray(byte[] paramArrayOfByte, int paramInt);
/*     */
/*     */   private static native short QTSPresGetPicture(int paramInt1, int paramInt2, int[] paramArrayOfInt);
/*     */ }

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

Related Classes of quicktime.qd.Pict

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.