00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 #include "camtypes.h"
00108
00109
00110 #include "page.h"
00111 #include "layer.h"
00112
00113
00114
00115
00116 #include "bmpprefs.h"
00117
00118
00119
00120
00121 #include "dlgmgr.h"
00122
00123
00124 #include "osrndrgn.h"
00125 #include "grndrgn.h"
00126 #include "bitfilt.h"
00127
00128
00129
00130
00131 #include "makebmp.h"
00132 #include "helpuser.h"
00133
00134
00135
00136 #include "exjpeg.h"
00137 #include "bmpfiltr.h"
00138 #include "pngfiltr.h"
00139 #ifndef WEBSTER
00140
00141 #endif //WEBSTER
00142
00143 #include "impexpop.h"
00144 #include "fileutil.h"
00145
00146
00147 #include "ngprop.h"
00148
00149
00150
00151 #include "bmpalint.h"
00152
00153 #include "slicehelper.h"
00154 #include "fillattr2.h"
00155
00156
00157
00158 DECLARE_SOURCE("$Revision: 1530 $");
00159
00160
00161
00162 PORTNOTE("other","Removed BmpPrefsDlg - derived from DialogOp")
00163 #ifndef EXCLUDE_FROM_XARALX
00164 CC_IMPLEMENT_DYNCREATE(BmpPrefsDlg, DialogOp)
00165 CC_IMPLEMENT_DYNCREATE(JPEGExportPrefsDialog, BmpPrefsDlg)
00166 CC_IMPLEMENT_DYNCREATE(PhotoCDDlg, DialogOp)
00167 #endif
00168
00169 CC_IMPLEMENT_DYNCREATE(BitmapExportOptions, OpParam)
00170 CC_IMPLEMENT_MEMDUMP(PhotoCDDlgParam, OpParam)
00171
00172
00173
00174 #define new CAM_DEBUG_NEW
00175 #define OPTION_ONE 0
00176 #define OPTION_FOUR 4
00177
00178 TCHAR OPTOKEN_JPGPREFSDLG[] = _T("JPGPrefsDlg");
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198 BOOL BitmapExportOptions::ms_fPutHTMLTagOnClipboard = FALSE;
00199 TCHAR BitmapExportOptions::ms_strPutHTMLTagOnClipboard[]
00200 = _T("Filters\\PutHTMLTagOnClipboard");
00201 BOOL BitmapExportOptions::ms_IsBackGroundTransparent = TRUE;
00202 ANTIALIASING BitmapExportOptions::ms_Antialiasing = MINIMISE_VISIBLE_AA;
00203 BOOL BitmapExportOptions::ms_bSeparateLayerFiles = FALSE;
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216 BitmapExportOptions::BitmapExportOptions() :
00217 m_SelectionType(SELECTION),
00218 m_OutputSize(0, 0),
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),
00227 m_bValid(FALSE),
00228 m_DPI(0),
00229 m_Depth(0),
00230 m_TransparencyIndex(-1),
00231 m_DialogID(0),
00232 m_pFilterName(0),
00233 m_bTempFileExported(FALSE),
00234 m_Antialiasing(MINIMISE_VISIBLE_AA)
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 }
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270 BitmapExportOptions::BitmapExportOptions(
00271 const CDlgResID DialogID,
00272 const FilterType FilterID,
00273 const StringBase* pFilterName) :
00274 m_SelectionType(SELECTION),
00275 m_OutputSize(0, 0),
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),
00284 m_bValid(FALSE),
00285 m_DPI(0),
00286 m_Depth(0),
00287 m_TransparencyIndex(-1),
00288 m_DialogID(DialogID),
00289 m_pFilterName(pFilterName),
00290 m_bTempFileExported(FALSE),
00291 m_Antialiasing(MINIMISE_VISIBLE_AA)
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 }
00314
00315
00316 BitmapExportOptions::~BitmapExportOptions()
00317 {
00318
00319 if (m__pLogicalPalette)
00320 {
00321 delete m__pLogicalPalette;
00322 m__pLogicalPalette = NULL;
00323 }
00324
00325
00326 if (m__pPaletteOptimiser)
00327 {
00328 delete m__pPaletteOptimiser;
00329 m__pPaletteOptimiser = NULL;
00330 }
00331 }
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342 BitmapExportOptions* BitmapExportOptions::MakeCopy()
00343 {
00344
00345 CCRuntimeClass* pCCRuntimeClass = GetRuntimeClass();
00346
00347
00348 BitmapExportOptions* p = (BitmapExportOptions*) pCCRuntimeClass->CreateObject();
00349 if (p != 0)
00350 {
00351
00352 p->m_bTempFileExported = FALSE;
00353
00354
00355 p->CopyFrom(this);
00356 }
00357
00358 return p;
00359 }
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374 BOOL BitmapExportOptions::CopyFrom(BitmapExportOptions* pOther)
00375 {
00376 if (pOther == 0)
00377 return FALSE;
00378
00379
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
00392
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;
00407
00408
00409 m_DPI = pOther->m_DPI;
00410
00411
00412
00413
00414
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
00423
00424 CopyPaletteInformationFrom(pOther);
00425 return TRUE;
00426 }
00427 else
00428 {
00429 return FALSE;
00430 }
00431 };
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452 BOOL BitmapExportOptions::FileTypeChangeCopyFrom(BitmapExportOptions *pOther)
00453 {
00454 m_SelectionType = pOther->m_SelectionType;
00455 m_OutputSize = pOther->m_OutputSize;
00456 m_PixelOutputSize = pOther->m_PixelOutputSize;
00457 m_pBmpDlgParam = pOther->m_pBmpDlgParam;
00458 m_NumColsInPalette = pOther->m_NumColsInPalette;
00459 m_UseSystemColours = pOther->m_UseSystemColours;
00460 m_DPI = pOther->m_DPI;
00461 m_Depth = pOther->m_Depth;
00462 m_TransparencyIndex = pOther->m_TransparencyIndex;
00463 m_DialogID = pOther->m_DialogID;
00464 m_bValid = pOther->m_bValid;
00465 m_bTempFileExported = pOther->m_bTempFileExported;
00466 m_TempPath = pOther->m_TempPath;
00467 m_fPutHTMLTagOnClipboard = pOther->m_fPutHTMLTagOnClipboard;
00468 m_Antialiasing = pOther->m_Antialiasing;
00469 m_UseDesignNotes = pOther->m_UseDesignNotes;
00470 m_bSeparateLayerFiles = pOther->m_bSeparateLayerFiles;
00471 m_bTempFileFlag = pOther->m_bTempFileFlag;
00472
00473
00474 m__NumberOfColoursUserRequested = pOther->m__NumberOfColoursUserRequested;
00475 m__UseBrowserPalette = pOther->m__UseBrowserPalette;
00476 m__UseSystemColoursInPalette = pOther->m__UseSystemColoursInPalette;
00477 m__UseWebSnapPalette = pOther->m__UseWebSnapPalette;
00478 m__UsePrimarySnapPalette = pOther->m__UsePrimarySnapPalette;
00479 m__BackgroundIsTransparent = pOther->m__BackgroundIsTransparent;
00480
00481
00482 CopyPaletteInformationFrom( pOther );
00483
00484 return TRUE;
00485 }
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496 void BitmapExportOptions::CopyPaletteInformationFrom( BitmapExportOptions* pOther )
00497 {
00498
00499
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
00513 return;
00514 }
00515
00516
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
00531 if (m__pLogicalPalette)
00532 {
00533 delete m__pLogicalPalette;
00534 m__pLogicalPalette = NULL;
00535 }
00536
00537
00538 m__PaletteIsValid = pOther->IsPaletteValid();
00539
00540
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 }
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559 ExtendedPalette* BitmapExportOptions::GetPalette()
00560 {
00561 return &m_Palette;
00562 }
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579 BOOL BitmapExportOptions::IsValid() const
00580 {
00581 return m_bValid;
00582 }
00583
00584
00585 void BitmapExportOptions::MarkInvalid()
00586 {
00587 m_bValid = FALSE;
00588 }
00589
00590
00591 void BitmapExportOptions::MarkValid()
00592 {
00593 m_bValid = TRUE;
00594 }
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609 BOOL BitmapExportOptions::RetrieveDefaults()
00610 {
00611 SetDPI(BMPFilter::GetDefaultExportDPI());
00612 SetDepth(BMPFilter::GetDefaultExportDepth());
00613
00614 SetPutHTMLTagOnClipboard(ms_fPutHTMLTagOnClipboard);
00615 m__BackgroundIsTransparent = ms_IsBackGroundTransparent;
00616 m_Antialiasing = ms_Antialiasing;
00617 m_bSeparateLayerFiles = ms_bSeparateLayerFiles;
00618
00619 return TRUE;
00620 }
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634 BOOL BitmapExportOptions::SetAsDefaults() const
00635 {
00636 BMPFilter::SetDefaultExportDPI(GetDPI());
00637 BMPFilter::SetDefaultExportDepth(GetDepth());
00638
00639 ms_fPutHTMLTagOnClipboard=m_fPutHTMLTagOnClipboard;
00640 ms_IsBackGroundTransparent = m__BackgroundIsTransparent;
00641 ms_Antialiasing = m_Antialiasing;
00642 ms_bSeparateLayerFiles = m_bSeparateLayerFiles;
00643
00644 return TRUE;
00645 }
00646
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658 BOOL BitmapExportOptions::Declare()
00659 {
00660 if (Camelot.DeclareSection(_T("Filters"), 10))
00661 {
00662 Camelot.DeclarePref( NULL, ms_strPutHTMLTagOnClipboard, &ms_fPutHTMLTagOnClipboard, FALSE, TRUE );
00663 }
00664
00665 return TRUE;
00666 }
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681 BOOL BitmapExportOptions::Write(CXaraFileRecord* pRec)
00682 {
00683 INT16 Packed = 0x0000;
00684
00685 if (m_Antialiasing) Packed += 1;
00686 if (m__BackgroundIsTransparent) Packed += 2;
00687 if (m__UseBrowserPalette) Packed += 4;
00688
00689 INT16 AmountOfPrimarySnap = (m__UsePrimarySnapPalette & 15) << 4;
00690 Packed += AmountOfPrimarySnap;
00691
00692 INT16 AmountOfWebSnap = (m__UseWebSnapPalette & 0xff) << 8;
00693 Packed += AmountOfWebSnap;
00694
00695 UINT32 PackedRequestedColours = m__NumberOfColoursUserRequested;
00696
00697
00698
00699
00700 if (!pRec->WriteINT16((INT16) m_SelectionType) ||
00701 !pRec->WriteCoord((const DocCoord&) m_OutputSize) ||
00702 !pRec->WriteCoord((const DocCoord&) m_PixelOutputSize) ||
00703 !pRec->WriteUINT32((UINT32) m_FilterID) ||
00704 !pRec->WriteBYTE((BYTE) !!m_UseDesignNotes) ||
00705 !pRec->WriteUINT32(PackedRequestedColours) ||
00706 !pRec->WriteBYTE((BYTE) !!m__UseSystemColoursInPalette) ||
00707 !pRec->WriteBYTE((BYTE) !!m_fPutHTMLTagOnClipboard) ||
00708 !pRec->WriteDOUBLE((double) m_DPI) ||
00709 !pRec->WriteUINT32((UINT32) m_Depth) ||
00710 !pRec->WriteINT32(m_TransparencyIndex) ||
00711 !pRec->WriteUINT32((UINT32) m_DialogID) ||
00712 !pRec->WriteINT16(Packed) ||
00713 !pRec->WriteINT32(m_Palette.NumberOfColours) ||
00714 !pRec->WriteUnicode(m_pFilterName ? ((LPTSTR) (LPCTSTR) *m_pFilterName) : (LPTSTR) _T("")))
00715 return FALSE;
00716
00717
00718 BYTE Dummy = 0;
00719 ExtendedPaletteEntry* peEnd = &m_Palette.Data[min(m_Palette.NumberOfColours, 256)];
00720 for (ExtendedPaletteEntry* pe = m_Palette.Data; pe < peEnd; pe++)
00721 {
00722 DWORD PackedPreEditedColours = pe->PreEditedRed + (pe->PreEditedGreen << 8) + (pe->PreEditedBlue << 16);
00723 if (!pRec->WriteBYTE(pe->Red) ||
00724 !pRec->WriteBYTE(pe->Green) ||
00725 !pRec->WriteBYTE(pe->Blue) ||
00726 !pRec->WriteBYTE(Dummy) ||
00727 !pRec->WriteINT32((INT32)PackedPreEditedColours) ||
00728 !pRec->WriteINT32(pe->Flags))
00729 return FALSE;
00730 }
00731
00732 return TRUE;
00733 }
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748 BOOL BitmapExportOptions::Read(CXaraFileRecord* pRec)
00749 {
00750
00751
00752 m_UseDesignNotes = m_UseSystemColours = m_fPutHTMLTagOnClipboard = FALSE;
00753
00754 INT16 Packed = 0;
00755 UINT32 PackedRequestedColours = 0;
00756
00757
00758 String_256 strFilterName;
00759 if (!pRec->ReadINT16((INT16*) &m_SelectionType) ||
00760 !pRec->ReadCoord((DocCoord*) &m_OutputSize) ||
00761 !pRec->ReadCoord((DocCoord*) &m_PixelOutputSize) ||
00762 !pRec->ReadUINT32((UINT32*) &m_FilterID) ||
00763 !pRec->ReadBYTEtoBOOL(&m_UseDesignNotes) ||
00764 !pRec->ReadUINT32((UINT32*) &PackedRequestedColours) ||
00765 !pRec->ReadBYTEtoBOOL(&m__UseSystemColoursInPalette) ||
00766 !pRec->ReadBYTEtoBOOL(&m_fPutHTMLTagOnClipboard) ||
00767 !pRec->ReadDOUBLE((double*) &m_DPI) ||
00768 !pRec->ReadUINT32((UINT32*) &m_Depth) ||
00769 !pRec->ReadINT32(&m_TransparencyIndex) ||
00770 !pRec->ReadUINT32((UINT32*) &m_DialogID) ||
00771 !pRec->ReadINT16((INT16*) &Packed) ||
00772 !pRec->ReadINT32((INT32*) &m_Palette.NumberOfColours) ||
00773 !pRec->ReadUnicode(&strFilterName))
00774 return FALSE;
00775
00776
00777 if (Packed & 1)
00778 m_Antialiasing = MINIMISE_VISIBLE_AA;
00779 else
00780 m_Antialiasing = MAINTAIN_SCREEN_AA;
00781
00782 m__BackgroundIsTransparent = Packed & 2;
00783 m__UseBrowserPalette = Packed & 4;
00784 m__UsePrimarySnapPalette = (Packed >> 4) & 15;
00785 m__UseWebSnapPalette = (Packed >> 8) & 0xff;
00786
00787 m__NumberOfColoursUserRequested = PackedRequestedColours;
00788
00789
00790 BYTE Dummy = 0;
00791 INT32 DummyPopularity = 0;
00792 ExtendedPaletteEntry* peEnd = &m_Palette.Data[min(m_Palette.NumberOfColours, 256)];
00793 for (ExtendedPaletteEntry* pe = m_Palette.Data; pe < peEnd; pe++)
00794 {
00795 if (!pRec->ReadBYTE(&pe->Red) ||
00796 !pRec->ReadBYTE(&pe->Green) ||
00797 !pRec->ReadBYTE(&pe->Blue) ||
00798 !pRec->ReadBYTE(&Dummy) ||
00799 !pRec->ReadINT32((INT32*) &DummyPopularity) ||
00800 !pRec->ReadINT32((INT32*) &pe->Flags))
00801 return FALSE;
00802
00803
00804 DWORD PackedPreEditedColours = DummyPopularity;
00805 pe->PreEditedRed = (PackedPreEditedColours && 0xff);
00806 pe->PreEditedGreen = ((PackedPreEditedColours >> 8) && 0xff);
00807 pe->PreEditedBlue = ((PackedPreEditedColours >> 16) && 0xff);
00808 }
00809
00810 if (m_DPI == 0)
00811 {
00812 TRACE( _T("DPI not set in export options in the .xar file - setting it to 96.0\n"));
00813 m_DPI = 96.0;
00814 }
00815
00816
00817
00818
00819 if (strFilterName.IsEmpty())
00820 strFilterName.Load(GetFilterNameStrID());
00821
00822 for (Filter* pf = Filter::GetFirst(); pf != 0; pf = Filter::GetNext(pf))
00823 if (pf->FilterName == strFilterName)
00824 {
00825
00826 m_pFilterName = &pf->FilterName;
00827 return TRUE;
00828 }
00829
00830
00831 TRACE( _T("BitmapExportOptions::Read: can't find %s filter\n"), (LPCTSTR) strFilterName);
00832 return FALSE;
00833 }
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846 const StringBase* BitmapExportOptions::GetFilterName() const
00847 {
00848 return m_pFilterName;
00849 }
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865 void BitmapExportOptions::SetPathName(PathName *pTempPath)
00866 {
00867
00868 m_bTempFileExported = (pTempPath != NULL);
00869
00870 if (m_bTempFileExported)
00871 {
00872
00873 m_TempPath = *pTempPath;
00874 }
00875 }
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891 BOOL BitmapExportOptions::SetDPI(const DPI& Dpi)
00892 {
00893 if (m_DPI != Dpi)
00894 BitmapSourceHasChanged();
00895
00896 m_DPI = Dpi;
00897 return TRUE;
00898 }
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911 DPI BitmapExportOptions::GetDPI() const
00912 {
00913 return m_DPI;
00914 }
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926 void BitmapExportOptions::SetSelectionType(const SelectionType& Sel)
00927 {
00928 if (m_SelectionType != Sel)
00929 BitmapSourceHasChanged();
00930 m_SelectionType = Sel;
00931 }
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942 void BitmapExportOptions::SetAntiAliasing( ANTIALIASING aa )
00943 {
00944 if (m_Antialiasing != aa)
00945 BitmapSourceHasChanged();
00946 m_Antialiasing = aa;
00947 }
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960 BMP_DEPTH BitmapExportOptions::GetDepth() const
00961 {
00963
00964
00965
00966
00967 if( m_Depth >= 1 )
00968 {
00969 return m_Depth;
00970 }
00971 else
00972 {
00973 return 32;
00974 }
00975 }
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991 BOOL BitmapExportOptions::SetDepth(const BMP_DEPTH& Depth)
00992 {
00993 if (m_Depth != Depth)
00994 {
00995 InvalidatePalette();
00996
00997
00998 if (m_Depth == 1)
00999 BitmapSourceHasChanged();
01000 }
01001
01002 m_Depth = Depth;
01003 return TRUE;
01004 }
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020 BOOL BitmapExportOptions::SetBitmapExportParam(BitmapExportParam* pParam)
01021 {
01022 ERROR2IF(pParam == NULL,FALSE,"pParam is NULL");
01023 m_pBmpDlgParam=pParam->GetBmpDlgParam();
01024
01025 if(m_pBmpDlgParam == NULL)
01026 return FALSE;
01027
01028 return TRUE;
01029 }
01030
01031
01032 BOOL BitmapExportOptions::IsClipToPage()
01033 {
01034 if( m_SelectionType == PAGE )
01035 return TRUE;
01036 else
01037 return FALSE;
01038 }
01039
01040
01041 BOOL BitmapExportOptions::IsCMYK()
01042 {
01043 return m_bCMYK;
01044 }
01045
01046 void BitmapExportOptions::SetCMYK(BOOL SetIt)
01047 {
01048 m_bCMYK = SetIt;
01049 }
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065 BOOL BitmapExportOptions::CanExportSeparateLayers()
01066 {
01067 return (GetSeparateLayerFiles() && GetTempFileFlag()==FALSE && (GetFilterNameStrID()==_R(IDN_FILTERNAME_GIF) || GetFilterNameStrID()==_R(IDS_FILTERNAME_PNG)));
01068 }
01069
01070
01071
01072 PORTNOTE("other", "Removed export dlgs");
01073 #if !defined(EXCLUDE_FROM_XARALX)
01074
01075
01076 PhotoCDDlgParam * PhotoCDDlg::pParams = NULL;
01077
01078
01079 CDlgResID BmpPrefsDlg::IDD = _R(IDD_EXPORTBMPOPTS);
01080 const CDlgMode BmpPrefsDlg::Mode = MODAL;
01081
01082 const CDlgMode PhotoCDDlg::Mode = MODAL;
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103 #define UNCOMPRESSED_TIFF 0
01104 #define LZW_TIFF 1
01105 #define HUFFMAN_TIFF 1
01106 #define G3FAX_TIFF 2
01107 #define G4FAX_TIFF 3
01108 #define PACKBITS_TIFF 4
01109 #define TWODENCODING_TIFF 5
01110
01111
01112
01113
01114
01115 static const double D_MAXDPI = 3000.0;
01116 static const INT32 MAXDPI = 3000;
01117
01118
01119 static const INT32 ANIMATION_EXTRABIT = 76;
01120 static const INT32 NUMCOLS_EXTRABIT = 56;
01121 static const INT32 NUMCOLS_GROUP_SHIFT = 80;
01122
01123
01124
01125
01126
01127 static const INT32 NUM_SYS_COLS = 28;
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140 BmpPrefsDlg::BmpPrefsDlg(): DialogOp(BmpPrefsDlg::IDD, BmpPrefsDlg::Mode)
01141 {
01142 m_pOptions = NULL;
01143
01144 Width = 0;
01145 Height = 0;
01146 PixelWidth = 0;
01147 PixelHeight = 0;
01148 Dpi = 96.0;
01149
01150 LastBppSelected = 0;
01151
01152 RecalculatingPixels = FALSE;
01153 RecalculatingXDpi = FALSE;
01154 RecalculatingYDpi = FALSE;
01155
01156 m_bDpiSupported = FALSE;
01157 m_bLockAspect = FALSE;
01158 IsDelayMany = FALSE;
01159 IsDelayDefault = FALSE;
01160 HasDelayChanged = FALSE;
01161 HasRestoreChanged = FALSE;
01162 IsManyDisplayed = FALSE;
01163 DisplayMany = FALSE;
01164 LoopCheckBoxEnabled = TRUE;
01165 }
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181
01182
01183
01184 SelectionType BmpPrefsDlg::GetSelection()
01185 {
01186
01187 BOOL Valid = FALSE;
01188
01189
01190 if (GetOptions()->GetSelectionType() == ABITMAP)
01191 return ABITMAP;
01192
01193 if (GetOptions()->GetSelectionType() == SOMEBITMAPS)
01194 return SOMEBITMAPS;
01195
01196 SelectionType FoundSelection = DRAWING;
01197
01198 BOOL ExportDrawing = GetLongGadgetValue(_R(IDC_BMPOPTS_DRAWING), 0, 1, 0, &Valid);
01199
01200 if (GetOptions()->GetSelectionType() == SELECTION)
01201 {
01202
01203 if (ExportDrawing)
01204 FoundSelection = DRAWING;
01205 else
01206 FoundSelection = SELECTION;
01207 }
01208 else
01209 {
01210
01211 FoundSelection = DRAWING;
01212 }
01213
01214
01215 return FoundSelection;
01216 }
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233
01234 void BmpPrefsDlg::RecalculateSize()
01235 {
01236
01237 SelectionType FoundSelection = GetSelection();
01238
01239
01240 ClipRect;
01241 ClipRect.MakeEmpty();
01242
01243 if (FoundSelection == ABITMAP)
01244 {
01245
01246 BaseBitmapFilter::GetSizeOfBitmap(&PixelWidth, &PixelHeight);
01247
01248 RecalculatingPixels = TRUE;
01249
01250 SetLongGadgetValue(_R(IDC_BMPOPTS_XPIXELS), PixelWidth);
01251 SetLongGadgetValue(_R(IDC_BMPOPTS_YPIXELS), PixelHeight);
01252
01253
01254
01255 #ifndef WEBSTER
01256 SetStringGadgetValue(_R(IDC_BMPOPTS_XSIZE), &String_8("-"));
01257 SetStringGadgetValue(_R(IDC_BMPOPTS_YSIZE), &String_8("-"));
01258 EnableGadget(_R(IDC_BMPOPTS_XSIZE), FALSE);
01259 EnableGadget(_R(IDC_BMPOPTS_YSIZE), FALSE);
01260 #endif // WEBSTER
01261 EnableGadget(_R(IDC_BMPOPTS_XPIXELS), FALSE);
01262 EnableGadget(_R(IDC_BMPOPTS_YPIXELS), FALSE);
01263
01264 RecalculatingPixels = FALSE;
01265
01266
01267 DocUnitList* pDocUnitList = DocUnitList::GetCurrentDocUnitList();
01268 ERROR3IF(pDocUnitList == NULL, "BmpPrefsDlg::RecalculateSize() - no pDocUnitList!")
01269 Unit* pPixelUnit = pDocUnitList->FindUnit(PIXELS);
01270 ERROR3IF(pPixelUnit == NULL, "BmpPrefsDlg::RecalculateSize() - no pixel units!")
01271 Unit* pInchUnit = pDocUnitList->FindUnit(INCHES);
01272 ERROR3IF(pInchUnit == NULL, "BmpPrefsDlg::RecalculateSize() - no inch units!")
01273 double newDpi = (pPixelUnit->GetMillipoints()>0) ? pInchUnit->GetMillipoints() / pPixelUnit->GetMillipoints() : 96.0;
01274 Dpi = (INT32)newDpi;
01275 GetOptions()->SetDPI(newDpi);
01276
01277 ClipRect.lo = DocCoord(0,0);
01278 ClipRect.hi = DocCoord(PixelWidth * (INT32)newDpi, PixelHeight * (INT32)newDpi);
01279
01280 Width = ClipRect.Width();
01281 Height = ClipRect.Height();
01282
01283
01284 return;
01285 }
01286
01287 if (FoundSelection == SOMEBITMAPS)
01288 {
01289
01290 ClipRect.lo = DocCoord(0,0);
01291 ClipRect.hi = DocCoord(GetOptions()->GetOutputSize().x, GetOptions()->GetOutputSize().y);
01292 }
01293
01294
01295 Application* pApplication = GetApplication();
01296 Document* pDocument = Document::GetSelected();
01297 Spread* pSpread = NULL;
01298
01299
01300
01301 if (pApplication && pDocument && FoundSelection != ABITMAP && FoundSelection != SOMEBITMAPS)
01302 {
01303
01304 SelRange* pSelection = pApplication->FindSelection();
01305 if (pSelection)
01306 {
01307
01308 ClipRect = pSelection->GetBoundingRect();
01309
01310
01311 Node* pNode = pSelection->FindFirst();
01312
01313
01314 if (pNode)
01315 pSpread = pNode->FindParentSpread();
01316 else
01317 pSpread = pDocument->FindFirstSpread();
01318 }
01319
01320 if (pSpread)
01321 {
01322 switch (FoundSelection)
01323 {
01324 case ABITMAP:
01325 ERROR3IF(TRUE, "BmpPrefsDlg::RecalculateSize() - This should have already been taken care of")
01326
01327 break;
01328 case SELECTION:
01329
01330 break;
01331 case SPREAD:
01332 {
01333
01334
01335 ERROR3("Selection == Spread!");
01336
01337 ClipRect = BaseBitmapFilter::GetSizeOfSpread(pSpread);
01338
01339 }
01340
01341 default:
01342 {
01343
01344
01345
01346 ClipRect = BaseBitmapFilter::GetSizeOfDrawing(pSpread);
01347 break;
01348 }
01349 }
01350 }
01351 }
01352
01353
01354
01355 if ( ClipRect.IsEmpty() ||
01356 ClipRect.Width() < BaseBitmapFilter::MinExportSize ||
01357 ClipRect.Height() < BaseBitmapFilter::MinExportSize )
01358 {
01359
01360 ClipRect = pSpread->FindFirstPageInSpread ()->GetPageRect ();
01361 }
01362
01363
01364
01365 Width = ClipRect.Width();
01366 Height = ClipRect.Height();
01367
01368
01369 DocUnitList* pDocUnitList = NULL;
01370 UnitType CurrentPageUnits = MILLIMETRES;
01371 if (pDocument)
01372 {
01373 pDocUnitList = pDocument->GetDocUnitList();
01374 if (pDocUnitList)
01375 CurrentPageUnits = pDocUnitList->GetPageUnits();
01376 }
01377
01378
01379
01380 #ifndef WEBSTER
01381 if (m_bDpiSupported)
01382 {
01383 SetUnitGadgetValue(_R(IDC_BMPOPTS_XSIZE), CurrentPageUnits, Width, FALSE, -1);
01384 SetUnitGadgetValue(_R(IDC_BMPOPTS_YSIZE), CurrentPageUnits, Height, FALSE, -1);
01385 }
01386 else
01387 {
01388 SetStringGadgetValue(_R(IDC_BMPOPTS_XSIZE), &String_8("-"));
01389 SetStringGadgetValue(_R(IDC_BMPOPTS_YSIZE), &String_8("-"));
01390 }
01391 #endif // WEBSTER
01392
01393
01394 RecalculatePixels();
01395 }
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413 void BmpPrefsDlg::RecalculatePixels()
01414 {
01415
01416
01417
01418 if (RecalculatingXDpi || RecalculatingYDpi)
01419 return;
01420
01421
01422 PixelWidth = 0;
01423 PixelHeight = 0;
01424 Dpi = 0;
01425 BOOL Valid = 0;
01426
01427
01428
01429 if (!m_bDpiSupported)
01430 {
01431 Dpi = GetOptions()->GetDPI();
01432 Valid = TRUE;
01433 }
01434 else
01435 {
01436 Dpi = (double)GetLongGadgetValue(_R(IDC_BMPOPTS_RES), 5, MAXDPI, NULL ,&Valid);
01437 }
01438
01439 if ( Valid )
01440 {
01441
01442
01443
01444
01445
01446 Matrix Identity;
01447 WinRect Rect = OSRenderRegion::BitmapDocRectToWin( Identity, ClipRect, Dpi );
01448 PixelWidth = Rect.Width();
01449 PixelHeight = Rect.Height();
01450
01451
01452 if (PixelWidth < 0)
01453 PixelWidth = 0;
01454 if (PixelHeight < 0)
01455 PixelHeight = 0;
01456
01457 RecalculatingPixels = TRUE;
01458
01459 SetLongGadgetValue(_R(IDC_BMPOPTS_XPIXELS), PixelWidth);
01460 SetLongGadgetValue(_R(IDC_BMPOPTS_YPIXELS), PixelHeight);
01461
01462 RecalculatingPixels = FALSE;
01463 }
01464 else
01465 {
01466 RecalculatingPixels = TRUE;
01467
01468
01469 SetStringGadgetValue(_R(IDC_BMPOPTS_XPIXELS), &String_8(""));
01470 SetStringGadgetValue(_R(IDC_BMPOPTS_YPIXELS), &String_8(""));
01471
01472 RecalculatingPixels = FALSE;
01473 }
01474 }
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487
01488
01489
01490
01491
01492 void BmpPrefsDlg::RecalculateDpiFromX()
01493 {
01494
01495
01496 if (RecalculatingPixels || RecalculatingYDpi)
01497 return;
01498
01499
01500
01501
01502 BOOL Valid = FALSE;
01503 PixelWidth = GetLongGadgetValue(_R(IDC_BMPOPTS_XPIXELS), 9, INT32_MAX, NULL ,&Valid);
01504
01505 if ( Valid )
01506 {
01507 RecalculatingXDpi = TRUE;
01508
01509 double Resolution = (Width>0) ? ((double) PixelWidth * 72000.0) / ((double) Width) : 96.0;
01510
01511
01512 if ((Resolution < 5.0) || (Resolution > D_MAXDPI))
01513 {
01514
01515
01516 SetStringGadgetValue(_R(IDC_BMPOPTS_YPIXELS), &String_8(""));
01517 if (m_bDpiSupported)
01518 {
01519 SetStringGadgetValue(_R(IDC_BMPOPTS_RES), &String_8(""), FALSE, -1);
01520 }
01521 }
01522 else
01523 {
01524
01525 INT32 b_dpi = (INT32)(Resolution + 0.5);
01526 Dpi = b_dpi;
01527 if (m_bDpiSupported)
01528 {
01529
01530 SetLongGadgetValue(_R(IDC_BMPOPTS_RES), (INT32)Dpi, FALSE, -1);
01531 }
01532
01533
01534
01535
01536
01537 Matrix Identity;
01538 WinRect Rect = OSRenderRegion::BitmapDocRectToWin( Identity, ClipRect, Dpi );
01539 PixelHeight = Rect.Height();
01540 SetLongGadgetValue(_R(IDC_BMPOPTS_YPIXELS), PixelHeight);
01541 }
01542
01543 RecalculatingXDpi = FALSE;
01544 }
01545 else
01546 {
01547 RecalculatingXDpi = TRUE;
01548
01549
01550
01551 SetStringGadgetValue(_R(IDC_BMPOPTS_YPIXELS), &String_8(""));
01552 if (m_bDpiSupported)
01553 {
01554 SetStringGadgetValue(_R(IDC_BMPOPTS_RES), &String_8(""), FALSE, -1);
01555 }
01556
01557 RecalculatingXDpi = FALSE;
01558 }
01559 }
01560
01561
01562
01563
01564
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577 void BmpPrefsDlg::RecalculateDpiFromY()
01578 {
01579
01580
01581 if (RecalculatingPixels || RecalculatingXDpi)
01582 return;
01583
01584
01585
01586
01587 BOOL Valid = FALSE;
01588 PixelHeight = GetLongGadgetValue(_R(IDC_BMPOPTS_YPIXELS), 9, INT32_MAX, NULL ,&Valid);
01589
01590 if ( Valid )
01591 {
01592 RecalculatingYDpi = TRUE;
01593
01594 double Resolution = (Height>0) ? ((double) PixelHeight * 72000.0) / ((double) Height) : 96.0;
01595
01596
01597 if ((Resolution < 5.0) || (Resolution > D_MAXDPI))
01598 {
01599
01600
01601 SetStringGadgetValue(_R(IDC_BMPOPTS_XPIXELS), &String_8(""));
01602 if (m_bDpiSupported)
01603 {
01604 SetStringGadgetValue(_R(IDC_BMPOPTS_RES), &String_8(""), FALSE, -1);
01605 }
01606 }
01607 else
01608 {
01609
01610 INT32 b_dpi = (INT32)(Resolution + 0.5);
01611 Dpi = b_dpi;
01612 {
01613
01614 SetLongGadgetValue(_R(IDC_BMPOPTS_RES), (INT32)Dpi, FALSE, -1);
01615 }
01616
01617
01618
01619
01620
01621 Matrix Identity;
01622 WinRect Rect = OSRenderRegion::BitmapDocRectToWin( Identity, ClipRect, Dpi );
01623 PixelWidth = Rect.Width();
01624 SetLongGadgetValue(_R(IDC_BMPOPTS_XPIXELS), PixelWidth);
01625 }
01626
01627 RecalculatingYDpi = FALSE;
01628 }
01629 else
01630 {
01631 RecalculatingYDpi = TRUE;
01632
01633
01634
01635 SetStringGadgetValue(_R(IDC_BMPOPTS_XPIXELS), &String_8(""));
01636 if (m_bDpiSupported)
01637 {
01638 SetStringGadgetValue(_R(IDC_BMPOPTS_RES), &String_8(""), FALSE, -1);
01639 }
01640
01641 RecalculatingYDpi = FALSE;
01642 }
01643 }
01644
01645
01646
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661 void BmpPrefsDlg::SetBPPButtons(CGadgetID ButtonClicked,BOOL CheckNumColValueRange)
01662 {
01663 BitmapExportOptions* pOptions = GetOptions();
01664 if (pOptions == NULL)
01665 {
01666 ERROR3("pOptions == NULL");
01667 return;
01668 }
01669
01670
01671 SetLongGadgetValue(ButtonClicked, TRUE);
01672
01673 BOOL EnablePalette = FALSE;
01674
01675
01676 if ( ButtonClicked == _R(IDC_BMPOPTS_8BPP) || ButtonClicked == _R(IDC_BMPOPTS_4BPP) || ButtonClicked == _R(IDC_BMPOPTS_1BPP))
01677 EnablePalette = TRUE;
01678
01679 EnableGadget(_R(IDC_BMPOPTS_PAL_STD), EnablePalette);
01680 EnableGadget(_R(IDC_BMPOPTS_PAL_OPT), EnablePalette);
01681 EnableGadget(_R(IDC_BMPOPTS_NODITHER), EnablePalette);
01682 EnableGadget(_R(IDC_BMPOPTS_DIFFUSION), EnablePalette);
01683
01684 if (EnablePalette)
01685 {
01686 BOOL Valid = 0;
01687 if ( GetLongGadgetValue(_R(IDC_BMPOPTS_PAL_OPT), 0, 1, 0, &Valid) )
01688 EnableGadget(_R(IDC_BMPOPTS_ORDDITHER), FALSE);
01689 else
01690 EnableGadget(_R(IDC_BMPOPTS_ORDDITHER), TRUE);
01691 }
01692 else
01693 EnableGadget(_R(IDC_BMPOPTS_ORDDITHER), FALSE);
01694
01695
01696
01697 if (pOptions->UseSpecificNumColsInPalette())
01698 UpdateNumColoursGroup(CheckNumColValueRange);
01699
01700 if (pOptions->GetFilterType() == MAKE_BITMAP_FILTER)
01701 {
01702
01703
01704 EnableGadget(_R(IDC_BMPOPTS_TRANSPARENT), EnablePalette);
01705
01706
01707
01708 if (!EnablePalette)
01709 {
01710 SetLongGadgetValue(_R(IDC_BMPOPTS_TRANSPARENT), 0);
01711 }
01712 else
01713 {
01714 MaskedFilterExportOptions* pMaskOptions = (MaskedFilterExportOptions*)pOptions;
01715 ERROR3IF(!pMaskOptions->IS_KIND_OF(MaskedFilterExportOptions), "pMaskOptions isn't");
01716
01717 SetLongGadgetValue(_R(IDC_BMPOPTS_TRANSPARENT), pMaskOptions->WantTransparent());
01718 }
01719 }
01720
01721
01722 if (pOptions->GetFilterType() == PNG)
01723 {
01724 PNGExportOptions* pPNGOptions = (PNGExportOptions*)pOptions;
01725 ERROR3IF(!pPNGOptions->IS_KIND_OF(PNGExportOptions), "pPNGOptions isn't");
01726
01727
01728 BOOL Enable = FALSE;
01729 if ( ButtonClicked == _R(IDC_BMPOPTS_8BPP) || ButtonClicked == _R(IDC_BMPOPTS_4BPP) ||
01730 ButtonClicked == _R(IDC_BMPOPTS_1BPP) )
01731 Enable = TRUE;
01732
01733
01734 EnableGadget(_R(IDC_BMPOPTS_TRANSPARENT), Enable);
01735 if (!Enable)
01736 {
01737 SetLongGadgetValue(_R(IDC_BMPOPTS_TRANSPARENT), 0);
01738 }
01739 else
01740 {
01741 SetLongGadgetValue(_R(IDC_BMPOPTS_TRANSPARENT), pPNGOptions->WantTransparent());
01742 }
01743 }
01744
01745
01746
01747 #ifndef WEBSTER
01748
01749 if (pOptions->GetFilterType() == BMP_UNCOMPRESSED)
01750 {
01751
01752
01753 BOOL Enable = FALSE;
01754 if ( ButtonClicked == _R(IDC_BMPOPTS_8BPP) || ButtonClicked == _R(IDC_BMPOPTS_4BPP) )
01755 Enable = TRUE;
01756
01757
01758
01759 EnableGadget(_R(IDC_BMPOPTS_COMPRESS), Enable);
01760 EnableGadget(_R(IDC_BMPOPTS_RLE), Enable);
01761 EnableGadget(_R(IDC_BMPOPTS_RGB), Enable);
01762 }
01763 #endif // WEBSTER
01764
01765
01766
01767 if (pOptions->GetFilterType() == TIFF_UNCOMPRESSED)
01768 {
01769
01770 #ifndef WEBSTER
01771 TIFFExportOptions* pTIFFOptions = (TIFFExportOptions*)pOptions;
01772 ERROR3IF(!pTIFFOptions->IS_KIND_OF(TIFFExportOptions), "pTIFFOptions isn't");
01773
01774
01775 BOOL bEnableLZW = FALSE;
01776 BOOL bEnableMonoCompression = FALSE;
01777
01778 if ( ButtonClicked == _R(IDC_BMPOPTS_1BPP))
01779 bEnableMonoCompression = TRUE;
01780
01781 if ( ButtonClicked == _R(IDC_BMPOPTS_24BPP) || ButtonClicked == _R(IDC_BMPOPTS_8BPP) || ButtonClicked == _R(IDC_BMPOPTS_CMYK) )
01782 bEnableLZW = TRUE;
01783
01784
01785
01786
01787
01788 if (
01789
01790
01791 TRUE )
01792 {
01793
01794
01795
01796
01797
01798
01799
01800
01801
01802
01803
01804 INT32 nBPP;
01805 switch( ButtonClicked )
01806 {
01807 case _R(IDC_BMPOPTS_1BPP): nBPP=1; break;
01808 case _R(IDC_BMPOPTS_4BPP): nBPP=4; break;
01809 case _R(IDC_BMPOPTS_8BPP): nBPP=8; break;
01810 case _R(IDC_BMPOPTS_24BPP): nBPP=24; break;
01811 case _R(IDC_BMPOPTS_CMYK): nBPP=32; break;
01812 default:
01813 ERROR3( "BmpPrefsDlg::SetBPPButtons - invalid bpp obtained" );
01814 }
01815
01816 INT32 CompressionType = GetTIFFCompressionSelection(nBPP);
01817
01818
01819 DeleteAllValues(_R(IDC_BMPOPTS_TIFF));
01820
01821 BOOL ok = SetLongGadgetValue(_R(IDC_BMPOPTS_TIFF), pTIFFOptions->GetCompression(), FALSE, -1);
01822
01823
01824 SetStringGadgetValue(_R(IDC_BMPOPTS_TIFF), &String_32(_R(IDN_TIFF_NONE)));
01825
01826
01827 if (bEnableLZW)
01828 {
01829
01830 SetStringGadgetValue(_R(IDC_BMPOPTS_TIFF), &String_32(_R(IDN_TIFF_LZW)));
01831 }
01832
01833 if (bEnableMonoCompression)
01834 {
01835
01836 SetStringGadgetValue(_R(IDC_BMPOPTS_TIFF), &String_32(_R(IDN_TIFF_HUFFMAN)));
01837 SetStringGadgetValue(_R(IDC_BMPOPTS_TIFF), &String_32(_R(IDN_TIFF_G3FAX)));
01838 SetStringGadgetValue(_R(IDC_BMPOPTS_TIFF), &String_32(_R(IDN_TIFF_G4FAX)));
01839 SetStringGadgetValue(_R(IDC_BMPOPTS_TIFF), &String_32(_R(IDN_TIFF_PACKBITS)));
01840
01841 }
01842
01843 SetComboListLength(_R(IDC_BMPOPTS_TIFF));
01844
01845
01846
01847 if( nBPP == 1 && LastBppSelected != _R(IDC_BMPOPTS_1BPP) && LastBppSelected )
01848 {
01849
01850
01851 ok = SetTIFFCompressionSelection( TIFF_UNCOMPRESSED, nBPP );
01852
01853
01854 ERROR3IF( (!ok), "BmpPrefsDlg::SetBPPButtons - could not select uncompressed" );
01855 }
01856 else if( nBPP >= 8 &&
01857 (LastBppSelected == _R(IDC_BMPOPTS_1BPP) || LastBppSelected == _R(IDC_BMPOPTS_4BPP)) )
01858 {
01859
01860
01861 ok = SetTIFFCompressionSelection( TIFF_LZW, nBPP );
01862
01863
01864 ERROR3IF( (!ok), "BmpPrefsDlg::SetBPPButtons - could not select LZW" );
01865 }
01866 else
01867 {
01868
01869 ok = SetTIFFCompressionSelection( CompressionType, nBPP );
01870
01871
01872 if( ! ok )
01873 {
01874
01875 ok = SetTIFFCompressionSelection( TIFF_UNCOMPRESSED, nBPP );
01876
01877
01878 ERROR3IF( (!ok), "BmpPrefsDlg::SetBPPButtons - could not select uncompressed" );
01879 }
01880 }
01881 }
01882
01883
01884 LastBppSelected = ButtonClicked;
01885 #endif //WEBSTER
01886 }
01887 }
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902
01903
01904 void BmpPrefsDlg::SetPaletteButtons(CGadgetID ButtonClicked)
01905 {
01906 if ( ButtonClicked == _R(IDC_BMPOPTS_PAL_OPT) )
01907 {
01908 BOOL Valid = 0;
01909 if ( GetLongGadgetValue(_R(IDC_BMPOPTS_ORDDITHER), 0, 1, 0, &Valid) )
01910 {
01911 SetLongGadgetValue(_R(IDC_BMPOPTS_ORDDITHER), FALSE);
01912 SetLongGadgetValue(_R(IDC_BMPOPTS_DIFFUSION), TRUE);
01913 }
01914
01915 SetLongGadgetValue(_R(IDC_BMPOPTS_PAL_OPT), TRUE);
01916
01917 EnableGadget(_R(IDC_BMPOPTS_ORDDITHER), FALSE);
01918
01919
01920
01921 UpdateNumColoursGroup(FALSE);
01922 }
01923 else
01924 {
01925 SetLongGadgetValue(_R(IDC_BMPOPTS_PAL_STD), TRUE);
01926
01927 EnableGadget(_R(IDC_BMPOPTS_ORDDITHER), TRUE);
01928
01929
01930 UpdateNumColoursGroup(FALSE);
01931 }
01932 }
01933
01934
01935
01936
01937
01938
01939
01940
01941
01942
01943
01944
01945
01946
01947
01948
01949 void BmpPrefsDlg::SetDitherButtons(CGadgetID ButtonClicked)
01950 {
01951 }
01952
01953
01954
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964
01965
01966
01967
01968
01969
01970
01971 TIFF_COMPRESSION BmpPrefsDlg::GetTIFFCompressionSelection( INT32 nBPP )
01972 {
01973
01974 TIFF_COMPRESSION Compression;
01975 INT32 nIndex = GetSelectedValueIndex(_R(IDC_BMPOPTS_TIFF));
01976
01977 if( nBPP == 1 )
01978 {
01979 switch ( nIndex )
01980 {
01981 case TWODENCODING_TIFF: Compression = TIFF_2D; break;
01982 case PACKBITS_TIFF: Compression = TIFF_PACK; break;
01983 case HUFFMAN_TIFF: Compression = TIFF_HUFFMAN; break;
01984 case G3FAX_TIFF: Compression = TIFF_G3_FAX; break;
01985 case G4FAX_TIFF: Compression = TIFF_G4_FAX; break;
01986 default:
01987 case UNCOMPRESSED_TIFF: Compression = TIFF_UNCOMPRESSED; break;
01988 }
01989 }
01990 else if( nBPP==8 || nBPP==24 || nBPP==32 )
01991 {
01992 switch ( nIndex )
01993 {
01994 case LZW_TIFF: Compression = TIFF_LZW; break;
01995 default:
01996 case UNCOMPRESSED_TIFF: Compression = TIFF_UNCOMPRESSED; break;
01997 }
01998 }
01999 else if( nBPP == 4 )
02000 {
02001 Compression = TIFF_UNCOMPRESSED;
02002 }
02003 else
02004 {
02005 ERROR2( -1, "BmpPrefsDlg::GetTIFFCompressionSelection - invalid nBPP" );
02006 }
02007
02008 return Compression;
02009 }
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024
02025
02026
02027
02028
02029
02030
02031
02032 BOOL BmpPrefsDlg::SetTIFFCompressionSelection( TIFF_COMPRESSION Compression, INT32 nBPP )
02033 {
02034 if( nBPP == 1 )
02035 {
02036 if
02037 (
02038 Compression != TIFF_2D &&
02039 Compression != TIFF_PACK &&
02040 Compression != TIFF_HUFFMAN &&
02041 Compression != TIFF_G3_FAX &&
02042 Compression != TIFF_G4_FAX &&
02043 Compression != TIFF_UNCOMPRESSED
02044 ) return FALSE;
02045 }
02046 else if( nBPP==8 || nBPP==24 || nBPP==32 )
02047 {
02048 if
02049 (
02050 Compression != TIFF_LZW &&
02051 Compression != TIFF_UNCOMPRESSED
02052 ) return FALSE;
02053 }
02054 else if( nBPP == 4 )
02055 {
02056 if
02057 (
02058 Compression != TIFF_UNCOMPRESSED
02059 ) return FALSE;
02060 }
02061 else
02062 {
02063 ERROR2( -1, "BmpPrefsDlg::GetTIFFCompressionSelection - invalid nBPP" );
02064 }
02065
02066
02067 INT32 nIndex;
02068 switch ( Compression )
02069 {
02070 case TIFF_UNCOMPRESSED: nIndex = UNCOMPRESSED_TIFF; break;
02071 case TIFF_LZW: nIndex = LZW_TIFF; break;
02072 case TIFF_HUFFMAN: nIndex = HUFFMAN_TIFF; break;
02073 case TIFF_G3_FAX: nIndex = G3FAX_TIFF; break;
02074 case TIFF_G4_FAX: nIndex = G4FAX_TIFF; break;
02075 case TIFF_PACK: nIndex = PACKBITS_TIFF; break;
02076 case TIFF_2D: nIndex = TWODENCODING_TIFF; break;
02077 default: nIndex = UNCOMPRESSED_TIFF; break;
02078 }
02079
02080
02081 return SetSelectedValueIndex(_R(IDC_BMPOPTS_TIFF), nIndex);
02082 }
02083
02084
02085
02086
02087
02088
02089
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101 BOOL BmpPrefsDlg::CommitDialogValues()
02102 {
02103 BitmapExportOptions* pOptions = GetOptions();
02104 ERROR2IF(pOptions == NULL, FALSE, "BmpPrefsDlg::CommitDialogValues called after duff initialisation?!");
02105
02106
02107
02108
02109 BOOL Valid = 0;
02110
02111
02112
02113 pOptions->SetPixelOutputSize(PixelWidth, PixelHeight);
02114
02115
02116
02117
02118 if (m_bDpiSupported)
02119 {
02120
02121
02122
02123 double Value = (double)GetLongGadgetValue(_R(IDC_BMPOPTS_RES), 5, MAXDPI, _R(IDS_BMPPREFS_INVALIDDPI) ,&Valid);
02124 if (Valid)
02125 {
02126
02127 pOptions->SetDPI(Value);
02128 }
02129 else
02130 return FALSE;
02131
02132 RecalculatePixels();
02133 }
02134 else
02135 {
02136 double Resolution = (Width>0) ? ((double) PixelWidth * 72000.0) / ((double) Width) : 96.0;
02137
02138 if (Resolution < 5.0)
02139 {
02140
02141 InformError(_R(IDS_BMPPREFS_DPITOOSMALL));
02142
02143 return FALSE;
02144 }
02145 else if (Resolution > D_MAXDPI)
02146 {
02147
02148 InformError(_R(IDS_BMPPREFS_DPITOOBIG));
02149
02150 return FALSE;
02151 }
02152 else
02153 {
02154 INT32 b_dpi = (INT32)(Resolution + 0.5);
02155 Dpi = b_dpi;
02156 }
02157 pOptions->SetDPI(Dpi);
02158 }
02159
02160
02161 BOOL State = 0;
02162 UINT32 Depth = 24;
02163 if ( GetLongGadgetValue(_R(IDC_BMPOPTS_CMYK), 0, 1, 0, &Valid) )
02164 {
02165 pOptions->SetCMYK(TRUE);
02166 Depth = 32;
02167 }
02168 else if ( GetLongGadgetValue(_R(IDC_BMPOPTS_24BPP), 0, 1, 0, &Valid) )
02169 Depth = 24;
02170 else if ( GetLongGadgetValue(_R(IDC_BMPOPTS_8BPP), 0, 1, 0, &Valid) )
02171 Depth = 8;
02172 else if ( GetLongGadgetValue(_R(IDC_BMPOPTS_4BPP), 0, 1, 0, &Valid) )
02173 Depth = 4;
02174 else if ( GetLongGadgetValue(_R(IDC_BMPOPTS_1BPP), 0, 1, 0, &Valid) )
02175 Depth = 1;
02176 pOptions->SetDepth(Depth);
02177
02178
02179
02180 if (!SetNumColoursInPalette(pOptions))
02181 return FALSE;
02182
02183
02184 PALETTE Palette = PAL_STANDARD;
02185 if ( GetLongGadgetValue(_R(IDC_BMPOPTS_PAL_OPT), 0, 1, 0, &Valid) )
02186 {
02187 TRACEUSER( "Will", _T("Optimised Palette selected\n"));
02188 Palette = PAL_OPTIMISED;
02189 }
02190
02191
02192 DITHER DitherType = XARADITHER_ERROR_DIFFUSION;
02193 if ( GetLongGadgetValue(_R(IDC_BMPOPTS_NODITHER), 0, 1, 0, &Valid) )
02194 DitherType = XARADITHER_NONE;
02195 else if ( GetLongGadgetValue(_R(IDC_BMPOPTS_ORDDITHER), 0, 1, 0, &Valid) )
02196 DitherType = XARADITHER_ORDERED_GREY;
02197 else if ( GetLongGadgetValue(_R(IDC_BMPOPTS_DIFFUSION), 0, 1, 0, &Valid) )
02198 DitherType = XARADITHER_ERROR_DIFFUSION;
02199
02200 TRACEUSER( "Will", _T("Dither %d selected\n"), DitherType);
02201
02202
02203
02204
02205
02206 if ((DWORD) PixelWidth > GRenderRegion::GetMaxBitmapWidth() ||
02207 (DWORD) PixelWidth < 1 || (DWORD) PixelHeight < 1 )
02208 {
02209
02210 String_256 WarnMsg;
02211
02212 WarnMsg.MakeMsg(_R(IDE_BMP_BADPIXELWIDTH), GRenderRegion::GetMaxBitmapWidth());
02213 Error::SetError(0, WarnMsg, 0);
02214 InformWarning(0, _R(IDS_OK));
02215 return FALSE;
02216 }
02217
02218
02219 switch ( pOptions->GetFilterType() )
02220 {
02221 case TIFF_UNCOMPRESSED:
02222 {
02223
02224 #ifndef WEBSTER
02225 TIFFExportOptions* pTIFFOptions = (TIFFExportOptions*)pOptions;
02226 ERROR3IF(!pTIFFOptions->IS_KIND_OF(TIFFExportOptions), "pTIFFOptions isn't");
02227
02228
02229 TIFF_COMPRESSION Compression = GetTIFFCompressionSelection(Depth);
02230 ERROR2IF( (Compression==-1), FALSE, "BmpPrefsDlg::CommitDialogValues - invalid compresion type" );
02231 pTIFFOptions->SetCompression(Compression);
02232
02233
02234
02235 pTIFFOptions->SetDither(DitherType);
02236 pTIFFOptions->SetPalette(Palette);
02237 AccusoftFilters::SetDitherToUse(DitherType);
02238
02239 #endif //WEBSTER
02240 break;
02241 }
02242 case PNG:
02243 {
02244 PNGExportOptions* pPNGOptions = (PNGExportOptions*)pOptions;
02245 ERROR3IF(!pPNGOptions->IS_KIND_OF(PNGExportOptions), "pPNGOptions isn't");
02246
02247
02248 BOOL Interlace = GetLongGadgetValue(_R(IDC_BMPOPTS_INTERLACED), 0, 1, 0, &Valid);
02249 BOOL Transparent = GetLongGadgetValue(_R(IDC_BMPOPTS_TRANSPARENT), 0, 1, 0, &Valid);
02250
02251
02252 if (Valid)
02253 {
02254
02255 pPNGOptions->SetMakeInterlaced(Interlace);
02256
02257
02258
02259 if (!Transparent)
02260 pPNGOptions->SetTransparencyIndex(-1);
02261 }
02262 pPNGOptions->SetDither(DitherType);
02263
02264 break;
02265 }
02266
02267 case MAKE_BITMAP_FILTER:
02268 {
02269 MakeBitmapExportOptions* pMkBOptions = (MakeBitmapExportOptions*)pOptions;
02270 ERROR3IF(!pMkBOptions->IS_KIND_OF(MakeBitmapExportOptions), "pMkBOptions isn't");
02271
02272 pMkBOptions->SetDither(DitherType);
02273
02274
02275
02276 BOOL Interlace = GetLongGadgetValue(_R(IDC_BMPOPTS_INTERLACED), 0, 1, 0, &Valid);
02277 BOOL Transparent = GetLongGadgetValue(_R(IDC_BMPOPTS_TRANSPARENT), 0, 1, 0, &Valid);
02278
02279 pMkBOptions->SetMakeInterlaced(Interlace);
02280
02281 break;
02282 }
02283 case TI_GIF:
02284 case TI_GIF_ANIM:
02285 {
02286 GIFExportOptions* pGIFOptions = (GIFExportOptions*)pOptions;
02287 ERROR3IF(!pGIFOptions->IS_KIND_OF(GIFExportOptions), "pGIFOptions isn't");
02288
02289 pGIFOptions->SetDither(DitherType);
02290
02291
02292
02293 BOOL Interlace = GetLongGadgetValue(_R(IDC_BMPOPTS_INTERLACED), 0, 1, 0, &Valid);
02294 BOOL Transparent = GetLongGadgetValue(_R(IDC_BMPOPTS_TRANSPARENT), 0, 1, 0, &Valid);
02295
02296 pGIFOptions->SetMakeInterlaced(Interlace);
02297
02298
02299
02300 if (!Transparent)
02301 pGIFOptions->SetTransparencyIndex(-1);
02302
02303 if (pOptions->GetFilterType() == TI_GIF)
02304 {
02305 HideGadget(_R(IDC_ANIMOPTS_LOOP), TRUE);
02306 HideGadget(_R(IDC_ANIMOPTS_DELAY), TRUE);
02307 HideGadget(_R(IDC_ANIMOPTS_ITERATIONS), TRUE);
02308 HideGadget(_R(IDC_ANIMOPTS_REMOVAL), TRUE);
02309 }
02310
02311 if (pOptions->GetFilterType() == TI_GIF_ANIM)
02312 {
02313 UINT32 List = 0;
02314 BmpDlgParam* pBmpDlgParam = pOptions->GetBmpDlgParam();
02315
02316 if (pBmpDlgParam != NULL)
02317 {
02318 KernelBitmap** pListOfBitmaps = pBmpDlgParam->GetBitmapList();
02319 List = pBmpDlgParam->GetListSize();
02320
02321 ERROR3IF(pListOfBitmaps == NULL && List > 0, "Where Have Our Bitmaps Gone?");
02322
02323 if(pListOfBitmaps != NULL)
02324 {
02325 pGIFOptions->SetBitmapList(pListOfBitmaps);
02326 pGIFOptions->SetListSize(List);
02327 }
02328 }
02329
02330
02331 if (HasDelayChanged)
02332 {
02333 CENTISECONDS Delay = GetLongGadgetValue(_R(IDC_ANIMOPTS_DELAY), 0, 65535, _R(IDS_BMPPREFS_INVALIDDELAY) ,&Valid);
02334
02335 if (Valid)
02336 {
02337 pBmpDlgParam->SetAnimDelay(Delay);
02338 pBmpDlgParam->SetAreDelayValuesSame(TRUE);
02339
02340 UINT32 ListSize = pGIFOptions->GetListSize();
02341 KernelBitmap** pListOfBitmaps = pGIFOptions->GetBitmapList();
02342
02343 ERROR3IF(pListOfBitmaps == NULL && ListSize > 0,"Do what");
02344
02345
02346
02347 if (pListOfBitmaps != NULL)
02348 {
02349 while (ListSize > 0)
02350 {
02351 KernelBitmap* pBitmap = pListOfBitmaps[--ListSize] ;
02352
02353 if(pBitmap != NULL)
02354 {
02355 pBitmap->SetDelay(pBmpDlgParam->GetAnimDelay());
02356 }
02357 }
02358 }
02359 }
02360 else
02361 return FALSE;
02362 }
02363
02364
02365 if (HasRestoreChanged)
02366 {
02367 INT32 Restore = GetSelectedValueIndex(_R(IDC_ANIMOPTS_REMOVAL));
02368
02369 if(Restore != OPTION_FOUR)
02370 {
02371 pBmpDlgParam->SetRestoreType((GIFDisposalMethod) Restore);
02372 pBmpDlgParam->SetSameRestoreType(TRUE);
02373 UINT32 ListSize = pGIFOptions->GetListSize();
02374
02375 KernelBitmap** pListOfBitmaps = pGIFOptions->GetBitmapList();
02376 ERROR3IF(pListOfBitmaps == NULL && ListSize > 0,"Do what");
02377
02378
02379 if (pListOfBitmaps != NULL)
02380 {
02381 while (ListSize > 0)
02382 {
02383 KernelBitmap* pKernelBitmap = pListOfBitmaps[--ListSize] ;
02384
02385 if (pKernelBitmap != NULL)
02386 {
02387 OILBitmap* pOILBitmap = pKernelBitmap->GetActualBitmap();
02388
02389 if (pOILBitmap != NULL)
02390 {
02391 pOILBitmap->SetAnimationRestoreType(pBmpDlgParam->GetRestoreType());
02392
02393 }
02394 }
02395 }
02396 }
02397 }
02398 }
02399
02400 BOOL Value = GetBoolGadgetSelected(_R(IDC_ANIMOPTS_LOOP));
02401 INT32 Loop = GetLongGadgetValue(_R(IDC_ANIMOPTS_ITERATIONS), 0, 65535, _R(IDS_BMPPREFS_INVALIDLOOP) ,&Valid);
02402 if (Valid)
02403 {
02404 pGIFOptions->SetAnimationLoopCount(Loop, Value);
02405 }
02406 else
02407 return FALSE;
02408
02409 }
02410 break;
02411 }
02412
02413 case BMP_UNCOMPRESSED:
02414 {
02415 BMPExportOptions* pBMPOptions = (BMPExportOptions*)pOptions;
02416 ERROR3IF(!pBMPOptions->IS_KIND_OF(BMPExportOptions), "pBMPOptions isn't");
02417
02418
02419
02420 #ifndef WEBSTER
02421
02422 BMP_COMPRESSION Compression;
02423 State = GetLongGadgetValue(_R(IDC_BMPOPTS_RLE), 0, 1, 0, &Valid);
02424 if (State && (Depth == 4 || Depth == 8))
02425 Compression = BMP_RLE;
02426 else
02427 Compression = BMP_RGB;
02428
02429 if (Valid)
02430 {
02431 pBMPOptions->SetCompression(Compression);
02432 }
02433 #endif // WEBSTER
02434
02435 pBMPOptions->SetCompression(BMP_RGB);
02436
02437 pBMPOptions->SetDither(DitherType);
02438 pBMPOptions->SetPalette(Palette);
02439 break;
02440 }
02441
02442
02443 case WPG:
02444 case PHOTOCD:
02445 case IFF_ILBM:
02446 case XWD:
02447 case DCX:
02448 case PCX:
02449 case PICT:
02450 case RAST:
02451 case PHOTOSHOP:
02452 case TARGA:
02453 case MACPAINT:
02454 case MSP:
02455 {
02456
02457 #ifndef WEBSTER
02458 AccusoftExportOptions* pAccyOptions = (AccusoftExportOptions*)pOptions;
02459 ERROR3IF(!pAccyOptions->IS_KIND_OF(AccusoftExportOptions), "pAccyOptions isn't");
02460
02461 pAccyOptions->SetDither(DitherType);
02462 pAccyOptions->SetPalette(Palette);
02463 #endif //WEBSTER
02464 break;
02465 }
02466
02467 default:
02468
02469
02470 break;
02471 }
02472
02473
02474 SelectionType FoundSelection = GetSelection();
02475 pOptions->SetSelectionType(FoundSelection);
02476
02477 return TRUE;
02478 }
02479
02480
02481
02482
02483
02484
02485
02486
02487
02488
02489
02490
02491
02492
02493
02494
02495
02496
02497 MsgResult BmpPrefsDlg::Message(Msg* Message)
02498 {
02499 if (IS_OUR_DIALOG_MSG(Message))
02500 {
02501 DialogMsg* Msg = (DialogMsg*) Message;
02502 MsgResult Result;
02503 BOOL EndDialog = FALSE;
02504
02505 BitmapExportOptions* pOptions = GetOptions();
02506 ERROR3IF(pOptions == NULL, "BmpPrefsDlg::Message - Parameters not been set up");
02507
02508
02509 switch (Msg->DlgMsg)
02510 {
02511 case DIM_CREATE:
02512 {
02513
02514 RecalculatingPixels = FALSE;
02515 RecalculatingXDpi = FALSE;
02516 RecalculatingYDpi = FALSE;
02517
02518
02519
02520
02521 InitDialog();
02522 HasDelayChanged = FALSE;
02523 HasRestoreChanged = FALSE;
02524 }
02525 break;
02526
02527 case DIM_COMMIT:
02528 {
02529
02530
02531
02532 BOOL ok;
02533 ok = CommitDialogValues();
02534 if (ok)
02535 {
02536
02537 GetOptions()->MarkValid();
02538 EndDialog = TRUE;
02539 }
02540 }
02541 break;
02542
02543 case DIM_CANCEL:
02544
02545 GetOptions()->MarkInvalid();
02546 EndDialog = TRUE;
02547 break;
02548
02549 case DIM_LISTDROPPED:
02550 {
02551
02552 HasRestoreChanged = TRUE;
02553
02554 if(IsManyDisplayed)
02555 {
02556 DeleteAllValues(_R(IDC_ANIMOPTS_REMOVAL));
02557 SetStringGadgetValue(_R(IDC_ANIMOPTS_REMOVAL), _R(IDS_RESTORE_NOTHING));
02558 SetStringGadgetValue(_R(IDC_ANIMOPTS_REMOVAL), _R(IDS_RESTORE_LEAVEASIS));
02559 SetStringGadgetValue(_R(IDC_ANIMOPTS_REMOVAL), _R(IDS_RESTORE_BACKGROUND));
02560 SetStringGadgetValue(_R(IDC_ANIMOPTS_REMOVAL), _R(IDS_RESTORE_PREVIOUS));
02561 SetStringGadgetValue(_R(IDC_ANIMOPTS_REMOVAL), _R(IDS_MANY));
02562 SetSelectedValueIndex(_R(IDC_ANIMOPTS_REMOVAL), OPTION_FOUR);
02563 SetComboListLength(_R(IDC_ANIMOPTS_REMOVAL));
02564 IsManyDisplayed = FALSE;
02565 }
02566 }
02567 break;
02568
02569 case DIM_LFT_BN_CLICKED:
02570
02571
02572 if (Msg->GadgetID == _R(ID_CC_HELP_BUTTON))
02573 {
02574 UINT32 HelpID = GetFilterHelpID(GetOptions()->GetFilterType());
02575
02576 if (HelpID > 0)
02577 {
02578
02579 HelpUserTopic(HelpID);
02580 return DLG_EAT_IF_HUNGRY(Msg);
02581 }
02582 }
02583
02584 switch (Msg->GadgetID)
02585 {
02586 if (pOptions->GetFilterType() != JPEG)
02587 {
02588
02589
02590
02591 case _R(IDC_BMPOPTS_CMYK):
02592 case _R(IDC_BMPOPTS_24BPP):
02593 case _R(IDC_BMPOPTS_8BPP):
02594 case _R(IDC_BMPOPTS_4BPP):
02595 case _R(IDC_BMPOPTS_1BPP):
02596 SetBPPButtons(Msg->GadgetID,TRUE);
02597 break;
02598
02599 case _R(IDC_BMPOPTS_PAL_STD):
02600 case _R(IDC_BMPOPTS_PAL_OPT):
02601 SetPaletteButtons(Msg->GadgetID);
02602 break;
02603
02604 case _R(IDC_BMPOPTS_NODITHER):
02605 case _R(IDC_BMPOPTS_ORDDITHER):
02606 case _R(IDC_BMPOPTS_DIFFUSION):
02607 SetDitherButtons(Msg->GadgetID);
02608 break;
02609 case _R(IDC_ANIMOPTS_LOOP):
02610 {
02611 BOOL Value = GetBoolGadgetSelected(_R(IDC_ANIMOPTS_LOOP));
02612 if (Value)
02613 {
02614 SetLoopCheckBox(TRUE);
02615 SetBmpPrefsDlgState();
02616 }
02617 else
02618 {
02619 SetLoopCheckBox(FALSE);
02620 SetBmpPrefsDlgState();
02621 }
02622 }
02623 break;
02624 }
02625
02626
02627
02628 case _R(IDC_BMPOPTS_DRAWING):
02629 case _R(IDC_BMPOPTS_SELECT):
02630 RecalculateSize();
02631 break;
02632 }
02633 break;
02634
02635 case DIM_SELECTION_CHANGED:
02636
02637 switch (Msg->GadgetID)
02638 {
02639 case _R(IDC_BMPOPTS_RES):
02640 RecalculatePixels();
02641 break;
02642 }
02643 break;
02644
02645 case DIM_TEXT_CHANGED:
02646
02647 switch (Msg->GadgetID)
02648 {
02649 case _R(IDC_BMPOPTS_RES):
02650 RecalculatePixels();
02651 break;
02652 case _R(IDC_BMPOPTS_XPIXELS):
02653 RecalculateDpiFromX();
02654 break;
02655 case _R(IDC_BMPOPTS_YPIXELS):
02656 RecalculateDpiFromY();
02657 break;
02658 case _R(IDC_ANIMOPTS_DELAY):
02659 HasDelayChanged = TRUE;
02660 break;
02661 }
02662 break;
02663
02664 }
02665
02666
02667
02668
02669 Result = DialogOp::Message(Message);
02670
02671
02672 if (EndDialog)
02673 {
02674 Close();
02675 End();
02676 }
02677
02678
02679
02680 return Result;
02681 }
02682
02683 return DialogOp::Message(Message);
02684 }
02685
02686
02687
02688
02689
02690
02691
02692
02693
02694
02695
02696
02697
02698
02699
02700
02701 UINT32 BmpPrefsDlg::GetFilterHelpID(UINT32 FilterType)
02702 {
02703 UINT32 HelpID = 0;
02704
02705 switch (FilterType)
02706 {
02707 case MAKE_BITMAP_FILTER:
02708 HelpID = _R(IDH_Command_Create_Bitmap_Copy);
02709 break;
02710
02711 case JPEG:
02712 HelpID = _R(IDH_Dialog_Bitmap_Export_JPEG);
02713 break;
02714
02715 case GIF:
02716 case TI_GIF:
02717 HelpID = _R(IDH_Dialog_Bitmap_Export_GIF);
02718 break;
02719
02720 case TI_GIF_ANIM:
02721 HelpID = _R(IDH_Dialog_Bitmap_Export_Animated_GIF);
02722 break;
02723
02724 case BMP_COMPRESSED:
02725 case BMP_UNCOMPRESSED:
02726 HelpID = _R(IDH_Dialog_Bitmap_Export_BMP);
02727 break;
02728 }
02729
02730 return HelpID;
02731 }
02732
02733
02734
02735
02736
02737
02738
02739
02740
02741
02742
02743
02744
02745
02746
02747
02748 OpState BmpPrefsDlg::GetState(String_256*, OpDescriptor*)
02749 {
02750 OpState OpSt;
02751 return(OpSt);
02752 }
02753
02754
02755
02756
02757
02758
02759
02760
02761
02762
02763
02764
02765
02766
02767
02768
02769
02770 BOOL BmpPrefsDlg::Init()
02771 {
02772 BOOL InitOK;
02773
02774 InitOK = RegisterOpDescriptor(
02775 0,
02776 _R(IDS_BMPPREFSDLG),
02777 CC_RUNTIME_CLASS(BmpPrefsDlg),
02778 OPTOKEN_BMPPREFSDLG,
02779 GetState,
02780 0,
02781 0,
02782 0,
02783 0
02784 );
02785
02786 if (InitOK)
02787 {
02788 InitOK = RegisterOpDescriptor(
02789 0,
02790 _R(IDS_BMPPREFSDLG),
02791 CC_RUNTIME_CLASS(JPEGExportPrefsDialog),
02792 OPTOKEN_JPGPREFSDLG,
02793 GetState,
02794 0,
02795 0,
02796 0,
02797 0
02798 );
02799 }
02800 return (InitOK);
02801 }
02802
02803
02804
02805
02806
02807
02808
02809
02810
02811
02812
02813
02814
02815
02816 BOOL BmpPrefsDlg::InvokeDialog(BitmapExportOptions* pExportOptions)
02817 {
02818 ERROR2IF(pExportOptions == NULL, FALSE, "pExportOptions NULL");
02819 ERROR3IF(!pExportOptions->IS_KIND_OF(BitmapExportOptions), "pExportOptions isn't");
02820
02821 IDD = pExportOptions->GetDialogType();
02822
02823 OpDescriptor *OpDesc;
02824 if (IDD == _R(IDD_EXPORTJPEGOPTS))
02825 OpDesc = OpDescriptor::FindOpDescriptor(OPTOKEN_JPGPREFSDLG);
02826 else
02827 OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(BmpPrefsDlg));
02828
02829
02830 if (OpDesc == NULL)
02831 {
02832 ERROR3("BmpPrefsDlg::InvokeDialog is unable to find the BmpPrefsDlg OpDescriptor");
02833 pExportOptions->MarkInvalid();
02834 }
02835 else
02836 {
02837 OpDesc->Invoke((OpParam *)pExportOptions);
02838 }
02839
02840 return pExportOptions->IsValid();
02841 }
02842
02843
02844
02845
02846
02847
02848
02849
02850
02851
02852
02853
02854
02855
02856
02857
02858
02859
02860
02861 BOOL BmpPrefsDlg::Create()
02862 {
02863 if (DialogOp::Create())
02864 {
02865
02866
02867
02868
02869 return TRUE;
02870 }
02871 else
02872 {
02873 return FALSE;
02874 }
02875 }
02876
02877
02878
02879
02880
02881
02882
02883
02884
02885
02886
02887
02888
02889
02890
02891
02892
02893
02894
02895 void BmpPrefsDlg::Do(OpDescriptor*)
02896 {
02897 BOOL ok;
02898
02899
02900 ok = Create();
02901
02902 if ( !ok )
02903 {
02904
02905 InformError();
02906 End();
02907 }
02908 }
02909
02910
02911
02912
02913
02914
02915
02916
02917
02918
02919
02920
02921
02922
02923
02924
02925
02926
02927 void BmpPrefsDlg::DoWithParam(OpDescriptor*, OpParam* pParam)
02928 {
02929 if (pParam == NULL)
02930 {
02931 ERROR3("BmpPrefsDlg::DoWithParam - NULL Args");
02932 return;
02933 }
02934
02935
02936 ERROR3IF(!pParam->IS_KIND_OF(BitmapExportOptions), "pParam isn't");
02937 m_pOptions = (BitmapExportOptions*) pParam;
02938
02939 BOOL ok;
02940
02941
02942 ok = Create();
02943
02944 if ( !ok )
02945 {
02946
02947 InformError();
02948 End();
02949 }
02950 }
02951
02952
02953
02954
02955
02956
02957
02958
02959
02960
02961
02962
02963
02964
02965
02966
02967
02968 BOOL BmpPrefsDlg::SetUpResolutionList()
02969 {
02970 if (!m_bDpiSupported)
02971 {
02972 SetStringGadgetValue(_R(IDC_BMPOPTS_RES), &String_8(" -"), FALSE, -1);
02973 return TRUE;
02974 }
02975
02976
02977
02978 SetLongGadgetValue(_R(IDC_BMPOPTS_RES), (INT32)GetOptions()->GetDPI(), FALSE, -1);
02979
02980 SetLongGadgetValue(_R(IDC_BMPOPTS_RES), 50);
02981 SetLongGadgetValue(_R(IDC_BMPOPTS_RES), 75);
02982 SetLongGadgetValue(_R(IDC_BMPOPTS_RES), 96);
02983 SetLongGadgetValue(_R(IDC_BMPOPTS_RES), 100);
02984 SetLongGadgetValue(_R(IDC_BMPOPTS_RES), 150);
02985 SetLongGadgetValue(_R(IDC_BMPOPTS_RES), 200);
02986 SetLongGadgetValue(_R(IDC_BMPOPTS_RES), 250);
02987 SetLongGadgetValue(_R(IDC_BMPOPTS_RES), 300);
02988 SetComboListLength(_R(IDC_BMPOPTS_RES));
02989
02990 return TRUE;
02991 }
02992
02993
02994
02995
02996
02997
02998
02999
03000
03001
03002
03003
03004
03005
03006
03007
03008 BOOL BmpPrefsDlg::SetBmpPrefsDlgState()
03009 {
03010 BitmapExportOptions* pOptions = GetOptions();
03011 ERROR2IF(pOptions == NULL, FALSE, "pOptions is NULL");
03012
03013
03014 if (GetLoopCheckBox())
03015 {
03016
03017 EnableGadget(_R(IDC_ANIMOPTS_ITERATIONS), FALSE);
03018 }
03019
03020
03021 if (!GetLoopCheckBox())
03022 {
03023 GIFExportOptions* pGIFOptions = (GIFExportOptions*)pOptions;
03024 ERROR3IF(!pGIFOptions->IS_KIND_OF(GIFExportOptions), "pGIFOptions isn't");
03025
03026
03027 EnableGadget(_R(IDC_ANIMOPTS_ITERATIONS), TRUE);
03028 SetLongGadgetValue(_R(IDC_ANIMOPTS_ITERATIONS), pGIFOptions->GetAnimationLoopCount());
03029 }
03030 return TRUE;
03031 }
03032
03033
03034
03035
03036
03037
03038
03039
03040
03041
03042
03043
03044 BOOL BmpPrefsDlg::InitDialog()
03045 {
03046 BitmapExportOptions* pOptions = GetOptions();
03047 ERROR2IF(pOptions == NULL, FALSE, "pOptions NULL");
03048
03049 if (pOptions->GetFilterType() != MAKE_BITMAP_FILTER)
03050 {
03051
03052
03053 String_256 Temp = *(pOptions->GetFilterName());
03054 Temp += String_256(_R(IDN_EXPORTBMPOPTS));
03055
03056 SetTitlebarName(&Temp);
03057 }
03058
03059
03060 m_bLockAspect = TRUE;
03061
03062
03063
03064
03065 UINT32 Depth = pOptions->GetDepth();
03066 BOOL bYoDither = FALSE;
03067 PALETTE Palette;
03068 DITHER Dither;
03069
03070
03071
03072 #ifdef WEBSTER
03073 HideGadget(_R(IDC_BMPOPTS_TIFF), TRUE);
03074 HideGadget(_R(IDC_BMPOPTS_RLE), TRUE);
03075 HideGadget(_R(IDC_BMPOPTS_RGB), TRUE);
03076 HideGadget(_R(IDC_BMPOPTS_COMPRESS), TRUE);
03077 #endif // WEBSTER
03078
03079
03080
03081
03082 InitNumColoursGroup(pOptions);
03083
03084
03085 switch ( pOptions->GetFilterType() )
03086 {
03087 case TIFF_UNCOMPRESSED:
03088 {
03089
03090 #ifndef WEBSTER
03091 BOOL ok;
03092 TIFFExportOptions* pTIFFOptions = (TIFFExportOptions*)pOptions;
03093 ERROR3IF(!pTIFFOptions->IS_KIND_OF(TIFFExportOptions), "pTIFFOptions isn't");
03094
03095
03096 HideGadget(_R(IDC_BMPOPTS_TIFF), FALSE);
03097 HideGadget(_R(IDC_BMPOPTS_RLE), TRUE);
03098 HideGadget(_R(IDC_BMPOPTS_RGB), TRUE);
03099 HideGadget(_R(IDC_BMPOPTS_COMPRESS), FALSE);
03100
03101
03102
03103
03104
03105 HideGadget(_R(IDC_BMPOPTS_32BPP), TRUE);
03106
03107
03108
03109 INT32 TiffCompression = pTIFFOptions->GetCompression();
03110
03111
03112
03113 ok = SetLongGadgetValue(_R(IDC_BMPOPTS_TIFF), pTIFFOptions->GetCompression(), FALSE, -1);
03114
03115
03116
03117 SetStringGadgetValue(_R(IDC_BMPOPTS_TIFF), &String_32(_R(IDN_TIFF_NONE)));
03118
03119 if( Depth==8 || Depth==24 || Depth==32 )
03120 {
03121 SetStringGadgetValue(_R(IDC_BMPOPTS_TIFF), &String_32(_R(IDN_TIFF_LZW)));
03122 }
03123
03124
03125 if (Depth == 1)
03126 {
03127
03128 SetStringGadgetValue(_R(IDC_BMPOPTS_TIFF), &String_32(_R(IDN_TIFF_HUFFMAN)));
03129 SetStringGadgetValue(_R(IDC_BMPOPTS_TIFF), &String_32(_R(IDN_TIFF_G3FAX)));
03130 SetStringGadgetValue(_R(IDC_BMPOPTS_TIFF), &String_32(_R(IDN_TIFF_G4FAX)));
03131 SetStringGadgetValue(_R(IDC_BMPOPTS_TIFF), &String_32(_R(IDN_TIFF_PACKBITS)));
03132 }
03133 else
03134 {
03135
03136
03137
03138
03139 }
03140 SetComboListLength(_R(IDC_BMPOPTS_TIFF));
03141
03142 ok = SetTIFFCompressionSelection( TiffCompression, Depth );
03143
03144
03145 if( ! ok )
03146 {
03147 ok = SetTIFFCompressionSelection( TIFF_UNCOMPRESSED, Depth );
03148
03149
03150 ERROR3IF( (!ok), "BmpPrefsDlg::InitDialog - could not select uncompressed" );
03151 }
03152
03153 Palette = pTIFFOptions->GetPalette();
03154 Dither = pTIFFOptions->GetDither();
03155 bYoDither = TRUE;
03156
03157 m_bDpiSupported = TRUE;
03158 #endif //WEBSTER
03159 break;
03160 }
03161 case PNG:
03162 {
03163 PNGExportOptions* pPNGOptions = (PNGExportOptions*)pOptions;
03164 ERROR3IF(!pPNGOptions->IS_KIND_OF(PNGExportOptions), "pPNGOptions isn't");
03165
03166
03167
03168
03169 #ifndef WEBSTER
03170 HideGadget(_R(IDC_BMPOPTS_TIFF), TRUE);
03171 HideGadget(_R(IDC_BMPOPTS_RLE), TRUE);
03172 HideGadget(_R(IDC_BMPOPTS_RGB), TRUE);
03173 HideGadget(_R(IDC_BMPOPTS_COMPRESS), TRUE);
03174 #endif // WEBSTER
03175
03176 HideGadget(_R(IDC_BMPOPTS_CMYK), TRUE);
03177 EnableGadget(_R(IDC_BMPOPTS_32BPP), FALSE);
03178
03179
03180
03181
03182
03183
03184 BOOL Transparent = pPNGOptions->WantTransparent();
03185 BOOL Interlace = pPNGOptions->WantInterlaced();
03186
03187 if (Depth == 24 || Depth == 32)
03188 Transparent = FALSE;
03189 HideGadget(_R(IDC_BMPOPTS_GIFTYPE), FALSE);
03190 HideGadget(_R(IDC_BMPOPTS_TRANSPARENT), FALSE);
03191 HideGadget(_R(IDC_BMPOPTS_INTERLACED), FALSE);
03192 EnableGadget(_R(IDC_BMPOPTS_GIFTYPE), TRUE);
03193 EnableGadget(_R(IDC_BMPOPTS_INTERLACED), TRUE);
03194 SetLongGadgetValue(_R(IDC_BMPOPTS_TRANSPARENT), Transparent);
03195 SetLongGadgetValue(_R(IDC_BMPOPTS_INTERLACED), Interlace);
03196
03197
03198 Dither = pPNGOptions->GetDither();
03199 bYoDither = TRUE;
03200
03201 m_bDpiSupported = TRUE;
03202 break;
03203 }
03204 case GIF:
03205 case TI_GIF:
03206 case TI_GIF_ANIM:
03207 {
03208 GIFExportOptions* pGIFOptions = (GIFExportOptions*)pOptions;
03209 ERROR3IF(!pGIFOptions->IS_KIND_OF(GIFExportOptions), "pGIFOptions isn't");
03210
03211
03212
03213
03214 #ifndef WEBSTER
03215 HideGadget(_R(IDC_BMPOPTS_TIFF), TRUE);
03216 HideGadget(_R(IDC_BMPOPTS_RLE), TRUE);
03217 HideGadget(_R(IDC_BMPOPTS_RGB), TRUE);
03218 HideGadget(_R(IDC_BMPOPTS_COMPRESS), TRUE);
03219 #endif // WEBSTER
03220
03221 m_bDpiSupported = FALSE;
03222
03223
03224 if (Depth == 32 || Depth == 24)
03225 Depth = 8;
03226
03227 HideGadget(_R(IDC_BMPOPTS_CMYK), TRUE);
03228 EnableGadget(_R(IDC_BMPOPTS_32BPP), FALSE);
03229 EnableGadget(_R(IDC_BMPOPTS_24BPP), FALSE);
03230
03231
03232
03233
03234 if (pOptions->GetFilterType() == TI_GIF ||
03235 pOptions->GetFilterType() == TI_GIF_ANIM)
03236 {
03237
03238
03239
03240
03241 BOOL Transparent = pGIFOptions->WantTransparent();
03242 BOOL Interlace = pGIFOptions->WantInterlaced();
03243 HideGadget(_R(IDC_BMPOPTS_GIFTYPE), FALSE);
03244 HideGadget(_R(IDC_BMPOPTS_TRANSPARENT), FALSE);
03245 HideGadget(_R(IDC_BMPOPTS_INTERLACED), FALSE);
03246 EnableGadget(_R(IDC_BMPOPTS_GIFTYPE), TRUE);
03247 EnableGadget(_R(IDC_BMPOPTS_INTERLACED), TRUE);
03248 EnableGadget(_R(IDC_BMPOPTS_TRANSPARENT), TRUE);
03249
03250 SetLongGadgetValue(_R(IDC_BMPOPTS_TRANSPARENT), Transparent);
03251 SetLongGadgetValue(_R(IDC_BMPOPTS_INTERLACED), Interlace);
03252 }
03253 if (pOptions->GetFilterType() == TI_GIF_ANIM)
03254 {
03255 HideGadget(_R(IDC_ANIMOPTS_ANIMGROUP) , FALSE);
03256 HideGadget(_R(IDC_ANIMOPTS_REMOVAL) , FALSE);
03257 HideGadget(_R(IDC_ANIMOPTS_DELAYFOR) , FALSE);
03258 HideGadget(_R(IDC_ANIMOPTS_CS) , FALSE);
03259 HideGadget(_R(IDC_ANIMOPTS_LOOPTEXT) , FALSE);
03260 HideGadget(_R(IDC_ANIMOPTS_DELAY) , FALSE);
03261 HideGadget(_R(IDC_ANIMOPTS_ITERATIONS), FALSE);
03262 HideGadget(_R(IDC_ANIMOPTS_TIMES) , FALSE);
03263 HideGadget(_R(IDC_ANIMOPTS_LOOP) , FALSE);
03264 HideGadget(_R(IDC_ANIMOPTS_RESTORE) , FALSE);
03265
03266
03267 m_bLockAspect = FALSE;
03268
03269
03270
03271
03272
03273 WINDOWPLACEMENT Place;
03274 Place.length = sizeof(WINDOWPLACEMENT);
03275 if (GetWindowPlacement((HWND)WindowID, &Place))
03276 {
03277 Place.rcNormalPosition.bottom = Place.rcNormalPosition.bottom + (ANIMATION_EXTRABIT);
03278 SetWindowPlacement((HWND)WindowID, &Place);
03279 }
03280
03281
03282 BmpDlgParam* pBmpDlgParam = pOptions->GetBmpDlgParam();
03283 if (pBmpDlgParam == NULL)
03284 return FALSE;
03285
03286
03287
03288
03289 UINT32 ListSize = pBmpDlgParam->GetListSize();
03290 KernelBitmap** pList = pBmpDlgParam->GetBitmapList();
03291 BOOL Transparent = FALSE;
03292 INT32 Index=0;
03293
03294
03295
03296 while (ListSize > 0)
03297 {
03298 KernelBitmap* pKernelBitmap = pList[--ListSize];
03299
03300 if (pKernelBitmap != NULL)
03301 {
03302
03303 if(pKernelBitmap->GetTransparencyIndex(&Index))
03304 Transparent = TRUE;
03305 }
03306 }
03307
03308 HideGadget(_R(IDC_BMPOPTS_TRANSPARENT), FALSE);
03309 EnableGadget(_R(IDC_BMPOPTS_TRANSPARENT), TRUE);
03310 SetLongGadgetValue(_R(IDC_BMPOPTS_TRANSPARENT), Transparent);
03311
03312 if (pBmpDlgParam->GetAreDelayValuesSame())
03313 {
03314 SetLongGadgetValue(_R(IDC_ANIMOPTS_DELAY), pBmpDlgParam->GetAnimDelay());
03315 IsDelayMany=FALSE;
03316 }
03317 else
03318 {
03319 SetStringGadgetValue(_R(IDC_ANIMOPTS_DELAY), _R(IDS_MANY));
03320 IsDelayMany=TRUE;
03321 }
03322
03323 if (pBmpDlgParam->GetSameRestoreType())
03324 {
03325 SetStringGadgetValue(_R(IDC_ANIMOPTS_REMOVAL), &String_32(_R(IDS_RESTORE_NOTHING)));
03326 SetStringGadgetValue(_R(IDC_ANIMOPTS_REMOVAL), &String_32(_R(IDS_RESTORE_LEAVEASIS)));
03327 SetStringGadgetValue(_R(IDC_ANIMOPTS_REMOVAL), &String_32(_R(IDS_RESTORE_BACKGROUND)));
03328 SetStringGadgetValue(_R(IDC_ANIMOPTS_REMOVAL), &String_32(_R(IDS_RESTORE_PREVIOUS)));
03329 SetComboListLength(_R(IDC_ANIMOPTS_REMOVAL));
03330 SetSelectedValueIndex(_R(IDC_ANIMOPTS_REMOVAL), pBmpDlgParam->GetRestoreType());
03331 }
03332 else
03333 {
03334 SetStringGadgetValue (_R(IDC_ANIMOPTS_REMOVAL), _R(IDS_MANY));
03335 SetSelectedValueIndex(_R(IDC_ANIMOPTS_REMOVAL), OPTION_ONE);
03336 IsManyDisplayed = TRUE;
03337 }
03338
03339 SetLongGadgetValue(_R(IDC_ANIMOPTS_ITERATIONS), pGIFOptions->GetAnimationLoopCount());
03340 EnableGadget(_R(IDC_ANIMOPTS_ITERATIONS), FALSE);
03341 SetBoolGadgetSelected(_R(IDC_ANIMOPTS_LOOP), TRUE);
03342
03343 }
03344
03345
03346 Dither = pGIFOptions->GetDither();
03347 bYoDither = TRUE;
03348
03349 break;
03350 }
03351 case MAKE_BITMAP_FILTER:
03352 {
03353 MakeBitmapExportOptions* pMkBOptions = (MakeBitmapExportOptions*)pOptions;
03354 ERROR3IF(!pMkBOptions->IS_KIND_OF(MakeBitmapExportOptions), "pMkBOptions isn't");
03355
03356 HideGadget(_R(IDC_BMPOPTS_CMYK), TRUE);
03357 EnableGadget(_R(IDC_BMPOPTS_32BPP), FALSE);
03358 HideGadget(_R(IDC_BMPOPTS_CREATEOPTS), FALSE);
03359 HideGadget(_R(IDC_BMPOPTS_GIFTYPE), TRUE);
03360
03361
03362 #ifndef WEBSTER
03363 HideGadget(_R(IDC_BMPOPTS_TIFF), TRUE);
03364 HideGadget(_R(IDC_BMPOPTS_RLE), TRUE);
03365 HideGadget(_R(IDC_BMPOPTS_RGB), TRUE);
03366 HideGadget(_R(IDC_BMPOPTS_COMPRESS), TRUE);
03367 #endif // WEBSTER
03368
03369 HideGadget(_R(IDC_ANIMOPTS_LOOP), TRUE);
03370 HideGadget(_R(IDC_ANIMOPTS_DELAY), TRUE);
03371 HideGadget(_R(IDC_ANIMOPTS_ITERATIONS), TRUE);
03372 HideGadget(_R(IDC_ANIMOPTS_REMOVAL), TRUE);
03373
03374 HideGadget(_R(IDC_TIMES_STATIC),TRUE);
03375 HideGadget(_R(IDC_RESTORE_STATIC),TRUE);
03376
03377 m_bDpiSupported = TRUE;
03378
03379
03380
03381
03382 String_256 Temp(_R(IDS_MAKEBMPOPTS));
03383 SetTitlebarName(&Temp);
03384
03385 SetStringGadgetValue(IDOK, &String_32(_R(IDS_CREATEBMP)));
03386 SetStringGadgetValue(_R(IDC_BMPOPTS_SAVEAREA), &String_32(_R(IDS_CREATEFROM)));
03387
03388
03389
03390
03391 BOOL Transparent = pMkBOptions->WantTransparent();
03392 BOOL Interlace = FALSE;
03393 HideGadget(_R(IDC_BMPOPTS_TRANSPARENT), FALSE);
03394 HideGadget(_R(IDC_BMPOPTS_INTERLACED), TRUE);
03395 EnableGadget(_R(IDC_BMPOPTS_INTERLACED), FALSE);
03396 EnableGadget(_R(IDC_BMPOPTS_TRANSPARENT), TRUE);
03397
03398 SetLongGadgetValue(_R(IDC_BMPOPTS_TRANSPARENT), Transparent);
03399
03400
03401 Dither = pMkBOptions->GetDither();
03402 bYoDither = TRUE;
03403 break;
03404 }
03405 case WPG:
03406
03407
03408
03409 #ifndef WEBSTER
03410 HideGadget(_R(IDC_BMPOPTS_TIFF), TRUE);
03411 HideGadget(_R(IDC_BMPOPTS_RLE), TRUE);
03412 HideGadget(_R(IDC_BMPOPTS_RGB), TRUE);
03413 HideGadget(_R(IDC_BMPOPTS_COMPRESS), TRUE);
03414 #endif // WEBSTER
03415
03416
03417 if (Depth == 32 || Depth == 24)
03418 Depth = 8;
03419 m_bDpiSupported = FALSE;
03420
03421 HideGadget(_R(IDC_BMPOPTS_CMYK), TRUE);
03422 EnableGadget(_R(IDC_BMPOPTS_32BPP), FALSE);
03423 EnableGadget(_R(IDC_BMPOPTS_24BPP), FALSE);
03424
03425
03426 #ifndef WEBSTER
03427 Palette = ((AccusoftExportOptions*)pOptions)->GetPalette();
03428 Dither = ((AccusoftExportOptions*)pOptions)->GetDither();
03429 #endif //WEBSTER
03430 bYoDither = TRUE;
03431
03432 break;
03433 case PHOTOCD:
03434
03435
03436
03437 #ifndef WEBSTER
03438 HideGadget(_R(IDC_BMPOPTS_TIFF), TRUE);
03439 HideGadget(_R(IDC_BMPOPTS_RLE), TRUE);
03440 HideGadget(_R(IDC_BMPOPTS_RGB), TRUE);
03441 HideGadget(_R(IDC_BMPOPTS_COMPRESS), TRUE);
03442 #endif // WEBSTER
03443
03444
03445 if (Depth != 24)
03446 Depth = 24;
03447
03448 HideGadget(_R(IDC_BMPOPTS_CMYK), TRUE);
03449 EnableGadget(_R(IDC_BMPOPTS_8BPP), FALSE);
03450 EnableGadget(_R(IDC_BMPOPTS_4BPP), FALSE);
03451 EnableGadget(_R(IDC_BMPOPTS_1BPP), FALSE);
03452 m_bDpiSupported = TRUE;
03453 break;
03454 case IFF_ILBM:
03455 case XWD:
03456 case DCX:
03457 case PCX:
03458 case PICT:
03459
03460
03461
03462 #ifndef WEBSTER
03463 HideGadget(_R(IDC_BMPOPTS_TIFF), TRUE);
03464 HideGadget(_R(IDC_BMPOPTS_RLE), TRUE);
03465 HideGadget(_R(IDC_BMPOPTS_RGB), TRUE);
03466 HideGadget(_R(IDC_BMPOPTS_COMPRESS), TRUE);
03467 #endif // WEBSTER
03468
03469
03470 if (Depth == 32)
03471 Depth = 24;
03472
03473 HideGadget(_R(IDC_BMPOPTS_CMYK), TRUE);
03474 EnableGadget(_R(IDC_BMPOPTS_32BPP), FALSE);
03475 m_bDpiSupported = FALSE;
03476
03477
03478 #ifndef WEBSTER
03479 Palette = ((AccusoftExportOptions*)pOptions)->GetPalette();
03480 Dither = ((AccusoftExportOptions*)pOptions)->GetDither();
03481 #endif // WEBSTER
03482 bYoDither = TRUE;
03483 break;
03484
03485 case RAST:
03486 case PHOTOSHOP:
03487
03488
03489
03490 #ifndef WEBSTER
03491 HideGadget(_R(IDC_BMPOPTS_TIFF), TRUE);
03492 HideGadget(_R(IDC_BMPOPTS_RLE), TRUE);
03493 HideGadget(_R(IDC_BMPOPTS_RGB), TRUE);
03494 HideGadget(_R(IDC_BMPOPTS_COMPRESS), TRUE);
03495 #endif // WEBSTER
03496
03497
03498 if (Depth == 32 || Depth == 4)
03499 Depth = 24;
03500
03501 HideGadget(_R(IDC_BMPOPTS_CMYK), TRUE);
03502 EnableGadget(_R(IDC_BMPOPTS_32BPP), FALSE);
03503 EnableGadget(_R(IDC_BMPOPTS_4BPP), FALSE);
03504 m_bDpiSupported = FALSE;
03505
03506
03507 #ifndef WEBSTER
03508 Palette = ((AccusoftExportOptions*)pOptions)->GetPalette();
03509 Dither = ((AccusoftExportOptions*)pOptions)->GetDither();
03510 #endif // WEBSTER
03511 bYoDither = TRUE;
03512
03513 break;
03514 case TARGA:
03515
03516
03517
03518 #ifndef WEBSTER
03519 HideGadget(_R(IDC_BMPOPTS_TIFF), TRUE);
03520 HideGadget(_R(IDC_BMPOPTS_RLE), TRUE);
03521 HideGadget(_R(IDC_BMPOPTS_RGB), TRUE);
03522 HideGadget(_R(IDC_BMPOPTS_COMPRESS), TRUE);
03523 #endif // WEBSTER
03524
03525
03526 if (Depth == 32 || Depth == 4 || Depth == 1)
03527 Depth = 24;
03528
03529 HideGadget(_R(IDC_BMPOPTS_CMYK), TRUE);
03530 EnableGadget(_R(IDC_BMPOPTS_32BPP), FALSE);
03531 EnableGadget(_R(IDC_BMPOPTS_4BPP), FALSE);
03532 EnableGadget(_R(IDC_BMPOPTS_1BPP), FALSE);
03533 m_bDpiSupported = FALSE;
03534
03535
03536 #ifndef WEBSTER
03537 Palette = ((AccusoftExportOptions*)pOptions)->GetPalette();
03538 Dither = ((AccusoftExportOptions*)pOptions)->GetDither();
03539 #endif // WEBSTER
03540 bYoDither = TRUE;
03541 break;
03542
03543 case MACPAINT:
03544 case MSP:
03545
03546 return FALSE;
03547 break;
03548 case BMP_UNCOMPRESSED:
03549 {
03550 BMPExportOptions* pBMPOptions = (BMPExportOptions*)pOptions;
03551 ERROR3IF(!pBMPOptions->IS_KIND_OF(BMPExportOptions), "pBMPOptions isn't");
03552
03553
03554
03555 #ifndef WEBSTER
03556 HideGadget(_R(IDC_BMPOPTS_TIFF), TRUE);
03557 HideGadget(_R(IDC_BMPOPTS_RLE), FALSE);
03558 HideGadget(_R(IDC_BMPOPTS_RGB), FALSE);
03559 HideGadget(_R(IDC_BMPOPTS_COMPRESS), FALSE);
03560
03561
03562 if (pBMPOptions->GetCompression())
03563 SetLongGadgetValue(_R(IDC_BMPOPTS_RLE), TRUE);
03564 else
03565 SetLongGadgetValue(_R(IDC_BMPOPTS_RGB), TRUE);
03566 #endif // WEBSTER
03567
03568
03569 if ( Depth == 16 )
03570 Depth = 24;
03571 EnableGadget(_R(IDC_BMPOPTS_32BPP), FALSE);
03572 HideGadget(_R(IDC_BMPOPTS_CMYK), FALSE);
03573 Palette = pBMPOptions->GetPalette();
03574 Dither = pBMPOptions->GetDither();
03575 bYoDither = TRUE;
03576
03577 m_bDpiSupported = TRUE;
03578 break;
03579 }
03580 default:
03581 return FALSE;
03582 }
03583
03584
03585 if (NamedExportProp::m_fApplyNotExport)
03586 SetStringGadgetValue(IDOK, &String(_R(IDS_PREVIEW_APPLY)));
03587
03588
03589 if (Depth != pOptions->GetDepth())
03590 {
03591 pOptions->SetDepth(Depth);
03592 }
03593
03594 if (!m_bDpiSupported)
03595 {
03596
03597 DocUnitList* pDocUnitList = DocUnitList::GetCurrentDocUnitList();
03598 ERROR3IF(pDocUnitList == NULL, "BmpPrefsDlg::InitDialog() - no pDocUnitList!")
03599 Unit* pPixelUnit = pDocUnitList->FindUnit(PIXELS);
03600 ERROR3IF(pPixelUnit == NULL, "BmpPrefsDlg::InitDialog() - no pixel units!")
03601 Unit* pInchUnit = pDocUnitList->FindUnit(INCHES);
03602 ERROR3IF(pInchUnit == NULL, "BmpPrefsDlg::InitDialog() - no inch units!")
03603 double newDpi = (pPixelUnit->GetMillipoints()>0) ? pInchUnit->GetMillipoints() / pPixelUnit->GetMillipoints() : 96.0;
03604 Dpi = (INT32)newDpi;
03605 pOptions->SetDPI(newDpi);
03606
03607
03608 SetUpResolutionList();
03609
03610
03611 EnableGadget(_R(IDC_BMPOPTS_RES), FALSE);
03612 EnableGadget(_R(IDC_BMPOPTS_DPI), FALSE);
03613 }
03614 else
03615 {
03616
03617 SetUpResolutionList();
03618 }
03619
03620
03621 InitDepthRadioGroup();
03622 InitSelectionRadioGroup();
03623 if (bYoDither)
03624 {
03625 InitPaletteRadioGroup(Palette);
03626 InitDitherRadioGroup(Dither);
03627 }
03628
03629
03630 RecalculateSize();
03631
03632 if (m_bDpiSupported)
03633 {
03634
03635 SetKeyboardFocus(_R(IDC_BMPOPTS_RES));
03636 }
03637 else
03638 {
03639
03640 SetKeyboardFocus(_R(IDC_BMPOPTS_XPIXELS));
03641 }
03642
03643 return TRUE;
03644 }
03645
03646
03647
03648
03649
03650
03651
03652
03653
03654
03655
03656
03657
03658
03659
03660
03661
03662
03663 void BmpPrefsDlg::InitNumColoursGroup(BitmapExportOptions* pOptions)
03664 {
03665 if (pOptions == NULL)
03666 return;
03667
03668
03669 if (!pOptions->UseSpecificNumColsInPalette())
03670 {
03671 HideNumColoursGroup();
03672 return;
03673 }
03674
03675 INT32 Gadgets[] = { _R(IDC_BMPOPTS_NUMCOLS_GROUP),
03676 _R(IDC_BMPOPTS_NUMCOLS_EDIT),
03677 _R(IDC_BMPOPTS_NUMCOLS_SYSCOLS),
03678 _R(IDC_BMPOPTS_NUMCOLS_EDITTEXT),
03679 0};
03680
03681
03682
03683
03684
03685
03686 {
03687 INT32 Index = 0;
03688 for (Index = 0;Gadgets[Index] != 0;Index++)
03689 {
03690 HWND hGadget = GetDlgItem((HWND)WindowID, (INT32)Gadgets[Index]);
03691 RECT MoveRect;
03692 POINT TopLeft;
03693
03694 if (GetWindowRect(hGadget, &MoveRect))
03695 {
03696 TopLeft.x = MoveRect.left;
03697 TopLeft.y = MoveRect.top;
03698 ScreenToClient((HWND)WindowID, &TopLeft);
03699 TopLeft.y -= NUMCOLS_GROUP_SHIFT;
03700
03701 SetWindowPos(hGadget, NULL,
03702 TopLeft.x, TopLeft.y, 0, 0,
03703 SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOZORDER);
03704 }
03705 }
03706
03707 for (Index = 0;Gadgets[Index] != 0;Index++)
03708 HideGadget(Gadgets[Index],FALSE);
03709
03710 WINDOWPLACEMENT Place;
03711 Place.length = sizeof(WINDOWPLACEMENT);
03712 if (GetWindowPlacement((HWND)WindowID, &Place))
03713 {
03714 Place.rcNormalPosition.bottom = Place.rcNormalPosition.bottom + (NUMCOLS_EXTRABIT);
03715 SetWindowPlacement((HWND)WindowID, &Place);
03716 }
03717 }
03718
03719
03720 INT32 NumCols = 0;
03721 BOOL UseSysCols = TRUE;
03722 NumCols = pOptions->GetNumColsInPalette();
03723 UseSysCols = pOptions->GetUseSystemColours();
03724
03725
03726 if (UseSysCols)
03727 NumCols -= NUM_SYS_COLS;
03728
03729 SetLongGadgetValue(_R(IDC_BMPOPTS_NUMCOLS_EDIT),NumCols);
03730 SetBoolGadgetSelected(_R(IDC_BMPOPTS_NUMCOLS_SYSCOLS),UseSysCols);
03731 }
03732
03733
03734
03735
03736
03737
03738
03739
03740
03741
03742
03743
03744
03745
03746
03747 void BmpPrefsDlg::HideNumColoursGroup()
03748 {
03749 HideGadget(_R(IDC_BMPOPTS_NUMCOLS_EDIT) ,TRUE);
03750 HideGadget(_R(IDC_BMPOPTS_NUMCOLS_SYSCOLS) ,TRUE);
03751 HideGadget(_R(IDC_BMPOPTS_NUMCOLS_GROUP) ,TRUE);
03752 HideGadget(_R(IDC_BMPOPTS_NUMCOLS_EDITTEXT),TRUE);
03753 }
03754
03755
03756
03757
03758
03759
03760
03761
03762
03763
03764
03765
03766
03767
03768
03769
03770
03771 void BmpPrefsDlg::UpdateNumColoursGroup(BOOL CheckValueRange)
03772 {
03773 BOOL OptPal = GetBoolGadgetSelected(_R(IDC_BMPOPTS_PAL_OPT));
03774 BOOL Bpp8 = GetBoolGadgetSelected(_R(IDC_BMPOPTS_8BPP));
03775 BOOL Bpp4 = GetBoolGadgetSelected(_R(IDC_BMPOPTS_4BPP));
03776
03777 EnableGadget(_R(IDC_BMPOPTS_NUMCOLS_EDIT) ,OptPal && (Bpp8 || Bpp4));
03778 EnableGadget(_R(IDC_BMPOPTS_NUMCOLS_EDITTEXT),OptPal && (Bpp8 || Bpp4));
03779 EnableGadget(_R(IDC_BMPOPTS_NUMCOLS_SYSCOLS) ,OptPal && Bpp8);
03780 EnableGadget(_R(IDC_BMPOPTS_NUMCOLS_GROUP) ,TRUE);
03781
03782
03783 if ((Bpp8 || Bpp4))
03784 {
03785 BOOL SystemColours = (Bpp8 && GetBoolGadgetSelected(_R(IDC_BMPOPTS_NUMCOLS_SYSCOLS)));
03786 UINT32 Max = 256;
03787 UINT32 Min = 2;
03788 if (Bpp4)
03789 Max = 16;
03790
03791
03792 if (SystemColours)
03793 Min = 0;
03794
03795
03796
03797
03798 if (CheckValueRange)
03799 Min = Max;
03800
03801 UINT32 NumCols = GetLongGadgetValue(_R(IDC_BMPOPTS_NUMCOLS_EDIT), Min, Max);
03802 if (NumCols > Max) NumCols = Max;
03803 if (NumCols < Min) NumCols = Min;
03804 SetLongGadgetValue(_R(IDC_BMPOPTS_NUMCOLS_EDIT),NumCols);
03805 }
03806 }
03807
03808
03809
03810
03811
03812
03813
03814
03815
03816
03817
03818
03819
03820
03821
03822
03823 BOOL BmpPrefsDlg::SetNumColoursInPalette(BitmapExportOptions* pOptions)
03824 {
03825
03826 if (!GetBoolGadgetSelected(_R(IDC_BMPOPTS_PAL_OPT)))
03827 return TRUE;
03828
03829
03830 if (pOptions != NULL && pOptions->UseSpecificNumColsInPalette())
03831 {
03832
03833 UINT32 MaxNumCols = 256;
03834 UINT32 MinNumCols = 2;
03835 BOOL SystemColours = GetBoolGadgetSelected(_R(IDC_BMPOPTS_NUMCOLS_SYSCOLS));
03836 UINT32 Depth = pOptions->GetDepth();
03837 BOOL Valid;
03838
03839
03840 if (Depth == 4)
03841 {
03842 MaxNumCols = 16;
03843 SystemColours = FALSE;
03844 }
03845
03846
03847 if (SystemColours)
03848 MinNumCols = 0;
03849
03850 UINT32 NumCols = GetLongGadgetValue(_R(IDC_BMPOPTS_NUMCOLS_EDIT), MinNumCols, MaxNumCols, 0, &Valid);
03851
03852 if (!Valid)
03853 {
03854
03855 if ((Depth == 8) || (Depth == 4))
03856 {
03857 String_256 ErrMsg;
03858 ErrMsg.MakeMsg(_R(IDS_BMPPREFS_NUMCOLSWRONG),MinNumCols,MaxNumCols);
03859 Error::SetError(0,ErrMsg,0);
03860 InformError();
03861 return FALSE;
03862 }
03863 NumCols = MaxNumCols;
03864 }
03865
03866
03867
03868
03869
03870 UINT32 NumSysCols = NUM_SYS_COLS;
03871 if (!SystemColours)
03872 NumSysCols = 0;
03873
03874 NumCols += NumSysCols;
03875 if (NumCols > MaxNumCols)
03876 NumCols = MaxNumCols;
03877
03878
03879 UINT32 NumTransparentCols = 0;
03880 if (GetBoolGadgetSelected(_R(IDC_BMPOPTS_TRANSPARENT)))
03881 NumTransparentCols = 1;
03882
03883
03884
03885 if (Depth == 8)
03886 {
03887
03888 if (NumCols <= (16-NumTransparentCols))
03889 GetOptions()->SetDepth(4);
03890
03891
03892 if (NumCols <= (2-NumTransparentCols))
03893 GetOptions()->SetDepth(1);
03894 }
03895
03896 pOptions->SetNumColsInPalette(NumCols);
03897 pOptions->SetUseSystemColours(SystemColours);
03898 }
03899
03900 return TRUE;
03901 }
03902
03903 void BmpPrefsDlg::InitDepthRadioGroup()
03904 {
03905
03906
03907 switch ( GetOptions()->GetDepth() )
03908 {
03909 case 1:
03910 SetBPPButtons(_R(IDC_BMPOPTS_1BPP),FALSE);
03911 SetLongGadgetValue(_R(IDC_BMPOPTS_1BPP), TRUE);
03912 LastBppSelected = _R(IDC_BMPOPTS_1BPP);
03913 break;
03914 case 4:
03915 SetBPPButtons(_R(IDC_BMPOPTS_4BPP),FALSE);
03916 SetLongGadgetValue(_R(IDC_BMPOPTS_4BPP), TRUE);
03917 LastBppSelected = _R(IDC_BMPOPTS_4BPP);
03918 break;
03919 case 8:
03920 SetBPPButtons(_R(IDC_BMPOPTS_8BPP),FALSE);
03921 SetLongGadgetValue(_R(IDC_BMPOPTS_8BPP), TRUE);
03922 LastBppSelected = _R(IDC_BMPOPTS_8BPP);
03923 break;
03924 case 24:
03925 SetBPPButtons(_R(IDC_BMPOPTS_24BPP),FALSE);
03926 SetLongGadgetValue(_R(IDC_BMPOPTS_24BPP), TRUE);
03927 LastBppSelected = _R(IDC_BMPOPTS_24BPP);
03928 break;
03929 default:
03930 SetBPPButtons(_R(IDC_BMPOPTS_CMYK),FALSE);
03931 SetLongGadgetValue(_R(IDC_BMPOPTS_CMYK), TRUE);
03932 LastBppSelected = _R(IDC_BMPOPTS_CMYK);
03933 break;
03934 }
03935 }
03936
03937
03938 void BmpPrefsDlg::InitPaletteRadioGroup(const PALETTE& Palette)
03939 {
03940
03941
03942
03943 switch (Palette)
03944 {
03945 case PAL_OPTIMISED:
03946 SetPaletteButtons(_R(IDC_BMPOPTS_PAL_OPT));
03947 break;
03948
03949 case PAL_STANDARD:
03950 SetPaletteButtons(_R(IDC_BMPOPTS_PAL_STD));
03951 break;
03952
03953 default:
03954 TRACE( _T("Non-standard palette set"));
03955 break;
03956 }
03957 }
03958
03959
03960 void BmpPrefsDlg::InitDitherRadioGroup(const DITHER& DitherType)
03961 {
03962
03963 switch (DitherType)
03964 {
03965 case XARADITHER_NONE:
03966 SetLongGadgetValue(_R(IDC_BMPOPTS_NODITHER), TRUE);
03967 break;
03968
03969 case XARADITHER_ORDERED_GREY:
03970 SetLongGadgetValue(_R(IDC_BMPOPTS_ORDDITHER), TRUE);
03971 break;
03972
03973 case XARADITHER_ERROR_DIFFUSION:
03974 SetLongGadgetValue(_R(IDC_BMPOPTS_DIFFUSION), TRUE);
03975 break;
03976
03977 default:
03978 SetLongGadgetValue(_R(IDC_BMPOPTS_DIFFUSION), TRUE);
03979 break;
03980 }
03981
03982 if (GetOptions()->GetSelectionType() == ABITMAP)
03983 {
03984
03985
03986 EnableGadget(_R(IDC_BMPOPTS_NODITHER), FALSE);
03987 EnableGadget(_R(IDC_BMPOPTS_ORDDITHER), FALSE);
03988 EnableGadget(_R(IDC_BMPOPTS_DIFFUSION), FALSE);
03989 EnableGadget(_R(IDC_BMPOPTS_PAL_STD), FALSE);
03990 EnableGadget(_R(IDC_BMPOPTS_PAL_OPT), FALSE);
03991 }
03992 }
03993
03994
03995
03996
03997
03998
03999 void BmpPrefsDlg::InitSelectionRadioGroup()
04000 {
04001
04002 EnableGadget(_R(IDC_BMPOPTS_SPREAD), FALSE);
04003
04004
04005 if (GetOptions()->GetFilterType() == MAKE_BITMAP_FILTER ||
04006 GetOptions()->GetFilterType() == TI_GIF_ANIM)
04007 {
04008 SetLongGadgetValue(_R(IDC_BMPOPTS_SELECT), TRUE);
04009
04010 EnableGadget(_R(IDC_BMPOPTS_SELECT), FALSE);
04011 EnableGadget(_R(IDC_BMPOPTS_DRAWING), FALSE);
04012 }
04013 else
04014 {
04015
04016 EnableGadget(_R(IDC_BMPOPTS_DRAWING), TRUE);
04017
04018
04019
04020
04021 switch (GetOptions()->GetSelectionType())
04022 {
04023 case SELECTION:
04024
04025 SetLongGadgetValue(_R(IDC_BMPOPTS_SELECT), TRUE);
04026
04027
04028 EnableGadget(_R(IDC_BMPOPTS_SELECT), TRUE);
04029 break;
04030
04031 default:
04032
04033 SetLongGadgetValue(_R(IDC_BMPOPTS_DRAWING), TRUE);
04034
04035
04036 EnableGadget(_R(IDC_BMPOPTS_SELECT), FALSE);
04037 break;
04038 }
04039 }
04040
04041
04042
04043 if (NamedExportProp::m_fApplyNotExport)
04044 {
04045 EnableGadget(_R(IDC_BMPOPTS_SAVEAREA), FALSE);
04046 EnableGadget(_R(IDC_BMPOPTS_SELECT), FALSE);
04047 EnableGadget(_R(IDC_BMPOPTS_DRAWING), FALSE);
04048 EnableGadget(_R(IDC_BMPOPTS_SPREAD), FALSE);
04049 }
04050 }
04051
04052
04053
04054
04055
04056
04057
04058
04059
04060
04061
04062
04063 BitmapExportOptions* BmpPrefsDlg::GetOptions() const
04064 {
04065 return m_pOptions;
04066 }
04067
04068
04069
04070
04071
04072
04073
04074
04075
04076
04077
04078
04079
04080
04081
04082
04083
04084
04085
04086
04087
04088 BOOL PhotoCDDlg::InvokeDialog(UINT32 * Page)
04089 {
04090
04091
04092 PhotoCDDlgParam Params(*Page);
04093 pParams = &Params;
04094
04095 Params.ImageNumber = 0;
04096 Params.PhotoCDOk = FALSE;
04097
04098 OpDescriptor *OpDesc = OpDescriptor::FindOpDescriptor(CC_RUNTIME_CLASS(PhotoCDDlg));
04099
04100 ERROR3IF(OpDesc == NULL,"PhotoCDDlg::InvokeDialog is unable to find the PhotoCDDlg OpDescriptor");
04101
04102 if (OpDesc != NULL)
04103 OpDesc->Invoke((OpParam *)&Params);
04104
04105
04106 if (Params.PhotoCDOk)
04107 *Page = Params.ImageNumber;
04108
04109 return Params.PhotoCDOk;
04110 }
04111
04112
04113
04114
04115
04116
04117
04118
04119
04120
04121
04122
04123
04124
04125
04126
04127 PhotoCDDlg::PhotoCDDlg(): DialogOp(PhotoCDDlg::IDD, PhotoCDDlg::Mode)
04128 {
04129
04130 }
04131
04132
04133
04134
04135
04136
04137
04138
04139
04140
04141
04142
04143
04144
04145
04146
04147
04148 BOOL PhotoCDDlg::CommitDialogValues(PhotoCDDlg* pPhotoCDPrefs)
04149 {
04150 ERROR3IF(pParams == NULL, "PhotoCDDlg::CommitDialogValues called after duff initialisation?!");
04151
04152
04153
04154
04155
04156 BOOL Valid = 0;
04157 BOOL State = 0;
04158 UINT32 Page = 0;
04159 State = GetLongGadgetValue(_R(IDC_PHOTOCD_BASE), 0, 1, 0, &Valid);
04160 if (State)
04161 Page = 0;
04162 State = GetLongGadgetValue(_R(IDC_PHOTOCD_BASEDIV4), 0, 1, 0, &Valid);
04163 if (State)
04164 Page = 1;
04165 State = GetLongGadgetValue(_R(IDC_PHOTOCD_BASEDIV16), 0, 1, 0, &Valid);
04166 if (State)
04167 Page = 2;
04168 State = GetLongGadgetValue(_R(IDC_PHOTOCD_BASE4), 0, 1, 0, &Valid);
04169 if (State)
04170 Page = 3;
04171 State = GetLongGadgetValue(_R(IDC_PHOTOCD_BASE16), 0, 1, 0, &Valid);
04172 if (State)
04173 Page = 4;
04174 pParams->ImageNumber = Page;
04175
04176 return TRUE;
04177 }
04178
04179
04180
04181
04182
04183
04184
04185
04186
04187
04188
04189
04190
04191
04192
04193
04194
04195
04196 MsgResult PhotoCDDlg::Message(Msg* Message)
04197 {
04198 ERROR3IF(pParams == NULL, "PhotoCDDlg::Message - Parameters not been set up");
04199
04200 if (IS_OUR_DIALOG_MSG(Message))
04201 {
04202 DialogMsg* Msg = (DialogMsg*)Message;
04203
04204 MsgResult Result;
04205
04206
04207 BOOL EndDialog = FALSE;
04208
04209
04210 switch (Msg->DlgMsg)
04211 {
04212 case DIM_CREATE:
04213
04214
04215 InitDialog(this);
04216 break;
04217
04218 case DIM_COMMIT:
04219
04220
04221 {
04222 BOOL ok;
04223 ok = CommitDialogValues(this);
04224 if (ok)
04225 {
04226
04227 pParams->PhotoCDOk = TRUE;
04228 EndDialog = TRUE;
04229 }
04230 }
04231 break;
04232
04233 case DIM_CANCEL:
04234
04235 pParams->PhotoCDOk = FALSE;
04236 EndDialog = TRUE;
04237 break;
04238 }
04239
04240
04241
04242
04243 Result = DialogOp::Message(Message);
04244
04245
04246 if (EndDialog)
04247 {
04248 Close();
04249 End();
04250 }
04251
04252
04253 return Result;
04254 }
04255 return DialogOp::Message(Message);
04256 }
04257
04258
04259
04260
04261
04262
04263
04264
04265
04266
04267
04268
04269
04270
04271
04272
04273 OpState PhotoCDDlg::GetState(String_256*, OpDescriptor*)
04274 {
04275 OpState OpSt;
04276 return(OpSt);
04277 }
04278
04279
04280
04281
04282
04283
04284
04285
04286
04287
04288
04289
04290
04291
04292
04293
04294
04295 BOOL PhotoCDDlg::Init()
04296 {
04297 BOOL InitOK;
04298
04299 InitOK = RegisterOpDescriptor(
04300 0,
04301 _R(IDS_PHOTOCDDLG),
04302 CC_RUNTIME_CLASS(PhotoCDDlg),
04303 OPTOKEN_PHOTOCDDLG,
04304 GetState,
04305 0,
04306 0,
04307 0,
04308 0
04309 );
04310
04311 return (InitOK);
04312 }
04313
04314
04315
04316
04317
04318
04319
04320
04321
04322
04323
04324
04325
04326
04327
04328
04329
04330 BOOL PhotoCDDlg::Create()
04331 {
04332 if (DialogOp::Create())
04333 {
04334
04335
04336
04337
04338 return TRUE;
04339 }
04340 else
04341 {
04342 return FALSE;
04343 }
04344 }
04345
04346
04347
04348
04349
04350
04351
04352
04353
04354
04355
04356
04357
04358
04359
04360
04361 void PhotoCDDlg::Do(OpDescriptor*)
04362 {
04363 ERROR3("PhotoCDDlg::Do called when should be using DoWithParam!");
04364 End();
04365 }
04366
04367
04368
04369
04370
04371
04372
04373
04374
04375
04376
04377
04378
04379
04380
04381
04382
04383
04384 void PhotoCDDlg::DoWithParam(OpDescriptor*, OpParam* Param)
04385 {
04386 ERROR3IF(Param == NULL, "PhotoCDDlg::DoWithParam - NULL Param passed in");
04387
04388
04389 PhotoCDDlgParam * BmpDlgParam = (PhotoCDDlgParam *) Param;
04390
04391 BOOL ok;
04392
04393
04394 ok = Create();
04395
04396 if ( !ok )
04397 {
04398
04399 InformError();
04400 End();
04401 }
04402 }
04403
04404
04405
04406
04407
04408
04409
04410
04411
04412
04413
04414
04415
04416
04417
04418
04419
04420 BOOL PhotoCDDlg::InitDialog(PhotoCDDlg* pBmpPrefs)
04421 {
04422 ERROR3IF(pParams == NULL, "PhotoCDDlg::InitDialog called after duff initialisation?!");
04423
04424
04425
04426
04427
04428 EnableGadget(_R(IDC_PHOTOCD_BASE16), (pParams->NumberOfPages > 3));
04429 EnableGadget(_R(IDC_PHOTOCD_BASE4), (pParams->NumberOfPages > 3));
04430 EnableGadget(_R(IDC_PHOTOCD_BASEDIV16), (pParams->NumberOfPages > 2));
04431 EnableGadget(_R(IDC_PHOTOCD_BASEDIV4), (pParams->NumberOfPages > 1));
04432 EnableGadget(_R(IDC_PHOTOCD_BASE), (pParams->NumberOfPages > 0));
04433
04434 switch (pParams->ImageNumber)
04435 {
04436 case 4:
04437 SetLongGadgetValue(_R(IDC_PHOTOCD_BASE16), TRUE);
04438 break;
04439 case 3:
04440 SetLongGadgetValue(_R(IDC_PHOTOCD_BASE4), TRUE);
04441 break;
04442 case 2:
04443 SetLongGadgetValue(_R(IDC_PHOTOCD_BASEDIV16), TRUE);
04444 break;
04445 case 1:
04446 SetLongGadgetValue(_R(IDC_PHOTOCD_BASEDIV4), TRUE);
04447 break;
04448 case 0:
04449 default:
04450 SetLongGadgetValue(_R(IDC_PHOTOCD_BASE), TRUE);
04451 break;
04452 }
04453
04454 return TRUE;
04455 }
04456
04457
04458
04459
04460
04461
04462
04463
04464
04465
04466
04467
04468 JPEGExportPrefsDialog::JPEGExportPrefsDialog(): BmpPrefsDlg()
04469 {
04470 m_OriginalSourcePresent = FALSE;
04471 }
04472
04473
04474
04475
04476
04477
04478
04479
04480
04481
04482
04483
04484
04485
04486
04487
04488 BOOL JPEGExportPrefsDialog::InitDialog()
04489 {
04490 JPEGExportOptions* pOptions = (JPEGExportOptions*)GetOptions();
04491 ERROR2IF(pOptions == NULL,FALSE, "BmpPrefsDlg::InitJPEGDialog called after duff initialisation?!");
04492
04493
04494
04495 String_256 Temp = *(pOptions->GetFilterName());
04496 Temp += String_256(_R(IDN_EXPORTBMPOPTS));
04497
04498 SetTitlebarName(&Temp);
04499
04500
04501
04502 pOptions->SetJPEGPresentAndSelected(FALSE);
04503
04504 KernelBitmap* pKernelBitmap = pOptions->GetKernelBitmap();
04505
04506 if (pKernelBitmap != NULL)
04507 {
04508 BitmapSource* pSource = NULL;
04509 BaseBitmapFilter* pDummyFilter;
04510
04511 pOptions->SetJPEGPresentAndSelected(pKernelBitmap->GetOriginalSource(&pSource, &pDummyFilter));
04512 }
04513
04514 if (pOptions->GetJPEGPresentAndSelected())
04515 {
04516 SetBoolGadgetSelected(_R(IDC_JPEG_ORIGINAL), TRUE);
04517
04518
04519
04520 EnableGadget(_R(IDC_BMPOPTS_DRAWING), FALSE);
04521 EnableGadget(_R(IDC_BMPOPTS_SELECT), FALSE);
04522 EnableGadget(_R(IDC_JPGOPTS_PROGRESSIVE), FALSE);
04523
04524
04525 SetGadgetRange(_R(IDC_BMPOPTS_QUALITY), 0, 100, 1);
04526 SetGadgetBitmaps(_R(IDC_BMPOPTS_QUALITY), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
04527 SetLongGadgetValue(_R(IDC_BMPOPTS_QUALITY), 0);
04528 EnableGadget(_R(IDC_BMPOPTS_QUALITY), FALSE);
04529
04530 EnableGadget(_R(IDC_BMPOPTS_RES), FALSE);
04531 EnableGadget(_R(IDC_BMPOPTS_XPIXELS), FALSE);
04532 EnableGadget(_R(IDC_BMPOPTS_YPIXELS), FALSE);
04533
04534
04535 #ifndef WEBSTER
04536 SetStringGadgetValue(_R(IDC_BMPOPTS_XSIZE), &String_8("-"));
04537 SetStringGadgetValue(_R(IDC_BMPOPTS_YSIZE), &String_8("-"));
04538 EnableGadget(_R(IDC_BMPOPTS_XSIZE), FALSE);
04539 EnableGadget(_R(IDC_BMPOPTS_YSIZE), FALSE);
04540 #endif // WEBSTER
04541 EnableGadget(_R(IDC_BMPOPTS_PERCENT), FALSE);
04542 }
04543 else
04544 {
04545
04546 EnableGadget(_R(IDC_JPEG_ORIGINAL), FALSE);
04547
04548
04549 m_bDpiSupported = TRUE;
04550
04551
04552 SetUpResolutionList();
04553
04554
04555 INT32 Quality = pOptions->GetQuality();
04556
04557 if (Quality > 100)
04558 Quality = 100;
04559
04560
04561 SetGadgetRange(_R(IDC_BMPOPTS_QUALITY), 0, 100, 1);
04562 SetGadgetBitmaps(_R(IDC_BMPOPTS_QUALITY), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
04563 SetLongGadgetValue(_R(IDC_BMPOPTS_QUALITY), 100 - Quality);
04564 SetBoolGadgetSelected(_R(IDC_JPGOPTS_PROGRESSIVE), pOptions->DoAsProgressive());
04565
04566
04567 TCHAR Str[32];
04568 String_32 jcf(_R(IDS_PERCENT_FORMAT));
04569 camSprintf(Str, jcf, Quality);
04570 String_32 PercentStr(Str);
04571 SetStringGadgetValue(_R(IDC_BMPOPTS_PERCENT), &PercentStr);
04572
04573 InitSelectionRadioGroup();
04574
04575
04576 RecalculateSize();
04577 }
04578
04579 return TRUE;
04580 }
04581
04582
04583
04584
04585
04586
04587
04588
04589
04590
04591
04592
04593
04594
04595
04596
04597
04598 void JPEGExportPrefsDialog::SetJPEGDlgState()
04599 {
04600 JPEGExportOptions* pOptions = (JPEGExportOptions*)GetOptions();
04601 ERROR3IF(pOptions == NULL, "pOptions is NULL");
04602
04603 if (pOptions->GetJPEGPresentAndSelected())
04604 {
04605 SetBoolGadgetSelected(_R(IDC_JPEG_ORIGINAL), TRUE);
04606
04607
04608
04609 EnableGadget(_R(IDC_BMPOPTS_DRAWING), FALSE);
04610 EnableGadget(_R(IDC_BMPOPTS_SELECT), FALSE);
04611 EnableGadget(_R(IDC_JPGOPTS_PROGRESSIVE), FALSE);
04612 EnableGadget(_R(IDC_BMPOPTS_QUALITY), FALSE);
04613 EnableGadget(_R(IDC_BMPOPTS_RES), FALSE);
04614
04615 EnableGadget(_R(IDC_BMPOPTS_XPIXELS), FALSE);
04616 EnableGadget(_R(IDC_BMPOPTS_YPIXELS), FALSE);
04617
04618
04619 #ifndef WEBSTER
04620 SetStringGadgetValue(_R(IDC_BMPOPTS_XSIZE), &String_8("-"));
04621 SetStringGadgetValue(_R(IDC_BMPOPTS_YSIZE), &String_8("-"));
04622 EnableGadget(_R(IDC_BMPOPTS_XSIZE), FALSE);
04623 EnableGadget(_R(IDC_BMPOPTS_YSIZE), FALSE);
04624 #endif // WEBSTER
04625 EnableGadget(_R(IDC_BMPOPTS_PERCENT), FALSE);
04626 }
04627 else
04628 {
04629
04630 EnableGadget(_R(IDC_BMPOPTS_QUALITY), TRUE);
04631 EnableGadget(_R(IDC_JPGOPTS_PROGRESSIVE), TRUE);
04632 EnableGadget(_R(IDC_BMPOPTS_PERCENT), TRUE);
04633
04634
04635 m_bDpiSupported = TRUE;
04636
04637
04638 SetUpResolutionList();
04639
04640
04641 INT32 Quality = pOptions->GetQuality();
04642
04643 if (Quality > 100)
04644 Quality = 100;
04645
04646
04647 SetGadgetRange(_R(IDC_BMPOPTS_QUALITY), 0, 100, 1);
04648 SetGadgetBitmaps(_R(IDC_BMPOPTS_QUALITY), _R(IDB_SLIDERBASE), _R(IDB_SLIDERSLIDER));
04649 SetLongGadgetValue(_R(IDC_BMPOPTS_QUALITY), 100 - Quality);
04650 SetBoolGadgetSelected(_R(IDC_JPGOPTS_PROGRESSIVE), pOptions->DoAsProgressive());
04651
04652
04653 TCHAR Str[32];
04654 String_32 jcf(_R(IDS_PERCENT_FORMAT));
04655 camSprintf(Str, jcf, Quality);
04656 String_32 PercentStr(Str);
04657 SetStringGadgetValue(_R(IDC_BMPOPTS_PERCENT), &PercentStr);
04658
04659 InitSelectionRadioGroup();
04660
04661
04662 RecalculateSize();
04663 }
04664 };
04665
04666
04667
04668
04669
04670
04671
04672
04673
04674
04675
04676 MsgResult JPEGExportPrefsDialog::Message(Msg* pMessage)
04677 {
04678 ERROR3IF(GetOptions() == NULL, "BmpPrefsDlg::Message - GetOptions() NULL");
04679
04680 if (IS_OUR_DIALOG_MSG(pMessage))
04681 {
04682 DialogMsg* pMsg = (DialogMsg*)pMessage;
04683 ERROR3IF(!pMsg->IS_KIND_OF(DialogMsg), "pMsg isn't");
04684
04685
04686 switch (pMsg->DlgMsg)
04687 {
04688 case DIM_SLIDER_POS_CHANGING:
04689
04690
04691 switch (pMsg->GadgetID)
04692 {
04693 case _R(IDC_BMPOPTS_QUALITY):
04694 {
04695
04696 TCHAR Str[32];
04697 BOOL Valid;
04698 INT32 Result = GetLongGadgetValue(_R(IDC_BMPOPTS_QUALITY), 0, 100, 0, &Valid);
04699 Result = 100 - Result;
04700
04701
04702 String_32 jcf(_R(IDS_PERCENT_FORMAT));
04703 wsprintf(Str, jcf, (INT32) Result);
04704 String_32 PercentStr(Str);
04705 SetStringGadgetValue(_R(IDC_BMPOPTS_PERCENT), &PercentStr);
04706 }
04707 break;
04708 }
04709 break;
04710
04711 case DIM_LFT_BN_CLICKED:
04712 {
04713 switch (pMsg->GadgetID)
04714 {
04715 case _R(IDC_JPEG_ORIGINAL):
04716 {
04717 BOOL Value = GetBoolGadgetSelected(_R(IDC_JPEG_ORIGINAL));
04718 if (Value)
04719 {
04720 JPEGExportOptions::SetJPEGPresentAndSelected(TRUE);
04721 SetJPEGDlgState();
04722 }
04723 else
04724 {
04725 JPEGExportOptions::SetJPEGPresentAndSelected(FALSE);
04726 SetJPEGDlgState();
04727 }
04728 }
04729 break;
04730 }
04731 break;
04732 }
04733 break;
04734
04735 case DIM_CANCEL:
04736 {
04737
04738
04739 JPEGExportOptions::SetKernelBitmap(NULL);
04740 }
04741 break;
04742 }
04743 }
04744 return BmpPrefsDlg::Message(pMessage);
04745 }
04746
04747
04748
04749
04750
04751
04752
04753
04754
04755
04756
04757
04758
04759
04760
04761
04762
04763 BOOL JPEGExportPrefsDialog::CommitDialogValues()
04764 {
04765 JPEGExportOptions* pOptions = (JPEGExportOptions*)GetOptions();
04766 ERROR3IF(pOptions == NULL, "JPEGExportPrefsDialog::CommitDialogValues called after duff initialisation?!");
04767
04768
04769
04770 pOptions->SetPixelOutputSize(PixelWidth, PixelHeight);
04771
04772
04773 if (!pOptions->GetJPEGPresentAndSelected())
04774 {
04775
04776
04777
04778 BOOL Valid = 0;
04779 BOOL State = 0;
04780
04781
04782
04783 INT32 Value = GetLongGadgetValue(_R(IDC_BMPOPTS_RES), 5, MAXDPI, _R(IDS_BMPPREFS_INVALIDDPI) ,&Valid);
04784 if ( Valid)
04785 {
04786
04787 pOptions->SetDPI(Value);
04788 }
04789 else
04790 return FALSE;
04791
04792
04793
04794 RecalculatePixels();
04795 if ((DWORD) PixelWidth > GRenderRegion::GetMaxBitmapWidth() ||
04796 (DWORD) PixelWidth < 1 || (DWORD) PixelHeight < 1 )
04797 {
04798
04799 String_256 WarnMsg;
04800
04801 WarnMsg.MakeMsg(_R(IDE_BMP_BADPIXELWIDTH), GRenderRegion::GetMaxBitmapWidth());
04802 Error::SetError(0, WarnMsg, 0);
04803 InformWarning(0, _R(IDS_OK));
04804 return FALSE;
04805 }
04806
04807
04808 State = GetLongGadgetValue(_R(IDC_BMPOPTS_QUALITY), 0, 100, 0, &Valid);
04809 if (Valid)
04810 {
04811
04812 pOptions->SetQuality(100 - State);
04813 }
04814
04815
04816 SelectionType FoundSelection = GetSelection();
04817 pOptions->SetSelectionType(FoundSelection);
04818
04819
04820 State = GetBoolGadgetSelected(_R(IDC_JPGOPTS_PROGRESSIVE), 0, &Valid);
04821 if (Valid)
04822 {
04823 pOptions->SetMakeProgressive(State);
04824 }
04825 }
04826 return TRUE;
04827 }
04828
04829
04830 DocRect RandomSelection::GetSize() { return DocRect(0,0,0,0); }
04831 DocRect SingleBitmapSelection::GetSize() { return DocRect(0,0,0,0); }
04832 DocRect MultipleBitmapSelection::GetSize() { return DocRect(0,0,0,0); }
04833 DocRect SpreadSelection::GetSize() { return BaseBitmapFilter::GetSizeOfSpread(m_pSpread); }
04834 DocRect DrawingSelection::GetSize() { return BaseBitmapFilter::GetSizeOfDrawing(m_pSpread); }
04835
04836 #endif
04837
04838
04839
04840
04841
04842
04843
04844
04845
04846
04847 BOOL BitmapExportOptions::IsPaletteValid()
04848 {
04849 return m__PaletteIsValid;
04850 }
04851
04852 void BitmapExportOptions::InvalidatePalette()
04853 {
04854 m__PaletteIsValid = FALSE;
04855 SetTempFileMatchesExportOptions(FALSE);
04856 BitmapExportPaletteInterface::InvalidateSortedPalette();
04857 }
04858
04859 void BitmapExportOptions::SetTransparencyIndex(INT32 TransparencyIndex)
04860 {
04861 if (m_TransparencyIndex != TransparencyIndex)
04862 SetTempFileMatchesExportOptions(FALSE);
04863 m_TransparencyIndex = TransparencyIndex;
04864 }
04865
04866 void BitmapExportOptions::SetBackgroundTransparency(BOOL t)
04867 {
04868 if (m__BackgroundIsTransparent != t)
04869 InvalidatePalette();
04870 m__BackgroundIsTransparent = t;
04871 }
04872
04873
04874 INT32 BitmapExportOptions::GetNumberOfUserRequestedColours()
04875 {
04876 return m__NumberOfColoursUserRequested;
04877 }
04878
04879 void BitmapExportOptions::SetNumberOfUserRequestedColours(INT32 n)
04880 {
04881 if (m__NumberOfColoursUserRequested != n)
04882 InvalidatePalette();
04883 m__NumberOfColoursUserRequested = n;
04884 }
04885
04886 BOOL BitmapExportOptions::IsUsingBrowserPalette()
04887 {
04888 return m__UseBrowserPalette;
04889 }
04890
04891 void BitmapExportOptions::SetToUseBrowserPalette(BOOL SetIt)
04892 {
04893 if (m__UseBrowserPalette != SetIt)
04894 {
04895 m__UseBrowserPalette = SetIt;
04896 InvalidatePalette();
04897 }
04898 }
04899
04900 BOOL BitmapExportOptions::IsUsingSystemPalette()
04901 {
04902 return m__UseSystemColoursInPalette;
04903 }
04904
04905 void BitmapExportOptions::SetToUseSystemPalette(BOOL SetIt)
04906 {
04907 if (m__UseSystemColoursInPalette != SetIt)
04908 {
04909 m__UseSystemColoursInPalette = SetIt;
04910 InvalidatePalette();
04911 }
04912 }
04913
04914 INT32 BitmapExportOptions::GetWebSnapPaletteAmount()
04915 {
04916 return m__UseWebSnapPalette;
04917 }
04918
04919 void BitmapExportOptions::SetWebSnapPaletteAmount(INT32 SetIt)
04920 {
04921 if (m__UseWebSnapPalette != SetIt)
04922 {
04923 m__UseWebSnapPalette = SetIt;
04924 InvalidatePalette();
04925 }
04926 }
04927
04928 INT32 BitmapExportOptions::GetPrimarySnapPaletteAmount()
04929 {
04930 return m__UsePrimarySnapPalette;
04931 }
04932
04933 void BitmapExportOptions::SetPrimarySnapPaletteAmount(INT32 SetIt)
04934 {
04935 if (m__UsePrimarySnapPalette != SetIt)
04936 {
04937 m__UsePrimarySnapPalette = SetIt;
04938 InvalidatePalette();
04939 }
04940 }
04941
04942
04943
04944 BOOL BitmapExportOptions::CreatePaletteOptimiser()
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;
04956 }
04957
04958 return FALSE;
04959 }
04960
04961
04962
04963 void BitmapExportOptions::BitmapSourceHasChanged()
04964 {
04965 m__HavePrimedOptimier = FALSE;
04966 if (m__pPaletteOptimiser != NULL)
04967 delete m__pPaletteOptimiser;
04968
04969 m__pPaletteOptimiser = NULL;
04970 InvalidatePalette();
04971 }
04972
04973
04974 void BitmapExportOptions::GatherPaletteStats(const RGBQUAD* pBitmap, UINT32 nSize )
04975 {
04976 if (m__pPaletteOptimiser)
04977 {
04978 m__pPaletteOptimiser->AddStats(pBitmap, nSize);
04979 }
04980 }
04981
04982
04983
04984 LOGPALETTE * BitmapExportOptions::GetLogicalPalette()
04985 {
04986 ERROR3IF(!m__PaletteIsValid, "Palette not validated");
04987
04988
04989 if (m__pLogicalPalette)
04990 return m__pLogicalPalette;
04991
04992
04993
04994
04995 m__pLogicalPalette = (LOGPALETTE * ) new BYTE[sizeof(LOGPALETTE) + ( sizeof(PALETTEENTRY) * 256 )];
04996 if (m__pLogicalPalette == NULL)
04997 return NULL;
04998
04999
05000
05001
05002 m__pLogicalPalette->palNumEntries = m_Palette.NumberOfColours;
05003 m__pLogicalPalette->palVersion = 0x300;
05004 INT32 i = 0;
05005 for( ; i < m__pLogicalPalette->palNumEntries; i++ )
05006 {
05007 m__pLogicalPalette->palPalEntry[ i ].peRed = m_Palette.Data[ i ].Red;
05008 m__pLogicalPalette->palPalEntry[ i ].peGreen = m_Palette.Data[ i ].Green;
05009 m__pLogicalPalette->palPalEntry[ i ].peBlue = m_Palette.Data[ i ].Blue;
05010 BOOL NonRenderable = (m_Palette.Data[i].Flags & (DELETED_COLOUR | TRANSPARENT_COLOUR));
05011 m__pLogicalPalette->palPalEntry[ i ].peFlags = NonRenderable ? 255 : 0;
05012 }
05013
05014 return m__pLogicalPalette;
05015 }
05016
05017
05018 BOOL BitmapExportOptions::SwapEditedColoursInLogicalPalette()
05019 {
05020 if (!m__pLogicalPalette)
05021 return FALSE;
05022
05023 BOOL DidASwap = FALSE;
05024 for( INT32 i = 0; i < m__pLogicalPalette->palNumEntries; i++ )
05025 {
05026 if (m_Palette.Data[ i ].Flags & LOCKED_COLOUR)
05027 {
05028 BYTE t;
05029 t = m_Palette.Data[ i ].Red;
05030 m_Palette.Data[ i ].Red = m_Palette.Data[ i ].PreEditedRed;
05031 m_Palette.Data[ i ].PreEditedRed = t;
05032 m__pLogicalPalette->palPalEntry[ i ].peRed = m_Palette.Data[ i ].Red;
05033
05034 t = m_Palette.Data[ i ].Green;
05035 m_Palette.Data[ i ].Green = m_Palette.Data[ i ].PreEditedGreen;
05036 m_Palette.Data[ i ].PreEditedGreen = t;
05037 m__pLogicalPalette->palPalEntry[ i ].peGreen = m_Palette.Data[ i ].Green;
05038
05039 t = m_Palette.Data[ i ].Blue;
05040 m_Palette.Data[ i ].Blue = m_Palette.Data[ i ].PreEditedBlue;
05041 m_Palette.Data[ i ].PreEditedBlue = t;
05042 m__pLogicalPalette->palPalEntry[ i ].peBlue = m_Palette.Data[ i ].Blue;
05043
05044 DidASwap = TRUE;
05045 }
05046 }
05047
05048 return DidASwap;
05049 }
05050
05051
05052
05053
05054 INT32 BitmapExportOptions::FindNextLockedColour(INT32 pos)
05055 {
05056 pos++;
05057 while (pos < m_Palette.NumberOfColours)
05058 {
05059 if (m_Palette.Data[pos].Flags & LOCKED_COLOUR || m_Palette.Data[pos].Flags & DELETED_COLOUR)
05060 return pos;
05061
05062 pos++;
05063 }
05064 return -1;
05065 }
05066
05067
05068
05069
05070
05071
05072
05073
05074
05075
05076 void BitmapExportOptions::CreateValidPalette()
05077 {
05078 ASSERT(m__pPaletteOptimiser);
05079
05080
05081 BitmapExportPaletteInterface::InvalidateSortedPalette();
05082
05083
05084 if (m__pLogicalPalette)
05085 {
05086 delete m__pLogicalPalette;
05087 m__pLogicalPalette = NULL;
05088 }
05089
05090
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
05099 memset(&NewFlags, 0, sizeof(INT32)*256);
05100
05101 memset(&EditedColours, 0, 3*256);
05102
05103 INT32 i = 0;
05104
05105
05106
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)
05112 {
05113
05114 m__pPaletteOptimiser->AddLockedColour(m_Palette.Data[i].Red, m_Palette.Data[i].Green, m_Palette.Data[i].Blue);
05115
05116 LockedColours++;
05117 }
05118 }
05119
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
05129
05130
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
05138
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
05148 m__pPaletteOptimiser->GetPalette( m__pLogicalPalette, max(2,MaxColoursInPalette - BackGroundTransp));
05149
05150
05151
05152
05153
05154
05155
05156
05157 INT32 index = -1;
05158 while ((index = FindNextLockedColour(index)) != -1)
05159 {
05160
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
05177 if (MaxColoursInPalette - BackGroundTransp == 1)
05178 {
05179 m_Palette.NumberOfColours = m__pLogicalPalette->palNumEntries = 2;
05180
05181
05182 DocColour dcol = Page::GetPageColour();
05183 INT32 bgr = 255, bgg = 255, bgb = 255;
05184
05185
05186
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(AttrFlatColourFill));
05194 if (pNode)
05195 dcol = *(((AttrFlatFill *)pNode)->GetStartColour());
05196 }
05197 }
05198
05199 dcol.GetRGBValue(&bgr,&bgg,&bgb);
05200
05201
05202 if (BackGroundTransp &&
05203 (m__pLogicalPalette->palPalEntry[ 0 ].peRed == (BYTE)bgr || m__pLogicalPalette->palPalEntry[ 0 ].peRed == (BYTE)bgr-1) &&
05204 (m__pLogicalPalette->palPalEntry[ 0 ].peGreen == (BYTE)bgg || m__pLogicalPalette->palPalEntry[ 0 ].peGreen == (BYTE)bgg-1) &&
05205 (m__pLogicalPalette->palPalEntry[ 0 ].peBlue == (BYTE)bgb || m__pLogicalPalette->palPalEntry[ 0 ].peBlue == (BYTE)bgb-1))
05206 {
05207 m__pLogicalPalette->palPalEntry[ 0 ].peRed = m__pLogicalPalette->palPalEntry[ 1 ].peRed;
05208 m__pLogicalPalette->palPalEntry[ 0 ].peGreen = m__pLogicalPalette->palPalEntry[ 1 ].peGreen;
05209 m__pLogicalPalette->palPalEntry[ 0 ].peBlue = m__pLogicalPalette->palPalEntry[ 1 ].peBlue;
05210 }
05211 }
05212 else if (MaxColoursInPalette == 2)
05213 {
05214
05215 m__pLogicalPalette->palPalEntry[ 0 ].peRed = 0;
05216 m__pLogicalPalette->palPalEntry[ 0 ].peGreen = 0;
05217 m__pLogicalPalette->palPalEntry[ 0 ].peBlue = 0;
05218 m__pLogicalPalette->palPalEntry[ 0 ].peFlags = 0;
05219 m__pLogicalPalette->palPalEntry[ 1 ].peRed = 255;
05220 m__pLogicalPalette->palPalEntry[ 1 ].peGreen = 255;
05221 m__pLogicalPalette->palPalEntry[ 1 ].peBlue = 255;
05222 m__pLogicalPalette->palPalEntry[ 1 ].peFlags = 0;
05223 }
05224
05225
05226
05227 if (BackGroundTransp)
05228 {
05229
05230 if (m__pLogicalPalette->palNumEntries < MaxColoursInPalette)
05231 m__pLogicalPalette->palNumEntries++;
05232
05233
05234 for (INT32 i = m__pLogicalPalette->palNumEntries-1; i > 0; i--)
05235 {
05236 m__pLogicalPalette->palPalEntry[ i ].peRed = m__pLogicalPalette->palPalEntry[ i-1 ].peRed;
05237 m__pLogicalPalette->palPalEntry[ i ].peGreen = m__pLogicalPalette->palPalEntry[ i-1 ].peGreen;
05238 m__pLogicalPalette->palPalEntry[ i ].peBlue = m__pLogicalPalette->palPalEntry[ i-1 ].peBlue;
05239 NewFlags[i] = NewFlags[i-1];
05240 EditedColours[i][0] = EditedColours[i-1][0];
05241 EditedColours[i][1] = EditedColours[i-1][1];
05242 EditedColours[i][2] = EditedColours[i-1][2];
05243 }
05244
05245
05246 m__pLogicalPalette->palPalEntry[ 0 ].peRed = 255;
05247 m__pLogicalPalette->palPalEntry[ 0 ].peGreen = 255;
05248 m__pLogicalPalette->palPalEntry[ 0 ].peBlue = 255;
05249
05250 NewFlags[0] = TRANSPARENT_COLOUR;
05251 SetTransparencyIndex(0);
05252 }
05253 else
05254 {
05255
05256
05257 INT32 TranspIndex = -1;
05258
05259 for (i = 0; i < m__pLogicalPalette->palNumEntries && TranspIndex == -1; i++)
05260 {
05261 if (NewFlags[i] & TRANSPARENT_COLOUR)
05262 TranspIndex = i;
05263
05264 }
05265
05266 SetTransparencyIndex(TranspIndex);
05267 }
05268
05269
05270 m__PaletteIsValid = TRUE;
05271
05272
05273
05274 m_Palette.NumberOfColours = m__pLogicalPalette->palNumEntries;
05275
05276
05277 for (i = 0; i < 256; i++)
05278 {
05279 m_Palette.Data[i].Red = m__pLogicalPalette->palPalEntry[ i ].peRed;
05280 m_Palette.Data[i].Green = m__pLogicalPalette->palPalEntry[ i ].peGreen;
05281 m_Palette.Data[i].Blue = m__pLogicalPalette->palPalEntry[ i ].peBlue;
05282 m_Palette.Data[i].Flags = NewFlags[i];
05283 m_Palette.Data[i].PreEditedRed = EditedColours[i][0];
05284 m_Palette.Data[i].PreEditedGreen = EditedColours[i][1];
05285 m_Palette.Data[i].PreEditedBlue = EditedColours[i][2];
05286
05287 if (i >= m__pLogicalPalette->palNumEntries ||
05288 (m_Palette.Data[i].Flags & (DELETED_COLOUR | TRANSPARENT_COLOUR)))
05289 m__pLogicalPalette->palPalEntry[ i ].peFlags = 255;
05290 else
05291 m__pLogicalPalette->palPalEntry[ i ].peFlags = 0;
05292 }
05293
05294 }
05295
05296
05297
05298
05299 void BitmapExportOptions::CreateValidPalette(LOGPALETTE * pPal, INT32 TranspIndex)
05300 {
05301
05302 BitmapExportPaletteInterface::InvalidateSortedPalette();
05303
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
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
05327 m_Palette.NumberOfColours = m__pLogicalPalette->palNumEntries = pPal->palNumEntries;
05328
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;
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 }
05349
05350
05351
05352 void BitmapExportOptions::CreateValidBrowserPalette(BOOL WantTransp)
05353 {
05354
05355 BitmapExportPaletteInterface::InvalidateSortedPalette();
05356
05357 if (m__pLogicalPalette)
05358 {
05359 delete m__pLogicalPalette;
05360 m__pLogicalPalette = NULL;
05361 }
05362
05363 m__PaletteIsValid = TRUE;
05364
05365
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
05377 m_Palette.NumberOfColours = m__pLogicalPalette->palNumEntries = WantTransp ? 217 : 216;
05378
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;
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 }
05408
05409
05410
05411
05412
05413
05414
05415
05416 BOOL BitmapExportOptions::GetSupportsPalette()
05417 {
05418
05419 BOOL Supported = FALSE;
05420 UINT32 FilterStrID = GetFilterNameStrID();
05421
05422
05423 if(m_Depth <= 8)
05424 {
05425
05426 Supported = (FilterStrID == _R(IDN_FILTERNAME_GIF) || FilterStrID == _R(IDT_FILTERNAME_BMP) || FilterStrID == _R(IDS_FILTERNAME_PNG));
05427 }
05428
05429 return Supported;
05430 }
05431
05432
05433
05434
05435
05436
05437
05438
05439
05440
05441
05442 DWORD BitmapExportOptions::GetSupportedDithers()
05443 {
05444
05445 DWORD Supported = 0;
05446 UINT32 FilterStrID = GetFilterNameStrID();
05447
05448
05449 if(m_Depth <= 8)
05450 {
05451
05452
05453
05454
05455
05456
05457 if (FilterStrID==_R(IDN_FILTERNAME_GIF) || FilterStrID==_R(IDS_FILTERNAME_PNG) || FilterStrID==_R(IDT_FILTERNAME_BMP))
05458 {
05459 Supported |= ERROR_DITHER;
05460
05461 if (m__UseBrowserPalette && m_Depth != 4)
05462 Supported |= ORDERED_DITHER;
05463
05464
05465 }
05466
05467
05468
05469
05470 }
05471
05472 return Supported;
05473 }
05474
05475
05476
05477
05478
05479
05480
05481
05482
05483
05484
05485 DWORD BitmapExportOptions::GetSupportedColourDepths()
05486 {
05487
05488 DWORD Supported = 0;
05489 UINT32 FilterStrID = GetFilterNameStrID();
05490
05491 if(FilterStrID == _R(IDN_FILTERNAME_GIF))
05492 Supported = (COLOUR_2 | COLOUR_16 | COLOUR_256 );
05493 else if(FilterStrID == _R(IDT_FILTERNAME_BMP))
05494 Supported = (COLOUR_2 | COLOUR_16 | COLOUR_256 | COLOUR_24BIT);
05495 else if(FilterStrID == _R(IDS_FILTERNAME_PNG))
05496 Supported = (COLOUR_2 | COLOUR_16 | COLOUR_256 | COLOUR_24BIT | COLOUR_32BIT);
05497 else if (FilterStrID == _R(IDS_JPG_EXP_FILTERNAME))
05498 Supported = COLOUR_24BIT;
05499 else
05500
05501 Supported = (COLOUR_2 | COLOUR_16 | COLOUR_256 | COLOUR_24BIT | COLOUR_32BIT);
05502
05503 return Supported;
05504 }
05505
05506
05507
05508
05509
05510
05511
05512
05513
05514
05515
05516 BOOL BitmapExportOptions::GetSupportsTransparency()
05517 {
05518
05519 BOOL Supported = FALSE;
05520 UINT32 FilterStrID = GetFilterNameStrID();
05521
05522
05523 if(m_Depth <= 8)
05524 {
05525 Supported = (FilterStrID == _R(IDN_FILTERNAME_GIF) || FilterStrID == _R(IDS_FILTERNAME_PNG));
05526 }
05527
05528 return Supported;
05529 }
05530
05531
05532
05533
05534
05535
05536
05537
05538
05539
05540
05541 DWORD BitmapExportOptions::GetInterlaceType()
05542 {
05543
05544 DWORD Supported = 0;
05545 UINT32 FilterStrID = GetFilterNameStrID();
05546
05547 if(FilterStrID == _R(IDN_FILTERNAME_GIF))
05548 Supported = GIF_INTERLACE;
05549 else if(FilterStrID == _R(IDS_FILTERNAME_PNG))
05550 Supported = PNG_INTERLACE;
05551 else if(FilterStrID == _R(IDS_JPG_EXP_FILTERNAME))
05552 Supported = JPG_PROGRESSIVE;
05553
05554 return Supported;
05555 }
05556
05557
05558
05559
05560
05561
05562
05563
05564
05565
05566
05567 BaseBitmapFilter * BitmapExportOptions::FindBitmapFilterForTheseExportOptions()
05568 {
05569
05570 const StringBase * pFilterName = GetFilterName();
05571 String_256 PreferedFiltersName = "";
05572
05573
05574 if (pFilterName)
05575 PreferedFiltersName = *(GetFilterName());
05576
05577
05578
05579 if (PreferedFiltersName.IsEmpty() || GetFilterNameStrID() == _R(IDT_FILTERNAME_BMP))
05580 {
05581 PreferedFiltersName.Load(GetFilterNameStrID());
05582 }
05583
05584
05585 Filter *pFilter = Filter::GetFirst();
05586 while (pFilter != NULL)
05587 {
05588
05589
05590 FilterFlags Flags = pFilter->GetFlags();
05591 if (Flags.CanExport && pFilter->IsKindOf(CC_RUNTIME_CLASS(BaseBitmapFilter)))
05592 {
05593 BaseBitmapFilter* pBitmapFilter = (BaseBitmapFilter*)pFilter;
05594 if (PreferedFiltersName.CompareTo(pFilter->pOILFilter->FilterName, FALSE) == 0)
05595 return pBitmapFilter;
05596 }
05597
05598 pFilter = Filter::GetNext(pFilter);
05599 }
05600
05601 return NULL;
05602 }
05603
05604
05605
05606