I am writing a filter plug-in, which uses ADM for its UI. There appear to be a couple different ways to implement an image preview in the dialog. My question: What is the best way to implement an ADM preview, particularly where color-management is critical. Thanks.
ADM Color Managed Preview?
Hi Grit.
A brief overview of how to implement an image preview with ADM (at least, the way I do it). The documentation terminology for this is a ''preview proxy.''
- In your dialog resource, include an ''ADM User Type'' as a placeholder for your preview proxy.
- When you initialise the dialog, get the local rect for the proxy and set up a PSPixelMap with the memory required to hold the pixel data.
- The PSPixelMap holds info like the bounds rect for the proxy, the memory address of the pixel data, the image mode (RGB, Lab, etc.) of the data and the structure of your pixel data (i.e. rowBytes, colBytes and planeBytes, which describe how the pixel data is ordered in terms of rows, columns and colour channels).
- For the proxy dialog item, call sADMItem-%26gt;SetDrawProc to set the DrawProc callback for your proxy.
- In the callback, just use sPSUIHooks-%26gt;displayPixels to actually display whatever's in the PSPixelMap in your dialog window (use sADMDrawer-%26gt;GetPortRef to get the context for this call).
- To actually update your preview, just invalidate the proxy item (e.g. with sADMItem-%26gt;Invalidate or sADMItem-%26gt;Update or whatever).
Now, to load new PSPixelMap data to be displayed (e.g. when the user changes a parameter value in your UI), use the Channel Ports callbacks. (Channel Ports are *the* way to go for getting image data to and from Photoshop.)
- You will probably want to use sPSChannelPorts-%26gt;ReadScaledPixels to fill the PSPixelMap with image data from whatever colour channels you have set up.
- The data structures you'll need to do this are PSScaling (which determines how the image data is scaled, if you're working with scaled views) and PixelMemoryDesc, which tells Photoshop how you want your pixel data arranged. (e.g. You can alter the bit offset between successive calls to sPSChannelPorts-%26gt;ReadScaledPixels in order to read all your colour channels into the one buffer in the correctly interleaved manner.)
- Also, depending on what colour spaces and image depths you're using and allowing, you may need to use sPSColorSpace functions to convert between colour spaces and bit depths.
Well, that was pretty dense. Hope you figure it out OK.
-- Matthew
Subscribe to:
Post Comments
(Atom)
No comments:
Post a Comment