• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa and PICT
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa and PICT


  • Subject: Re: Cocoa and PICT
  • From: glenn andreas <email@hidden>
  • Date: Fri, 10 Aug 2007 08:51:00 -0500


On Aug 10, 2007, at 12:41 AM, Uli Kusterer wrote:

On 09.08.2007, at 16:14, I. Savant wrote:
  So there's my problem: I need transparency *and* vector information
preserved and can see no way of doing so.

To do transparency, you can use QuickTime, I think. Create a GWorld, erase the whole image in it manually (including the alpha channel), then draw the PICT into it. Quickdraw will only touch the Alpha channel of pixels it actually modified, so if you then draw the PICT using Quickdraw, you'll get transparency. Then copy the raw pixels back out.

That's not exactly true - quickdraw does undefined things with the unused bytes (that happen to correspond to alpha information in a different rendering model). Sometimes it leaves it alone, sometimes it completely resets it to 0xff, depending on the operation, the cpu, phase of the moon, etc...

But I guess if you really want vector, you'd have to parse PICTs yourself. The format is mostly documented in the old Inside Macintosh volumes, and pretty well, too. Not sure some of the QuickTime extensions to it are, though.

All of the "common" extensions are documented in IM:Imaging with Quickdraw (only some app specific "meta storage" aren't).



Oh wait ... you want to generate PICTs, not read them? Well, should be a tad easier, as the format is documented. Just spit out the byte sequences equivalent to whatever shape you wanna draw. The only issue you'll have is simulating the Quartz commands in Quickdraw. It should be possible to map across almost everything, but may be some work. There's even support for smoothing polygons using picture comments, which might be handy for simulating bezier paths.

Quickdraw pic comment based smooth polygons are cubics, and bezier paths are quadratic curves, and converting from one to the other is non-trivial (for any sort of decent quality).


There are also pic comments for dashed lines and rotation. The main thing to remember about pic comments, however, is that they exist as a way for an application to communicate with the printer driver - they don't magically add new capabilities to the format or rendering engine as such. This is important because while Cocoa can easily display a PDF with all these features, and it can display a PICT file, it won't display these features on screen. Normally an app would send (effectively) two versions of the picture to the printer - one with this richer semantic version (say, a polygon with smooth poly pic comment), and another version (usually a lower resolution bitmap that has the rendered version). The printer driver then decides which to use based on its capabilities, either drawing a smoothed polygon using its own routines, or using the alternative representation.

The net result is that if the application that is to receive and parse this PICT file needs to understand these pic comments or it won't matter (since there's nothing in QD that magically translates these comments into anything else - they are just ignored and the alternate representation is displayed).

So the bottom line is that anything beyond simple lines, rects, ovals and arcs you're going to have to go through a lot of work to make a decent looking PICT for the various "nice looking" PDF/Quartz features, often resorting to, you guessed it, rendering a bitmap.

Though for gradient fills, you'll probably have to go and clip a bitmap, or a series of polygons, which may give some banding at high resolutions.

Note that QuickDraw only supports alpha transparency in bitmapped data. For vector information it's either 100% transparent vs. 100% opaque, or you can use a transfer mode like "blend" and opColor etc. to define what ends up transparent. May be able to fake it, but not sure it's worth the hassle.


Quickdraw doesn't have any sort of alpha transparency at all - it does support per component alpha masks on bitmap drawing (CopyDeepMask), but that's not exactly the same (see above comment about how QD treats the byte that one would expect to be used as alpha).


Quicktime (through the QT pict opcodes) can draw bitmap data that contains an alpha byte, but that gets problematic fast (due to other operations not preserving that alpha byte).

Glenn Andreas email@hidden
<http://www.gandreas.com/> wicked fun!
quadrium | flame : flame fractals & strange attractors : build, mutate, evolve, animate




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Cocoa and PICT
      • From: Alastair Houghton <email@hidden>
    • Re: Cocoa and PICT
      • From: "I. Savant" <email@hidden>
References: 
 >Cocoa and PICT (From: "I. Savant" <email@hidden>)
 >Re: Cocoa and PICT (From: Uli Kusterer <email@hidden>)

  • Prev by Date: Re: Cocoa and PICT
  • Next by Date: Watching folders for new files and event handling based on that?
  • Previous by thread: Re: Cocoa and PICT
  • Next by thread: Re: Cocoa and PICT
  • Index(es):
    • Date
    • Thread