BitmapExportOptions Class Reference

Base class for storing information about the bitmap we're exporting. More...

#include <bmpprefs.h>

Inheritance diagram for BitmapExportOptions:

OpParam CCObject SimpleCCObject BMPExportOptions JPEGExportOptions MaskedFilterExportOptions GIFExportOptions ImageMagickExportOptions MakeBitmapExportOptions PNGExportOptions List of all members.

Public Types

enum  eCOLOUR_DEPTHS {
  COLOUR_2 = 1, COLOUR_16 = 2, COLOUR_256 = 4, COLOUR_16BIT = 8,
  COLOUR_24BIT = 16, COLOUR_32BIT = 32
}
enum  eINTERLACE_PROGRESSIVE { GIF_INTERLACE = 1, PNG_INTERLACE = 2, JPG_PROGRESSIVE = 4 }
enum  eDITHERING { ORDERED_DITHER = 1, ERROR_DITHER = 2 }

Public Member Functions

 BitmapExportOptions ()
 Default constructor. See Also: BaseBitmapFilter::CreateBitmapOptions().
 BitmapExportOptions (const CDlgResID DialogID, const FilterType FilterID, const StringBase *pFilterName)
 Allows options in the bitmap export dialog to be freely passed around See Also: BaseBitmapFilter::CreateBitmapOptions().
 ~BitmapExportOptions ()
BOOL IsValid () const
 Determines whether or not the values contained in this object are valid or whether the user has cancelled the export: using MarkValid() & MarkInvalid() will state the veracity of this fact.
void MarkInvalid ()
void MarkValid ()
virtual BOOL RetrieveDefaults ()
 Retrieves defaults for accessible members from preferences See Also: BitmapExportOptions::SetAsDefaults().
virtual BOOL SetAsDefaults () const
 Sets the current options as preferences which may be retrieved by a subsequent RetrieveDefaults() See Also: BitmapExportOptions::RetrieveDefaults().
virtual BOOL Write (CXaraFileRecord *pRec)
 Writes this object to the given record.
virtual BOOL Read (CXaraFileRecord *pRec)
 Reads this object from the given record.
DPI GetDPI () const
 Support function to obtain bitmap info.
BOOL SetDPI (const DPI &Dpi)
 Support function to set up information for the ensuing export See Also: GetDpi().
virtual BOOL GetSupportsImageMap ()
virtual INT32 GetTransparencyIndex () const
virtual void SetTransparencyIndex (INT32 TransparencyIndex)
BMP_DEPTH GetDepth () const
 Support function to obtain bitmap options.
BOOL SetDepth (const BMP_DEPTH &Depth)
 Support function to set up information for the ensuing export See Also: GetDepth().
SelectionType GetSelectionType () const
void SetSelectionType (const SelectionType &Sel)
 sets the the item(s) being exported eg selection, page, drawing, etc
BOOL GetSeparateLayerFiles () const
void SetSeparateLayerFiles (const BOOL newFlag)
BOOL GetTempFileFlag () const
void SetTempFileFlag (const BOOL newFlag)
CDlgResID GetDialogType () const
const FilterType GetFilterType () const
const StringBaseGetFilterName () const
 Allows the export dialog to display the filter name in its title bar.
virtual UINT32 GetFilterNameStrID ()
BaseBitmapFilterFindBitmapFilterForTheseExportOptions ()
Coord GetOutputSize ()
void SetOutputSize (UINT32 x, UINT32 y)
Coord GetPixelOutputSize ()
void SetPixelOutputSize (UINT32 x, UINT32 y)
BmpDlgParamGetBmpDlgParam ()
BOOL SetBitmapExportParam (BitmapExportParam *pParam)
virtual BOOL CanExportSeparateLayers ()
 
  • See Also: -

virtual void SetNumColsInPalette (UINT32 NumCols)
virtual void SetUseSystemColours (BOOL SystemColours)
virtual UINT32 GetNumColsInPalette ()
virtual BOOL GetUseSystemColours ()
virtual BOOL UseSpecificNumColsInPalette ()
ANTIALIASING GetAntiAliasing () const
void SetAntiAliasing (ANTIALIASING aa)
 Sets the anti-aliasing on the export bitmap.
virtual DITHER GetDither () const
virtual BOOL SetDither (const DITHER &)
BOOL ShouldPutHTMLTagOnClipboard ()
void SetPutHTMLTagOnClipboard (BOOL fValueToSet)
void SetPathName (PathName *pTempPath)
 Allows the export options to keep the path to a temporary file, created during bitmap preview, so the export function can simply rename this to create the final exported file.
PathName GetPathName ()
BOOL HasTempFile ()
void SetTempFileMatchesExportOptions (BOOL OptionsMatch)
BOOL DoesTempFileMatchExportOptions ()
BitmapExportOptionsMakeCopy ()
 Makes a copy object of this object See Also: BitmapExportOptions::CopyFrom().
virtual BOOL CopyFrom (BitmapExportOptions *pOther)
virtual BOOL FileTypeChangeCopyFrom (BitmapExportOptions *pOther)
 Copies the information from the BitmapExportOptions object passed in as the argument to the palette object in this class.
void SetCanUseDesignNotes (BOOL ok)
BOOL GetCanUseDesignNotes () const
ExtendedPaletteGetPalette ()
void MakePaletteEntryUnreadable (INT32 i)
BOOL CreatePaletteOptimiser ()
void BitmapSourceHasChanged ()
void GatherPaletteStats (const RGBQUAD *pBitmap, UINT32 nSize)
void CreateValidPalette ()
void CreateValidPalette (LOGPALETTE *pPal, INT32 TranspIndex=0)
void CreateValidBrowserPalette (BOOL WantTransp=TRUE)
LOGPALETTEGetLogicalPalette ()
BOOL SwapEditedColoursInLogicalPalette ()
INT32 FindNextLockedColour (INT32 pos)
BOOL IsBackgroundTransparent ()
void SetBackgroundTransparency (BOOL t)
ExtendedPaletteGetExtendedPalette ()
BOOL IsClipToPage ()
BOOL IsPaletteValid ()
void InvalidatePalette ()
INT32 GetNumberOfUserRequestedColours ()
void SetNumberOfUserRequestedColours (INT32 n)
BOOL IsUsingBrowserPalette ()
void SetToUseBrowserPalette (BOOL SetIt)
BOOL IsUsingSystemPalette ()
void SetToUseSystemPalette (BOOL SetIt)
INT32 GetWebSnapPaletteAmount ()
void SetWebSnapPaletteAmount (INT32 SetIt)
INT32 GetPrimarySnapPaletteAmount ()
void SetPrimarySnapPaletteAmount (INT32 SetIt)
DWORD GetSupportedDithers ()
 Returns the allowed dither types the current filter supports.
DWORD GetInterlaceType ()
 Return true if the current filter allows palette info.
DWORD GetSupportedColourDepths ()
 Returns the all the colour depths the current filter supports.
BOOL GetSupportsTransparency ()
 Used to see if the current filter allows transparencies.
BOOL GetSupportsPalette ()
 Return true if the current filter allows palette info.
void SetCMYK (BOOL SetIt)
BOOL IsCMYK ()

Static Public Member Functions

static BOOL Init ()
 Declares a preference that allows you to clear memory in delete().
static BOOL Declare ()
 Declares our base class preferences.

Public Attributes

BOOL m_fPutHTMLTagOnClipboard

Static Public Attributes

static BOOL ms_fPutHTMLTagOnClipboard = FALSE
 The path to default to when opening the Export File dialogWhether we should put an HTML tag on the clipboard. FALSE by default.
static TCHAR ms_strPutHTMLTagOnClipboard [] = _T("Filters\\PutHTMLTagOnClipboard")
static BOOL ms_IsBackGroundTransparent = TRUE
static ANTIALIASING ms_Antialiasing = MINIMISE_VISIBLE_AA
static BOOL ms_bSeparateLayerFiles = FALSE

Protected Member Functions

BOOL ArePalettesEqual (BitmapExportOptions *pOther)
void CopyPaletteInformationFrom (BitmapExportOptions *pOther)

Protected Attributes

SelectionType m_SelectionType
Coord m_OutputSize
Coord m_PixelOutputSize
FilterType m_FilterID
BmpDlgParamm_pBmpDlgParam
BOOL m_UseDesignNotes
BOOL m_bSeparateLayerFiles
BOOL m_bTempFileFlag
UINT32 m_NumColsInPalette
BOOL m_UseSystemColours

Static Protected Attributes

static UINT32 g_NumColsInPalette = 256
static BOOL g_UseSystemColours = FALSE

Private Attributes

BOOL m_bValid
DPI m_DPI
BMP_DEPTH m_Depth
INT32 m_TransparencyIndex
CDlgResID m_DialogID
const StringBasem_pFilterName
PathName m_TempPath
BOOL m_bTempFileExported
ExtendedPalette m_Palette
ANTIALIASING m_Antialiasing
BOOL m__PaletteIsValid
LOGPALETTEm__pLogicalPalette
INT32 m__NumberOfColoursUserRequested
BOOL m__UseBrowserPalette
BOOL m__UseSystemColoursInPalette
INT32 m__UseWebSnapPalette
INT32 m__UsePrimarySnapPalette
BOOL m__BackgroundIsTransparent
PaletteOptimiserm__pPaletteOptimiser
BOOL m__HavePrimedOptimier
BOOL m__TempFileMatchesExportOptions
BOOL m_bCMYK

Detailed Description

Base class for storing information about the bitmap we're exporting.

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

Definition at line 196 of file bmpprefs.h.


Member Enumeration Documentation

enum BitmapExportOptions::eCOLOUR_DEPTHS
 

Enumerator:
COLOUR_2 
COLOUR_16 
COLOUR_256 
COLOUR_16BIT 
COLOUR_24BIT 
COLOUR_32BIT 

Definition at line 369 of file bmpprefs.h.

00370     {
00371         COLOUR_2 = 1,
00372         COLOUR_16 = 2,
00373         COLOUR_256 = 4,
00374         COLOUR_16BIT = 8,
00375         COLOUR_24BIT = 16,
00376         COLOUR_32BIT = 32
00377     };

enum BitmapExportOptions::eDITHERING
 

Enumerator:
ORDERED_DITHER 
ERROR_DITHER 

Definition at line 392 of file bmpprefs.h.

00393     {
00394         ORDERED_DITHER = 1,
00395         ERROR_DITHER = 2
00396     };

enum BitmapExportOptions::eINTERLACE_PROGRESSIVE
 

Enumerator:
GIF_INTERLACE 
PNG_INTERLACE 
JPG_PROGRESSIVE 

Definition at line 382 of file bmpprefs.h.

00383     {
00384         GIF_INTERLACE = 1,
00385         PNG_INTERLACE = 2,
00386         JPG_PROGRESSIVE = 4
00387     };


Constructor & Destructor Documentation

BitmapExportOptions::BitmapExportOptions  ) 
 

Default constructor. See Also: BaseBitmapFilter::CreateBitmapOptions().

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/10/96

Definition at line 216 of file bmpprefs.cpp.

00216                                          :
00217     m_SelectionType(SELECTION),         // BaseBitmapFilter uses these...
00218     m_OutputSize(0, 0),                 // And initialise the output size
00219     m_PixelOutputSize(0, 0),
00220     m_FilterID(INVALID),
00221     m_pBmpDlgParam(0),
00222     m_bSeparateLayerFiles(FALSE),
00223     m_bTempFileFlag(FALSE),
00224     m_NumColsInPalette(0),
00225     m_UseSystemColours(FALSE),
00226     m_fPutHTMLTagOnClipboard(ms_fPutHTMLTagOnClipboard), // default HTML to clipboard
00227     m_bValid(FALSE),                    // Always use this...
00228     m_DPI(0),
00229     m_Depth(0),
00230     m_TransparencyIndex(-1),            // WEBSTER - markn 5/2/97 - no transparent colour
00231     m_DialogID(0),                      // BmpPrefsDlg uses these...
00232     m_pFilterName(0),
00233     m_bTempFileExported(FALSE),         // export preview uses this
00234     m_Antialiasing(MINIMISE_VISIBLE_AA) // Always start with the highest quality option
00235 {
00236     m_Palette.NumberOfColours = 0;
00237     memset(&(m_Palette.Data), 0, sizeof(ExtendedPaletteEntry)*256);
00238 PORTNOTE("DesignNotes", "Removed use of DesignNotes")
00239 #if !defined(EXCLUDE_FROM_XARALX)
00240     m_UseDesignNotes = GetRegistryFlagForDesignNotes();
00241 #else
00242     m_UseDesignNotes = FALSE;
00243 #endif
00244     m__pLogicalPalette = NULL;
00245     m__NumberOfColoursUserRequested = 256;
00246     m__UseBrowserPalette = FALSE;
00247     m__UseSystemColoursInPalette = FALSE;
00248     m__UseWebSnapPalette = 0;
00249     m__UsePrimarySnapPalette = 1;
00250     m__PaletteIsValid = FALSE;
00251     m__BackgroundIsTransparent = TRUE;
00252     m__pPaletteOptimiser = NULL;
00253     m__HavePrimedOptimier = FALSE;
00254     m__TempFileMatchesExportOptions = FALSE;
00255     m_bCMYK = FALSE;
00256 }

BitmapExportOptions::BitmapExportOptions const CDlgResID  DialogID,
const FilterType  FilterID,
const StringBase pFilterName
 

Allows options in the bitmap export dialog to be freely passed around See Also: BaseBitmapFilter::CreateBitmapOptions().

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/10/96

Definition at line 270 of file bmpprefs.cpp.

00273                                                                :
00274     m_SelectionType(SELECTION),         // BaseBitmapFilter uses these...
00275     m_OutputSize(0, 0),                 // And initialise the output size
00276     m_PixelOutputSize(0, 0),
00277     m_FilterID(FilterID),
00278     m_pBmpDlgParam(0),
00279     m_bSeparateLayerFiles(FALSE),
00280     m_bTempFileFlag(FALSE),
00281     m_NumColsInPalette(0),
00282     m_UseSystemColours(FALSE),
00283     m_fPutHTMLTagOnClipboard(ms_fPutHTMLTagOnClipboard), // default HTML to clipboard
00284     m_bValid(FALSE),                    // Always use this...
00285     m_DPI(0),
00286     m_Depth(0),
00287     m_TransparencyIndex(-1),            // WEBsTER - markn 5/2/97 - no transparent colour
00288     m_DialogID(DialogID),               // BmpPrefsDlg uses these...
00289     m_pFilterName(pFilterName),
00290     m_bTempFileExported(FALSE),         // export preview uses this
00291     m_Antialiasing(MINIMISE_VISIBLE_AA) // Always start with the highest quality option
00292 {
00293     m_Palette.NumberOfColours = 0;
00294     memset(&(m_Palette.Data), 0, sizeof(ExtendedPaletteEntry)*256);
00295 PORTNOTE("DesignNotes", "Removed use of DesignNotes")
00296 #if !defined(EXCLUDE_FROM_XARALX)
00297     m_UseDesignNotes = GetRegistryFlagForDesignNotes();
00298 #else
00299     m_UseDesignNotes = FALSE;
00300 #endif
00301     m__pLogicalPalette = NULL;
00302     m__NumberOfColoursUserRequested = 256;
00303     m__UseBrowserPalette = FALSE;
00304     m__UseSystemColoursInPalette = FALSE;
00305     m__UseWebSnapPalette = 0;
00306     m__UsePrimarySnapPalette = 1;
00307     m__PaletteIsValid = FALSE;
00308     m__BackgroundIsTransparent = TRUE;
00309     m__pPaletteOptimiser = NULL;
00310     m__HavePrimedOptimier = FALSE;
00311     m__TempFileMatchesExportOptions = FALSE;
00312     m_bCMYK = FALSE;
00313 }

BitmapExportOptions::~BitmapExportOptions  ) 
 

Definition at line 316 of file bmpprefs.cpp.

00317 {
00318     // the export options manages the logical palette so this is deleted when the export options are deleted
00319     if (m__pLogicalPalette)
00320     {
00321         delete m__pLogicalPalette;
00322         m__pLogicalPalette = NULL;
00323     }
00324 
00325     // the cache for the palette optimiser which holds the stats on the image
00326     if (m__pPaletteOptimiser)
00327     {
00328         delete m__pPaletteOptimiser;
00329         m__pPaletteOptimiser = NULL;
00330     }
00331 }


Member Function Documentation

BOOL BitmapExportOptions::ArePalettesEqual BitmapExportOptions pOther  )  [protected]
 

void BitmapExportOptions::BitmapSourceHasChanged  ) 
 

Definition at line 4963 of file bmpprefs.cpp.

04964 {
04965     m__HavePrimedOptimier = FALSE;
04966     if (m__pPaletteOptimiser != NULL)
04967         delete m__pPaletteOptimiser;
04968 
04969     m__pPaletteOptimiser = NULL;
04970     InvalidatePalette(); // the palette we are holding will be wrong too
04971 }

BOOL BitmapExportOptions::CanExportSeparateLayers  )  [virtual]
 

  • See Also: -

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
05/04/2004
Parameters:
- [INPUTS]
Returns:
-

Definition at line 1065 of file bmpprefs.cpp.

01066 {
01067     return (GetSeparateLayerFiles() && GetTempFileFlag()==FALSE && (GetFilterNameStrID()==_R(IDN_FILTERNAME_GIF) || GetFilterNameStrID()==_R(IDS_FILTERNAME_PNG)));
01068 }

BOOL BitmapExportOptions::CopyFrom BitmapExportOptions pOther  )  [virtual]
 

Reimplemented in JPEGExportOptions, MakeBitmapExportOptions, BMPExportOptions, GIFExportOptions, and MaskedFilterExportOptions.

Definition at line 374 of file bmpprefs.cpp.

00375 {
00376     if (pOther == 0)
00377         return FALSE;
00378 
00379     // Copy all the data items that can be copied for any type of BitmapExportOptions
00380     
00381     m_SelectionType                 = pOther->m_SelectionType;
00382     m_fPutHTMLTagOnClipboard        = pOther->m_fPutHTMLTagOnClipboard;
00383     m_Antialiasing                  = pOther->m_Antialiasing;
00384     m_UseDesignNotes                = pOther->m_UseDesignNotes;
00385     m_bSeparateLayerFiles           = pOther->m_bSeparateLayerFiles;
00386     m_bTempFileFlag                 = pOther->m_bTempFileFlag;
00387 
00388 
00389     if (IS_SAME_CLASS(pOther, this))
00390     {
00391         // Only copy these if we are copying from a class that is of the
00392         // same type
00393         
00394         m_OutputSize                = pOther->m_OutputSize;
00395         m_PixelOutputSize           = pOther->m_PixelOutputSize;
00396         m_FilterID                  = pOther->m_FilterID;
00397         m_pBmpDlgParam              = pOther->m_pBmpDlgParam;       
00398         m_NumColsInPalette          = pOther->m_NumColsInPalette;
00399         m_UseSystemColours          = pOther->m_UseSystemColours;
00400         m_TransparencyIndex         = pOther->m_TransparencyIndex;
00401         m_DialogID                  = pOther->m_DialogID;
00402         m_pFilterName               = pOther->m_pFilterName;
00403         m_bValid                    = pOther->m_bValid;
00404         m_bTempFileExported         = pOther->m_bTempFileExported;
00405         m_TempPath                  = pOther->m_TempPath;
00406         m_Depth                     = pOther->m_Depth; // move to derived classes
00407 
00408         // Added to stop the name gallery killing itself on export
00409         m_DPI                       = pOther->m_DPI;
00410 
00411         // It should be safe to copy the following for any file type but I have not tested this
00412         // so I am only copying them if they are of the same type for now - Jonathan.
00413 
00414         // smfix new ones added
00415         m__NumberOfColoursUserRequested = pOther->m__NumberOfColoursUserRequested;
00416         m__UseBrowserPalette            = pOther->m__UseBrowserPalette;
00417         m__UseSystemColoursInPalette    = pOther->m__UseSystemColoursInPalette;
00418         m__UseWebSnapPalette            = pOther->m__UseWebSnapPalette;
00419         m__UsePrimarySnapPalette        = pOther->m__UsePrimarySnapPalette;
00420         m__BackgroundIsTransparent      = pOther->m__BackgroundIsTransparent;
00421 
00422         // Also need to copy all the palette information over.  It should also be safe to copy
00423         // this but again, I have not tested this so I am going for the safe option - Jonathan.
00424         CopyPaletteInformationFrom(pOther);
00425         return TRUE;
00426     }
00427     else
00428     {
00429         return FALSE;
00430     }
00431 };

void BitmapExportOptions::CopyPaletteInformationFrom BitmapExportOptions pOther  )  [protected]
 

Definition at line 496 of file bmpprefs.cpp.

00497 {
00498     //  The first few times that this function is called, the palette passed in
00499     //  is uninitialised. If this is the case, then just make our palette a default one.
00500     if( ( pOther->m_Palette.NumberOfColours > 256 ) || ( pOther->m_Palette.NumberOfColours < 0 ) )
00501     {
00502         m_Palette.NumberOfColours = 0;
00503 
00504         INT32 i = 0;
00505         for( i=0; i < 256; i++ )
00506         {
00507             m_Palette.Data[ i ].Red                 = 0;
00508             m_Palette.Data[ i ].Green               = 0;
00509             m_Palette.Data[ i ].Blue                = 0;
00510             m_Palette.Data[ i ].Flags               = 0;
00511         }
00512         //  Finished here, so return.
00513         return;
00514     }
00515 
00516     //  Simply copy the entire palette over from pOther.
00517     m_Palette.NumberOfColours   = pOther->m_Palette.NumberOfColours;
00518 
00519     INT32 i = 0;
00520     INT32 Colours = m_Palette.NumberOfColours;
00521     Colours = max( 256, Colours );
00522     for( i=0; i < Colours; i++ )
00523     {
00524         m_Palette.Data[ i ].Red                 = ( pOther->m_Palette ).Data[ i ].Red;
00525         m_Palette.Data[ i ].Green               = ( pOther->m_Palette ).Data[ i ].Green;
00526         m_Palette.Data[ i ].Blue                = ( pOther->m_Palette ).Data[ i ].Blue;
00527         m_Palette.Data[ i ].Flags               = ( pOther->m_Palette ).Data[ i ].Flags;
00528     }
00529 
00530     // delete our old logical palette if we had one
00531     if (m__pLogicalPalette)
00532     {
00533         delete m__pLogicalPalette;
00534         m__pLogicalPalette = NULL;
00535     }
00536 
00537     // our copy is valid if the original is valid
00538     m__PaletteIsValid = pOther->IsPaletteValid();
00539 
00540     // copy the logical palette data if it was valid
00541     if (m__PaletteIsValid)
00542     {
00543         m__pLogicalPalette = (LOGPALETTE * ) new BYTE[sizeof(LOGPALETTE) + ( sizeof(PALETTEENTRY) * 256 )];
00544 
00545         memcpy(m__pLogicalPalette, pOther->GetLogicalPalette(), sizeof(LOGPALETTE) + ( sizeof(PALETTEENTRY) * 256 ));
00546     }
00547 
00548 }

BOOL BitmapExportOptions::CreatePaletteOptimiser  ) 
 

Definition at line 4944 of file bmpprefs.cpp.

04945 {
04946     if (m__pPaletteOptimiser == NULL)
04947     {
04948         m__HavePrimedOptimier = FALSE;
04949         m__pPaletteOptimiser = new PaletteOptimiser();
04950 
04951         ERROR2IF(m__pPaletteOptimiser == NULL, FALSE, "Low on memory, couldn't create palette optimiser");
04952 
04953         m__pPaletteOptimiser->Initialise();
04954 
04955         return TRUE; // we created a new one
04956     }
04957 
04958     return FALSE; // we kept the old one
04959 }

void BitmapExportOptions::CreateValidBrowserPalette BOOL  WantTransp = TRUE  ) 
 

Definition at line 5352 of file bmpprefs.cpp.

05353 {
05354     // tell the export dlg palette ctrl that a new palette is on the horizon
05355     BitmapExportPaletteInterface::InvalidateSortedPalette();
05356     // delete our old logical palette if we had one
05357     if (m__pLogicalPalette)
05358     {
05359         delete m__pLogicalPalette;
05360         m__pLogicalPalette = NULL;
05361     }
05362 
05363     m__PaletteIsValid = TRUE;
05364 
05365     // copy the logical palette data if it was valid
05366     m__pLogicalPalette = (LOGPALETTE * ) new BYTE[sizeof(LOGPALETTE) + ( sizeof(PALETTEENTRY) * 256 )];
05367 
05368     if (m__pLogicalPalette == NULL)
05369     {
05370         InvalidatePalette();
05371         return;
05372     }
05373 
05374     m__pLogicalPalette->palVersion = 0x300;
05375 
05376     // set the number of colours in the extended palette to match those in the new palette passed in
05377     m_Palette.NumberOfColours = m__pLogicalPalette->palNumEntries = WantTransp ? 217 : 216;
05378     // fill in the extended palette from the new logical palette from the logical palette passed in
05379 
05380     m_Palette.Data[0].Red = 255 ;
05381     m_Palette.Data[0].Green = 255;
05382     m_Palette.Data[0].Blue = 255;
05383     m_Palette.Data[0].Flags = WantTransp ? TRANSPARENT_COLOUR : 0;
05384     m__pLogicalPalette->palPalEntry[ 0 ].peRed = m_Palette.Data[0].Red;
05385     m__pLogicalPalette->palPalEntry[ 0 ].peGreen = m_Palette.Data[0].Green;
05386     m__pLogicalPalette->palPalEntry[ 0 ].peBlue = m_Palette.Data[0].Blue;
05387     m__pLogicalPalette->palPalEntry[ 0 ].peFlags = WantTransp ? 255 : 0;
05388 
05389     SetTransparencyIndex(WantTransp ? 0 : -1);
05390     
05391     INT32 i = 1;
05392     for (INT32 r = 0; r < 256; r += 51)
05393         for (INT32 g = 0; g < 256; g += 51)
05394             for (INT32 b = 0; b < 256; b += 51)
05395             {
05396                 m_Palette.Data[i].Red = r ;
05397                 m_Palette.Data[i].Green = g;
05398                 m_Palette.Data[i].Blue = b;
05399                 m_Palette.Data[i].Flags = 0; // no flags set this will loose any locked colours etc as these are not part of a logical palette
05400 
05401                 m__pLogicalPalette->palPalEntry[ i ].peRed = m_Palette.Data[i].Red;
05402                 m__pLogicalPalette->palPalEntry[ i ].peGreen = m_Palette.Data[i].Green;
05403                 m__pLogicalPalette->palPalEntry[ i ].peBlue = m_Palette.Data[i].Blue;
05404                 m__pLogicalPalette->palPalEntry[ i ].peFlags = 0;
05405                 i++;
05406             }
05407 }

void BitmapExportOptions::CreateValidPalette LOGPALETTE pPal,
INT32  TranspIndex = 0
 

Definition at line 5299 of file bmpprefs.cpp.

05300 {
05301     // tell the export dlg palette ctrl that a new palette is on the horizon
05302     BitmapExportPaletteInterface::InvalidateSortedPalette();
05303     // delete our old logical palette if we had one
05304     if (m__pLogicalPalette)
05305     {
05306         delete m__pLogicalPalette;
05307         m__pLogicalPalette = NULL;
05308     }
05309 
05310     m__PaletteIsValid = (pPal != NULL);
05311 
05312     if (!m__PaletteIsValid)
05313         return;
05314 
05315     // copy the logical palette data if it was valid
05316     m__pLogicalPalette = (LOGPALETTE * ) new BYTE[sizeof(LOGPALETTE) + ( sizeof(PALETTEENTRY) * 256 )];
05317 
05318     if (m__pLogicalPalette == NULL)
05319     {
05320         InvalidatePalette();
05321         return;
05322     }
05323 
05324     m__pLogicalPalette->palVersion = 0x300;
05325 
05326     // set the number of colours in the extended palette to match those in the new palette passed in
05327     m_Palette.NumberOfColours = m__pLogicalPalette->palNumEntries = pPal->palNumEntries;
05328     // fill in the extended palette from the new logical palette from the logical palette passed in
05329     for (INT32 i = 0; i < pPal->palNumEntries; i++)
05330     {
05331         m_Palette.Data[i].Red = pPal->palPalEntry[ i ].peRed;
05332         m_Palette.Data[i].Green = pPal->palPalEntry[ i ].peGreen;
05333         m_Palette.Data[i].Blue = pPal->palPalEntry[ i ].peBlue;
05334         m_Palette.Data[i].Flags = 0; // no flags set this will loose any locked colours etc as these are not part of a logical palette
05335 
05336         m__pLogicalPalette->palPalEntry[ i ].peRed = m_Palette.Data[i].Red;
05337         m__pLogicalPalette->palPalEntry[ i ].peGreen = m_Palette.Data[i].Green;
05338         m__pLogicalPalette->palPalEntry[ i ].peBlue = m_Palette.Data[i].Blue;
05339         m__pLogicalPalette->palPalEntry[ i ].peFlags = 0;
05340     }
05341 
05342     if (TranspIndex >= 0 && TranspIndex < pPal->palNumEntries)
05343     {
05344         m_Palette.Data[TranspIndex].Flags = TRANSPARENT_COLOUR;
05345         m__pLogicalPalette->palPalEntry[ TranspIndex ].peFlags = 255;
05346         SetTransparencyIndex(TranspIndex);
05347     }
05348 }

void BitmapExportOptions::CreateValidPalette  ) 
 

Definition at line 5076 of file bmpprefs.cpp.

05077 {
05078     ASSERT(m__pPaletteOptimiser);
05079 
05080     // tell the export dlg palette ctrl that a new palette is on the horizon
05081     BitmapExportPaletteInterface::InvalidateSortedPalette();
05082 
05083     // delete our old logical palette if we had one
05084     if (m__pLogicalPalette)
05085     {
05086         delete m__pLogicalPalette;
05087         m__pLogicalPalette = NULL;
05088     }
05089 
05090     // allocate space for a logical palette
05091     m__pLogicalPalette = (LOGPALETTE * ) new BYTE[sizeof(LOGPALETTE) + ( sizeof(PALETTEENTRY) * 256 )];
05092     if (m__pLogicalPalette == NULL)
05093         return;
05094     INT32 NewFlags[256];
05095     BYTE EditedColours[256][3];
05096     INT32 BackGroundTransp = m__BackgroundIsTransparent? 1: 0;
05097 
05098     // init the flags for the new palette
05099     memset(&NewFlags, 0, sizeof(INT32)*256);
05100     // init the edited colours for the new palette
05101     memset(&EditedColours, 0, 3*256);
05102 
05103     INT32 i = 0;
05104     // count the locked colours that we had in the last palette,
05105     // these are still the same locked colours for the new palette 
05106     // as the flags would have been removed if they were no longer required
05107     m__pPaletteOptimiser->RemoveLockedColours();
05108     INT32 LockedColours = 0;
05109     for (i = 0; i < m_Palette.NumberOfColours; i++)
05110     {
05111         if (m_Palette.Data[i].Flags & LOCKED_COLOUR || m_Palette.Data[i].Flags & DELETED_COLOUR) // found a locked colour?
05112         {
05113             // add it as a locked colour to the palette
05114             m__pPaletteOptimiser->AddLockedColour(m_Palette.Data[i].Red, m_Palette.Data[i].Green, m_Palette.Data[i].Blue);
05115             // count the locked colours so far
05116             LockedColours++;
05117         }
05118     }
05119     // how many colours can we fit in the palette
05120     INT32 MaxColoursInPalette = 256;
05121     if (m_Depth == 4)
05122         MaxColoursInPalette = 16;
05123     else if (m_Depth == 1)
05124         MaxColoursInPalette = 2;
05125 
05126     MaxColoursInPalette = max(2, min(MaxColoursInPalette, m__NumberOfColoursUserRequested));
05127 
05128     // work out how many spare colours we have within the user defined restraint
05129     // once we have kept these locked colours and have account for the transparency
05130 //  INT32 NoOfColoursToOptimise = MaxColoursInPalette - LockedColours - BackGroundTransp;
05131 
05132     m__pPaletteOptimiser->SnapToBrowserPalette(m__UseWebSnapPalette);
05133     m__pPaletteOptimiser->SnapToPrimaries(m__UsePrimarySnapPalette);
05134     m__pPaletteOptimiser->AddSystemColours((m__UseSystemColoursInPalette == TRUE));
05135     m__pPaletteOptimiser->UseBrowserPalette((m__UseBrowserPalette == TRUE));
05136 
05137     // tell the optimiser that we have finished gathering the stats
05138     //if (!m__HavePrimedOptimier) // can I get away with putting this optimisation back gav?
05139     {
05140         m__pPaletteOptimiser->GenPalette(max(2,MaxColoursInPalette - BackGroundTransp));
05141         m__HavePrimedOptimier = TRUE;
05142     }
05143 
05144     m__pLogicalPalette->palNumEntries = MaxColoursInPalette;
05145     m__pLogicalPalette->palVersion = 0x300;
05146 
05147     // get the optimised palette from the optimser
05148     /*BOOL JustBmpColours =*/ m__pPaletteOptimiser->GetPalette( m__pLogicalPalette, max(2,MaxColoursInPalette - BackGroundTransp));
05149 
05150 //  if (JustBmpColours)
05151 //      TRACE( _T("Just bmp colours\n"));
05152 //  else
05153 //      TRACE( _T("fully optimised colours\n"));
05154 
05155     // reset the flags in the new palette from the locked/deleted colours we had in the old palette
05156     // they may not be in the new palette, but they are LIKELY to be there
05157     INT32 index = -1;
05158     while ((index = FindNextLockedColour(index)) != -1) // find the next locked colour
05159     {
05160         // does this match in the palette
05161         for (i = 0; i < m__pLogicalPalette->palNumEntries; i++)
05162             if (NewFlags[i] == 0 &&
05163                 m_Palette.Data[index].Red   == m__pLogicalPalette->palPalEntry[ i ].peRed &&
05164                 m_Palette.Data[index].Green == m__pLogicalPalette->palPalEntry[ i ].peGreen &&
05165                 m_Palette.Data[index].Blue  == m__pLogicalPalette->palPalEntry[ i ].peBlue
05166                 )
05167             {
05168                 NewFlags[i] = m_Palette.Data[index].Flags;
05169                 EditedColours[i][0] = m_Palette.Data[index].PreEditedRed;
05170                 EditedColours[i][1] = m_Palette.Data[index].PreEditedGreen;
05171                 EditedColours[i][2] = m_Palette.Data[index].PreEditedBlue;
05172                 break;
05173             }
05174     }
05175 
05176     // special case for 1 colour - dont mix them up
05177     if (MaxColoursInPalette - BackGroundTransp == 1)
05178     {
05179         m_Palette.NumberOfColours = m__pLogicalPalette->palNumEntries = 2;
05180         // bias against the background colour and use the other colour if 
05181         // the background colour is more predominant
05182         DocColour dcol = Page::GetPageColour();
05183         INT32 bgr = 255, bgg = 255, bgb = 255;
05184 
05185         // the above call the GetPageColour doesn't work very well
05186         // this code gets it better if the spread and the layer exist
05187         Spread* pSelSpread = Document::GetSelectedSpread();
05188         if (pSelSpread)
05189         {
05190             Layer * pLayer = pSelSpread->FindFirstPageBackgroundLayer();
05191             if (pLayer)
05192             {
05193                 Node * pNode = SliceHelper::FindNextOfClass(pLayer, pLayer, CC_RUNTIME_CLASS(