|
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Thank you, it works!Dmitry Markman
Now i only have to make sure the inputstream that i
got from the transferable is a pict format that
Quicktime understands. How can i ensure the
inputstream (image/x-pict) be a quicktime pict format.
--- Dmitry Markman <email@hidden> wrote:1. if you don't need java.awt.ImageSystem.arraycopy(pictbytes,0,newpictbytes,512,pictbytes.length);
converting code is fairly simple (with QTJava) THANK
YOU APPLE.
public static void saveAsJPEG(File inFile,File
outFile){
try{
Pict pict = Pict.fromFile(inFile);
GraphicsExporter gex = new
GraphicsExporter(QTUtils.toOSType("JPEG"));
gex.setInputPicture(pict);
QTFile qtf = new QTFile(outFile);
gex.setOutputFile(qtf);
gex.doExport();
}catch(Throwable t){}
}
so just call
saveAsJPEG(new File("test.pict"),new
File("test.jpg"));
2.if you do need java image do the following
try{
Pict pict = Pict.fromFile(new
File("test.pict"));
byte []pictbytes = pict.getBytes();
//check here 512 length 0 header
//if you have that header do nothing
//if you don't have that header you must add it:
byte []newpictbytes = new
byte[512+pictbytes.length];
QTHandle qt = newgc.createCompatibleImage(qdRect.getWidth(),qdRect.getHeight());
QTHandle(newpictbytes);
GraphicsImporter gc = new
GraphicsImporter(QTUtils.toOSType("PICT"));
gc.setDataHandle(qt);
QDRect qdRect = gc.getNaturalBounds();
GraphicsImporterDrawer myDrawer = new
quicktime.app.view.GraphicsImporterDrawer(gc);
QTImageProducer qtProducer = new
QTImageProducer (myDrawer,
new
Dimension(qdRect.getWidth(),qdRect.getHeight()));
Image img =
Toolkit.getDefaultToolkit().createImage(qtProducer);
//YOU'RE ALL SET
}catch(Throwable t){
System.out.println("Picture Exception "+t);
}
On Mar 18, 2004, at 3:20 PM, x l wrote:
here is the attached file:the
thx
--- Dmitry Markman <email@hidden> wrote:send me that file, if you want
and I'll take a look
On Mar 18, 2004, at 1:05 PM, x l wrote:
thank you again for your quick reply. i triedfromcode, i have problem reading my pict file. thispictfile is written when i drag and drop the fileiNetscape to my app, i was able to open the fileusingPreview and Quicktime Player. However, when ireadthe file using Pict.fromFile(), i can't see the
Dimension from qdRect, they are 0 x 0. How can
newensure the pict file in proper format?work
Thanks again.
Margaret Fung
--- Dmitry Markman <email@hidden> wrote:
Margaret, you don't have to look for 1.3.1 tomyDrawer =with qtjava
qtjava 6.1 works happily with 1.4.X (QT >= 6.4)
that code will work with 1.4.X
Pict p = ....
QTHandle qt = new QTHandle(p. getBytes());
GraphicsImporter gc = new
GraphicsImporter(QTUtils.toOSType("PICT"));
gc.setDataHandle(qtHandle);
QDRect qdRect = gc.getNaturalBounds();
quicktime.app.view.GraphicsImporterDrawer
newnew
quicktime.app.view.GraphicsImporterDrawer (gc);
quicktime.app.view.QTImageProducer qtProducer =
quicktime.app.view.QTImageProducer (myDrawer,Dimension(qdRect.getWidth(),qdRect.getHeight()));
Toolkit.getDefaultToolkit().createImage(qtProducer);
//YOU CAN USE EXPORTER IF YOU WISH
Image javaImage =
GraphicsEnvironment.getLocalGraphicsEnvironment();
//create BufferedImage here
GraphicsEnvironment ge =
GraphicsDevice gd =
ge.getDefaultScreenDevice();
GraphicsConfiguration gc =
gd.getDefaultConfiguration();
BufferedImage retValue = null;
BufferedImage bim =
=== message truncated ===javax.imageio.ImageIO.write(bim,"png",fos);//check
try{
Graphics g2d = bim.createGraphics()
g2d.drawImage(javaImage,null,0,0);
g2d.dispose();
java.io.FileOutputStream fos = new
java.io.FileOutputStream(<yourname here>);
notout that command
you can convert it to jpeg/tiff for sure I'm
javax.imageio.ImageIO.getReaderFormatNames()sure about gif
/*
possible values are
jpeg
tiff
gif
png
JPG
jpg
JPEG
usefindtofind out what types
javax.imageio.ImageIO.write does support
*/
fos.close();
}catch(Throwable t){
System.out.println("TEST THROWABLE "+t);
}
On Mar 13, 2004, at 12:13 PM, x l wrote:
Thanks for the reply.
My Mac OS has 1.4.2 installed. Where can iwouldapplicationthejdk 1.3.1? so that i can run the QTJavacorrectly? Itried on apple site, and no luck. Myneeds to run on both window and mac. so iWhereliketo use QTJava.
Thanks
Margaret
Thanks for the reply.
My application needs to do multi-platform.--- Dmitry Markman <email@hidden> wrote:well, Margaret
__________________________________
Do you Yahoo!?
Yahoo! Mail - More reliable, more storage, less spam
http://mail.yahoo.com
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.
| References: | |
| >Re: How to convert pict file into jpg/gif? (From: x l <email@hidden>) |
| Home | Archives | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2011 Apple Inc. All rights reserved.