Skip to Content
Swing Hacks
book

Swing Hacks

by Joshua Marinacci, Chris Adamson
June 2005
Intermediate to advanced
544 pages
22h 24m
English
O'Reilly Media, Inc.
Content preview from Swing Hacks
Handling Dropped Picts on Mac OS X #68
Chapter 9, Drag-and-Drop
|
349
HACK
Next is the QTJ stuff. It’s OK if you don’t totally understand it—QTJ code
is pretty twisted. That’s why there’s a whole book on it. First, you open a
QTSession
, which initializes QuickTime and allocates resources. You have to
do this before any QTJ call. It can throw a
QTException
, as can most other
QTJ calls, so the whole thing is wrapped in a
try
-
catch
block.
Next, you create a
Pict
object from the byte array and pass that to
DataRef
,
which is a sort of generic media reference. In this case, you pass in flags to tell
the
DataRef exactly what it’s pointing to. The second and third arguments
indicate that we’re using the old-style Mac OS file type and that its value is
PICT. You might be wondering why being a Pict object isn’t self-descriptive
enough. It’s because many QTJ objects are just pointers to blocks of memory
and the functions that work with them. The
DataRef signature used here
takes a
QTHandleRef as an argument. QTHandleRef is subclassed by Pict, but it
is little more than a pointer; the only level on which the
DataRef understands
the
Pict, in fact, is as a block of memory. My point here: QTJ code is weird
and often C-like.
Create a
GraphicsImporter for the Pict format, and point it to the DataRef.
You have now read the Pict “file” from memory. Now, you can get the size
of the imported image and create a
QTImageProducer, with ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Learning Swing GUI Programming

Learning Swing GUI Programming

Brian Cole
Java Swing

Java Swing

Robert Eckstein, Marc Loy, Dave Wood
JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second Edition

JFC Swing Tutorial, The: A Guide to Constructing GUIs, Second Edition

Kathy Walrath, Mary Campione, Alison Huml, Sharon Zakhour

Publisher Resources

ISBN: 0596009070Purchase bookErrata Page