Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

plpicenc.cpp

Go to the documentation of this file.
00001 /*
00002 |
00003 |      $Id: plpicenc.cpp,v 1.1 2004/05/21 21:02:53 maxx Exp $
00004 |      Generic Picture Encoder Class
00005 |
00006 |      Abstract base class to dump picture data to memory or file.
00007 |      Classes derived from this class implement concrete encoders
00008 |      for specific file formats.
00009 |
00010 |      Copyright (c) 1996-2002 Ulrich von Zadow
00011 |
00012 \--------------------------------------------------------------------
00013 */
00014 
00015 // not quite ready for prime-time; bdelmee; 2/99
00016 
00017 #include "plstdpch.h"
00018 #include "plpicenc.h"
00019 #include "plfilesink.h"
00020 #include "plexcept.h"
00021 // only for the tracing facility
00022 #include "plpicdec.h"
00023 
00024 
00025 PLPicEncoder::PLPicEncoder()
00026   : PLObject()
00027 // Creates an encoder
00028 {}
00029 
00030 
00031 PLPicEncoder::~PLPicEncoder()
00032 {}
00033 
00034 
00035 // Encodes a picture by creating a file data sink and
00036 // calling SaveBmp with this data sink.
00037 
00038 void PLPicEncoder::MakeFileFromBmp (const char * pszFName, PLBmp * pBmp)
00039 {
00040   PLFileSink FileSink;
00041   int err;
00042 
00043   char sz[1024];
00044   sprintf (sz, "--- Encoding file %s. ---\n", pszFName);
00045   Trace (1, sz);
00046 
00047   // We allocate a buffer large enough to hold the raw bitmap
00048   // plus some overhead.In most cases this should be enough to
00049   // hold the uncompressed data in any format, plus headers, etc...
00050   // Some "pathological" cases however may end up with a CODEC
00051   // producing more data than the uncompressed version!
00052   int bufsize = pBmp->GetMemUsed();
00053   bufsize = bufsize < 20000 ? bufsize + 4096 : int(1.2 * bufsize);
00054   err = FileSink.Open( pszFName, bufsize );
00055   if (err)
00056   {
00057     sprintf (sz, "Opening %s failed", pszFName);
00058     raiseError (err, sz);
00059   }
00060 
00061   SaveBmp ( pBmp, &FileSink );
00062   FileSink.Close ();
00063 }
00064 
00065 // Encodes a picture by getting the encoded data from pDataSrc.
00066 // Saves the results to pDataSrc
00067 // Actually, a wrapper so thin around "DoEncode", you could see through...
00068 void PLPicEncoder::SaveBmp (PLBmp* pBmp, PLDataSink* pDataSnk)
00069 {
00070   DoEncode( pBmp, pDataSnk );
00071 }
00072 
00074 // As long as the tracing code lives in the base decoder,
00075 // we'll just forward everything to it without bothering the user
00076 
00077 void PLPicEncoder::SetTraceConfig( int Level, char * pszFName )
00078 {
00079   PLPicDecoder::SetTraceConfig( Level, pszFName );
00080 }
00081 
00082 void PLPicEncoder::raiseError( int Code, char * pszErr )
00083 {
00084   PLPicDecoder::raiseError( Code, pszErr );
00085 }
00086 
00087 void PLPicEncoder::Trace( int TraceLevel, const char * pszMessage )
00088 {
00089   PLPicDecoder::Trace( TraceLevel, pszMessage );
00090 }
00091 /*
00092 /--------------------------------------------------------------------
00093 |
00094 |      $Log: plpicenc.cpp,v $
00095 |      Revision 1.1  2004/05/21 21:02:53  maxx
00096 |      Initial Version of vuVolume, moderatly changed to make it compile on my windows and linux machine.
00097 |
00098 |      Revision 1.1  2002/11/13 01:58:21  mspindle
00099 |      *** empty log message ***
00100 |
00101 |      Revision 1.3  2002/02/24 13:00:24  uzadow
00102 |      Documentation update; removed buggy PLFilterRotate.
00103 |
00104 |      Revision 1.2  2001/10/06 20:44:45  uzadow
00105 |      Linux compatibility
00106 |
00107 |      Revision 1.1  2001/09/16 19:03:22  uzadow
00108 |      Added global name prefix PL, changed most filenames.
00109 |
00110 |      Revision 1.8  2001/02/04 14:31:52  uzadow
00111 |      Member initialization list cleanup (Erik Hoffmann).
00112 |
00113 |      Revision 1.7  2001/02/04 14:07:24  uzadow
00114 |      Changed max. filename length.
00115 |
00116 |      Revision 1.6  2000/01/16 20:43:14  anonymous
00117 |      Removed MFC dependencies
00118 |
00119 |      Revision 1.5  2000/01/10 23:52:59  Ulrich von Zadow
00120 |      Changed formatting & removed tabs.
00121 |
00122 |      Revision 1.4  2000/01/08 15:51:30  Ulrich von Zadow
00123 |      Misc. modifications to png encoder.
00124 |
00125 |      Revision 1.3  1999/10/03 18:50:51  Ulrich von Zadow
00126 |      Added automatic logging of changes.
00127 |
00128 |
00129 --------------------------------------------------------------------
00130 */

Generated on Wed Dec 15 21:20:30 2004 for vuVolume by  doxygen 1.3.9.1