prvwflt.cpp

Go to the documentation of this file.
00001 // $Id: prvwflt.cpp 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 
00099 // The preview filters. Basically the same as the normal filter but never puts
00100 // a dialog up for the export options - always provides sensible defaults for
00101 // the preview.
00102 
00103 
00104 #include "camtypes.h"
00105 
00106 #include "prvwflt.h"
00107 
00108 //#include "oilfltrs.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 //#include "accures.h"  // Accusoft errors and messages - and lots of resource ids
00110 //#include "rik.h"      // _R(IDS_BUILDINGPREVIEW)
00111 //#include "filtrres.h" // _R(IDS_IMPORTMSG_PNG)
00112 //#include "andy.h"     // _R(IDT_IMPORTMSG_BMP)
00113 //#include "tim.h"      // _R(IDT_AIEPS_FILTERNAME)
00114 #include "grndbmp.h"    // For GRenderBitmap.
00115 #include "ai_epsrr.h"   // For AIEPSRenderRegion.
00116 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00117 //#include "view.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00118                         
00119 // This is not compulsory, registers the correct version of your file in the .exe
00120 DECLARE_SOURCE("$Revision: 1282 $");
00121 
00122 CC_IMPLEMENT_DYNAMIC(PreviewFilter, Filter)
00123 
00124 CC_IMPLEMENT_DYNAMIC(PreviewFilterBMP, BMPFilter)
00125 CC_IMPLEMENT_DYNAMIC(PreviewFilterGIF, TI_GIFFilter)
00126 CC_IMPLEMENT_MEMDUMP(PreviewFilterJPEG, JPEGExportFilter)
00127 CC_IMPLEMENT_DYNAMIC(PreviewFilterPNG, PNGFilter)
00128 CC_IMPLEMENT_DYNAMIC(ThumbnailFilterPNG, PreviewFilterPNG)
00129 
00130 // This will get Camelot to display the filename and linenumber of any memory allocations
00131 // that are not released at program exit
00132 #define new CAM_DEBUG_NEW
00133 
00134 
00135 /********************************************************************************************
00136 
00137     Preference:     PreviewBitmapSize
00138     Section:        Filters
00139     Range:          1 to INT_MAX
00140     Purpose:        Allows people to set the approximate size of the Preview bitmap that can
00141                     be included in Camelot Native EPS files and Camelot EPS files. It is
00142                     measured in Millipoints and defaults to 96000 (about 128 pixels or just
00143                     over an inch).
00144 
00145 ********************************************************************************************/
00146 
00147 MILLIPOINT PreviewFilter::PreviewBitmapSize = 96000;
00148 
00149 /********************************************************************************************
00150 // Preview Bitmap filter definition
00151 ********************************************************************************************/
00152 
00153 /********************************************************************************************
00154 
00155 >   PreviewFilter::PreviewFilter()
00156 
00157     Author:     Martin_Bell (Xara Group Ltd) <camelotdev@xara.com>
00158     Created:    15/01/97
00159     Purpose:    Constructor for an PreviewFilter object.  The object should be initialised
00160                 to put it in the filter list, but NEVER used for anything.
00161     SeeAlso:    PreviewFilter::Init
00162 
00163 ********************************************************************************************/
00164 
00165 PreviewFilter::PreviewFilter() : Filter()
00166 {
00167     ImportMsgID = _R(IDN_IMPORTMSG_TIFF);   // the preview used to be a TIFF ?don't know what to do?
00168     
00169     // Set it up so that it can neither Import or Export so that it does not appear in the
00170     // Filter menus.
00171     Flags.CanImport = FALSE;
00172     Flags.CanExport = FALSE;
00173     FilterID = FILTERID_PREVIEW;
00174 
00175     ExportMsgID = _R(IDS_BUILDINGPREVIEW);
00176 }
00177 
00178 /********************************************************************************************
00179 
00180 >   BOOL PreviewFilter::Init()
00181 
00182     Author:     Martin_Bell (Xara Group Ltd) <camelotdev@xara.com>
00183     Created:    15/01/97
00184     Returns:    TRUE if the filter was initialised ok, FALSE otherwise.
00185     Purpose:    Initialise a PreviewFilter object.
00186     Errors:     Will fail if not enough memory to initialise.
00187     SeeAlso:    EPSStack; BMPFilter::Init()
00188 
00189 ********************************************************************************************/
00190 
00191 BOOL PreviewFilter::Init()
00192 {
00193     // Get an OILFilter object
00194     pOILFilter = new OILFilter(this);
00195     if (pOILFilter==NULL)
00196         return FALSE;
00197 
00198     // Load the description strings
00199     FilterName.Load(_R(IDN_FILTERNOTPRESENT));
00200 
00201     // All ok
00202     return TRUE;
00203 }
00204 
00205 
00206 /********************************************************************************************
00207 
00208 >   INT32 PreviewFilter::HowCompatible(PathName& Filename, ADDR HeaderStart, UINT32 HeaderSize, 
00209                                  UINT32 FileSize)
00210 
00211     Author:     Martin_Bell (Xara Group Ltd) <camelotdev@xara.com>
00212     Created:    22/01/97
00213     Inputs:     Are all ignored
00214                 Filename - name of the file.
00215                 HeaderStart - Address of the first few bytes of the file.
00216                 HeaderSize - the number of bytes in the header pointed to by FileStart.
00217                 FileSize - the size of the whole file, in bytes.
00218     Returns:    0 = not compatible with anything.
00219     Purpose:    Override pure virtual function so we can have an instance of this object.
00220 
00221 ********************************************************************************************/
00222 
00223 INT32 PreviewFilter::HowCompatible(PathName& Filename, ADDR HeaderStart, UINT32 HeaderSize, 
00224                              UINT32 FileSize)
00225 {
00226     //TRACEUSER( "Martin", __FILE__ "(%d) : warning: PreviewFilter::HowCompatible called\n", __LINE__ );
00227     // Not compatible with anything.
00228     return 0;
00229 }
00230 
00231 /********************************************************************************************
00232 
00233 >   BOOL PreviewFilter::DoImport(SelOperation *Op, CCLexFile* pFile, 
00234                                 Document *DestDoc, BOOL AutoChosen, ImportPosition *Pos,
00235                                 KernelBitmap** ppImportedBitmap, DocCoord* pPosTranslate, String_256* URL)
00236 
00237     Author:     Martin_Bell (Xara Group Ltd) <camelotdev@xara.com>
00238     Created:    22/01/97
00239     Inputs:     Are all ignored
00240                 Op - pointer to the operation that this input process is associated with.
00241                 pFile - The file that we should load the bitmap from
00242                 DestDoc - The Document object which should hold the data read in from
00243                           the bitmap.
00244                 URL - original URL of the imported file
00245     Returns:    FALSE because we don't do any thing.
00246     Purpose:    Override pure virtual function so we can have an instance of this object.
00247 
00248 ********************************************************************************************/
00249 
00250 BOOL PreviewFilter::DoImport(SelOperation *Op, CCLexFile* pFile, 
00251                                 Document *DestDoc, BOOL AutoChosen, ImportPosition *Pos,
00252                                 KernelBitmap** ppImportedBitmap, DocCoord* pPosTranslate, String_256* URL)
00253 {
00254     ERROR3( "PreviewFilter::DoImport called\n");
00255 
00256     return FALSE;
00257 }
00258 
00259 /********************************************************************************************
00260 
00261 >   BOOL PreviewFilter::DoExport(Operation* pOp, CCLexFile* pFile, PathName* pPath,
00262                                  Document* pDoc, BOOL ShowOptions)
00263 
00264     Author:     Martin_Bell (Xara Group Ltd) <camelotdev@xara.com>
00265     Created:    22/01/97
00266     Inputs:     Are all ignored
00267                 pOp - the operation that started the export off
00268                 pDiskFile - the file to put the exported data into
00269                 pPath - the pathname of the file to be exported to
00270                 pDoc - the document to export
00271                 ShowOptions - Show the export options dialogue?
00272     Returns:    FALSE because we don't do any thing.
00273     Purpose:    Override pure virtual function so we can have an instance of this object.
00274 
00275 ********************************************************************************************/
00276 
00277 BOOL PreviewFilter::DoExport(Operation *pOp, CCLexFile* pFile,
00278                              PathName* pPath, Document* pDoc,
00279                              BOOL ShowOptions)
00280 {
00281     ERROR3( "PreviewFilter::DoExport called\n");
00282 
00283     return FALSE;
00284 }
00285 
00286 
00287 /********************************************************************************************/
00288 
00289 /********************************************************************************************
00290 
00291 >   PreviewFilterBMP::PreviewFilterBMP()
00292 
00293     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00294     Created:    24/6/95
00295     Purpose:    Constructor for an PreviewFilterBMP object.  The object should be initialised
00296                 before use.
00297     SeeAlso:    PreviewFilterBMP::Init
00298 
00299 ********************************************************************************************/
00300 
00301 PreviewFilterBMP::PreviewFilterBMP() : BMPFilter()
00302 {
00303     ImportMsgID = _R(IDT_IMPORTMSG_BMP);
00304     
00305     // Set it up so that it can neither Import or Export so that it does not appear in the
00306     // Filter menus.
00307     Flags.CanImport = FALSE;
00308     Flags.CanExport = FALSE;
00309     FilterID = FILTERID_PREVIEW_BMP;
00310 
00311     ExportRegion = NULL;
00312     ExportMsgID = _R(IDS_BUILDINGPREVIEW);
00313     ExportingMsgID = _R(IDS_BUILDINGPREVIEW);
00314 }
00315 
00316 /********************************************************************************************
00317 
00318 >   BOOL PreviewFilterBMP::Init()
00319 
00320     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00321     Created:    24/6/95
00322     Returns:    TRUE if the filter was initialised ok, FALSE otherwise.
00323     Purpose:    Initialise an PreviewFilter object.
00324     Errors:     Will fail if not enough memory to initialise.
00325     SeeAlso:    BMPFilter::Init()
00326 
00327 ********************************************************************************************/
00328 
00329 BOOL PreviewFilterBMP::Init()
00330 {
00331     // Get the OILFilter object
00332     pOILFilter = new BMPOILFilter(this);
00333     if (pOILFilter==NULL)
00334         return FALSE;
00335 
00336     // Load the description strings
00337     FilterName.Load(_R(IDT_BMP_FILTERNAME));
00338     FilterInfo.Load(_R(IDT_BMP_FILTERINFO));
00339 
00340     // All ok
00341     return TRUE;
00342 }
00343 
00344 /********************************************************************************************
00345 
00346 >   virtual BOOL PreviewFilterBMP::DoExport(Operation*, CCLexFile*, PathName*, Document*)
00347 
00348     Author:     Martin_Bell (Xara Group Ltd) <camelotdev@xara.com>
00349     Created:    30/01/97
00350 
00351     Purpose:    Do some set up before exporting so the BaseBitmapFilter base class knows
00352                 it is really a preview. The BaseBitmapFilter can then do resizing as 
00353                 necessary.
00354 
00355     Notes:      copied from BaseCamelotFilter::ExportPreviewBitmap which does the set up
00356                 for us usually (why?). We repeat it here so the _BATCHING thumnail
00357                 generation stuff is the right size as well.
00358 
00359 ********************************************************************************************/
00360 
00361 BOOL PreviewFilterBMP::DoExport(Operation* pOp, CCLexFile* pFile, PathName* pPath, 
00362                                 Document* TheDocument, BOOL ShowOptions)
00363 {
00364     INT32 OldPreviewSize = PreviewFilter::PreviewBitmapSize;
00365     // Set the Preview to be just over an inch accross
00366     PreviewFilter::PreviewBitmapSize = 96000;
00367 
00368     // set ourselves up - this flags the BaseBitmapFilter to do resizing, which needs to be
00369     // done there because of Accusoft.
00370     SetPreviewBitmap(TRUE);
00371 
00372     // Export the Preview to the file by doing what our base class does
00373     BOOL ok = BMPFilter::DoExport(pOp, pFile, pPath, TheDocument, TRUE);
00374 
00375     // Set ourselves back
00376     SetPreviewBitmap(FALSE);
00377     // Set the Preview back to its default setting
00378     PreviewFilter::PreviewBitmapSize = OldPreviewSize;
00379 
00380     return ok;
00381 }
00382 
00383 /********************************************************************************************
00384 
00385 >   virtual BOOL PreviewFilterBMP::GetExportOptions(BitmapExportOptions* pOptions)
00386 
00387     Author:     Martin_Bell (Xara Group Ltd) <camelotdev@xara.com>
00388     Created:    15/01/97
00389     Purpose:    Override base class so we don't put up a dialog but still provide fixed 
00390                 options for preview bitmap filters.
00391     Notes:      See BaseBitmapFilter for interface details
00392 
00393 ********************************************************************************************/
00394 
00395 BOOL PreviewFilterBMP::GetExportOptions(BitmapExportOptions* pOptions)
00396 {
00397     ERROR2IF(pOptions == NULL, FALSE, "NULL Args");
00398     ERROR3IF(!pOptions->IS_KIND_OF(BMPExportOptions), "pOptions isn't a BMPExportOptions");
00399 
00400     BMPExportOptions* pBMPOptions = (BMPExportOptions*)pOptions;
00401 
00402     // the depth we ask GDraw to render is always 32-bit, so we can get transparency
00403     // we have to convert for other formats when writing the actual bytes to the file
00404     SetDepthToRender(32);
00405 
00406     // We haven't written the header yet
00407     WrittenHeader = FALSE;
00408 
00410     // BitmapExportOptions
00411     //
00412 
00413     // this dpi will be used to scale the preview
00414     pBMPOptions->SetDPI(96.0);
00415 
00416     // the export depth of the preview is always 8
00417     pBMPOptions->SetDepth(8);
00418 
00419     // I'm fairly sure this isn't used for anything in WEBSTER-Martin-17/01/97
00420     // PreviewDither = ?;
00421     PreviewPalette = PAL_OPTIMISED;
00422 
00424     // BMPExportOptions
00425     //
00426 
00427     pBMPOptions->SetDither( XARADITHER_NONE );
00428 
00429     // Previews have an optimized palette
00430     PaletteType = PreviewPalette;
00431     pBMPOptions->SetPalette( (PALETTE)PreviewPalette );
00432 
00433     return TRUE;
00434 }
00435 
00436 
00437 /********************************************************************************************/
00438 
00439 /********************************************************************************************
00440 
00441 >   PreviewFilterGIF::PreviewFilterGIF()
00442 
00443     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00444     Created:    24/6/95
00445     Purpose:    Constructor for an PreviewFilterGIF object.  The object should be initialised
00446                 before use.
00447     SeeAlso:    PreviewFilterGIF::Init
00448 
00449 ********************************************************************************************/
00450 
00451 PreviewFilterGIF::PreviewFilterGIF() : TI_GIFFilter()
00452 {
00453     ImportMsgID = _R(IDN_IMPORTMSG_GIF);
00454     
00455     // Set it up so that it can neither Import or Export so that it does not appear in the
00456     // Filter menus.
00457     Flags.CanImport = FALSE;
00458     Flags.CanExport = FALSE;
00459     FilterID = FILTERID_PREVIEW_GIF;
00460 
00461     ExportRegion = NULL;
00462 
00463     ExportMsgID = _R(IDS_BUILDINGPREVIEW);
00464     ExportingMsgID = _R(IDS_BUILDINGPREVIEW);
00465 }
00466 
00467 /********************************************************************************************
00468 
00469 >   BOOL PreviewFilterGIF::Init()
00470 
00471     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00472     Created:    24/6/95
00473     Returns:    TRUE if the filter was initialised ok, FALSE otherwise.
00474     Purpose:    Initialise an PreviewFilter object.
00475     Errors:     Will fail if not enough memory to initialise.
00476     SeeAlso:    BMPFilter::Init()
00477 
00478 ********************************************************************************************/
00479 
00480 BOOL PreviewFilterGIF::Init()
00481 {
00482     // Get the OILFilter object
00483     pOILFilter = new GIFOILFilter(this);
00484     if (pOILFilter==NULL)
00485         return FALSE;
00486 
00487     // Load the description strings
00488     FilterName.Load(_R(IDN_FILTERNAME_GIF));
00489     FilterInfo.Load(_R(IDN_GIF_FILTERINFO));
00490 
00491     // All ok
00492     return TRUE;
00493 }
00494 
00495 /********************************************************************************************
00496 
00497 >   virtual BOOL PreviewFilterGIF::DoExport(Operation*, CCLexFile*, PathName*, Document*)
00498 
00499     Author:     Martin_Bell (Xara Group Ltd) <camelotdev@xara.com>
00500     Created:    30/01/97
00501 
00502     Purpose:    Do some set up before exporting so the BaseBitmapFilter base class knows
00503                 it is really a preview. The BaseBitmapFilter can then do resizing as 
00504                 necessary.
00505 
00506     Notes:      copied from BaseCamelotFilter::ExportPreviewBitmap which does the set up
00507                 for us usually (why?). We repeat it here so the _BATCHING thumnail
00508                 generation stuff is the right size as well.
00509 
00510 ********************************************************************************************/
00511 
00512 BOOL PreviewFilterGIF::DoExport(Operation* pOp, CCLexFile* pFile, PathName* pPath, 
00513                                 Document* TheDocument, BOOL ShowOptions)
00514 {
00515     INT32 OldPreviewSize = PreviewFilter::PreviewBitmapSize;
00516     // Set the Preview to be just over an inch accross
00517     PreviewFilter::PreviewBitmapSize = 96000;
00518 
00519     // set ourselves up - this flags the BaseBitmapFilter to do resizing, which needs to be
00520     // done there because of Accusoft.
00521     SetPreviewBitmap(TRUE);
00522 
00523     // Export the Preview to the file by doing what our base class does
00524     BOOL ok = TI_GIFFilter::DoExport(pOp, pFile, pPath, TheDocument, TRUE);
00525 
00526     // Set ourselves back
00527     SetPreviewBitmap(FALSE);
00528     // Set the Preview back to its default setting
00529     PreviewFilter::PreviewBitmapSize = OldPreviewSize;
00530 
00531     return ok;
00532 }
00533 
00534 /********************************************************************************************
00535 
00536 >   virtual BOOL PreviewFilterGIF::GetExportOptions(BitmapExportOptions* pOptions)
00537 
00538     Author:     Martin_Bell (Xara Group Ltd) <camelotdev@xara.com>
00539     Created:    15/01/97
00540     Purpose:    Override base class so we don't put up a dialog but still provide fixed 
00541                 options for preview bitmap filters.
00542     Notes:      See BaseBitmapFilter for interface details
00543 
00544 ********************************************************************************************/
00545 
00546 BOOL PreviewFilterGIF::GetExportOptions(BitmapExportOptions* pOptions)
00547 {
00548     ERROR2IF(pOptions == NULL, FALSE, "NULL Args");
00549     ERROR3IF(!pOptions->IS_KIND_OF(GIFExportOptions), "pOptions isn't a GIFExportOptions");
00550 
00551     GIFExportOptions* pGIFOptions = (GIFExportOptions*)pOptions;
00552 
00553     // the depth we ask GDraw to render is always 32-bit, so we can get transparency
00554     // we have to convert for other formats when writing the actual bytes to the file
00555     SetDepthToRender(32);
00556 
00557     // We haven't written the header yet
00558     WrittenHeader = FALSE;
00559 
00561     // BitmapExportOptions
00562     //
00563 
00564     // this dpi will be used to scale the preview
00565     pGIFOptions->SetDPI(96.0);
00566 
00567     // the export depth of the preview is always 8
00568     pGIFOptions->SetDepth(8);
00569 
00570     // I'm fairly sure this isn't used for anything in WEBSTER-Martin-17/01/97
00571     //PreviewDither = ?;
00572 
00573     // WEBSTER - markn 12/2/97
00574     // Use the standard palette for the preview
00575     PreviewPalette = PAL_STANDARD;
00576 
00578     // MaskedFilterExportOptions
00579     //
00580 
00581     // WEBSTER - markn 12/2/97
00582     // Use error diffusion
00583     pGIFOptions->SetDither( XARADITHER_ERROR_DIFFUSION );
00584 
00585     // Previews have an optimized palette
00586     PaletteType = PreviewPalette;
00587 //  pGIFOptions->SetPalette( (PALETTE)PreviewPalette );
00588 
00589     // Previews have no interlace/transparency
00590     //pGIFOptions->SetMakeTransparent( FALSE );
00591     pGIFOptions->SetTransparencyIndex(-1);
00592 
00593     pGIFOptions->SetMakeInterlaced( FALSE );
00594 
00595     // We are a first pass render and not doing the mask, by default
00596     SecondPass = FALSE;
00597     DoingMask = FALSE;
00598 
00599     // Default will range from 0 to 4 types which correspond to the combinations of
00600     // on/off interlaced and on/off transparent
00601     Compression = 0;                // Previews have no interlace/transparency
00602 
00603     // Determine the filter type currently in use in Accusoft format
00604     FilterID = FILTERID_TI_GIF;
00605     pGIFOptions->SetFilterType(TI_GIF);
00606 
00607     m_DoingAnimation = FALSE;
00608 
00609     return TRUE;
00610 }
00611 
00612 /********************************************************************************************/
00613 
00614 /********************************************************************************************
00615 
00616 >   PreviewFilterJPEG::PreviewFilterJPEG()
00617 
00618     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00619     Created:    24/6/95
00620     Purpose:    Constructor for an PreviewFilterJPEG object.  The object should be initialised
00621                 before use.
00622     SeeAlso:    PreviewFilterJPEG::Init
00623 
00624 ********************************************************************************************/
00625 
00626 PreviewFilterJPEG::PreviewFilterJPEG() : JPEGExportFilter()
00627 {
00628     ImportMsgID = _R(IDN_IMPORTMSG_JPEG);
00629     
00630     // Set it up so that it can neither Import or Export so that it does not appear in the
00631     // Filter menus.
00632     Flags.CanImport = FALSE;
00633     Flags.CanExport = FALSE;
00634     FilterID = FILTERID_PREVIEW_JPEG;
00635 
00636     ExportRegion = NULL;
00637     ExportMsgID = _R(IDS_BUILDINGPREVIEW);
00638     ExportingMsgID = _R(IDS_BUILDINGPREVIEW);
00639 }
00640 
00641 /********************************************************************************************
00642 
00643 >   BOOL PreviewFilterJPEG::Init()
00644 
00645     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00646     Created:    24/6/95
00647     Returns:    TRUE if the filter was initialised ok, FALSE otherwise.
00648     Purpose:    Initialise an PreviewFilter object.
00649     Errors:     Will fail if not enough memory to initialise.
00650     SeeAlso:    BMPFilter::Init()
00651 
00652 ********************************************************************************************/
00653 
00654 BOOL PreviewFilterJPEG::Init()
00655 {
00656     // Get the OILFilter object
00657     pOILFilter = new JPEGOILFilter(this);
00658     if (pOILFilter==NULL)
00659         return FALSE;
00660 
00661     // Load the description strings
00662     FilterName.Load(_R(IDN_JPEG_FILTERNAME));
00663     FilterInfo.Load(_R(IDN_JPEG_FILTERINFO));
00664 
00665     // All ok
00666     return TRUE;
00667 }
00668 
00669 /********************************************************************************************
00670 
00671 >   virtual BOOL PreviewFilterJPEG::DoExport(Operation*, CCLexFile*, PathName*, Document*)
00672 
00673     Author:     Martin_Bell (Xara Group Ltd) <camelotdev@xara.com>
00674     Created:    30/01/97
00675 
00676     Purpose:    Do some set up before exporting so the BaseBitmapFilter base class knows
00677                 it is really a preview. The BaseBitmapFilter can then do resizing as 
00678                 necessary.
00679 
00680     Notes:      copied from BaseCamelotFilter::ExportPreviewBitmap which does the set up
00681                 for us usually (why?). We repeat it here so the _BATCHING thumnail
00682                 generation stuff is the right size as well.
00683 
00684 ********************************************************************************************/
00685 
00686 BOOL PreviewFilterJPEG::DoExport(Operation* pOp, CCLexFile* pFile, PathName* pPath, 
00687                                 Document* TheDocument, BOOL ShowOptions)
00688 {
00689     INT32 OldPreviewSize = PreviewFilter::PreviewBitmapSize;
00690     // Set the Preview to be just over an inch accross
00691     PreviewFilter::PreviewBitmapSize = 96000;
00692 
00693     // set ourselves up - this flags the BaseBitmapFilter to do resizing, which needs to be
00694     // done there because of Accusoft.
00695     SetPreviewBitmap(TRUE);
00696 
00697     // Export the Preview to the file by doing what our base class does
00698     BOOL ok = JPEGExportFilter::DoExport(pOp, pFile, pPath, TheDocument, TRUE);
00699 
00700     // Set ourselves back
00701     SetPreviewBitmap(FALSE);
00702     // Set the Preview back to its default setting
00703     PreviewFilter::PreviewBitmapSize = OldPreviewSize;
00704 
00705     return ok;
00706 }
00707 
00708 /********************************************************************************************
00709 
00710 >   virtual BOOL PreviewFilterJPEG::GetExportOptions(BitmapExportOptions* pOptions)
00711 
00712     Author:     Martin_Bell (Xara Group Ltd) <camelotdev@xara.com>
00713     Created:    15/01/97
00714     Purpose:    Override base class so we don't put up a dialog but still provide fixed 
00715                 options for preview bitmap filters.
00716     Notes:      See BaseBitmapFilter for interface details
00717 
00718 ********************************************************************************************/
00719 
00720 BOOL PreviewFilterJPEG::GetExportOptions(BitmapExportOptions* pOptions)
00721 {
00722     ERROR2IF(pOptions == NULL, FALSE, "NULL Args");
00723     ERROR3IF(!pOptions->IS_KIND_OF(JPEGExportOptions), "pOptions isn't a JPEGExportOptions");
00724 
00725     JPEGExportOptions* pJPEGOptions = (JPEGExportOptions*)pOptions;
00726 
00727     // the depth we ask GDraw to render is always 32-bit, so we can get transparency
00728     // we have to convert for other formats when writing the actual bytes to the file
00729     SetDepthToRender(32);
00730 
00731     // We haven't written the header yet
00732     WrittenHeader = FALSE;
00733 
00735     // BitmapExportOptions
00736     //
00737 
00738     // this dpi will be used to scale the preview
00739     pJPEGOptions->SetDPI(96.0);
00740 
00741     // the export depth of the preview is always 8
00742     pJPEGOptions->SetDepth(8);
00743 
00744     // I'm fairly sure this isn't used for anything in WEBSTER-Martin-17/01/97
00745     //PreviewDither = ?;
00746     PreviewPalette = PAL_OPTIMISED;
00747 
00749     // JPEGExportOptions
00750     //
00751 
00752     // Previews have an optimized palette
00753     PaletteType = PreviewPalette;
00754 
00755     return TRUE;
00756 }
00757 
00758 
00759 /********************************************************************************************/
00760 
00761 /********************************************************************************************
00762 
00763 >   PreviewFilterPNG::PreviewFilterPNG()
00764 
00765     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00766     Created:    24/6/95
00767     Purpose:    Constructor for an PreviewFilterPNG object.  The object should be initialised
00768                 before use.
00769     SeeAlso:    PreviewFilterPNG::Init
00770 
00771 ********************************************************************************************/
00772 
00773 PreviewFilterPNG::PreviewFilterPNG() : PNGFilter()
00774 {
00775     ImportMsgID = _R(IDS_IMPORTMSG_PNG);
00776     
00777     // Set it up so that it can neither Import or Export so that it does not appear in the
00778     // Filter menus.
00779     Flags.CanImport = FALSE;
00780     Flags.CanExport = FALSE;
00781     FilterID = FILTERID_PNG;        // FILTERID_PREVIEW_PNG;
00782 
00783     ExportRegion = NULL;
00784     ExportMsgID = _R(IDS_BUILDINGPREVIEW);
00785     ExportingMsgID = _R(IDS_BUILDINGPREVIEW);
00786 }
00787 
00788 /********************************************************************************************
00789 
00790 >   BOOL PreviewFilterPNG::Init()
00791 
00792     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00793     Created:    24/6/95
00794     Returns:    TRUE if the filter was initialised ok, FALSE otherwise.
00795     Purpose:    Initialise an PreviewFilter object.
00796     Errors:     Will fail if not enough memory to initialise.
00797     SeeAlso:    BMPFilter::Init()
00798 
00799 ********************************************************************************************/
00800 
00801 BOOL PreviewFilterPNG::Init()
00802 {
00803     // Get the OILFilter object
00804     pOILFilter = new PNGOILFilter(this);
00805     if (pOILFilter==NULL)
00806         return FALSE;
00807 
00808     // Load the description strings
00809     FilterName.Load(_R(IDS_PNG_FILTERNAME));
00810     FilterInfo.Load(_R(IDS_PNG_FILTERINFO));
00811 
00812     // All ok
00813     return TRUE;
00814 }
00815 
00816 /********************************************************************************************
00817 
00818 >   virtual BOOL PreviewFilterPNG::DoExport(Operation*, CCLexFile*, PathName*, Document*)
00819 
00820     Author:     Martin_Bell (Xara Group Ltd) <camelotdev@xara.com>
00821     Created:    30/01/97
00822 
00823     Purpose:    Do some set up before exporting so the BaseBitmapFilter base class knows
00824                 it is really a preview. The BaseBitmapFilter can then do resizing as 
00825                 necessary.
00826 
00827     Notes:      copied from BaseCamelotFilter::ExportPreviewBitmap which does the set up
00828                 for us usually (why?). We repeat it here so the _BATCHING thumnail
00829                 generation stuff is the right size as well.
00830 
00831 ********************************************************************************************/
00832 
00833 BOOL PreviewFilterPNG::DoExport(Operation* pOp, CCLexFile* pFile, PathName* pPath, 
00834                                 Document* TheDocument, BOOL ShowOptions)
00835 {
00836     INT32 OldPreviewSize = PreviewFilter::PreviewBitmapSize;
00837     // Set the Preview to be just over an inch accross
00838     PreviewFilter::PreviewBitmapSize = 96000;
00839 
00840     // set ourselves up - this flags the BaseBitmapFilter to do resizing, which needs to be
00841     // done there because of Accusoft.
00842     SetPreviewBitmap(TRUE);
00843 
00844     // Export the Preview to the file by doing what our base class does
00845     BOOL ok = PNGFilter::DoExport(pOp, pFile, pPath, TheDocument, TRUE);
00846 
00847     // Set ourselves back
00848     SetPreviewBitmap(FALSE);
00849     // Set the Preview back to its default setting
00850     PreviewFilter::PreviewBitmapSize = OldPreviewSize;
00851 
00852     return ok;
00853 }
00854 
00855 /********************************************************************************************
00856 
00857 >   virtual BOOL PreviewFilterPNG::GetExportOptions(BitmapExportOptions* pOptions)
00858 
00859     Author:     Martin_Bell (Xara Group Ltd) <camelotdev@xara.com>
00860     Created:    15/01/97
00861     Purpose:    Override base class so we don't put up a dialog but still provide fixed 
00862                 options for preview bitmap filters.
00863     Notes:      See BaseBitmapFilter for interface details
00864 
00865 ********************************************************************************************/
00866 
00867 BOOL PreviewFilterPNG::GetExportOptions(BitmapExportOptions* pOptions)
00868 {
00869     ERROR2IF(pOptions == NULL, FALSE, "NULL Args");
00870     ERROR3IF(!pOptions->IS_KIND_OF(PNGExportOptions), "pOptions isn't a PNGExportOptions");
00871 
00872     PNGExportOptions* pPNGOptions = (PNGExportOptions*)pOptions;
00873 
00874     // the depth we ask GDraw to render is always 32-bit, so we can get transparency
00875     // we have to convert for other formats when writing the actual bytes to the file
00876     SetDepthToRender(32);
00877 
00878     // We haven't written the header yet
00879     WrittenHeader = FALSE;
00880 
00882     // BitmapExportOptions
00883     //
00884 
00885     // this dpi will be used to scale the preview
00886     pPNGOptions->SetDPI(96.0);
00887 
00888     // the export depth of the preview is always 8
00889     pPNGOptions->SetDepth(8);
00890 
00891     // I'm fairly sure this isn't used for anything in WEBSTER-Martin-17/01/97
00892     //PreviewDither = ?;
00893     PreviewPalette = PAL_OPTIMISED;
00894 
00896     // MaskedFilterExportOptions
00897     //
00898 
00899     pPNGOptions->SetDither( XARADITHER_NONE );
00900 
00901     // Previews have an optimized palette
00902     PaletteType = PreviewPalette;
00903 //  pPNGOptions->SetPalette( (PALETTE)PreviewPalette );
00904 
00905     // Previews have no interlace/transparency
00906 //  pPNGOptions->SetMakeTransparent( FALSE );
00907     pPNGOptions->SetTransparencyIndex(-1);
00908     pPNGOptions->SetMakeInterlaced( FALSE );
00909 
00910     // We are a first pass render and not doing the mask, by default
00911     SecondPass = FALSE;
00912     DoingMask = FALSE;
00913 
00914     // Default will range from 0 to 4 types which correspond to the combinations of
00915     // on/off interlaced and on/off transparent
00916     Compression = 0;                // Previews have no interlace/transparency
00917 
00918     // Determine the filter type currently in use in Accusoft format
00919     FilterID = FILTERID_PNG;
00920     pPNGOptions->SetFilterType(PNG);
00921 
00922     return TRUE;
00923 }
00924 
00925 
00926 
00927 /********************************************************************************************/
00928 
00929 /********************************************************************************************
00930 
00931 >   BOOL ThumbnailFilterPNG::DoExport(Operation* pOp, CCLexFile* pFile, PathName* pPath, 
00932                                 Document* TheDocument)
00933 
00934     Author:     Stefan_Stoykov (Xara Group Ltd) <camelotdev@xara.com>
00935     Created:    10/6/97
00936     Purpose:    Exports a document into a png file. Creates and attaches a DocView to the 
00937                 document before calling the DoExport function of the PNG filter, because it 
00938                 depends on a view being available. Unlike the preview filters no 
00939                 PreviewBitmapSize value is set in this function, so the caller should set it 
00940                 if something different then the default size is required
00941     SeeAlso:    BaseBitmapFilter::DoExport
00942 
00943 ********************************************************************************************/
00944 
00945 BOOL ThumbnailFilterPNG::DoExport(Operation* pOp, CCLexFile* pFile, PathName* pPath, 
00946                                 Document* TheDocument, BOOL ShowOptions)
00947 {
00948     // set ourselves up - this flags the BaseBitmapFilter to do resizing, which needs to be
00949     // done there because of Accusoft.
00950     SetPreviewBitmap(TRUE);
00951 
00952     // create a new view for the document
00953     DocView *pView = new DocView(TheDocument);
00954 
00955     if (pView && pView->Init())
00956     {
00957         // set the view as current, but remember the last current one
00958         View *pOldView = View::GetCurrent();
00959         pView->SetCurrent();
00960 
00961         // Export the thumbnail to the file by doing what our base class does
00962         BOOL ok = PNGFilter::DoExport(pOp, pFile, pPath, TheDocument, TRUE);
00963 
00964         // restore the last view
00965         if (pOldView != NULL)
00966             pOldView->SetCurrent();
00967         else
00968             View::SetNoCurrent();
00969 
00970         // delete our view
00971         delete pView;
00972 
00973         return ok;
00974     }
00975     else
00976         return FALSE; // view creation failed
00977 }

Generated on Sat Nov 10 03:46:38 2007 for Camelot by  doxygen 1.4.4