Mailing Lists: Apple Mailing Lists

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

Re: NativeGraphics and ClassCastException



Running with a debugger shows it's getting the peer of the canvas and casting it to a sun.awt.DrawingSurface. That's an undocumented class, and I'm sure all this stuff changed dramatically between Carbon and Cocoa on the Mac, so you may be out of luck.

I would probably suggest going more of a "pure Java" way, create a BufferedImage and copy byte[]'s around. I haven't done that sort of thing myself but you ought to be able to get that to work without using any of the QuickTime-AWT integration stuff, which seems to be the cause of all these problems.

-Rolf

Dear list,

This is the smallest complete program I could come up with that exhibited the symptom. Does anybody else get a different result? Is there an obvious error?

import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Frame;

import quicktime.QTSession;
import quicktime.qd.NativeGraphics;
import quicktime.qd.QDGraphics;

/**
* @author (c) 2005 Stephyn G. W. Butcher - Jul 8, 2005
*/
public class CanvasTest {
    public static void main(String[] args) throws Exception {
        QTSession.open();
        Frame frame = new Frame( "Canvas Test");
        Canvas canvas = new Canvas();
        frame.add( canvas, BorderLayout.CENTER);
        frame.setSize( 350, 250);
        frame.show();
        NativeGraphics ng = NativeGraphics.getContext( canvas);
        QDGraphics gWorld = ng.getGWorld();
        QTSession.close();
    }
}

which results in:

Exception in thread "main" java.lang.ClassCastException
    at quicktime.qd.NativeGraphics.getContext(NativeGraphics.java:47)
    at quicktime.qd.NativeGraphics.getContext(NativeGraphics.java:31)
    at com.trantech.clearview.recorder.CanvasTest.main(CanvasTest.java:22)

It is not obvious from the javadoc that this should be the result.

Cheers,
Steve

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

This email sent to email@hidden


--
Rolf Howarth
Square Box Systems Ltd
Stratford-upon-Avon UK.
http://www.squarebox.co.uk
_______________________________________________
Do not post admin requests to the list. They will be ignored.
QuickTime-java mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quicktime-java/email@hidden

This email sent to email@hidden
References: 
 >Re: NativeGraphics and ClassCastException (From: "Steve Butcher (Steve-O)" <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.