JCWColourFilter Class Reference

Load's Jason's private palette file format. More...

#include <coplfilr.h>

Inheritance diagram for JCWColourFilter:

PaletteFilter Filter ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 JCWColourFilter ()
 Constructor.
 ~JCWColourFilter ()
 Destructor.
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 Attributes

UINT32 m_NumToImport
BOOL m_ColoursAreSpots

Private Member Functions

 CC_DECLARE_DYNAMIC (JCWColourFilter)

Detailed Description

Load's Jason's private palette file format.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/8/96

Definition at line 375 of file coplfilr.h.


Constructor & Destructor Documentation

JCWColourFilter::JCWColourFilter  ) 
 

Constructor.

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/8/96
Parameters:
- [INPUTS]
Returns:
-
The JCWPalette filter loads my own personal file format, which I invented to store PANTONE libraries in a reasonably sensible form.

See also:
PaletteFilter

Definition at line 2328 of file coplfilr.cpp.

02329 {
02330     // Set up filter descriptions.
02331     FilterName.Load(_R(IDT_FILTERNAME_JCWPALETTE));
02332     FilterInfo.Load(_R(IDT_FILTERINFO_JCWPALETTE));
02333     FilterID = FILTERID_JCWPALETTE;
02334 
02335 #ifndef STANDALONE
02336     Flags.CanImport = TRUE;
02337 #else
02338     Flags.CanImport = FALSE;
02339 #endif
02340 
02341     // Never export, 'cos JCW is the only dude who knows the format! ;-)
02342     Flags.CanExport = FALSE;
02343 
02344     // And never show this filter in the UI
02345     Flags.ShowFilter = FALSE;
02346 
02347     m_ColoursAreSpots = FALSE;
02348     m_NumToImport = 0;
02349 }

JCWColourFilter::~JCWColourFilter  ) 
 

Destructor.

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

Definition at line 2362 of file coplfilr.cpp.

02363 {
02364 }


Member Function Documentation

JCWColourFilter::CC_DECLARE_DYNAMIC JCWColourFilter   )  [private]
 

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

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

Author:
Jason_Williams (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/8/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 2400 of file coplfilr.cpp.

02401 {
02402 PORTNOTE("byteorder", "TODO: Check byte ordering")
02403     // Adobe colour swatchs appear to be just raw data.  We have to go on file extension
02404     ERROR2IF(pOILFilter==NULL, 0, "No oil filter present");
02405 
02406     if (HeaderSize < 4)
02407     {
02408         TRACE( _T("JCWColourFilter needs 4 or more bytes in HowCompatible\n"));
02409         return 0;
02410     }
02411 
02412     if (((JCWColourOILFilter*)pOILFilter)->HowCompatible(Filename))
02413     {
02414         BYTE *Hdr = (BYTE *)HeaderStart;
02415         if (Hdr[0] == 'J' && Hdr[1] == 'C' && Hdr[2] == 'W' && Hdr[3] > 0)
02416             return(9);
02417     }
02418 
02419     return(0);
02420 }

BOOL JCWColourFilter::ImportPalette  )  [virtual]
 

Imports colours from an Adobe colour swatch.

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

Implements PaletteFilter.

Definition at line 2465 of file coplfilr.cpp.

02466 {
02467     BOOL ok = StartPercentage(m_NumToImport);
02468     UINT32 Index = 0;
02469 
02470     BYTE ColourDef[8];
02471     String_64 Name;
02472 
02473     while (ok && m_pImportFile->good() && Index < m_NumToImport)
02474     {
02475         // Read the values for this colour from the file
02476         m_pImportFile->read(ColourDef, 8);
02477         m_pImportFile->read((TCHAR *)Name, 16);
02478 
02479         // Add the colour to the imported colours list
02480         if (m_pImportFile->good())
02481         {
02482             ColourCMYK NewColour;
02483             NewColour.Cyan      = (double) ((ColourDef[0] + (ColourDef[1] << 8))) / 10000.0;
02484             NewColour.Magenta   = (double) ((ColourDef[2] + (ColourDef[3] << 8))) / 10000.0;
02485             NewColour.Yellow    = (double) ((ColourDef[4] + (ColourDef[5] << 8))) / 10000.0;
02486             NewColour.Key       = (double) ((ColourDef[6] + (ColourDef[7] << 8))) / 10000.0;
02487 
02488             if (ImportIntoGallery)
02489             {
02490                 // Add the colour to the gallery, as either a process or spot colour (as appropriate)
02491                 // Every 7th colour has a newline after it
02492                 ok = AddColourToGallery(((m_ColoursAreSpots) ? PalettePrefix_PantoneSpot : PalettePrefix_Pantone),
02493                                             &Name, (ColourGeneric *)&NewColour, COLOURMODEL_CMYK, (Index % 7 == 6),
02494                                             m_ColoursAreSpots);
02495             }
02496             else
02497                 ok = m_pNewColours->AddColour(&Name, &NewColour);
02498         }
02499 
02500         SetPercentage(Index++);
02501     }
02502 
02503     return ok && m_pImportFile->good();
02504 }

BOOL JCWColourFilter::Init void   )  [virtual]
 

Initialise the filter, attaches OIL filter.

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

Implements Filter.

Definition at line 2378 of file coplfilr.cpp.

02379 {
02380     // Get the OILFilter object
02381     pOILFilter = new JCWColourOILFilter(this);
02382     
02383     return (pOILFilter != NULL);
02384 }

BOOL JCWColourFilter::PostImport void   )  [virtual]
 

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

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

Implements PaletteFilter.

Definition at line 2517 of file coplfilr.cpp.

02518 {
02519     // Nothing to do, no cleanup required.
02520     return TRUE;
02521 }

BOOL JCWColourFilter::PreImport  )  [virtual]
 

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

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

Implements PaletteFilter.

Definition at line 2433 of file coplfilr.cpp.

02434 {
02435     ERROR2IF( m_pImportFile==NULL, FALSE, "NULL pointer");
02436 
02437     // Read info out of the header.
02438     BYTE HeaderBuffer[8];
02439     m_pImportFile->read(HeaderBuffer, 8);
02440 
02441     if (m_pImportFile->good() && HeaderBuffer[0] == 'J' && HeaderBuffer[1] == 'C' && HeaderBuffer[2] == 'W' && HeaderBuffer[3] == 1)
02442     {
02443         m_NumToImport = HeaderBuffer[4] + (HeaderBuffer[5] << 8);
02444         m_ColoursAreSpots = (HeaderBuffer[6] & 0x01) ? TRUE : FALSE;
02445         // HeaderBuffer[7] is currently reserved, and set to zero
02446         return TRUE;
02447     }
02448 
02449     m_NumToImport = 0;
02450     return FALSE;
02451 }


Member Data Documentation

BOOL JCWColourFilter::m_ColoursAreSpots [protected]
 

Definition at line 395 of file coplfilr.h.

UINT32 JCWColourFilter::m_NumToImport [protected]
 

Definition at line 394 of file coplfilr.h.


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