PPMFilter Class Reference

Encapsulates a Unix PPM import filter. More...

#include <ppmfiltr.h>

Inheritance diagram for PPMFilter:

BasePMFilter BaseBitmapFilter BitmapFilter Filter ListItem CCObject SimpleCCObject List of all members.

Public Member Functions

 PPMFilter ()
 Constructor for an PPMFilter object. The object should be initialised before use.
BOOL Init ()
 Initialise an PPMFilter object.

Protected Member Functions

virtual BOOL CheckString (TCHAR *pHeader)
 To see if the header of a PPM file is correct or not.
virtual BOOL ReadDataIntoBitmap (INT32 Number, INT32 *Count, LPBYTE *pData, BOOL *NextPixel)
 Place the number read in into the specified place in the bitmap.

Private Member Functions

 CC_DECLARE_DYNAMIC (PPMFilter)

Detailed Description

Encapsulates a Unix PPM import filter.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/11/95

Definition at line 211 of file ppmfiltr.h.


Constructor & Destructor Documentation

PPMFilter::PPMFilter  ) 
 

Constructor for an PPMFilter object. The object should be initialised before use.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/11/95
See also:
PPMFilter::Init

Definition at line 195 of file ppmfiltr.cpp.

00195                      : BasePMFilter()
00196 {
00197     ImportMsgID = _R(IDN_IMPORTMSG_PPM);
00198     Flags.CanImport = TRUE;
00199     Flags.CanExport = FALSE;
00200     FilterID = FILTERID_PPM;
00201 
00202     ExportRegion = NULL;
00203     ExportMsgID = _R(IDN_EXPORTMSG_PPM);            // "Preparing PPM file..."
00204 
00205     ExportingMsgID = _R(IDN_EXPORTINGMSG_PPM);      // "Exporting PPM file..."
00206 
00207 //  CurrentSelection = DRAWING;
00208 }


Member Function Documentation

PPMFilter::CC_DECLARE_DYNAMIC PPMFilter   )  [private]
 

BOOL PPMFilter::CheckString TCHAR pHeader  )  [protected, virtual]
 

To see if the header of a PPM file is correct or not.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/11/95
Returns:
TRUE if the filter reckonises the string, FALSE otherwise.
See also:
BasePMFilter::HowCompatible;

Reimplemented from BasePMFilter.

Definition at line 250 of file ppmfiltr.cpp.

00251 {
00252     if (
00253         (camStrncmp(pHeader, _T("P3"), 2) == 0) ||      // ASCII PPM
00254         (camStrncmp(pHeader, _T("P6"), 2) == 0)         // BINARY PPM
00255        )
00256     {
00257         // finding PBM should be good enough to determine that there is
00258         // a high chance that this is the right file.
00259 
00260         return TRUE;
00261     }
00262 
00263     return FALSE;
00264 }

BOOL PPMFilter::Init void   )  [virtual]
 

Initialise an PPMFilter object.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/11/95
Returns:
TRUE if the filter was initialised ok, FALSE otherwise.

Errors: Will fail if not enough memory to initialise.

See also:
EPSStack

Reimplemented from BasePMFilter.

Definition at line 223 of file ppmfiltr.cpp.

00224 {
00225     // Get the OILFilter object
00226     pOILFilter = new PPMOILFilter(this);
00227     if (pOILFilter==NULL)
00228         return FALSE;
00229 
00230     // Load the description strings
00231     FilterName.Load(_R(IDN_PPM_FILTERNAME));
00232     FilterInfo.Load(_R(IDN_PPM_FILTERINFO));
00233 
00234     // All ok
00235     return TRUE;
00236 }

BOOL PPMFilter::ReadDataIntoBitmap INT32  Number,
INT32 *  Count,
LPBYTE pData,
BOOL *  NextPixel
[protected, virtual]
 

Place the number read in into the specified place in the bitmap.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/11/95
Parameters:
Number value read in; [INPUTS]
Count can be used to distinquish between R, G and B data (can be incremented) [OUTPUTS] pData place to store the data (can be incremented)
Returns:
TRUE if everything went ok, FALSE otherwise.
See also:
BasePMFilter::ReadBinaryFromFile; BasePMFilterReadASCIIFromFile;

Reimplemented from BasePMFilter.

Definition at line 1601 of file ppmfiltr.cpp.

01602 {
01603     // By default, do not move onto the next pixel
01604     *NextPixel = FALSE;
01605 
01606     BOOL ok = TRUE;
01607 
01608     BYTE value  = 0;
01609 
01610     // Now work out what to do with this
01611     switch (*Count)
01612     {
01613         case 0:
01614             Red = Number;
01615             break;
01616 
01617         case 1:
01618             Green = Number;
01619             break;
01620 
01621         case 2:
01622             Blue = Number;
01623             break;
01624 
01625         default:
01626             // Flag a bad token so that we stop parsing this line
01627             ok = FALSE;
01628             TRACEUSER( "Neville", _T("PPM: Didn't expect to get this number ('%d')\n"), Number);
01629             break;
01630     }
01631     
01632     // Increment our count and see if we have enough info yet
01633     (*Count)++;
01634 
01635     if ((*Count) == 3)
01636     {
01637         // We have read in the three colour components so stuff
01638         // them in the required byte
01639         // Now work out what to do with this
01640         switch (RGBBits)
01641         {
01642             case 8:
01643                 // Poke those RGB bytes into the next three bytes in memory
01644                 *((*pData)++) = Blue & RGBColours;
01645                 *((*pData)++) = Green & RGBColours;
01646                 *((*pData)++) = Red & RGBColours;
01647                 break;
01648 
01649             case 2:
01650                 value = (Red & RGBColours);
01651                 value = (value << RGBBits) + (Green & RGBColours);
01652                 value = (value << RGBBits) + (Blue & RGBColours);
01653                 *((*pData)++) = value;
01654                 break;
01655 
01656             default:
01657                 // Shouldn't get here so error 2
01658                 ERROR2(FALSE, "PPMFilter::ReadDataIntoBitmap bad ColoursPerRGB");
01659                 break;
01660         }
01661 
01662         // reset the count
01663         *Count = 0;
01664 
01665         // Say we want to move onto the next pixel
01666         *NextPixel = TRUE;
01667     }
01668 
01669     return ok;  
01670 }


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