PBMFilter Class Reference

Encapsulates a Unix PBM import filter. More...

#include <ppmfiltr.h>

Inheritance diagram for PBMFilter:

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

Public Member Functions

 PBMFilter ()
 Constructor for an PBMFilter object. The object should be initialised before use.
BOOL Init ()
 Initialise an PBMFilter 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 (PBMFilter)

Detailed Description

Encapsulates a Unix PBM import filter.

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

Definition at line 259 of file ppmfiltr.h.


Constructor & Destructor Documentation

PBMFilter::PBMFilter  ) 
 

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

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

Definition at line 408 of file ppmfiltr.cpp.

00408                      : BasePMFilter()
00409 {
00410     ImportMsgID = _R(IDN_IMPORTMSG_PBM);
00411     Flags.CanImport = TRUE;
00412     Flags.CanExport = FALSE;
00413     FilterID = FILTERID_PBM;
00414 
00415     ExportRegion = NULL;
00416     ExportMsgID = _R(IDN_EXPORTMSG_PBM);            // "Preparing PBM file..."
00417 
00418     ExportingMsgID = _R(IDN_EXPORTINGMSG_PBM);      // "Exporting PBM file..."
00419 
00420 //  CurrentSelection = DRAWING;
00421 }


Member Function Documentation

PBMFilter::CC_DECLARE_DYNAMIC PBMFilter   )  [private]
 

BOOL PBMFilter::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 464 of file ppmfiltr.cpp.

00465 {
00466     if (
00467         (camStrncmp(pHeader, _T("P1"), 2) == 0) ||      // ASCII PBM
00468         (camStrncmp(pHeader, _T("P4"), 2) == 0)     // BINARY PBM
00469        )
00470     {
00471         // finding PBM should be good enough to determine that there is
00472         // a high chance that this is the right file.
00473 
00474         return TRUE;
00475     }
00476 
00477     return FALSE;
00478 }

BOOL PBMFilter::Init void   )  [virtual]
 

Initialise an PBMFilter 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 436 of file ppmfiltr.cpp.

00437 {
00438     // Get the OILFilter object
00439     pOILFilter = new PBMOILFilter(this);
00440     if (pOILFilter==NULL)
00441         return FALSE;
00442 
00443     // Load the description strings
00444     FilterName.Load(_R(IDN_PBM_FILTERNAME));
00445     FilterInfo.Load(_R(IDN_PBM_FILTERINFO));
00446 
00447     // All ok
00448     return TRUE;
00449 }

BOOL PBMFilter::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 number of bytes already read in [OUTPUTS] pData place to store the data (can be incremented) NextPixel whether this pixel is finished or not
Returns:
TRUE if everything went ok, FALSE otherwise.
See also:
BasePMFilter::ReadBinaryFromFile; BasePMFilterReadASCIIFromFile;

Reimplemented from BasePMFilter.

Definition at line 1748 of file ppmfiltr.cpp.

01749 {
01750     // (ChrisG 24/01/01) NextPixel should never be set to false for single component images,
01751     //  as it is supposed to show whether we're halfway through a pixel (e.g. we've written
01752     //  the R and G parts of an RGB pixel, but still have to write the B part), NOT halfway
01753     //  through a byte. That's what the Count variable is for.
01754     *NextPixel = TRUE;
01755 
01756     if (TypeOfPPM == PBM_BINARY)
01757     {
01758         // The bits are stored eight per byte, high bit first low bit last.
01759         // Work out what to do with the data
01760         switch (RGBBits)
01761         {
01762             case 1:
01763                 // Poke this monochrome byte into the next byte in memory
01764                 *((*pData)++) = Number;
01765                 break;
01766 
01767             default:
01768                 // Shouldn't get here so error 2
01769                 ERROR2(FALSE, "PBMFilter::ReadDataIntoBitmap bad ColoursPerRGB");
01770                 break;
01771         }
01772 
01773         // Reset the count
01774         *Count = 0;
01775     }
01776     else
01777     {
01778         // Must be 1 bpp
01779         Bits = (Bits << 1) | (Number & RGBBits);
01780 
01781         // Increment our count and see if we have enough info yet
01782         (*Count)++;
01783 
01784         if (*Count == 8)
01785         {
01786             // Work out what to do with the data
01787             switch (RGBBits)
01788             {
01789                 case 1:
01790                     // Poke those RGB bytes into the next three bytes in memory
01791                     *((*pData)++) = Bits;
01792                     break;
01793 
01794                 default:
01795                     // Shouldn't get here so error 2
01796                     ERROR2(FALSE, "PBMFilter::ReadDataIntoBitmap bad ColoursPerRGB");
01797                     break;
01798             }
01799 
01800             // Reset the count
01801             *Count = 0;
01802             
01803             // Reset the bits accumulator
01804             Bits = 0;
01805         }
01806     }
01807 
01808     return TRUE;    
01809 }


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