AdobeColourSwatchFilter Class Reference

Adobe Colour Swatch palette filter. More...

#include <coplfilr.h>

Inheritance diagram for AdobeColourSwatchFilter:

PaletteFilter Filter ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 AdobeColourSwatchFilter ()
 Constructor for a Adobe Colour Swatch palette filter.
 ~AdobeColourSwatchFilter ()
 Destructor for a Adobe Colour Swatch palette filter.
BOOL Init ()
 Initialise the filter, attaches OIL filter.
INT32 HowCompatible (PathName &Filename, ADDR HeaderStart, UINT32 HeaderSize, UINT32 FileSize)
 Examines a file to see how compatable it is with this filter.
virtual BOOL PreImport ()
 Reads the MS palette file header to see how many colours are in the file.
virtual BOOL ImportPalette ()
 Imports colours from an Adobe colour swatch.
virtual BOOL PostImport ()
 Called to allow post import cleanup (if required) for this filter.

Protected Member Functions

WORD ReverseWord (WORD Orig)
 WORDs in swatch files have the wrong byte order. This function swaps the bytes.

Protected Attributes

UINT32 m_NumToImport
BOOL m_MetUnknownModel

Private Member Functions

 CC_DECLARE_DYNAMIC (AdobeColourSwatchFilter)

Detailed Description

Adobe Colour Swatch palette filter.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/5/96

Definition at line 298 of file coplfilr.h.


Constructor & Destructor Documentation

AdobeColourSwatchFilter::AdobeColourSwatchFilter  ) 
 

Constructor for a Adobe Colour Swatch palette filter.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/5/96
Parameters:
- [INPUTS]
Returns:
-
See also:
PaletteFilter

Definition at line 1882 of file coplfilr.cpp.

01883 {
01884     // Set up filter descriptions.
01885     FilterName.Load(_R(IDT_FILTERNAME_ADOBECOLOURSWATCH));
01886     FilterInfo.Load(_R(IDT_FILTERINFO_ADOBECOLOURSWATCH));
01887     FilterID = FILTERID_ADOBECOLOURSWATCH;
01888 
01889 #ifndef STANDALONE
01890     Flags.CanImport = TRUE;
01891     Flags.CanExport = FALSE;
01892 #else
01893     Flags.CanImport = FALSE;
01894     Flags.CanExport = FALSE;
01895 #endif
01896 
01897 #ifndef DO_EXPORT
01898     Flags.CanExport = FALSE;
01899 #endif
01900 }

AdobeColourSwatchFilter::~AdobeColourSwatchFilter  ) 
 

Destructor for a Adobe Colour Swatch palette filter.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/5/96
Parameters:
- [INPUTS]
Returns:
-
See also:
PaletteFilter

Definition at line 1913 of file coplfilr.cpp.

01914 {
01915 }


Member Function Documentation

AdobeColourSwatchFilter::CC_DECLARE_DYNAMIC AdobeColourSwatchFilter   )  [private]
 

INT32 AdobeColourSwatchFilter::HowCompatible PathName Filename,
ADDR  HeaderStart,
UINT32  HeaderSize,
UINT32  FileSize
[virtual]
 

Examines a file to see how compatable it is with this filter.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/5/96
Parameters:
Filename - the file being loads (allows checks on extensions). [INPUTS] HeaderStart - address of some bytes from the start of the file HeaderSize - the number of bytes at HeaderStart FileSize - the total length of the file
Returns:
Between 10 (Mine!) and 0 (Not Mine!) inclusive
See also:
Filter::HowCompatible

Reimplemented from Filter.

Definition at line 1951 of file coplfilr.cpp.

01952 {
01953 PORTNOTE("byteorder", "TODO: Check byte ordering")
01954     // Adobe colour swatchs appear to be just raw data.  We have to go on file extension
01955     ERROR2IF(pOILFilter==NULL, 0, "No oil filter present");
01956     return ((AdobeColourSwatchOILFilter*)pOILFilter)->HowCompatible(Filename);
01957 }

BOOL AdobeColourSwatchFilter::ImportPalette  )  [virtual]
 

Imports colours from an Adobe colour swatch.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/5/96
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE/FALSE for success/error

Implements PaletteFilter.

Definition at line 2005 of file coplfilr.cpp.

02006 {
02007     ERROR2IF(m_pImportFile==NULL, FALSE, "NULL pointer");
02008 
02009     BOOL ok = StartPercentage(m_NumToImport);
02010     UINT32 StillToRead = m_NumToImport;
02011 
02012     while ( ok && m_pImportFile->good() && StillToRead>0 )
02013     {
02014         // Read the values for this colour from the file
02015         WORD ColourDef[5];
02016         m_pImportFile->read(ColourDef, 10);
02017 
02018         // Add the colour to the imported colours list
02019         if (m_pImportFile->good())
02020         {
02021             switch (ReverseWord(ColourDef[0]))
02022             {
02023                 case 0 :    ok = ProcessRGBColour(ReverseWord(ColourDef[1])/(double)0xFFFF,
02024                                                     ReverseWord(ColourDef[2])/(double)0xFFFF,
02025                                                     ReverseWord(ColourDef[3])/(double)0xFFFF );
02026                             break;
02027 
02028                 case 1 :    ok = ProcessHSVColour(ReverseWord(ColourDef[1])/(double)0xFFFF,
02029                                                     ReverseWord(ColourDef[2])/(double)0xFFFF,
02030                                                     ReverseWord(ColourDef[3])/(double)0xFFFF );
02031                             break;
02032 
02033                 case 2 :    ok = ProcessCMYKColour((0xFFFF-ReverseWord(ColourDef[1]))/(double)0xFFFF,
02034                                                     (0xFFFF-ReverseWord(ColourDef[2]))/(double)0xFFFF,
02035                                                     (0xFFFF-ReverseWord(ColourDef[3]))/(double)0xFFFF,
02036                                                     (0xFFFF-ReverseWord(ColourDef[4]))/(double)0xFFFF );
02037                             break;
02038 
02039                 case 7 :    ok = ProcessLabColour(ReverseWord(ColourDef[1])/100.0,
02040                                                     (signed short)(ReverseWord(ColourDef[2]))/100.0,
02041                                                     (signed short)(ReverseWord(ColourDef[3]))/100.0 );
02042                             break;
02043 
02044                 case 8 :    ok = ProcessGreyColour((0x2710-ReverseWord(ColourDef[1]))/10000.0);
02045                             break;
02046 
02047                 default :   if (!m_MetUnknownModel)
02048                             {
02049                                 InformWarning(_R(IDE_PALETTEIMPORT_ACOUNKNOWN));
02050                                 m_MetUnknownModel = TRUE;
02051                             }
02052                             break;
02053             }
02054         }
02055 
02056         SetPercentage(m_NumToImport-StillToRead);
02057         StillToRead--;
02058     }
02059 
02060     return ok && m_pImportFile->good();
02061 }

BOOL AdobeColourSwatchFilter::Init void   )  [virtual]
 

Initialise the filter, attaches OIL filter.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/5/96
Parameters:
- [INPUTS]
Returns:
TRUE for successful init, FALSE if error occured
See also:
Filter::Init

Implements Filter.

Definition at line 1929 of file coplfilr.cpp.

01930 {
01931     // Get the OILFilter object
01932     pOILFilter = new AdobeColourSwatchOILFilter(this);
01933     
01934     return (pOILFilter != NULL);
01935 }

BOOL AdobeColourSwatchFilter::PostImport void   )  [virtual]
 

Called to allow post import cleanup (if required) for this filter.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/5/96
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE/FALSE for success/error

Implements PaletteFilter.

Definition at line 2074 of file coplfilr.cpp.

02075 {
02076     // Nothing to do, no cleanup required.
02077     return TRUE;
02078 }

BOOL AdobeColourSwatchFilter::PreImport  )  [virtual]
 

Reads the MS palette file header to see how many colours are in the file.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/5/96
Parameters:
- [INPUTS]
Sets import member vars [OUTPUTS]
Returns:
TRUE/FALSE for success/error

Implements PaletteFilter.

Definition at line 1970 of file coplfilr.cpp.

01971 {
01972     ERROR2IF( m_pImportFile==NULL, FALSE, "NULL pointer");
01973     ERROR3IF( sizeof(WORD)!=2, "How come a WORD is not two bytes?");
01974 
01975     m_MetUnknownModel = FALSE;
01976 
01977     // Read info out of the header.
01978     WORD HeaderBuffer[2];
01979     m_pImportFile->read(HeaderBuffer, 4);
01980 
01981     if (m_pImportFile->good())
01982     {
01983         m_NumToImport = ReverseWord(HeaderBuffer[1]);
01984         return TRUE;
01985     }
01986     else
01987     {
01988         m_NumToImport = 0;
01989         return FALSE;
01990     }
01991 }

WORD AdobeColourSwatchFilter::ReverseWord WORD  Orig  )  [protected]
 

WORDs in swatch files have the wrong byte order. This function swaps the bytes.

Author:
Peter_Arnold (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/5/96
Parameters:
Orig - a word with the 'wrong' byte order [INPUTS]
- [OUTPUTS]
Returns:
A word with the two bytes switched

Definition at line 2091 of file coplfilr.cpp.

02092 {
02093     BYTE NewLow = (Orig & 0xFF00) >> 8;
02094     Orig = Orig << 8;
02095     
02096     return Orig | NewLow;
02097 }


Member Data Documentation

BOOL AdobeColourSwatchFilter::m_MetUnknownModel [protected]
 

Definition at line 321 of file coplfilr.h.

UINT32 AdobeColourSwatchFilter::m_NumToImport [protected]
 

Definition at line 320 of file coplfilr.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:49:51 2007 for Camelot by  doxygen 1.4.4