Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

BufferedImage and QTJava



I'm not sure whether QTJava questions are best asked here or on Java- dev, but here goes...

I'm trying to update some code which used QTImageProducer to produce a Java Image, but this no longer works now that the quicktime.app package has been deprecated. I'm fairly stumped trying to come up with a replacement. I want to produce a BufferedImage from a GraphicsImporter (and when I've done that, I'll want to go the other way). So far, the only thing I've come up with after a whole load of head-scratching is this:

GraphicsImporter graphicsImporter = new GraphicsImporter (qtFile);
QDRect bounds = graphicsImporter.getNaturalBounds();
int w = bounds.getWidth(), h = bounds.getHeight();
QDGraphics gWorld = new QDGraphics( bounds );
graphicsImporter.setGWorld( gWorld, null );
graphicsImporter.draw();


int rowBytes = gWorld.getPixMap().getPixelData ().getRowBytes();
int[] pixels = new int[ w*h ];
RawEncodedImage rei = gWorld.getPixMap().getPixelData();
for ( int y = 0; y < h; y++ )
rei.copyToArray( y*rowBytes, pixels, y*w, w);


ImageProducer producer = new MemoryImageSource( w, h, pixels, 0, w );

(I know I can produce a BufferedImage directly from the pixels, but the API I'm using requires an ImageProducer)

This solution seems to work but seems very fragile and I don't know what will happen if an importer produces a non-ARGB pixel format.

All the QTJava sample code is biased towards reading and displaying images entirely in QTJava - there seems to be nothing for interoperating with the rest of Java. The documentation states that the old API is deprecated because you can do everything using other parts of Java, presumably JMF, but JMF doesn't deal with static images and ImageIO only reads and writes 2 or 3 file formats. What's the correct way to read and write Java images in the new world of QTJava?

Jerry

_______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-API mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quicktime-api/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.