Disabled external gits

This commit is contained in:
2022-04-07 18:46:57 +02:00
parent 88cb3426ad
commit 15e7120d6d
5316 changed files with 4563444 additions and 6 deletions

View File

@ -0,0 +1,2 @@
.DS_Store
CVS

View File

@ -0,0 +1,90 @@
############################################################################
Building the OpenEXR Photoshop plug-in
By Paul Schneider (pauls@ilm.com) 5-15-03
############################################################################
The Macintosh build requires Metrowerks CodeWarrior 8.3 (or higher).
The Windows build requires Microsoft Visual C++ 6.0 (or higher).
1) install the Photoshop SDK
These projects expect that you have checked the "Photoshop"
module out to the same root directory that contains the other
OpenEXR modules, and that you have added a directory called
"sdk" to the Photoshop module that contains the Adobe Photoshop
SDK. Your source tree should look like this:
|- MacCodeWarrior
|- OpenEXR
|- Photoshop
|- doc
|- mac
|- rsrc
|- sdk
| |- PhotoshopAPI
| |- PhotoshopUtils
| |- resources
|- src
|- win32
|- zlib
Note that this distribution does not include the Photoshop SDK because of
licensing issues. You must be a registered Adobe developer to obtain this
SDK. Visit www.adobe.com to learn more.
The "Photoshop/sdk/resources" folder can be found here:
{Photoshop SDK}/samplecode/resources
This contains the tools necessary to create the PiPL resources on the Windows platform.
If you're unfamiliar with PiPLs, there is some excellent documentation available
in the Photoshop SDK.
Note that if you're only interested in building the Windows version of this plug-in,
you don't need to check out the "MacCodeWarrior" module from the OpenEXR repository.
If you plan to make changes for submission to CVS, though, please make sure they
work correctly on both platforms.
2) build zlib
Both the Mac and Windows builds require a static library, "zlib.lib", to be built.
The Macintosh project will look for the library in "MacCodeWarrior/zlib-1.1.3",
while the Windows project will look for the library in "zlib".
Zlib source is not included with this distribution because of licensing issues.
The source is available for download at www.gzip.org/zlib/ and is very easy to
build on any platform.
3) build the plug-ins
Macintosh:
- open the project file "Photoshop/mac/EXRFormat.mcp" in CodeWarrior.
- build the target "Plugin".
This will build both Carbon and Classic versions of the plug-in in the
package "Photoshop/mac/EXRFormat". It will also turn this folder into
a package, but you may have to log out and log back in to see this change
in the Finder.
Windows:
- open the project file "Photoshop/win32/EXRFormat.dsw" in VC++.
- you will be asked to locate the file "SimpleFormat.dsp". Choose
"Photoshop/win32/EXRFormat.dsp". If you know how to stop VC++ from
asking for this file, please let me know.\
- build the target "Win32 - Release".
This will create the plug-in "Photoshop/win32/Release/EXRFormat.8bi"
4) install the plug-in:
Copy the built plug-in to the "Plug-Ins" folder located in the directory
where Photoshop lives.
5) Enjoy!

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

View File

@ -0,0 +1,180 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.78 [en] (X11; U; Linux 2.4.18-19.7.x+obaq i686) [Netscape]">
<meta name="Author" content="Paul Schneider">
<meta name="Description" content="Describes how to use the OpenEXR file format plug-in for Photoshop
">
<title>OpenEXR for Adobe Photoshop</title>
</head>
<body>
<h1>
OpenEXR for Adobe Photoshop</h1>
This document describes how to use the "EXRFormat" plug-in to read and
write OpenEXR images using Adobe Photoshop.&nbsp; For more information
about the OpenEXR format, please visit <a href="http://www.openexr.com">www.openexr.com</a>.
<br>&nbsp;
<h2>
Supported Operating Systems</h2>
This plug-in has only been tested on MacOS 9.2.2, Mac OS X 10.2.4, and
Windows 2000.&nbsp; It should work on MacOS 8.1 and higher, and Windows
98 and higher, but this has not been verified.
<br>&nbsp;
<h2>
Supported Host Applications</h2>
This plug-in has only been tested with Adobe Photoshop 7.0.&nbsp; It should
work with Photoshop 5.5 and higher, but this has not been verified.&nbsp;
This plug-in will not work with versions of Photoshop earlier than 5.5.
<p>This plug-in will not work correctly with other applications which support
some Photoshop file format plug-ins, such as combustion from Discreet,
or Commotion from Pinnacle Systems.
<p>This plug-in will also not work correctly with Adobe After Effects.&nbsp;
An After Effects-specific plug-in may be included in a future release of
OpenEXR.
<br>&nbsp;
<h2>
Installation</h2>
To install the plug-in, copy it to your Photoshop plug-ins folder.&nbsp;
If Photoshop is running, you will have to quit it and launch it again.&nbsp;
Here is a typical Macintosh installation:
<p><img SRC="images/Picture00.jpg" NOSAVE height=717 width=453>
<p>You could also place the EXRFormat plug-in in the "File Formats" folder,
or in any folder inside the "Plug-Ins" folder.
<br>&nbsp;
<br>&nbsp;
<h2>
Opening an OpenEXR image</h2>
Once you have installed the plug-in, you will be able to open images in
the OpenEXR format.&nbsp; Select "Open..." from Photoshop's File menu:
<p><img SRC="images/Picture01.jpg" NOSAVE height=100 width=212>
<p>and navigate to a folder containing OpenEXR images.&nbsp; This example
uses the images distributed with the OpenEXR source code release.
<p><img SRC="images/Picture02.jpg" NOSAVE height=434 width=561>
<p>Note that when you select an OpenEXR image, the "Format:" menu in the
Open dialog reads "OpenEXR".&nbsp; This lets you know that the plug-in
is installed correctly, and that Photoshop has detected that the file is
in the OpenEXR format.
<p>When you click Open in the Open dialog, you will see a new dialog which
allows you to specify how the image is interpreted in Photoshop.
<p><img SRC="images/Picture03.jpg" NOSAVE height=323 width=494>
<p>This dialog is necessary because an OpenEXR image can contain many more
colors than you can work with in Photoshop, even in Photoshop's "16 Bits/Channel"
mode.&nbsp; OpenEXR uses floating-point (real number) pixels, and supports
a high dynamic range of pixel values - that is, colors which are brighter
than white.&nbsp; Photoshop uses integer (whole number) pixels, and does
not support colors brighter than white.&nbsp; Because of this, not all
of the pixels in the OpenEXR image will be preserved when the image is
loaded into Photoshop.&nbsp; This dialog lets you control which pixels
are preserved, so that you can work with the image in Photoshop with a
minimal loss of quality.
<p>Here is a quick explanation of what these controls do:
<ul>
<li>
Exposure: this controls the apparent exposure of the image.&nbsp; An exposure
of 0 (the default) will apply no change to the image.&nbsp; An exposure
of 1 will make the image twice as bright, revealing more detail in the
low end.&nbsp; An exposure of -1 will make the image twice as dark, revealing
highlights that may have been clipped at higher exposures.</li>
<li>
Gamma: this controls the gamma correction that is applied to the image.&nbsp;
Most images, such as JPEGs or TIFFs, are stored with an implicit gamma
encoding of 2.2, the standard for video images.&nbsp; OpenEXR images are
stored with no gamma correction.&nbsp; By default, the EXRFormat plug-in
applies a gamma correction of 2.2 to the image as it is read into Photoshop,
so that it will match the color space of other images, and display correctly
on a computer monitor.&nbsp; If you do not need to color-match the EXR
image with an image in another, gamma-corrected format, you might find
other gamma values more visually appealing.&nbsp; For example, most Macintosh
monitors have a display gamma of 1.8, not 2.2.&nbsp; (Microsoft Windows
computers generally have a display gamma of 2.2).</li>
<li>
Un-Premultiply: by convention, OpenEXR images are "premultiplied" - the
color channel values are already matted against black using the alpha channel.&nbsp;
In Photoshop, it's more convenient to work with unmatted images.&nbsp;
It's important to use this option rather than un-premultiplying the image
within Photoshop, because the plug-in will un-premultiply before applying
exposure and gamma correction.&nbsp; This option will have no affect if
your image does not contain an alpha channel.</li>
</ul>
The dialog also contains a preview area, which lets you see the effect
your settings will have on the image.&nbsp; Click in the black area of
the dialog to load the preview:
<p><img SRC="images/Picture04.jpg" NOSAVE height=324 width=494>
<p>In this preview, we can see that this image has a fairly broad dynamic
range.&nbsp; Much of the image is too dark to see clearly, but the lamps
are so bright that they have been clipped at the default settings.&nbsp;
If we darken our exposure, however, we can see that the image does contain
data for those bright areas.&nbsp; Setting the exposure to -2 makes the
image four times darker - the pixels that now appear white are actually
four times brighter than "white".
<p><img SRC="images/Picture05.jpg" NOSAVE height=324 width=494>
<p>We could reduce the exposure even further, and reveal more detail in
the highlights, but we would start to lose detail in the dark areas.&nbsp;&nbsp;
If we click "OK" at this point, the image will be opened in Photoshop at
an exposure of -2, and will appear very dark (as we saw in the preview):
<p><img SRC="images/Picture06.jpg" NOSAVE height=461 width=636>
<p>It appears that we have lost a large amount of detail in the image,
but there is actually much more detail here than can be displayed on your
computer screen.&nbsp; Checking the "Image->Mode" menu in Photoshop reveals
that this image is 16 bits per channel, and a computer monitor can only
display 8 bits of information per channel.
<p><img SRC="images/Picture07.jpg" NOSAVE height=315 width=337>
<p>To see the hidden detail, we can use the preview feature of Photoshop's
Levels command:
<p><img SRC="images/Picture08.jpg" NOSAVE height=99 width=367>
<p>This will create a dialog that will show us the histogram of the image.&nbsp;
Note that there is a large gap between the brightest pixels (the blown-out
highlights) and the majority of the colors in the image.
<p><img SRC="images/Picture09.jpg" NOSAVE height=465 width=926>
<p>If we adjust the white point so that the majority of the pixels define
the full range of the image, the highlights will be blown out, but more
low-end detail will be revealed.
<p><img SRC="images/Picture10.jpg" NOSAVE height=467 width=926>
<p>Note that if you click OK in the Levels dialog, the range adjustment
will be applied to the actual image, and all of the overrange pixel values
will be clipped to white.&nbsp; When working with OpenEXR image in Photoshop,
It's important to be careful that the details you care about are preserved.
<p>Also, note that when working on a 16 bit image in Photoshop, many features
such as painting and layers are unavailable.&nbsp; If you wish to use these
tools, you must convert the image to 8 bits per channel using the "Image->Mode"
menu, which will result in an even greater loss of data.&nbsp; Cautious
use of the exposure and gamma controls in the EXR Import dialog, along
with applying the Levels command before converting to 8 bits, will help
you use all of Photoshop's powerful tools while preserving the colors that
are most important in your image.&nbsp; Of course, some images will simply
contain too much data to be manipulated safely in Photoshop - it's up to
you to ensure that the image you end up with is correct and visually appealing.
<br>&nbsp;
<h2>
Saving an OpenEXR image</h2>
Saving an OpenEXR image is similar to opening one.&nbsp; When you choose
to save an image in OpenEXR format, a dialog will appear, allowing you
to specify how the image should be saved.&nbsp; Many of these settings
are similar to the controls provided by the Import dialog.
<p><img SRC="images/Picture11.jpg" NOSAVE height=301 width=363>
<p>Note that the Exposure and Gamma settings mean something different in
this dialog - they specify the settings that currently apply to the image.&nbsp;
For example, when the image opened in the previous example is saved, this
dialog states that the image has been gamma corrected and darkened.&nbsp;
The plug-in will undo both of these settings before saving the OpenEXR
file.&nbsp; This means that if you use the same settings when you save
an OpenEXR image as when you opened it, the color space of the image will
stay the same.&nbsp; However, any colors which were lost when the image
was opened (clipped highlights or crushed low-end values) will not be restored.&nbsp;
If you are saving a new image, or an image originally in another format,
as an OpenEXR image, the default settings will result in a valid image.
<p>This dialog also allows you to specify the compression scheme used to
save the OpenEXR image.&nbsp; The OpenEXR format supports several methods
of compression, all of them lossless.&nbsp; For details about which method
best suits your needs, see <a href="http://www.openexr.com">www.openexr.com.</a>
<p><img SRC="images/Picture12.jpg" NOSAVE height=302 width=362>
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
</body>
</html>

View File

@ -0,0 +1 @@
// ===========================================================================

View File

@ -0,0 +1 @@
// ===========================================================================

View File

@ -0,0 +1 @@
// ===========================================================================

View File

@ -0,0 +1 @@
// ===========================================================================

View File

@ -0,0 +1,105 @@
// ===========================================================================
// ExrFormat.r Part of OpenEXR
// ===========================================================================
#include "PIGeneral.r"
//-------------------------------------------------------------------------------
// PiPL resource
//-------------------------------------------------------------------------------
resource 'PiPL' (16000, "OpenEXR PiPL", purgeable)
{
{
Kind { ImageFormat },
Name { "OpenEXR" },
Version { (latestFormatVersion << 16) | latestFormatSubVersion },
#if MSWindows
CodeWin32X86 { "PluginMain" },
#elif TARGET_API_MAC_CARBON
CodeCarbonPowerPC { 0, 0, "" },
#else
CodePowerPC { 0, 0, "" },
#endif
FmtFileType { 'EXR ', '8BIM' },
ReadTypes { { 'EXR ', ' ' } },
FilteredTypes { { 'EXR ', ' ' } },
ReadExtensions { { 'exr ' } },
WriteExtensions { { 'exr ' } },
FilteredExtensions { { 'exr ' } },
FormatMaxSize { { 32767, 32767 } },
// this is to make us available when saving a 16-bit image
EnableInfo
{
"in (PSHOP_ImageMode, RGBMode, RGB48Mode)"
},
// this is apparently just for backwards compatability
SupportedModes
{
noBitmap,
noGrayScale,
noIndexedColor,
doesSupportRGBColor, // yes
noCMYKColor,
noHSLColor,
noHSBColor,
noMultichannel,
noDuotone,
noLABColor
#if !MSWindows
,
noGray16,
doesSupportRGB48, // yes
noLab48,
noCMYK64,
noDeepMultichannel,
noDuotone16
#endif
},
FormatFlags
{
fmtDoesNotSaveImageResources,
fmtCanRead,
fmtCanWrite,
fmtCanWriteIfRead,
fmtCannotWriteTransparency
#if MSWindows
,
fmtCannotCreateThumbnail
#endif
},
FormatMaxChannels
{
{
1,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4,
4
}
}
}
};

View File

@ -0,0 +1,46 @@
// ===========================================================================
// PSAutoBuffer.cp Part of OpenEXR
// ===========================================================================
//
#if MSWindows
#pragma warning (disable: 161)
#endif
#include "PSAutoBuffer.h"
#include <new>
PSAutoBuffer::PSAutoBuffer
(
int32 inSize,
BufferProcs* inProcs
)
{
OSErr err;
mBufferID = 0;
mProcs = inProcs;
err = mProcs->allocateProc (inSize, &mBufferID);
if (err != noErr)
{
throw std::bad_alloc();
}
}
PSAutoBuffer::~PSAutoBuffer ()
{
if (mBufferID != 0)
{
mProcs->freeProc (mBufferID);
mBufferID = 0;
}
}
Ptr PSAutoBuffer::Lock ()
{
return mProcs->lockProc (mBufferID, false);
}

View File

@ -0,0 +1,27 @@
// ===========================================================================
// PSAutoBuffer.h Part of OpenEXR
// ===========================================================================
//
#pragma once
#include "PIGeneral.h"
class PSAutoBuffer
{
public:
PSAutoBuffer (int32 inSize,
BufferProcs* inProcs);
~PSAutoBuffer ();
Ptr Lock ();
protected:
BufferProcs* mProcs;
BufferID mBufferID;
};

View File

@ -0,0 +1,42 @@
// ===========================================================================
// PSAutoBuffer.cp Part of OpenEXR
// ===========================================================================
//
#include "PSAutoBuffer.h"
#include <new>
PSAutoBuffer::PSAutoBuffer
(
int32 inSize,
BufferProcs* inProcs
)
{
OSErr err;
mBufferID = 0;
mProcs = inProcs;
err = mProcs->allocateProc (inSize, &mBufferID);
if (err != noErr)
{
throw std::bad_alloc();
}
}
PSAutoBuffer::~PSAutoBuffer ()
{
if (mBufferID != 0)
{
mProcs->freeProc (mBufferID);
mBufferID = 0;
}
}
Ptr PSAutoBuffer::Lock ()
{
return mProcs->lockProc (mBufferID, false);
}

View File

@ -0,0 +1,27 @@
// ===========================================================================
// PSAutoBuffer.h Part of OpenEXR
// ===========================================================================
//
#pragma once
#include "PIGeneral.h"
class PSAutoBuffer
{
public:
PSAutoBuffer (int32 inSize,
BufferProcs* inProcs);
~PSAutoBuffer ();
Ptr Lock ();
protected:
BufferProcs* mProcs;
BufferID mBufferID;
};

View File

@ -0,0 +1,28 @@
// ===========================================================================
// PSFormatGlobals.h Part of OpenEXR
// ===========================================================================
#pragma once
//-------------------------------------------------------------------------------
// Forward Declarations
//-------------------------------------------------------------------------------
struct FormatRecord;
//-------------------------------------------------------------------------------
// Globals struct
//-------------------------------------------------------------------------------
//
// you may subclass this struct for your own globals, but don't add a vtable!
// (no virtual methods, please) If you do add fields, you will have to override
// GlobalsSize() and InitGlobals() to account for your additional fields.
//
struct PSFormatGlobals
{
};

View File

@ -0,0 +1,413 @@
// ===========================================================================
// PSFormatPlugin.cp Part of OpenEXR
// ===========================================================================
#if MSWindows
#pragma warning (disable: 161)
#endif
#include "PSFormatPlugin.h"
#include "PIFormat.h"
#include <string.h>
//-------------------------------------------------------------------------------
// PSFormatPlugin
//-------------------------------------------------------------------------------
PSFormatPlugin::PSFormatPlugin ()
{
mGlobals = NULL;
mFormatRec = NULL;
mResult = NULL;
}
//-------------------------------------------------------------------------------
// ~PSFormatPlugin
//-------------------------------------------------------------------------------
PSFormatPlugin::~PSFormatPlugin ()
{
}
#pragma mark-
//-------------------------------------------------------------------------------
// Run
//-------------------------------------------------------------------------------
void PSFormatPlugin::Run
(
short inSelector,
FormatRecord* inFormatRecord,
long* inData,
short* outResult
)
{
// plug-in's main routine
// does the work of setting up the globals, and then
// calls the appropriate override hook
if (inSelector == formatSelectorAbout)
{
// format record isn't valid, so can't set up globals
// just show about box
DoAbout ((AboutRecord*) inFormatRecord);
}
else
{
// set up globals
mResult = outResult;
mFormatRec = inFormatRecord;
AllocateGlobals (inFormatRecord, inData, outResult);
if (mGlobals == NULL)
{
*outResult = memFullErr;
return;
}
// handle selector through override hooks
switch (inSelector)
{
case formatSelectorFilterFile: DoFilterFile(); break;
case formatSelectorReadPrepare: DoReadPrepare(); break;
case formatSelectorReadStart: DoReadStart(); break;
case formatSelectorReadContinue: DoReadContinue(); break;
case formatSelectorReadFinish: DoReadFinish(); break;
case formatSelectorOptionsPrepare: DoOptionsPrepare(); break;
case formatSelectorOptionsStart: DoOptionsStart(); break;
case formatSelectorOptionsContinue: DoOptionsContinue(); break;
case formatSelectorOptionsFinish: DoOptionsFinish(); break;
case formatSelectorEstimatePrepare: DoEstimatePrepare(); break;
case formatSelectorEstimateStart: DoEstimateStart(); break;
case formatSelectorEstimateContinue: DoEstimateContinue(); break;
case formatSelectorEstimateFinish: DoEstimateFinish(); break;
case formatSelectorWritePrepare: DoWritePrepare(); break;
case formatSelectorWriteStart: DoWriteStart(); break;
case formatSelectorWriteContinue: DoWriteContinue(); break;
case formatSelectorWriteFinish: DoWriteFinish(); break;
default: *mResult = formatBadParameters; break;
}
// unlock the handle containing our globals
if ((Handle)*inData != NULL)
inFormatRecord->handleProcs->unlockProc ((Handle)*inData);
}
}
#pragma mark-
//-------------------------------------------------------------------------------
// AllocateGlobals
//-------------------------------------------------------------------------------
//
void PSFormatPlugin::AllocateGlobals
(
FormatRecord* inFormatRecord,
long* inData,
short* outResult
)
{
// make sure globals are ready to go
// allocate them if necessary, set pointer correctly if not needed
// based heavily on AllocateGlobals() in PIUtilities.c, but modified
// to allow subclasses to easily extend the Globals struct
mGlobals = NULL;
if (!*inData)
{
// Data is empty, so initialize our globals
// Create a chunk of memory to put our globals.
// Have to call HostNewHandle directly, since gStuff (in
// the PINewHandle macro) hasn't been defined yet
// use override hook to get size of globals struct
Handle h = inFormatRecord->handleProcs->newProc (GlobalsSize());
if (h != NULL)
{
// We created a valid handle. Use it.
// lock the handle and move it high
// (we'll unlock it after we're done):
mGlobals = (PSFormatGlobals*) inFormatRecord->handleProcs->lockProc (h, TRUE);
if (mGlobals != NULL)
{
// was able to create global pointer.
// if we have revert info, copy it into the globals
// otherwise, just init them
if (inFormatRecord->revertInfo != NULL)
{
char* ptr = inFormatRecord->handleProcs->lockProc (inFormatRecord->revertInfo, false);
memcpy (mGlobals, ptr, GlobalsSize());
inFormatRecord->handleProcs->unlockProc (inFormatRecord->revertInfo);
}
else
{
InitGlobals ();
}
// store the handle in the passed in long *data:
*inData = (long)h;
h = NULL; // clear the handle, just in case
}
else
{
// There was an error creating the pointer. Back out
// of all of this.
inFormatRecord->handleProcs->disposeProc (h);
h = NULL; // just in case
}
}
}
else
{
// we've already got a valid structure pointed to by *data
// lock it, cast the returned pointer to a global pointer
// and point globals at it:
mGlobals = (PSFormatGlobals*) inFormatRecord->handleProcs->lockProc ((Handle)*inData, TRUE);
}
}
//-------------------------------------------------------------------------------
// GlobalsSize
//-------------------------------------------------------------------------------
int PSFormatPlugin::GlobalsSize ()
{
// override if your subclass adds fields to the Globals struct
// the first two fields must always be:
// short* result;
// FormatRecord* formatParamBlock;
return sizeof (PSFormatGlobals);
}
//-------------------------------------------------------------------------------
// InitGlobals
//-------------------------------------------------------------------------------
void PSFormatPlugin::InitGlobals ()
{
// override hook - PSFormatGlobals are set up in AllocateGlobals()
}
#pragma mark-
//-------------------------------------------------------------------------------
// DoAbout
//-------------------------------------------------------------------------------
void PSFormatPlugin::DoAbout (AboutRecord* inAboutRec)
{
// override hook
}
#pragma mark-
//-------------------------------------------------------------------------------
// DoReadPrepare
//-------------------------------------------------------------------------------
void PSFormatPlugin::DoReadPrepare ()
{
// override hook
}
//-------------------------------------------------------------------------------
// DoReadStart
//-------------------------------------------------------------------------------
void PSFormatPlugin::DoReadStart ()
{
// override hook
}
//-------------------------------------------------------------------------------
// DoReadContinue
//-------------------------------------------------------------------------------
void PSFormatPlugin::DoReadContinue ()
{
// override hook
}
//-------------------------------------------------------------------------------
// DoReadFinish
//-------------------------------------------------------------------------------
void PSFormatPlugin::DoReadFinish ()
{
// override hook
}
#pragma mark-
//-------------------------------------------------------------------------------
// DoOptionsPrepare
//-------------------------------------------------------------------------------
void PSFormatPlugin::DoOptionsPrepare ()
{
// override hook
}
//-------------------------------------------------------------------------------
// DoOptionsStart
//-------------------------------------------------------------------------------
void PSFormatPlugin::DoOptionsStart ()
{
// override hook
}
//-------------------------------------------------------------------------------
// DoOptionsContinue
//-------------------------------------------------------------------------------
void PSFormatPlugin::DoOptionsContinue ()
{
// override hook
}
//-------------------------------------------------------------------------------
// DoOptionsFinish
//-------------------------------------------------------------------------------
void PSFormatPlugin::DoOptionsFinish ()
{
// override hook
}
#pragma mark-
//-------------------------------------------------------------------------------
// DoEstimatePrepare
//-------------------------------------------------------------------------------
void PSFormatPlugin::DoEstimatePrepare ()
{
// override hook
}
//-------------------------------------------------------------------------------
// DoEstimateStart
//-------------------------------------------------------------------------------
void PSFormatPlugin::DoEstimateStart ()
{
// override hook
}
//-------------------------------------------------------------------------------
// DoEstimateContinue
//-------------------------------------------------------------------------------
void PSFormatPlugin::DoEstimateContinue ()
{
// override hook
}
//-------------------------------------------------------------------------------
// DoEstimateFinish
//-------------------------------------------------------------------------------
void PSFormatPlugin::DoEstimateFinish ()
{
// override hook
}
#pragma mark-
//-------------------------------------------------------------------------------
// DoWritePrepare
//-------------------------------------------------------------------------------
void PSFormatPlugin::DoWritePrepare ()
{
// override hook
}
//-------------------------------------------------------------------------------
// DoWriteStart
//-------------------------------------------------------------------------------
void PSFormatPlugin::DoWriteStart ()
{
// override hook
}
//-------------------------------------------------------------------------------
// DoWriteContinue
//-------------------------------------------------------------------------------
void PSFormatPlugin::DoWriteContinue ()
{
// override hook
}
//-------------------------------------------------------------------------------
// DoWriteFinish
//-------------------------------------------------------------------------------
void PSFormatPlugin::DoWriteFinish ()
{
// override hook
}
#pragma mark-
//-------------------------------------------------------------------------------
// DoFilterFile
//-------------------------------------------------------------------------------
void PSFormatPlugin::DoFilterFile ()
{
// override hook
}

View File

@ -0,0 +1,97 @@
// ===========================================================================
// PSFormatPlugin.h Part of OpenEXR
// ===========================================================================
#pragma once
#include "PSFormatGlobals.h"
#include "PIAbout.h"
//-------------------------------------------------------------------------------
// PSFormatPlugin
//-------------------------------------------------------------------------------
//
// Base class for a Photoshop File Format plugin.
//
class PSFormatPlugin
{
public:
//-------------------------------------------------------------------
// Constructor / Destructor
//-------------------------------------------------------------------
PSFormatPlugin ();
virtual ~PSFormatPlugin ();
//-------------------------------------------------------------------
// Run - main function called from plug-ins main entry point
//-------------------------------------------------------------------
void Run (short inSelector,
FormatRecord* inFormatRecord,
long* inData,
short* outResult);
protected:
//-------------------------------------------------------------------
// Convenience routines for making globals as painless
// as possible (not very painless, though)
//-------------------------------------------------------------------
void AllocateGlobals (FormatRecord* inFormatRecord,
long* inData,
short* outResult);
//-------------------------------------------------------------------
// Override hooks - subclasses should override as many of these
// as they need to, and disregard the rest
//-------------------------------------------------------------------
virtual int GlobalsSize ();
virtual void InitGlobals ();
virtual void DoAbout (AboutRecord* inAboutRec);
virtual void DoReadPrepare ();
virtual void DoReadStart ();
virtual void DoReadContinue ();
virtual void DoReadFinish ();
virtual void DoOptionsPrepare ();
virtual void DoOptionsStart ();
virtual void DoOptionsContinue ();
virtual void DoOptionsFinish ();
virtual void DoEstimatePrepare ();
virtual void DoEstimateStart ();
virtual void DoEstimateContinue ();
virtual void DoEstimateFinish ();
virtual void DoWritePrepare ();
virtual void DoWriteStart ();
virtual void DoWriteContinue ();
virtual void DoWriteFinish ();
virtual void DoFilterFile ();
//-------------------------------------------------------------------
// Globals - valid upon entry into every override hook
// except DoAbout(). May actually be a pointer to your
// subclass of PSFormatGlobals.
//-------------------------------------------------------------------
PSFormatGlobals* mGlobals;
short* mResult;
FormatRecord* mFormatRec;
};

View File

@ -0,0 +1,83 @@
// ===========================================================================
// ExrFormatGlobals.h Part of OpenEXR
// ===========================================================================
//
// Structure in which the EXRFormat plug-in stores its state
//
#pragma once
#include "PSFormatGlobals.h"
#include <ImfRgbaFile.h>
#include <ImfLineOrder.h>
#include <ImfCompression.h>
class RefNumIFStream;
//-------------------------------------------------------------------------------
// Limits
//-------------------------------------------------------------------------------
const int kExr_MaxPixelValue_8 = 0xFF;
const int kExr_MaxPixelValue_16 = 0xFFFF;
//-------------------------------------------------------------------------------
// Configurable Limits
//-------------------------------------------------------------------------------
//
// these are globals so they can be changed based on the capabilities
// of the host. For example, Commotion has a max pixel depth of 8 and
// a max pixel value of 0xFF. Photoshop has a max pixel depth of 16, but
// only a max pixel value of 0x8000. Other hosts might support the full
// 16-bit range up to 0xFFFF (combustion?)
//
extern int gExr_MaxPixelValue;
extern int gExr_MaxPixelDepth;
//-------------------------------------------------------------------------------
// Globals struct
//-------------------------------------------------------------------------------
class EXRFormatGlobals : public PSFormatGlobals
{
public:
void Reset ();
void DefaultIOSettings ();
int MaxPixelValue () const;
Imf::RgbaInputFile* inputFile;
RefNumIFStream* inputStream;
int bpc;
double exposure;
double gamma;
bool premult;
Imf::RgbaChannels outputChannels;
Imf::LineOrder outputLineOrder;
Imf::Compression outputCompression;
};
typedef EXRFormatGlobals* GPtr;
//-------------------------------------------------------------------------------
// MaxPixelValue
//-------------------------------------------------------------------------------
inline int EXRFormatGlobals::MaxPixelValue () const
{
if (bpc == 16)
return (kExr_MaxPixelValue_16 < gExr_MaxPixelValue) ? kExr_MaxPixelValue_16 : gExr_MaxPixelValue;
return (kExr_MaxPixelValue_8 < gExr_MaxPixelValue) ? kExr_MaxPixelValue_8 : gExr_MaxPixelValue;
}

View File

@ -0,0 +1,692 @@
// ===========================================================================
// EXRFormatPlugin.cp Part of OpenEXR
// ===========================================================================
#if MSWindows
#pragma warning (disable: 161)
#endif
#include "EXRFormatPlugin.h"
#include "EXRResample.h"
#include "EXRImportDialog.h"
#include "EXRExportDialog.h"
#include "RefNumIO.h"
#include "PIFormat.h"
#include "PSAutoBuffer.h"
#include "ImfFrameBuffer.h"
#include "ImfRgbaFile.h"
#include "ImathBox.h"
#include "ImfArray.h"
#include "ImfIO.h"
#include "ImathFun.h"
#include "PITypes.h"
#include "ADMBasic.h"
#include <cassert>
//-------------------------------------------------------------------------------
// ConfigureLimits
//-------------------------------------------------------------------------------
static void ConfigureLimits (const FormatRecord* inFormatRec)
{
// set gExr_MaxPixelValue and gExr_MaxPixelDepth here
if (inFormatRec != NULL)
{
if (inFormatRec->maxValue >= 0xFFFF)
{
// host supports 16 bit pixels
gExr_MaxPixelDepth = 16;
gExr_MaxPixelValue = 0x8000;
}
else
{
// host only supports 8 bit pixels.
gExr_MaxPixelDepth = 8;
gExr_MaxPixelValue = 0x00FF;
}
}
}
#pragma mark-
//-------------------------------------------------------------------------------
// EXRFormatPlugin
//-------------------------------------------------------------------------------
EXRFormatPlugin::EXRFormatPlugin ()
{
// nothing to do
}
//-------------------------------------------------------------------------------
// ~EXRFormatPlugin
//-------------------------------------------------------------------------------
EXRFormatPlugin::~EXRFormatPlugin ()
{
// nothing to do
}
#pragma mark-
//-------------------------------------------------------------------------------
// GlobalsSize
//-------------------------------------------------------------------------------
int EXRFormatPlugin::GlobalsSize ()
{
return sizeof (EXRFormatGlobals);
}
//-------------------------------------------------------------------------------
// InitGlobals
//-------------------------------------------------------------------------------
void EXRFormatPlugin::InitGlobals ()
{
Globals()->Reset();
}
#pragma mark-
//-------------------------------------------------------------------------------
// DoAbout
//-------------------------------------------------------------------------------
void EXRFormatPlugin::DoAbout (AboutRecord* inAboutRec)
{
if (inAboutRec != NULL && inAboutRec->sSPBasic != NULL)
{
ADMBasicSuite6* basicSuite = NULL;
inAboutRec->sSPBasic->AcquireSuite (kADMBasicSuite, kADMBasicSuiteVersion6, (void**) &basicSuite);
if (basicSuite != NULL)
{
basicSuite->MessageAlert ("OpenEXR Format v1.1.1\n\n"
"Format by Florian Kainz, Rod Bogart, Josh Pines, and Drew Hess\n"
"Plug-in by Paul Schneider\n"
"www.openexr.com");
inAboutRec->sSPBasic->ReleaseSuite (kADMBasicSuite, kADMBasicSuiteVersion6);
basicSuite = NULL;
}
}
}
#pragma mark-
//-------------------------------------------------------------------------------
// DoReadStart
//-------------------------------------------------------------------------------
void EXRFormatPlugin::DoReadStart ()
{
using namespace Imf;
using namespace Imath;
// construct input file from refnum
assert( Globals()->inputStream == NULL );
assert( Globals()->inputFile == NULL );
Globals()->inputStream = new RefNumIFStream (mFormatRec->dataFork, "EXR File");
Globals()->inputFile = new RgbaInputFile (* (Globals()->inputStream));
// get dimension info
const Box2i& dw = Globals()->inputFile->dataWindow();
int w = dw.max.x - dw.min.x + 1;
int h = dw.max.y - dw.min.y + 1;
int dx = dw.min.x;
int dy = dw.min.y;
// get resampling configuration
// pop up dialog, ask user for config
// don't display dialog if running in a host other than Photoshop,
// for partial After Effects compatibility
if (mFormatRec->hostSig == '8BIM' || mFormatRec->hostSig == 'MIB8')
{
if (!DoImportPreviewDlog())
{
// user hit cancel. clean up (some hosts like AE won't
// call us with the ReadFinish selector in this case)
// and return a user canceled error to the host.
DoReadFinish();
*mResult = userCanceledErr;
return;
}
}
// we need this here, because the table is initialized to
// 8-bit (preview) mode.
ResetHalfToIntTable (Globals());
// return image info to host
// always do interleaved RGB or RGBA for now
// if image is RGB, don't add an alpha channel
// if image is single channel, add all four channels
// so that we don't have to switch to grayscale mode
mFormatRec->imageSize.v = h;
mFormatRec->imageSize.h = w;
mFormatRec->planes = (Globals()->inputFile->channels() == WRITE_RGB) ? 3 : 4;
mFormatRec->depth = (Globals()->bpc == 8) ? 8 : 16;
mFormatRec->imageMode = (mFormatRec->depth > 8) ? plugInModeRGB48 : plugInModeRGBColor;
mFormatRec->maxValue = Globals()->MaxPixelValue();
}
//-------------------------------------------------------------------------------
// DoReadContinue
//-------------------------------------------------------------------------------
void EXRFormatPlugin::DoReadContinue ()
{
using namespace Imf;
using namespace Imath;
int rowBytes;
int done, total;
bool haveAlpha;
bool premult;
// sanity check
if (Globals()->inputFile == NULL)
{
*mResult = formatCannotRead;
return;
}
// get channel info
haveAlpha = !(Globals()->inputFile->channels() == WRITE_RGB);
premult = Globals()->premult;
// get dimension info
const Box2i& dw = Globals()->inputFile->dataWindow();
int w = dw.max.x - dw.min.x + 1;
int h = dw.max.y - dw.min.y + 1;
int dx = dw.min.x;
int dy = dw.min.y;
// prepare for progress reporting
done = 0;
total = h;
// get rowbytes, and add alignment padding
rowBytes = (mFormatRec->imageSize.h * mFormatRec->planes * (mFormatRec->depth / 8));
rowBytes = (rowBytes * mFormatRec->depth + 7) >> 3;
// create a half buffer for reading into
// buffer is big enough for one scanline
Array2D<Rgba> p2 (1, w);
// create an integer buffer for returning pixels to the host
// buffer is big enough for one scanline
PSAutoBuffer intBuffer (rowBytes, mFormatRec->bufferProcs);
mFormatRec->data = intBuffer.Lock();
unsigned char* data8 = (unsigned char*) mFormatRec->data;
unsigned short* data16 = (unsigned short*) mFormatRec->data;
// Set up to start returning chunks of data.
// use RGBA interleaved format
mFormatRec->colBytes = mFormatRec->planes * (mFormatRec->depth / 8);
mFormatRec->rowBytes = rowBytes;
mFormatRec->planeBytes = mFormatRec->depth / 8;
mFormatRec->loPlane = 0;
mFormatRec->hiPlane = 3;
mFormatRec->theRect.left = 0;
mFormatRec->theRect.right = mFormatRec->imageSize.h;
// read one scanline at a time
for (int scanline = dw.min.y; scanline <= dw.max.y && *mResult == noErr; ++scanline)
{
// read scanline
// need to offset into array so that scanline
// starts at the front of the array
Globals()->inputFile->setFrameBuffer (&p2[-scanline][-dx], 1, w);
Globals()->inputFile->readPixels (scanline);
// unmult scanline if necessary
if (premult)
{
for (int x = 0; x < w; ++x)
{
// we're going to throw away any alpha data > 1, so
// clamp it to that range before using it for unmulting
float a = p2[0][x].a;
a = Imath::clamp (a, 0.f, 1.f);
if (a != 0)
{
p2[0][x].r /= a;
p2[0][x].g /= a;
p2[0][x].b /= a;
}
}
}
// convert scanline
int i = 0;
if (mFormatRec->depth > 8)
{
for (int x = 0; x < w; ++x)
{
data16[i] = HalfToInt (p2[0][x].r, 0); i++;
data16[i] = HalfToInt (p2[0][x].g, 1); i++;
data16[i] = HalfToInt (p2[0][x].b, 2); i++;
if (haveAlpha)
{
data16[i] = HalfToInt (p2[0][x].a, 3);
i++;
}
}
}
else
{
for (int x = 0; x < w; ++x)
{
data8[i] = HalfToInt (p2[0][x].r, 0); i++;
data8[i] = HalfToInt (p2[0][x].g, 1); i++;
data8[i] = HalfToInt (p2[0][x].b, 2); i++;
if (haveAlpha)
{
data8[i] = HalfToInt (p2[0][x].a, 3);
i++;
}
}
}
// pass scanline back to host
// offset data window to origin, because pshop doesn't have "data window" concept
mFormatRec->theRect.top = scanline - dw.min.y;
mFormatRec->theRect.bottom = mFormatRec->theRect.top + 1;
*mResult = mFormatRec->advanceState();
// report progress
mFormatRec->progressProc (++done, total);
}
// we are done
mFormatRec->data = NULL;
}
//-------------------------------------------------------------------------------
// DoReadFinish
//-------------------------------------------------------------------------------
void EXRFormatPlugin::DoReadFinish ()
{
// clean up Globals()
delete Globals()->inputFile;
Globals()->inputFile = NULL;
delete Globals()->inputStream;
Globals()->inputStream = NULL;
}
#pragma mark-
//-------------------------------------------------------------------------------
// DoOptionsStart
//-------------------------------------------------------------------------------
void EXRFormatPlugin::DoOptionsStart ()
{
// show options dialog
if (DoExportSettingsDlog ())
{
// user configured options, so set revert info up so that it reflects
// the new options. Commotion, in particular, uses this so it doesn't
// bring the options dialog up when saving each frame of a sequence.
if (mFormatRec->revertInfo == NULL)
{
mFormatRec->revertInfo = mFormatRec->handleProcs->newProc (GlobalsSize());
}
if (mFormatRec->revertInfo != NULL)
{
char* ptr = mFormatRec->handleProcs->lockProc (mFormatRec->revertInfo, false);
memcpy (ptr, Globals(), GlobalsSize());
mFormatRec->handleProcs->unlockProc (mFormatRec->revertInfo);
}
}
else
{
// user canceled out of options dialog
*mResult = userCanceledErr;
}
}
#pragma mark-
//-------------------------------------------------------------------------------
// DoEstimateStart
//-------------------------------------------------------------------------------
void EXRFormatPlugin::DoEstimateStart ()
{
// provide an estimate as to how much disk space
// we need to write the file. If we don't set a
// non-zero size, Photoshop won't open the file!
// Thanks to Chris Cox @ Adobe for this fix.
int32 dataBytes;
// minimum file size estimate is just the header
mFormatRec->minDataBytes = 100;
// estimate maximum file size if it were uncompressed
// header plus 4 channels, 2 bytes per channel
dataBytes = 100 +
4 * 2 * (int32) mFormatRec->imageSize.h * mFormatRec->imageSize.v;
mFormatRec->maxDataBytes = dataBytes;
// tell the host not to call us with DoEstimateContinue
mFormatRec->data = NULL;
}
#pragma mark-
//-------------------------------------------------------------------------------
// DoWriteStart
//-------------------------------------------------------------------------------
void EXRFormatPlugin::DoWriteStart ()
{
using namespace Imf;
using namespace Imath;
int done, total;
unsigned char* pix8;
unsigned short* pix16;
// set globals to reflect the pixels we're recieving, and
// rebuild the LUT to convert integer pixels
// to floating point pixels
Globals()->bpc = mFormatRec->depth;
ResetIntToHalfTable (Globals());
// construct output file from file spec
Header header (mFormatRec->imageSize.h,
mFormatRec->imageSize.v,
1,
Imath::V2f (0, 0),
1,
Imf::INCREASING_Y,
Globals()->outputCompression);
RefNumOFStream stream (mFormatRec->dataFork, "EXR File");
RgbaOutputFile out (stream, header, (mFormatRec->planes == 3) ? WRITE_RGB : WRITE_RGBA);
// tell the host what format we want to recieve pixels in
// interleaved RGBA format is always popular
// note that we don't align the rowbytes in this case
mFormatRec->imageMode = (mFormatRec->depth > 8) ? plugInModeRGB48 : plugInModeRGBColor;
mFormatRec->loPlane = 0;
mFormatRec->hiPlane = mFormatRec->planes - 1;
mFormatRec->planeBytes = mFormatRec->depth / 8;
mFormatRec->colBytes = mFormatRec->planeBytes * mFormatRec->planes;
mFormatRec->rowBytes = mFormatRec->colBytes * mFormatRec->imageSize.h;
mFormatRec->theRect.left = 0;
mFormatRec->theRect.right = mFormatRec->imageSize.h;
// set up progress
done = 0;
total = mFormatRec->imageSize.v;
// create buffers for one scanline
PSAutoBuffer intBuffer (mFormatRec->rowBytes, mFormatRec->bufferProcs);
Array2D<Rgba> p2 (1, mFormatRec->imageSize.h);
// tell host where our buffer is
mFormatRec->data = intBuffer.Lock();
// convert one scanline at a time
for (int y = 0; y < mFormatRec->imageSize.v; ++y)
{
// get one scanline from host
mFormatRec->theRect.top = y;
mFormatRec->theRect.bottom = y+1;
mFormatRec->advanceState();
// convert scanline
if (mFormatRec->depth > 8)
{
pix16 = (unsigned short*) (mFormatRec->data);
for (int x = 0; x < mFormatRec->imageSize.h; ++x)
{
p2[0][x].r = IntToHalf (*pix16++, 0);
p2[0][x].g = IntToHalf (*pix16++, 1);
p2[0][x].b = IntToHalf (*pix16++, 2);
p2[0][x].a = (mFormatRec->planes > 3) ? IntToHalf (*pix16++, 3) : half(1.0);
}
}
else
{
pix8 = (unsigned char*) (mFormatRec->data);
for (int x = 0; x < mFormatRec->imageSize.h; ++x)
{
p2[0][x].r = IntToHalf (*pix8++, 0);
p2[0][x].g = IntToHalf (*pix8++, 1);
p2[0][x].b = IntToHalf (*pix8++, 2);
p2[0][x].a = (mFormatRec->planes > 3) ? IntToHalf (*pix8++, 3) : half(1.0);
}
}
// premult if necessary
if (Globals()->premult)
{
for (int x = 0; x < mFormatRec->imageSize.h; ++x)
{
half a = p2[0][x].a;
p2[0][x].r *= a;
p2[0][x].g *= a;
p2[0][x].b *= a;
}
}
// write scanline
out.setFrameBuffer (&p2[-y][0], 1, mFormatRec->imageSize.h);
out.writePixels (1);
// report progress
mFormatRec->progressProc (++done, total);
}
// we are done
mFormatRec->data = NULL;
}
#pragma mark-
//-------------------------------------------------------------------------------
// DoImportPreviewDlog
//-------------------------------------------------------------------------------
bool EXRFormatPlugin::DoImportPreviewDlog ()
{
return EXRImportDialog (Globals(), mFormatRec->sSPBasic, mFormatRec->plugInRef);
}
//-------------------------------------------------------------------------------
// DoExportSettingsDlog
//-------------------------------------------------------------------------------
bool EXRFormatPlugin::DoExportSettingsDlog ()
{
return EXRExportDialog (Globals(), mFormatRec->sSPBasic, mFormatRec->plugInRef);
}
#pragma mark-
//-------------------------------------------------------------------------------
// Main entry point
//-------------------------------------------------------------------------------
DLLExport MACPASCAL
void PluginMain
(
const short inSelector,
FormatRecord* inFormatRecord,
long* inData,
short* outResult
)
{
// configure resampling based on host's capabilities
if (inSelector != formatSelectorAbout)
{
ConfigureLimits (inFormatRecord);
}
// create and run the plug-in
try
{
EXRFormatPlugin plugin;
plugin.Run (inSelector, inFormatRecord, inData, outResult);
}
// catch out-of-memory exception
catch (const std::bad_alloc&)
{
*outResult = memFullErr;
}
// catch an exception that provides an error string
catch (const std::exception& ex)
{
if (inSelector == formatSelectorAbout || ex.what() == NULL)
{
*outResult = formatCannotRead;
}
else
{
memcpy (& (*inFormatRecord->errorString)[1], ex.what(), strlen (ex.what()));
(*inFormatRecord->errorString)[0] = strlen (ex.what());
*outResult = errReportString;
}
}
// catch any other exception (we don't want to throw back into the host)
catch (...)
{
*outResult = formatCannotRead;
}
}

View File

@ -0,0 +1,69 @@
// ===========================================================================
// EXRFormatPlugin.h Part of OpenEXR
// ===========================================================================
#pragma once
#include "PSFormatPlugin.h"
#include "EXRFormatGlobals.h"
#include "PIDefines.h"
#include "PITypes.h"
//-------------------------------------------------------------------------------
// EXRFormatPlugin
//-------------------------------------------------------------------------------
class EXRFormatPlugin : public PSFormatPlugin
{
public:
EXRFormatPlugin ();
virtual ~EXRFormatPlugin ();
protected:
// access to our Globals struct
inline EXRFormatGlobals* Globals ()
{
return (EXRFormatGlobals*) mGlobals;
}
// PSFormatPlugin Overrides
virtual int GlobalsSize ();
virtual void InitGlobals ();
virtual void DoAbout (AboutRecord* inAboutRec);
virtual void DoReadStart ();
virtual void DoReadContinue ();
virtual void DoReadFinish ();
virtual void DoOptionsStart ();
virtual void DoEstimateStart ();
virtual void DoWriteStart ();
// UI methods
bool DoImportPreviewDlog ();
bool DoExportSettingsDlog ();
};
//-------------------------------------------------------------------------------
// Main entry point
//-------------------------------------------------------------------------------
DLLExport MACPASCAL
void PluginMain (const short inSelector,
FormatRecord* inFormatRecord,
long* inData,
short* outResult);

View File

@ -0,0 +1,52 @@
// ===========================================================================
// ExrFormatGlobals.cp Part of OpenEXR
// ===========================================================================
//
// Structure in which the EXRFormat plug-in stores its state
//
#if MSWindows
#pragma warning (disable: 161)
#endif
#include "EXRFormatGlobals.h"
//-------------------------------------------------------------------------------
// Globals
//-------------------------------------------------------------------------------
int gExr_MaxPixelValue = 0xFF;
int gExr_MaxPixelDepth = 8;
//-------------------------------------------------------------------------------
// Reset
//-------------------------------------------------------------------------------
void EXRFormatGlobals::Reset ()
{
inputFile = NULL;
inputStream = NULL;
DefaultIOSettings();
}
//-------------------------------------------------------------------------------
// DefaultIOSettings
//-------------------------------------------------------------------------------
void EXRFormatGlobals::DefaultIOSettings ()
{
exposure = 0;
gamma = 2.2;
bpc = (gExr_MaxPixelDepth == 8) ? 8 : 16;
premult = true;
outputChannels = Imf::WRITE_RGBA;
outputLineOrder = Imf::DECREASING_Y;
outputCompression = Imf::PIZ_COMPRESSION;
}

View File

@ -0,0 +1,434 @@
// ===========================================================================
// RefNumIO.cpp Part of OpenEXR
// ===========================================================================
#include "RefNumIO.h"
#include <IexBaseExc.h>
#include <PITypes.h> // for Macintosh and MSWindows defines
// ===========================================================================
// Macintosh IO Abstraction
//
// use 64-bit HFS+ APIs if the system supports them,
// fall back to 32-bit classic File Manager APIs otherwise
// ===========================================================================
#pragma mark ===== Macintosh =====
#if Macintosh
#include <Gestalt.h>
#include <Files.h>
//-------------------------------------------------------------------------------
// HaveHFSPlusAPIs
//-------------------------------------------------------------------------------
static bool HaveHFSPlusAPIs ()
{
static bool sCheckedForHFSPlusAPIs = false;
static bool sHaveHFSPlusAPIs = false;
if (!sCheckedForHFSPlusAPIs)
{
long response = 0;
OSErr err = noErr;
err = Gestalt (gestaltFSAttr, &response);
if (err == noErr && (response & (1 << gestaltHasHFSPlusAPIs)))
{
sHaveHFSPlusAPIs = true;
}
sCheckedForHFSPlusAPIs = true;
}
return sHaveHFSPlusAPIs;
}
//-------------------------------------------------------------------------------
// Read
//-------------------------------------------------------------------------------
static bool Read (short refNum, int n, void* c)
{
OSErr err = noErr;
if (HaveHFSPlusAPIs())
{
ByteCount actual;
err = FSReadFork (refNum, fsFromMark, 0, n, c, &actual);
}
else
{
long count = n;
err = FSRead (refNum, &count, c);
}
return (err == noErr);
}
//-------------------------------------------------------------------------------
// Write
//-------------------------------------------------------------------------------
static bool Write (short refNum, int n, const void* c)
{
OSErr err = noErr;
if (HaveHFSPlusAPIs())
{
ByteCount actual;
err = FSWriteFork (refNum, fsFromMark, 0, n, c, &actual);
}
else
{
long count = n;
err = FSWrite (refNum, &count, c);
}
return (err == noErr);
}
//-------------------------------------------------------------------------------
// Tell
//-------------------------------------------------------------------------------
static bool Tell (short refNum, Imf::Int64& pos)
{
OSErr err = noErr;
if (HaveHFSPlusAPIs())
{
SInt64 p;
err = FSGetForkPosition (refNum, &p);
pos = p;
}
else
{
long p;
err = GetFPos (refNum, &p);
pos = p;
}
return (err == noErr);
}
//-------------------------------------------------------------------------------
// Seek
//-------------------------------------------------------------------------------
static bool Seek (short refNum, const Imf::Int64& pos)
{
OSErr err = noErr;
if (HaveHFSPlusAPIs())
{
err = FSSetForkPosition (refNum, fsFromStart, pos);
}
else
{
err = SetFPos (refNum, fsFromStart, pos);
}
return (err == noErr);
}
//-------------------------------------------------------------------------------
// GetSize
//-------------------------------------------------------------------------------
static bool GetSize (short refNum, Imf::Int64& size)
{
OSErr err = noErr;
if (HaveHFSPlusAPIs())
{
SInt64 fileSize;
err = FSGetForkSize (refNum, &fileSize);
size = fileSize;
}
else
{
long fileSize;
err = GetEOF (refNum, &fileSize);
size = fileSize;
}
return (err == noErr);
}
#endif
#pragma mark-
#pragma mark ===== Windows =====
// ===========================================================================
// Windows IO Abstraction
// ===========================================================================
#if MSWindows
//-------------------------------------------------------------------------------
// Read
//-------------------------------------------------------------------------------
static bool Read (short refNum, int n, void* c)
{
DWORD nRead;
return ReadFile ((HANDLE) refNum, c, n, &nRead, NULL);
}
//-------------------------------------------------------------------------------
// Write
//-------------------------------------------------------------------------------
static bool Write (short refNum, int n, const void* c)
{
DWORD nRead;
return WriteFile ((HANDLE) refNum, c, n, &nRead, NULL);
}
//-------------------------------------------------------------------------------
// Tell
//-------------------------------------------------------------------------------
static bool Tell (short refNum, Imf::Int64& pos)
{
LARGE_INTEGER li;
li.QuadPart = 0;
li.LowPart = SetFilePointer ((HANDLE) refNum, 0, &li.HighPart, FILE_CURRENT);
if (li.HighPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR)
{
return false;
}
pos = li.QuadPart;
return true;
}
//-------------------------------------------------------------------------------
// Seek
//-------------------------------------------------------------------------------
static bool Seek (short refNum, const Imf::Int64& pos)
{
LARGE_INTEGER li;
li.QuadPart = pos;
SetFilePointer ((HANDLE) refNum, li.LowPart, &li.HighPart, FILE_BEGIN);
return !(li.HighPart == INVALID_SET_FILE_POINTER && GetLastError() != NO_ERROR);
}
//-------------------------------------------------------------------------------
// GetSize
//-------------------------------------------------------------------------------
static bool GetSize (short refNum, Imf::Int64& size)
{
LARGE_INTEGER li;
DWORD hi;
li.QuadPart = 0;
li.LowPart = GetFileSize ((HANDLE) refNum, &hi);
li.HighPart = hi;
size = li.QuadPart;
return !(li.LowPart == INVALID_FILE_SIZE && GetLastError() != NO_ERROR);
}
#endif
#pragma mark-
//-------------------------------------------------------------------------------
// IStream Constructor
//-------------------------------------------------------------------------------
RefNumIFStream::RefNumIFStream
(
short refNum,
const char fileName[]
) :
IStream (fileName),
_refNum (refNum)
{
}
//-------------------------------------------------------------------------------
// IStream Destructor
//-------------------------------------------------------------------------------
RefNumIFStream::~RefNumIFStream ()
{
}
//-------------------------------------------------------------------------------
// read
//-------------------------------------------------------------------------------
bool
RefNumIFStream::read (char c[/*n*/], int n)
{
if (!Read (_refNum, n, c))
{
throw Iex::InputExc ("Unable to read file.");
}
Imf::Int64 fileSize;
if (!GetSize (_refNum, fileSize))
{
throw Iex::InputExc ("Couldn't get file size.");
}
return !(fileSize == tellg());
}
//-------------------------------------------------------------------------------
// tellg
//-------------------------------------------------------------------------------
Imf::Int64
RefNumIFStream::tellg ()
{
Imf::Int64 fpos = 0;
if (!Tell (_refNum, fpos))
{
throw Iex::InputExc ("Error finding file positon.");
}
return fpos;
}
//-------------------------------------------------------------------------------
// seekg
//-------------------------------------------------------------------------------
void
RefNumIFStream::seekg (Imf::Int64 pos)
{
if (!Seek (_refNum, pos))
{
throw Iex::InputExc ("Error setting file positon.");
}
}
//-------------------------------------------------------------------------------
// clear
//-------------------------------------------------------------------------------
void
RefNumIFStream::clear ()
{
// nothing to do
}
#pragma mark-
//-------------------------------------------------------------------------------
// OStream Constructor
//-------------------------------------------------------------------------------
RefNumOFStream::RefNumOFStream
(
short refNum,
const char fileName[]
) :
OStream (fileName),
_refNum (refNum)
{
}
//-------------------------------------------------------------------------------
// OStream Destructor
//-------------------------------------------------------------------------------
RefNumOFStream::~RefNumOFStream ()
{
}
//-------------------------------------------------------------------------------
// write
//-------------------------------------------------------------------------------
void
RefNumOFStream::write (const char c[/*n*/], int n)
{
if (!Write (_refNum, n, c))
{
throw Iex::IoExc ("Unable to write file.");
}
}
//-------------------------------------------------------------------------------
// tellp
//-------------------------------------------------------------------------------
Imf::Int64
RefNumOFStream::tellp ()
{
Imf::Int64 fpos = 0;
if (!Tell (_refNum, fpos))
{
throw Iex::InputExc ("Error finding file positon.");
}
return fpos;
}
//-------------------------------------------------------------------------------
// seekp
//-------------------------------------------------------------------------------
void
RefNumOFStream::seekp (Imf::Int64 pos)
{
if (!Seek (_refNum, pos))
{
throw Iex::InputExc ("Error setting file positon.");
}
}

View File

@ -0,0 +1,58 @@
// ===========================================================================
// RefNumIO.h Part of OpenEXR
// ===========================================================================
#ifndef INCLUDED_REFNUM_IO_H
#define INCLUDED_REFNUM_IO_H
#include <ImfIO.h>
//-------------------------------------------------------------------------------
// RefNumIFStream - an implementation of Imf::IStream that uses the "data fork"
// reference number passed to us by Photoshop
//-------------------------------------------------------------------------------
class RefNumIFStream : public Imf::IStream
{
public:
RefNumIFStream (short refNum,
const char fileName[]);
virtual ~RefNumIFStream ();
virtual bool read (char c[/*n*/], int n);
virtual Imf::Int64 tellg ();
virtual void seekg (Imf::Int64 pos);
virtual void clear ();
private:
short _refNum;
};
//-------------------------------------------------------------------------------
// RefNumOFStream - an implementation of Imf::OStream that uses the "data fork"
// reference number passed to us by Photoshop
//-------------------------------------------------------------------------------
class RefNumOFStream : public Imf::OStream
{
public:
RefNumOFStream (short refNum,
const char fileName[]);
virtual ~RefNumOFStream ();
virtual void write (const char c[/*n*/], int n);
virtual Imf::Int64 tellp ();
virtual void seekp (Imf::Int64 pos);
private:
short _refNum;
};
#endif

View File

@ -0,0 +1,212 @@
// ===========================================================================
// EXRResample.cp Part of OpenEXR
// ===========================================================================
//
// Routines for converting EXR pixel data to integers of various bit depths.
// Configuration parameters are passed in Globals struct
//
#if MSWindows
#pragma warning (disable: 161)
#endif
#include "EXRResample.h"
//-------------------------------------------------------------------------------
// big lookup tables
//-------------------------------------------------------------------------------
unsigned short halftoint [4] [1<<16];
unsigned short inttohalf [4] [1<<16];
//-------------------------------------------------------------------------------
// clamp
//-------------------------------------------------------------------------------
inline int clampi (int v, int l, int h)
{
return v < l ? l : v > h ? h : v;
}
//-------------------------------------------------------------------------------
// ResetHalfToIntTable
//-------------------------------------------------------------------------------
void ResetHalfToIntTable (const GPtr inGlobals)
{
float multiplier;
int i, c, v;
half x;
int maxval;
// get float - int scalar
maxval = inGlobals->MaxPixelValue();
// calculate exposure multiplier
multiplier = pow (2.0, inGlobals->exposure);
// build table
for (i = 0; i < 1<<16; ++i)
{
x.setBits (i);
//------------------------------------------
// rgb
//------------------------------------------
for (c = 0; c < 3; ++c)
{
float f = x;
// apply exposure multiplier
f *= multiplier;
// apply gamma
if (inGlobals->gamma != 0)
{
f = pow ((double) f, 1.0 / inGlobals->gamma);
}
// convert to integer space
v = f * maxval + .5;
// clamp to legal range
v = clampi (v, 0, maxval);
// store value
halftoint[c][i] = v;
}
//------------------------------------------
// alpha - no correction applied
//------------------------------------------
// convert to integer space
v = x * maxval + .5;
// clamp to legal range
v = clampi (v, 0, maxval);
// store value
halftoint[3][i] = v;
}
}
//-------------------------------------------------------------------------------
// ResetIntToHalfTable
//-------------------------------------------------------------------------------
void ResetIntToHalfTable (const GPtr inGlobals)
{
float multiplier;
int i, c;
half x;
float f;
int maxval;
// get float - int scalar
maxval = inGlobals->MaxPixelValue();
// calculate exposure multiplier
multiplier = pow (2.0, inGlobals->exposure);
// build table
for (i = 0; i < 1<<16; ++i)
{
//------------------------------------------
// rgb
//------------------------------------------
for (c = 0; c < 3; ++c)
{
// get float
f = (float) i;
// convert to float range
f /= maxval;
// undo gamma
if (inGlobals->gamma != 0)
{
f = pow ((double) f, inGlobals->gamma);
}
// undo exposure
f /= multiplier;
// store value
x = f;
inttohalf[c][i] = x.bits();
}
//------------------------------------------
// alpha - no correction applied
//------------------------------------------
// get float
f = (float) i;
// convert to float range
f = f / maxval;
// store value
x = f;
inttohalf[3][i] = x.bits();
}
}

View File

@ -0,0 +1,64 @@
// ===========================================================================
// EXRResample.h Part of OpenEXR
// ===========================================================================
//
// Routines for converting EXR pixel data to integers of various bit depths.
// Configuration parameters are passed in Globals struct
//
// Channel 0 = red, 1 = green, 2 = blue, 3 = alpha
//
#pragma once
#include "half.h"
#include "EXRFormatGlobals.h"
//-------------------------------------------------------------------------------
// Lookup table rebuilders
//-------------------------------------------------------------------------------
extern void
ResetHalfToIntTable (const GPtr inGlobals);
extern void
ResetIntToHalfTable (const GPtr inGlobals);
//-------------------------------------------------------------------------------
// HalfToInt
//-------------------------------------------------------------------------------
inline unsigned short
HalfToInt
(
const half& inHalf,
int inChannel
)
{
extern unsigned short halftoint [4] [1<<16];
return halftoint[inChannel][inHalf.bits()];
}
//-------------------------------------------------------------------------------
// IntToHalf
//-------------------------------------------------------------------------------
inline half
IntToHalf
(
unsigned short inInt,
int inChannel
)
{
extern unsigned short inttohalf [4] [1<<16];
half x;
x.setBits (inttohalf[inChannel][inInt]);
return x;
}

View File

@ -0,0 +1,453 @@
// ===========================================================================
// EXRExportDialog.cpp Part of OpenEXR
// ===========================================================================
#if MSWindows
#pragma warning (disable: 161)
#endif
#include "EXRExportDialog.h"
#include "ADMDialog.h"
#include "ADMItem.h"
#include "ADMList.h"
#include "ADMEntry.h"
// ---------------------------------------------------------------------------
// Resource ID's
// ---------------------------------------------------------------------------
enum
{
kItem_OK = 1,
kItem_Cancel,
kItem_Defaults,
kItem_Sep1,
kItem_ColorGroup,
kItem_ExposureLabel,
kItem_Exposure,
kItem_GammaLabel,
kItem_Gamma,
kItem_AlphaGroup,
kItem_Premult,
kItem_CompressionGroup,
kItem_CompressionNone,
kItem_CompressionRLE,
kItem_CompressionZip,
kItem_CompressionZips,
kItem_CompressionPiz,
kItem_Sep2,
kItem_Text1,
kItem_Text2
};
// ---------------------------------------------------------------------------
// Globals - ADM makes it hard to avoid them
// ---------------------------------------------------------------------------
static ADMDialogSuite5* sDlogSuite = NULL;
static ADMItemSuite5* sItemSuite = NULL;
static ADMListSuite3* sListSuite = NULL;
static ADMEntrySuite4* sEntrySuite = NULL;
// ---------------------------------------------------------------------------
// ASSetRect
// ---------------------------------------------------------------------------
inline void ASSetRect (ASRect* rect, short l, short t, short r, short b)
{
rect->left = l;
rect->top = t;
rect->right = r;
rect->bottom = b;
}
// ---------------------------------------------------------------------------
// BuildDialog
// ---------------------------------------------------------------------------
static void BuildDialog (ADMDialogRef dialog)
{
ADMItemRef item;
ASRect rect;
// set the dialog to the correct size
sDlogSuite->Size (dialog, 474, 295);
// OK button
ASSetRect (&rect, 388, 270, 468, 290);
item = sItemSuite->Create (dialog, kItem_OK, kADMTextPushButtonType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "OK");
// cancel button
ASSetRect (&rect, 296, 270, 376, 290);
item = sItemSuite->Create (dialog, kItem_Cancel, kADMTextPushButtonType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "Cancel");
// defaults button
ASSetRect (&rect, 8, 270, 88, 290);
item = sItemSuite->Create (dialog, kItem_Defaults, kADMTextPushButtonType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "Defaults");
// separator
ASSetRect (&rect, 5, 263, 469, 265);
item = sItemSuite->Create (dialog, kItem_Sep1, kADMFrameType, &rect, NULL, NULL, 0);
sItemSuite->SetItemStyle (item, kADMEtchedFrameStyle);
// exposure label
ASSetRect (&rect, 22, 140, 115, 160);
item = sItemSuite->Create (dialog, kItem_ExposureLabel, kADMTextStaticType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "Exposure:");
sItemSuite->SetJustify (item, kADMRightJustify);
// exposure control
ASSetRect (&rect, 120, 140, 220, 160);
item = sItemSuite->Create (dialog, kItem_Exposure, kADMSpinEditType, &rect, NULL, NULL, 0);
// gamma label
ASSetRect (&rect, 22, 165, 115, 185);
item = sItemSuite->Create (dialog, kItem_GammaLabel, kADMTextStaticType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "Gamma:");
sItemSuite->SetJustify (item, kADMRightJustify);
// gamma control
ASSetRect (&rect, 120, 165, 220, 185);
item = sItemSuite->Create (dialog, kItem_Gamma, kADMSpinEditType, &rect, NULL, NULL, 0);
// color group
ASSetRect (&rect, 12, 113, 268, 200);
item = sItemSuite->Create (dialog, kItem_ColorGroup, kADMFrameType, &rect, NULL, NULL, 0);
sItemSuite->SetItemStyle (item, kADMEtchedFrameStyle);
sItemSuite->SetText (item, "Color Settings:");
// premult checkbox
ASSetRect (&rect, 65, 225, 250, 245);
item = sItemSuite->Create (dialog, kItem_Premult, kADMTextCheckBoxType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "Premultiply");
// alpha group
ASSetRect (&rect, 12, 205, 268, 255);
item = sItemSuite->Create (dialog, kItem_AlphaGroup, kADMFrameType, &rect, NULL, NULL, 0);
sItemSuite->SetItemStyle (item, kADMEtchedFrameStyle);
sItemSuite->SetText (item, "Alpha:");
// compression choices
ASSetRect (&rect, 300, 134, 444, 154);
item = sItemSuite->Create (dialog, kItem_CompressionNone, kADMTextRadioButtonType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "None");
ASSetRect (&rect, 300, 154, 444, 174);
item = sItemSuite->Create (dialog, kItem_CompressionRLE, kADMTextRadioButtonType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "RLE");
ASSetRect (&rect, 300, 174, 444, 194);
item = sItemSuite->Create (dialog, kItem_CompressionZips, kADMTextRadioButtonType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "Zip");
ASSetRect (&rect, 300, 194, 444, 214);
item = sItemSuite->Create (dialog, kItem_CompressionZip, kADMTextRadioButtonType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "Zip (multi-scanline)");
ASSetRect (&rect, 300, 214, 444, 234);
item = sItemSuite->Create (dialog, kItem_CompressionPiz, kADMTextRadioButtonType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "Piz");
// compression group
ASSetRect (&rect, 288, 113, 464, 255);
item = sItemSuite->Create (dialog, kItem_CompressionGroup, kADMFrameType, &rect, NULL, NULL, 0);
sItemSuite->SetItemStyle (item, kADMEtchedFrameStyle);
sItemSuite->SetText (item, "Compression:");
// separator
ASSetRect (&rect, 5, 106, 469, 108);
item = sItemSuite->Create (dialog, kItem_Sep2, kADMFrameType, &rect, NULL, NULL, 0);
sItemSuite->SetItemStyle (item, kADMEtchedFrameStyle);
// some text
ASSetRect (&rect, 24, 8, 450, 44);
item = sItemSuite->Create (dialog, kItem_Text1, kADMTextStaticType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "The inverse of these settings will be applied to the image.");
// some more text
ASSetRect (&rect, 24, 48, 450, 100);
item = sItemSuite->Create (dialog, kItem_Text2, kADMTextStaticType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "If you use the same settings as when you loaded the image, "
"it will be returned to its original colorspace.");
// if on Windows, swap the OK and Cancel button positions
#if MSWindows
item = sDlogSuite->GetItem (dialog, kItem_OK);
sItemSuite->Move (item, 296, 270);
item = sDlogSuite->GetItem (dialog, kItem_Cancel);
sItemSuite->Move (item, 388, 270);
#endif
}
// ---------------------------------------------------------------------------
// DoDialogOK - ADM callback
// ---------------------------------------------------------------------------
static void ASAPI DoDialogOK (ADMItemRef inItem, ADMNotifierRef inNotifier)
{
ADMDialogRef dialog = (ADMDialogRef) sItemSuite->GetUserData (inItem);
GPtr globals = (GPtr) sDlogSuite->GetUserData (dialog);
ADMItemRef item = NULL;
ADMListRef list = NULL;
ADMEntryRef entry = NULL;
// apply control values to globals
item = sDlogSuite->GetItem (dialog, kItem_Exposure);
globals->exposure = sItemSuite->GetFloatValue (item);
item = sDlogSuite->GetItem (dialog, kItem_Gamma);
globals->gamma = sItemSuite->GetFloatValue (item);
item = sDlogSuite->GetItem (dialog, kItem_Premult);
globals->premult = sItemSuite->GetIntValue (item);
item = sDlogSuite->GetItem (dialog, kItem_CompressionNone);
if (sItemSuite->GetBooleanValue (item)) globals->outputCompression = Imf::NO_COMPRESSION;
item = sDlogSuite->GetItem (dialog, kItem_CompressionRLE);
if (sItemSuite->GetBooleanValue (item)) globals->outputCompression = Imf::RLE_COMPRESSION;
item = sDlogSuite->GetItem (dialog, kItem_CompressionZip);
if (sItemSuite->GetBooleanValue (item)) globals->outputCompression = Imf::ZIP_COMPRESSION;
item = sDlogSuite->GetItem (dialog, kItem_CompressionZips);
if (sItemSuite->GetBooleanValue (item)) globals->outputCompression = Imf::ZIPS_COMPRESSION;
item = sDlogSuite->GetItem (dialog, kItem_CompressionPiz);
if (sItemSuite->GetBooleanValue (item)) globals->outputCompression = Imf::PIZ_COMPRESSION;
// call default handler
sItemSuite->DefaultNotify (inItem, inNotifier);
}
// ---------------------------------------------------------------------------
// DoDialogDefaults - ADM callback
// ---------------------------------------------------------------------------
static void ASAPI DoDialogDefaults (ADMItemRef inItem, ADMNotifierRef inNotifier)
{
ADMDialogRef dialog = (ADMDialogRef) sItemSuite->GetUserData (inItem);
GPtr globals = (GPtr) sDlogSuite->GetUserData (dialog);
ADMItemRef item = NULL;
ADMListRef list = NULL;
ADMEntryRef entry = NULL;
// set control values
item = sDlogSuite->GetItem (dialog, kItem_Exposure);
sItemSuite->SetFloatValue (item, 0.0f);
item = sDlogSuite->GetItem (dialog, kItem_Gamma);
sItemSuite->SetFloatValue (item, 2.2f);
item = sDlogSuite->GetItem (dialog, kItem_Premult);
sItemSuite->SetIntValue (item, true);
item = sDlogSuite->GetItem (dialog, kItem_CompressionNone);
sItemSuite->SetBooleanValue (item, false);
item = sDlogSuite->GetItem (dialog, kItem_CompressionRLE);
sItemSuite->SetBooleanValue (item, false);
item = sDlogSuite->GetItem (dialog, kItem_CompressionZip);
sItemSuite->SetBooleanValue (item, false);
item = sDlogSuite->GetItem (dialog, kItem_CompressionZips);
sItemSuite->SetBooleanValue (item, false);
item = sDlogSuite->GetItem (dialog, kItem_CompressionPiz);
sItemSuite->SetBooleanValue (item, true);
}
// ---------------------------------------------------------------------------
// DoDialogInit - ADM callback
// ---------------------------------------------------------------------------
static ASErr ASAPI DoDialogInit (ADMDialogRef dialog)
{
const char* compressionNames[] = { "None", "RLE", "Zip - 1 Scanline", "Zip - 16 Scanlines", "Piz" };
GPtr globals = (GPtr) sDlogSuite->GetUserData (dialog);
ADMItemRef item = NULL;
ADMListRef list = NULL;
ADMEntryRef entry = NULL;
int c = (int) globals->outputCompression;
// create UI elements
BuildDialog (dialog);
// set dialog title
sDlogSuite->SetText (dialog, "EXR Export Settings");
// set control values
item = sDlogSuite->GetItem (dialog, kItem_Exposure);
sItemSuite->SetUnits (item, kADMNoUnits);
sItemSuite->SetFloatValue (item, globals->exposure);
item = sDlogSuite->GetItem (dialog, kItem_Gamma);
sItemSuite->SetUnits (item, kADMNoUnits);
sItemSuite->SetFloatValue (item, globals->gamma);
item = sDlogSuite->GetItem (dialog, kItem_Premult);
sItemSuite->SetIntValue (item, globals->premult);
item = sDlogSuite->GetItem (dialog, kItem_CompressionNone);
sItemSuite->SetBooleanValue (item, globals->outputCompression == Imf::NO_COMPRESSION);
item = sDlogSuite->GetItem (dialog, kItem_CompressionRLE);
sItemSuite->SetBooleanValue (item, globals->outputCompression == Imf::RLE_COMPRESSION);
item = sDlogSuite->GetItem (dialog, kItem_CompressionZip);
sItemSuite->SetBooleanValue (item, globals->outputCompression == Imf::ZIP_COMPRESSION);
item = sDlogSuite->GetItem (dialog, kItem_CompressionZips);
sItemSuite->SetBooleanValue (item, globals->outputCompression == Imf::ZIPS_COMPRESSION);
item = sDlogSuite->GetItem (dialog, kItem_CompressionPiz);
sItemSuite->SetBooleanValue (item, globals->outputCompression == Imf::PIZ_COMPRESSION);
// set "OK" callback
item = sDlogSuite->GetItem (dialog, kItem_OK);
sItemSuite->SetUserData (item, dialog);
sItemSuite->SetNotifyProc (item, DoDialogOK);
// set "Defaults" callback
item = sDlogSuite->GetItem (dialog, kItem_Defaults);
sItemSuite->SetUserData (item, dialog);
sItemSuite->SetNotifyProc (item, DoDialogDefaults);
return kSPNoError;
}
// ---------------------------------------------------------------------------
// EXRExportDialog - show the Export Settings dialog
// ---------------------------------------------------------------------------
bool EXRExportDialog (GPtr ioGlobals, SPBasicSuite* inSPBasic, void* inPluginRef)
{
int item = kItem_Cancel;
// get suites
inSPBasic->AcquireSuite (kADMDialogSuite, kADMDialogSuiteVersion5, (void**) &sDlogSuite);
inSPBasic->AcquireSuite (kADMItemSuite, kADMItemSuiteVersion5, (void**) &sItemSuite);
inSPBasic->AcquireSuite (kADMListSuite, kADMListSuiteVersion3, (void**) &sListSuite);
inSPBasic->AcquireSuite (kADMEntrySuite, kADMEntrySuiteVersion4, (void**) &sEntrySuite);
// show dialog
if (sDlogSuite != NULL && sItemSuite != NULL && sListSuite != NULL)
{
item = sDlogSuite->Modal ((SPPluginRef) inPluginRef,
"EXR Export Settings",
0,
kADMModalDialogStyle,
DoDialogInit,
ioGlobals,
0);
}
// release suites
if (sDlogSuite != NULL)
{
inSPBasic->ReleaseSuite (kADMDialogSuite, kADMDialogSuiteVersion5);
sDlogSuite = NULL;
}
if (sItemSuite != NULL)
{
inSPBasic->ReleaseSuite (kADMItemSuite, kADMItemSuiteVersion5);
sItemSuite = NULL;
}
if (sListSuite != NULL)
{
inSPBasic->ReleaseSuite (kADMListSuite, kADMListSuiteVersion3);
sListSuite = NULL;
}
if (sEntrySuite != NULL)
{
inSPBasic->ReleaseSuite (kADMEntrySuite, kADMEntrySuiteVersion4);
sEntrySuite = NULL;
}
// return true if user hit OK, false if user hit Cancel
return (item == kItem_OK);
}

View File

@ -0,0 +1,15 @@
// ===========================================================================
// EXRExportDialog.h Part of OpenEXR
// ===========================================================================
#pragma once
#include "EXRFormatGlobals.h"
struct SPBasicSuite;
extern bool
EXRExportDialog (GPtr ioGlobals, SPBasicSuite* inSPBasic, void* inPluginRef);

View File

@ -0,0 +1,782 @@
// ===========================================================================
// EXRImportDialog.cpp Part of OpenEXR
// ===========================================================================
#if MSWindows
#pragma warning (disable: 161)
#endif
#include "EXRImportDialog.h"
#include "EXRResample.h"
#include "ADMDialog.h"
#include "ADMItem.h"
#include "ADMDrawer.h"
#include "ADMImage.h"
#include "ADMTracker.h"
#include "ADMResource.h"
#include <ImfArray.h>
#include <ImfRgbaFile.h>
#include <ImathFun.h>
#include "PITypes.h"
#if Macintosh
#include <Appearance.h>
using std::min;
using std::max;
#endif
using Imf::Array2D;
using Imf::Rgba;
// ---------------------------------------------------------------------------
// Resource IDs
// ---------------------------------------------------------------------------
enum
{
kItem_OK = 1,
kItem_Cancel,
kItem_Defaults,
kItem_Sep1,
kItem_ExposureLabel,
kItem_Exposure,
kItem_GammaLabel,
kItem_Gamma,
kItem_Unmult,
kItem_Sep2,
kItem_Preview
};
// ---------------------------------------------------------------------------
// Globals
// ---------------------------------------------------------------------------
static ADMDialogSuite5* sDlogSuite = NULL;
static ADMItemSuite5* sItemSuite = NULL;
static ADMDrawerSuite3* sDrawSuite = NULL;
static ADMImageSuite2* sImageSuite = NULL;
static ADMTrackerSuite1* sTrackSuite = NULL;
static Array2D< Rgba > sEXRBuffer;
static ADMImageRef sPreviewImage = NULL;
// ---------------------------------------------------------------------------
// round
// ---------------------------------------------------------------------------
#if MSWindows
inline double round (double d)
{
return (double) (int) (d + .5);
}
#endif
// ---------------------------------------------------------------------------
// ASSetRect
// ---------------------------------------------------------------------------
inline void ASSetRect (ASRect* rect, short l, short t, short r, short b)
{
rect->left = l;
rect->top = t;
rect->right = r;
rect->bottom = b;
}
// ---------------------------------------------------------------------------
// CenterRectInRect
// ---------------------------------------------------------------------------
//
// Return a rect that has the aspect ratio of rect A, and is centered
// in rect B.
//
static void CenterRectInRect
(
const ASRect& inRectToCenter,
const ASRect& inBoundsRect,
ASRect& outRect
)
{
int cw, ch;
int bw, bh;
int ow, oh;
double dx, dy;
cw = inRectToCenter.right - inRectToCenter.left;
ch = inRectToCenter.bottom - inRectToCenter.top;
bw = inBoundsRect.right - inBoundsRect.left;
bh = inBoundsRect.bottom - inBoundsRect.top;
dx = double (cw) / double (bw);
dy = double (ch) / double (bh);
if (dy > dx)
{
ow = cw / dy;
oh = ch / dy;
}
else
{
ow = cw / dx;
oh = ch / dx;
}
if (cw < bw)
{
ow = cw;
}
if (ch < bh)
{
oh = ch;
}
outRect.left = inBoundsRect.left + ((bw - ow) / 2);
outRect.top = inBoundsRect.top + ((bh - oh) / 2);
outRect.right = outRect.left + ow;
outRect.bottom = outRect.top + oh;
}
#pragma mark-
// ---------------------------------------------------------------------------
// AllocatePreview
// ---------------------------------------------------------------------------
static void ReadAllocatePreview (GPtr globals, ADMItemRef previewWidget)
{
int w, h, dx, dy;
int pw, ph;
ASRect r1, r2, r3;
float xSkip, ySkip;
Array2D< Rgba > scanline;
float x1, x2, y1, y2;
int x1i, x2i, y1i, y2i;
ASRect previewRect;
int previewWidth, previewHeight;
#if Macintosh
unsigned int step = 0;
unsigned int lastUpdate = 0;
#endif
#if MSWindows
SetCursor (LoadCursor (NULL, IDC_WAIT));
#endif
// get dimensions of preview widget
sItemSuite->GetBoundsRect (previewWidget, &previewRect);
previewWidth = previewRect.right - previewRect.left;
previewHeight = previewRect.bottom - previewRect.top;
// get dimensions of image on disk
const Imath::Box2i& dw = globals->inputFile->dataWindow();
w = dw.max.x - dw.min.x + 1;
h = dw.max.y - dw.min.y + 1;
dx = dw.min.x;
dy = dw.min.y;
// get dimensions preview should be
// we want to preserve the aspect ratio of the real image
ASSetRect (&r1, 0, 0, w, h);
ASSetRect (&r2, 0, 0, previewWidth, previewHeight);
CenterRectInRect (r1, r2, r3);
pw = min ((int) (r3.right - r3.left), previewWidth);
ph = min ((int) (r3.bottom - r3.top), previewHeight);
// get skip amounts for downsampling resolution
xSkip = ((float)w / (float)pw);
ySkip = ((float)h / (float)ph);
// allocate EXR buffers
scanline.resizeErase (1, w);
sEXRBuffer.resizeErase (ph, pw);
// read and downsample one scanline at a time
for (y1 = dw.min.y, y2 = 0; y2 < ph; y1 += ySkip, y2 += 1)
{
y1i = round (y1);
y2i = round (y2);
// read scanline
globals->inputFile->setFrameBuffer (&scanline[-y1i][-dx], 1, w);
globals->inputFile->readPixels (y1i);
// downsample scanline into preview buffer
for (x1 = dw.min.x, x2 = 0; x2 < pw; x1 += xSkip, x2 += 1)
{
x1i = round (x1);
x2i = round (x2);
sEXRBuffer[y2i][x2i] = scanline[0][x1i];
}
// give a little feedback
#if Macintosh
unsigned int now = TickCount();
if (now - lastUpdate > 20)
{
SetAnimatedThemeCursor (kThemeWatchCursor, step++);
lastUpdate = now;
}
#endif
}
// allocate 8-bit buffer for drawing to screen
sPreviewImage = sImageSuite->Create (pw, ph, 0);
}
// ---------------------------------------------------------------------------
// FreePreview
// ---------------------------------------------------------------------------
static void FreePreview ()
{
if (sPreviewImage != NULL)
{
sImageSuite->Destroy (sPreviewImage);
sPreviewImage = NULL;
}
sEXRBuffer.resizeErase (0, 0);
}
// ---------------------------------------------------------------------------
// ResamplePreview
// ---------------------------------------------------------------------------
static void ResamplePreview (GPtr globals)
{
// downsample the 16-bit EXR data into the 8-bit buffer
if (sPreviewImage != NULL)
{
ASBytePtr baseAddr;
int w, h, rowBytes;
// get preview image info
baseAddr = sImageSuite->BeginBaseAddressAccess (sPreviewImage);
w = sImageSuite->GetWidth (sPreviewImage);
h = sImageSuite->GetHeight (sPreviewImage);
rowBytes = sImageSuite->GetByteWidth (sPreviewImage);
// globals changed, so rebuild lookup table
int bpc = globals->bpc;
globals->bpc = 8;
ResetHalfToIntTable (globals);
globals->bpc = bpc;
// downsample one scanline at a time
for (int y = 0; y < h; ++y)
{
// downsample scanline
for (int x = 0; x < w; ++x)
{
// get half pixel
Rgba bigPixel = sEXRBuffer[y][x];
// unmult
if (globals->premult && bigPixel.a != 0)
{
// we're going to throw away any alpha data > 1, so
// clamp it to that range before using it for unmulting
float a = Imath::clamp ((float) bigPixel.a, 0.f, 1.f);
bigPixel.r /= a;
bigPixel.g /= a;
bigPixel.b /= a;
}
// convert
char r = HalfToInt (bigPixel.r, 0);
char g = HalfToInt (bigPixel.g, 1);
char b = HalfToInt (bigPixel.b, 2);
// write to preview buffer
ASBytePtr pix = &baseAddr[ (y * rowBytes) + (x * 4) ];
#if MSWindows
// ADM pixel data is little endian
*pix = b; pix++;
*pix = g; pix++;
*pix = r; pix++;
pix++;
#else
// ADM pixel data is big endian
pix++;
*pix = r; pix++;
*pix = g; pix++;
*pix = b; pix++;
#endif
}
}
// clean up
sImageSuite->EndBaseAddressAccess (sPreviewImage);
}
}
// ---------------------------------------------------------------------------
// DrawPreview - ADM callback
// ---------------------------------------------------------------------------
static void ASAPI DrawPreview (ADMItemRef item, ADMDrawerRef drawer)
{
ASRect rect;
sDrawSuite->GetBoundsRect (drawer, &rect);
sDrawSuite->SetADMColor (drawer, kADMBlackColor);
sDrawSuite->FillRect (drawer, &rect);
if (sPreviewImage != NULL)
{
sDrawSuite->DrawADMImageCentered (drawer, sPreviewImage, &rect);
}
else
{
sDrawSuite->SetADMColor (drawer, kADMWhiteColor);
sDrawSuite->DrawTextCentered (drawer, "Click for Preview", &rect);
}
}
// ---------------------------------------------------------------------------
// TrackPreview - ADM callback
// ---------------------------------------------------------------------------
static ASBoolean ASAPI TrackPreview (ADMItemRef inItem, ADMTrackerRef inTracker)
{
// we need to return true so that the notifier proc will be called
sTrackSuite->Abort(inTracker);
return true;
}
// ---------------------------------------------------------------------------
// ClickPreview - ADM callback
// ---------------------------------------------------------------------------
static void ASAPI ClickPreview (ADMItemRef inItem, ADMNotifierRef inNotifier)
{
if (sPreviewImage == NULL)
{
ADMDialogRef dialog = (ADMDialogRef) sItemSuite->GetUserData (inItem);
GPtr globals = (GPtr) sDlogSuite->GetUserData (dialog);
ADMItemRef item = NULL;
// update the preview
item = sDlogSuite->GetItem (dialog, kItem_Preview);
ReadAllocatePreview (globals, item);
ResamplePreview (globals);
sItemSuite->Invalidate (item);
}
}
#pragma mark-
// ---------------------------------------------------------------------------
// BuildDialog
// ---------------------------------------------------------------------------
static void BuildDialog (ADMDialogRef dialog)
{
ADMItemRef item;
ASRect rect;
// set the dialog to the correct size
sDlogSuite->Size (dialog, 474, 285);
// OK button
ASSetRect (&rect, 388, 260, 468, 280);
item = sItemSuite->Create (dialog, kItem_OK, kADMTextPushButtonType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "OK");
// cancel button
ASSetRect (&rect, 296, 260, 376, 280);
item = sItemSuite->Create (dialog, kItem_Cancel, kADMTextPushButtonType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "Cancel");
// defaults button
ASSetRect (&rect, 8, 260, 88, 280);
item = sItemSuite->Create (dialog, kItem_Defaults, kADMTextPushButtonType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "Defaults");
// separator
ASSetRect (&rect, 5, 253, 469, 255);
item = sItemSuite->Create (dialog, kItem_Sep1, kADMFrameType, &rect, NULL, NULL, 0);
sItemSuite->SetItemStyle (item, kADMEtchedFrameStyle);
// exposure label
ASSetRect (&rect, 15, 230, 75, 250);
item = sItemSuite->Create (dialog, kItem_ExposureLabel, kADMTextStaticType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "Exposure:");
sItemSuite->SetJustify (item, kADMRightJustify);
// exposure control
ASSetRect (&rect, 80, 230, 160, 250);
item = sItemSuite->Create (dialog, kItem_Exposure, kADMSpinEditType, &rect, NULL, NULL, 0);
// gamma label
ASSetRect (&rect, 165, 230, 225, 250);
item = sItemSuite->Create (dialog, kItem_GammaLabel, kADMTextStaticType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "Gamma:");
sItemSuite->SetJustify (item, kADMRightJustify);
// gamma control
ASSetRect (&rect, 230, 230, 290, 250);
item = sItemSuite->Create (dialog, kItem_Gamma, kADMSpinEditType, &rect, NULL, NULL, 0);
// unmult checkbox
ASSetRect (&rect, 320, 230, 450, 250);
item = sItemSuite->Create (dialog, kItem_Unmult, kADMTextCheckBoxType, &rect, NULL, NULL, 0);
sItemSuite->SetText (item, "Un-Premultiply");
// separator
ASSetRect (&rect, 5, 224, 469, 226);
item = sItemSuite->Create (dialog, kItem_Sep2, kADMFrameType, &rect, NULL, NULL, 0);
sItemSuite->SetItemStyle (item, kADMEtchedFrameStyle);
// preview
ASSetRect (&rect, 5, 5, 469, 212);
item = sItemSuite->Create (dialog, kItem_Preview, kADMUserType, &rect, NULL, NULL, 0);
// if on Windows, swap the OK and Cancel button positions
#if MSWindows
item = sDlogSuite->GetItem (dialog, kItem_OK);
sItemSuite->Move (item, 296, 260);
item = sDlogSuite->GetItem (dialog, kItem_Cancel);
sItemSuite->Move (item, 388, 260);
#endif
}
// ---------------------------------------------------------------------------
// DoDialogOK - ADM callback
// ---------------------------------------------------------------------------
static void ASAPI DoDialogOK (ADMItemRef inItem, ADMNotifierRef inNotifier)
{
ADMDialogRef dialog = (ADMDialogRef) sItemSuite->GetUserData (inItem);
GPtr globals = (GPtr) sDlogSuite->GetUserData (dialog);
ADMItemRef item = NULL;
// apply control values to globals
item = sDlogSuite->GetItem (dialog, kItem_Exposure);
globals->exposure = sItemSuite->GetFloatValue (item);
item = sDlogSuite->GetItem (dialog, kItem_Gamma);
globals->gamma = sItemSuite->GetFloatValue (item);
item = sDlogSuite->GetItem (dialog, kItem_Unmult);
globals->premult = sItemSuite->GetIntValue (item);
// call default handler
sItemSuite->DefaultNotify (inItem, inNotifier);
}
// ---------------------------------------------------------------------------
// DoDialogDefaults - ADM callback
// ---------------------------------------------------------------------------
static void ASAPI DoDialogDefaults (ADMItemRef inItem, ADMNotifierRef inNotifier)
{
ADMDialogRef dialog = (ADMDialogRef) sItemSuite->GetUserData (inItem);
GPtr globals = (GPtr) sDlogSuite->GetUserData (dialog);
ADMItemRef item = NULL;
// reset the globals
globals->DefaultIOSettings();
// update control values
item = sDlogSuite->GetItem (dialog, kItem_Exposure);
sItemSuite->SetFloatValue (item, globals->exposure);
item = sDlogSuite->GetItem (dialog, kItem_Gamma);
sItemSuite->SetFloatValue (item, globals->gamma);
item = sDlogSuite->GetItem (dialog, kItem_Unmult);
sItemSuite->SetIntValue (item, true);
// update the preview
ResamplePreview (globals);
item = sDlogSuite->GetItem (dialog, kItem_Preview);
sItemSuite->Invalidate (item);
}
// ---------------------------------------------------------------------------
// DoDialogControl - ADM callback
// ---------------------------------------------------------------------------
static void ASAPI DoDialogControl (ADMItemRef inItem, ADMNotifierRef inNotifier)
{
ADMDialogRef dialog = (ADMDialogRef) sItemSuite->GetUserData (inItem);
GPtr globals = (GPtr) sDlogSuite->GetUserData (dialog);
ADMItemRef item = NULL;
// call default handler first
sItemSuite->DefaultNotify (inItem, inNotifier);
// apply control values to globals
item = sDlogSuite->GetItem (dialog, kItem_Exposure);
globals->exposure = sItemSuite->GetFloatValue (item);
item = sDlogSuite->GetItem (dialog, kItem_Gamma);
globals->gamma = sItemSuite->GetFloatValue (item);
item = sDlogSuite->GetItem (dialog, kItem_Unmult);
globals->premult = sItemSuite->GetIntValue (item);
// update the preview with the new globals values
ResamplePreview (globals);
item = sDlogSuite->GetItem (dialog, kItem_Preview);
sItemSuite->Invalidate (item);
}
// ---------------------------------------------------------------------------
// DoDialogInit - ADM callback
// ---------------------------------------------------------------------------
static ASErr ASAPI DoDialogInit (ADMDialogRef dialog)
{
GPtr globals = (GPtr) sDlogSuite->GetUserData (dialog);
ADMItemRef item = NULL;
// create dialog
BuildDialog (dialog);
// set dialog title
sDlogSuite->SetText (dialog, "EXR Import Settings");
// set control values
item = sDlogSuite->GetItem (dialog, kItem_Exposure);
sItemSuite->SetUnits (item, kADMNoUnits);
sItemSuite->SetFloatValue (item, globals->exposure);
sItemSuite->SetUserData (item, dialog);
sItemSuite->SetNotifyProc (item, DoDialogControl);
item = sDlogSuite->GetItem (dialog, kItem_Gamma);
sItemSuite->SetUnits (item, kADMNoUnits);
sItemSuite->SetFloatValue (item, globals->gamma);
sItemSuite->SetUserData (item, dialog);
sItemSuite->SetNotifyProc (item, DoDialogControl);
item = sDlogSuite->GetItem (dialog, kItem_Unmult);
sItemSuite->SetIntValue (item, globals->premult);
sItemSuite->SetUserData (item, dialog);
sItemSuite->SetNotifyProc (item, DoDialogControl);
// set up the preview widget
item = sDlogSuite->GetItem (dialog, kItem_Preview);
sItemSuite->SetDrawProc (item, DrawPreview);
sItemSuite->SetUserData (item, dialog);
sItemSuite->SetNotifyProc (item, ClickPreview);
sItemSuite->SetMask (item, kADMButtonUpMask);
sItemSuite->SetTrackProc (item, TrackPreview);
// set "OK" callback
item = sDlogSuite->GetItem (dialog, kItem_OK);
sItemSuite->SetUserData (item, dialog);
sItemSuite->SetNotifyProc (item, DoDialogOK);
// set "Defaults" callback
item = sDlogSuite->GetItem (dialog, kItem_Defaults);
sItemSuite->SetUserData (item, dialog);
sItemSuite->SetNotifyProc (item, DoDialogDefaults);
return kSPNoError;
}
#pragma mark-
// ---------------------------------------------------------------------------
// EXRImportDialog - show the Import Settings dialog
// ---------------------------------------------------------------------------
bool EXRImportDialog (GPtr ioGlobals, SPBasicSuite* inSPBasic, void* inPluginRef)
{
int item = kItem_Cancel;
// get suites
inSPBasic->AcquireSuite (kADMDialogSuite, kADMDialogSuiteVersion5, (void**) &sDlogSuite);
inSPBasic->AcquireSuite (kADMItemSuite, kADMItemSuiteVersion5, (void**) &sItemSuite);
inSPBasic->AcquireSuite (kADMDrawerSuite, kADMDrawerSuiteVersion3, (void**) &sDrawSuite);
inSPBasic->AcquireSuite (kADMImageSuite, kADMImageSuiteVersion2, (void**) &sImageSuite);
inSPBasic->AcquireSuite (kADMTrackerSuite, kADMTrackerSuiteVersion1, (void**) &sTrackSuite);
// show dialog
if (sDlogSuite != NULL && sItemSuite != NULL && sDrawSuite != NULL && sImageSuite != NULL)
{
item = sDlogSuite->Modal ((SPPluginRef) inPluginRef,
"EXR Import Settings",
0,
kADMModalDialogStyle,
DoDialogInit,
ioGlobals,
0);
FreePreview();
}
// release suites
if (sDlogSuite != NULL)
{
inSPBasic->ReleaseSuite (kADMDialogSuite, kADMDialogSuiteVersion5);
sDlogSuite = NULL;
}
if (sItemSuite != NULL)
{
inSPBasic->ReleaseSuite (kADMItemSuite, kADMItemSuiteVersion5);
sItemSuite = NULL;
}
if (sDrawSuite != NULL)
{
inSPBasic->ReleaseSuite (kADMDrawerSuite, kADMDrawerSuiteVersion3);
sDrawSuite = NULL;
}
if (sImageSuite != NULL)
{
inSPBasic->ReleaseSuite (kADMImageSuite, kADMImageSuiteVersion2);
sImageSuite = NULL;
}
if (sTrackSuite != NULL)
{
inSPBasic->ReleaseSuite (kADMTrackerSuite, kADMTrackerSuiteVersion1);
sTrackSuite = NULL;
}
// return true if user hit OK, false if user hit Cancel
return (item == kItem_OK);
}

View File

@ -0,0 +1,14 @@
// ===========================================================================
// EXRImportDialog.h Part of OpenEXR
// ===========================================================================
#pragma once
#include "EXRFormatGlobals.h"
struct SPBasicSuite;
extern bool
EXRImportDialog (GPtr ioGlobals, SPBasicSuite* inSPBasic, void* inPluginRef);

View File

@ -0,0 +1,64 @@
// Microsoft Visual C++ generated resource script.
//
#include "EXRformat-sym.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#define APSTUDIO_HIDDEN_SYMBOLS
#include "windows.h"
#undef APSTUDIO_HIDDEN_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"EXRformat-sym.h\0"
END
2 TEXTINCLUDE
BEGIN
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
"#include ""windows.h""\r\n"
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
#ifdef _DEBUG
#include "tempDebug\EXRFormat.pipl"
#else
#include "tempRelease\EXRFormat.pipl"
#endif
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

View File

@ -0,0 +1,363 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="EXRFormat"
ProjectGUID="{AF6C131F-B34E-45BC-B788-4E59864740C8}"
SccProjectName="SimpleFormat"
SccLocalPath=".">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Release|Win32"
OutputDirectory=".\tempRelease"
IntermediateDirectory=".\tempRelease"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="2"
AdditionalIncludeDirectories="..\rsrc,..\src\framework,..\src\main,..\src\resample,..\src\ui,..\sdk\PhotoshopAPI\ADM,..\sdk\PhotoshopAPI\General,..\sdk\PhotoshopAPI\Photoshop,..\sdk\PhotoshopAPI\Pica_sp,..\sdk\PhotoshopAPI\Resources,..\sdk\PhotoshopUtils\Includes,..\..\OpenEXR\Half,..\..\OpenEXR\Iex,..\..\OpenEXR\Imath,..\..\OpenEXR\IlmImf"
PreprocessorDefinitions="NDEBUG;WIN32;_WINDOWS;MSWindows=1;ISOLATION_AWARE_ENABLED;PLATFORM_WIN32;WIN_ENV"
StringPooling="TRUE"
RuntimeLibrary="0"
EnableFunctionLevelLinking="TRUE"
PrecompiledHeaderFile=""
AssemblerListingLocation=".\tempRelease/"
ObjectFile=".\tempRelease/"
ProgramDataBaseFileName=".\tempRelease/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="0"
CompileAs="0"
DisableSpecificWarnings="4290; 4068; 4244; 4800;"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="zlib_static.lib Halfs.lib Iexs.lib IlmImfs.lib Imaths.lib odbc32.lib odbccp32.lib"
OutputFile="Release\EXRFormat.8bi"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\zlib\;..\..\OpenEXR\vc\vc7\lib\half;..\..\OpenEXR\vc\vc7\lib\iex;..\..\OpenEXR\vc\vc7\lib\ilmimf;..\..\OpenEXR\vc\vc7\lib\imath"
IgnoreAllDefaultLibraries="FALSE"
ProgramDatabaseFile=".\tempRelease/EXRFormat.pdb"
SubSystem="2"
ImportLibrary=".\tempRelease/EXRFormat.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\temp/EXRFormat.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="MSWindows=1"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\tempDebug"
IntermediateDirectory=".\tempDebug"
ConfigurationType="2"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\rsrc,..\src\framework,..\src\main,..\src\resample,..\src\ui,..\sdk\PhotoshopAPI\ADM,..\sdk\PhotoshopAPI\General,..\sdk\PhotoshopAPI\Photoshop,..\sdk\PhotoshopAPI\Pica_sp,..\sdk\PhotoshopAPI\Resources,..\sdk\PhotoshopUtils\Includes,..\..\OpenEXR\Half,..\..\OpenEXR\Iex,..\..\OpenEXR\Imath,..\..\OpenEXR\IlmImf"
PreprocessorDefinitions="_DEBUG;WIN32;_WINDOWS;MSWindows=1;ISOLATION_AWARE_ENABLED;PLATFORM_WIN32;WIN_ENV"
RuntimeLibrary="2"
PrecompiledHeaderFile=""
AssemblerListingLocation=".\tempDebug/"
ObjectFile=".\tempDebug/"
ProgramDataBaseFileName=".\tempDebug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"
CompileAs="0"
DisableSpecificWarnings="4290; 4068; 4244; 4800;"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="zlibd.lib Halfd.lib Iexd.lib IlmImfd.lib Imathd.lib odbc32.lib odbccp32.lib"
OutputFile=".\Debug\EXRFormat.8bi"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\zlib\;..\..\OpenEXR\vc\vc7\lib\half;..\..\OpenEXR\vc\vc7\lib\iex;..\..\OpenEXR\vc\vc7\lib\ilmimf;..\..\OpenEXR\vc\vc7\lib\imath"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\tempDebug/EXRFormat.pdb"
SubSystem="2"
ImportLibrary=".\tempDebug/EXRFormat.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
PreprocessorDefinitions="_DEBUG"
MkTypLibCompatible="TRUE"
SuppressStartupBanner="TRUE"
TargetEnvironment="1"
TypeLibraryName=".\temp/EXRFormat.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG,MSWindows=1"
Culture="1033"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Main"
Filter="">
<File
RelativePath="..\src\main\ExrFormatGlobals.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\main\EXRFormatGlobals.h">
</File>
<File
RelativePath="..\src\main\EXRFormatPlugin.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\main\EXRFormatPlugin.h">
</File>
<File
RelativePath="..\src\resample\EXRResample.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\resample\EXRResample.h">
</File>
<File
RelativePath="..\src\main\RefNumIO.cpp">
</File>
<File
RelativePath="..\src\main\RefNumIO.h">
</File>
</Filter>
<Filter
Name="Framework"
Filter="">
<File
RelativePath="..\src\framework\PSAutoBuffer.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\framework\PSAutoBuffer.h">
</File>
<File
RelativePath="..\src\framework\PSFormatGlobals.h">
</File>
<File
RelativePath="..\src\framework\PSFormatPlugin.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\framework\PSFormatPlugin.h">
</File>
</Filter>
<Filter
Name="UI"
Filter="">
<File
RelativePath="..\src\ui\EXRExportDialog.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\ui\EXRExportDialog.h">
</File>
<File
RelativePath="..\src\ui\EXRImportDialog.cpp">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=""
BrowseInformation="1"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
BrowseInformation="1"/>
</FileConfiguration>
</File>
<File
RelativePath="..\src\ui\EXRImportDialog.h">
</File>
</Filter>
<Filter
Name="Resources"
Filter="">
<File
RelativePath="..\rsrc\EXRFormat.r">
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCustomBuildTool"
Description="Compiling PiPL resource..."
CommandLine="cl /I..\sdk\PhotoshopAPI\General /I..\sdk\PhotoshopAPI\PICA_SP /I..\sdk\PhotoshopAPI\Photoshop /I..\sdk\PhotoshopAPI\Resources /EP /DMSWindows=1 /Tc&quot;$(InputPath)&quot; &gt; &quot;$(IntDir)&quot;\\&quot;$(InputName)&quot;.rr
..\sdk\resources\cnvtpipl &quot;$(IntDir)&quot;\\&quot;$(InputName)&quot;.rr &quot;$(IntDir)&quot;\\&quot;$(InputName)&quot;.pipl
del &quot;$(IntDir)&quot;\\&quot;$(InputName)&quot;.rr
"
Outputs="$(IntDir)\$(InputName).pipl"/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCustomBuildTool"
Description="Compiling PiPL resource..."
CommandLine="cl /I..\sdk\PhotoshopAPI\General /I..\sdk\PhotoshopAPI\PICA_SP /I..\sdk\PhotoshopAPI\Photoshop /I..\sdk\PhotoshopAPI\Resources /EP /DMSWindows=1 /Tc&quot;$(InputPath)&quot; &gt; &quot;$(IntDir)&quot;\\&quot;$(InputName)&quot;.rr
..\sdk\resources\cnvtpipl &quot;$(IntDir)&quot;\\&quot;$(InputName)&quot;.rr &quot;$(IntDir)&quot;\\&quot;$(InputName)&quot;.pipl
del &quot;$(IntDir)&quot;\\&quot;$(InputName)&quot;.rr
"
Outputs="$(IntDir)\$(InputName).pipl"/>
</FileConfiguration>
</File>
<File
RelativePath="EXRFormat.rc">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,19 @@
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by EXRFormat.rc
//
#define IDD_ABOUT 16000
#define FORMATPARAMS 16000
#define IDC_STATIC -1
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1007
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif