PGMFilter Class Reference

Encapsulates a Unix PGM import filter. More...

#include <ppmfiltr.h>

Inheritance diagram for PGMFilter:

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

Public Member Functions

 PGMFilter ()
 Constructor for an PGMFilter 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 PBM 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 (PGMFilter)

Detailed Description

Encapsulates a Unix PGM import filter.

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

Definition at line 235 of file ppmfiltr.h.


Constructor & Destructor Documentation

PGMFilter::PGMFilter  ) 
 

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

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

Definition at line 301 of file ppmfiltr.cpp.

00301                      : BasePMFilter()
00302 {
00303     ImportMsgID = _R(IDN_IMPORTMSG_PGM);
00304     Flags.CanImport = TRUE;
00305     Flags.CanExport = FALSE;
00306     FilterID = FILTERID_PGM;
00307 
00308     ExportRegion = NULL;
00309     ExportMsgID = _R(IDN_EXPORTMSG_PGM);            // "Preparing PGM file..."
00310 
00311     ExportingMsgID = _R(IDN_EXPORTINGMSG_PGM);      // "Exporting PGM file..."
00312 
00313 //  CurrentSelection = DRAWING;
00314 }


Member Function Documentation

PGMFilter::CC_DECLARE_DYNAMIC PGMFilter   )  [private]
 

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

To see if the header of a PBM 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 356 of file ppmfiltr.cpp.

00357 {
00358     if (
00359         (camStrncmp(pHeader, _T("P2"), 2) == 0) ||      // ASCII PGM
00360         (camStrncmp(pHeader, _T("P5"), 2) == 0)         // BINARY PGM
00361        )
00362     {
00363         // finding PBM should be good enough to determine that there is
00364         // a high chance that this is the right file.
00365 
00366         return TRUE;
00367     }
00368 
00369     return FALSE;
00370 }

BOOL PGMFilter::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 329 of file ppmfiltr.cpp.

00330 {
00331     // Get the OILFilter object
00332     pOILFilter = new PGMOILFilter(this);
00333     if (pOILFilter==NULL)
00334         return FALSE;
00335 
00336     // Load the description strings
00337     FilterName.Load(_R(IDN_PGM_FILTERNAME));
00338     FilterInfo.Load(_R(IDN_PGM_FILTERINFO));
00339 
00340     // All ok
00341     return TRUE;
00342 }

BOOL PGMFilter::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 [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 1688 of file ppmfiltr.cpp.

01689 {
01690     // By default, do not move onto the next pixel
01691     *NextPixel = FALSE;
01692 
01693     // Work out what to do with the data
01694     switch (RGBBits)
01695     {
01696         case 8:
01697             // Poke those RGB bytes into the next three bytes in memory
01698             *((*pData)++) = Number & RGBColours;
01699             // Always move onto the next pixel
01700             *NextPixel = TRUE;
01701             break;
01702 
01703         case 4:
01704             // 4bpp so we must put the data into either the high or low nibble.
01705             // This will be dependent on whether we are on an odd or even pixel.
01706             // So test the LSBit of the curx, if set we will be odd.
01707             // Only move onto next byte every other pixel hence curx/2.
01708             // Get whole present byte 
01709             if (x & 1)
01710             {
01711                 **(pData) = ((**(pData)) & 0xF0) | (Number & 0x0F);      // add into low nibble 
01712                 *NextPixel = FALSE;
01713             }
01714             else
01715             {
01716                 **(pData) = ((**(pData)) & 0x0F) | ((Number << 4) & 0xF0); // add into top nibble
01717                 (*pData)++;
01718                 *NextPixel = TRUE;
01719             }
01720             break;
01721 
01722         default:
01723             // Shouldn't get here so error 2
01724             ERROR2(FALSE, "PGMFilter::ReadDataIntoBitmap bad ColoursPerRGB");
01725             break;
01726     }
01727 
01728     return TRUE;    
01729 }


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