MSPaletteFilter Class Reference

Microsoft Windows palette filter. More...

#include <coplfilr.h>

Inheritance diagram for MSPaletteFilter:

PaletteFilter Filter ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 MSPaletteFilter ()
 Constructor for a Microsoft Windows palette filter.
 ~MSPaletteFilter ()
 Destructor for a Microsoft Windows palette filter.
BOOL Init ()
 Initialise the Windows palette 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 a MS palette file.
virtual BOOL PostImport ()
 Called to allow post import cleanup (if required) for this filter.

Protected Attributes

UINT32 m_NumToImport

Private Member Functions

 CC_DECLARE_DYNAMIC (MSPaletteFilter)

Detailed Description

Microsoft Windows palette filter.

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

Definition at line 210 of file coplfilr.h.


Constructor & Destructor Documentation

MSPaletteFilter::MSPaletteFilter  ) 
 

Constructor for a Microsoft Windows palette filter.

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

Definition at line 1527 of file coplfilr.cpp.

01528 {
01529     // Set up filter descriptions.
01530     FilterName.Load(_R(IDT_FILTERNAME_WINDOWSPALETTE));
01531     FilterInfo.Load(_R(IDT_FILTERINFO_WINDOWSPALETTE));
01532     FilterID = FILTERID_MSPALETTE;
01533 
01534 #ifndef STANDALONE
01535     Flags.CanImport = TRUE;
01536     Flags.CanExport = FALSE;
01537 #else
01538     Flags.CanImport = FALSE;
01539     Flags.CanExport = FALSE;
01540 #endif
01541 
01542 #ifndef DO_EXPORT
01543     Flags.CanExport = FALSE;
01544 #endif
01545 }

MSPaletteFilter::~MSPaletteFilter  ) 
 

Destructor for a Microsoft Windows palette filter.

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

Definition at line 1558 of file coplfilr.cpp.

01559 {
01560 }


Member Function Documentation

MSPaletteFilter::CC_DECLARE_DYNAMIC MSPaletteFilter   )  [private]
 

INT32 MSPaletteFilter::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:
30/4/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 1596 of file coplfilr.cpp.

01597 {
01598 PORTNOTE("byteorder", "TODO: Check byte ordering")
01599     // MS palette files have a well defined format.  Bytes 0-3 = "RIFF".  Bytes 8-15 = "PAL data"
01600 
01601     // Check we have enough of the file header to look at
01602     if (HeaderSize < 16)
01603     {
01604         TRACE( _T("MSPalette filter needs 16+ bytes in HowCompatible\n"));
01605         return 0;
01606     }
01607 
01608     if (    HeaderStart[0] == 0x52 &&       // R
01609             HeaderStart[1] == 0x49 &&       // I
01610             HeaderStart[2] == 0x46 &&       // F
01611             HeaderStart[3] == 0x46 &&       // F
01612             HeaderStart[8] == 0x50 &&       // P
01613             HeaderStart[9] == 0x41 &&       // A
01614             HeaderStart[10] == 0x4C &&      // L
01615             HeaderStart[11] == 0x20 &&      // <Space>
01616             HeaderStart[12] == 0x64 &&      // d
01617             HeaderStart[13] == 0x61 &&      // a
01618             HeaderStart[14] == 0x74 &&      // t
01619             HeaderStart[15] == 0x61 )       // a
01620         return 10;
01621     else
01622         return 0;
01623 }

BOOL MSPaletteFilter::ImportPalette  )  [virtual]
 

Imports colours from a MS palette file.

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

Implements PaletteFilter.

Definition at line 1667 of file coplfilr.cpp.

01668 {
01669     UINT32 ColoursToRead = m_NumToImport;
01670     BOOL ok = StartPercentage(m_NumToImport);
01671 
01672     while ( ok && (ColoursToRead > 0) && m_pImportFile->good() )
01673     {
01674         // Read the RGB values for this colour from the file
01675         BYTE ColourDef[4];
01676         m_pImportFile->read(ColourDef, 4);
01677 
01678         // Add the colour to the imported colours list
01679         if (m_pImportFile->good())
01680             ok = ProcessRGBColour(ColourDef[0]/(double)0xff, ColourDef[1]/(double)0xff, ColourDef[2]/(double)0xff);
01681 
01682         SetPercentage(m_NumToImport-ColoursToRead);
01683         ColoursToRead--;
01684     }
01685 
01686     return ok && m_pImportFile->good();
01687 }

BOOL MSPaletteFilter::Init void   )  [virtual]
 

Initialise the Windows palette filter, attaches OIL filter.

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

Implements Filter.

Definition at line 1574 of file coplfilr.cpp.

01575 {
01576     // Get the OILFilter object
01577     pOILFilter = new MSPaletteOILFilter(this);
01578     
01579     return (pOILFilter != NULL);
01580 }

BOOL MSPaletteFilter::PostImport void   )  [virtual]
 

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

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

Implements PaletteFilter.

Definition at line 1700 of file coplfilr.cpp.

01701 {
01702     // Nothing to do, no cleanup required.
01703     return TRUE;
01704 }

BOOL MSPaletteFilter::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:
1/5/96
Parameters:
- [INPUTS]
Sets import member vars [OUTPUTS]
Returns:
TRUE/FALSE for success/error

Implements PaletteFilter.

Definition at line 1636 of file coplfilr.cpp.

01637 {
01638     ERROR2IF( m_pImportFile==NULL, FALSE, "NULL pointer");
01639 
01640     // Read info out of the header.
01641     BYTE HeaderBuffer[24];
01642     m_pImportFile->read(HeaderBuffer, 24);
01643 
01644     if (m_pImportFile->good())
01645     {
01646         m_NumToImport = *((WORD*)(HeaderBuffer+22));
01647         return TRUE;
01648     }
01649     else
01650     {
01651         m_NumToImport = 0;
01652         return FALSE;
01653     }
01654 }


Member Data Documentation

UINT32 MSPaletteFilter::m_NumToImport [protected]
 

Definition at line 229 of file coplfilr.h.


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