00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "plstdpch.h"
00015
00016
00017
00018
00019
00020 #include <stdarg.h>
00021 #include "pltiffenc.h"
00022 #include "pltiffencex.h"
00023 #include "plbitmap.h"
00024 #include "plexcept.h"
00025
00026 extern "C"
00027 {
00028 #include "tiffio.h"
00029 #include "tif_msrc.h"
00030 }
00031
00032
00034
00035
00036
00037 PLTIFFEncoderEx::PLTIFFEncoderEx()
00038 : PLTIFFEncoder(),
00039 m_TiffToken(0)
00040 {}
00041
00042
00043
00044 PLTIFFEncoderEx::~PLTIFFEncoderEx()
00045 {
00046 Dissociate();
00047 }
00048
00049
00050 bool PLTIFFEncoderEx::Associate( PLDataSink* pDataSnk )
00051 {
00052 m_TiffToken = TIFFOpenMem (pDataSnk->m_pStartData,
00053 pDataSnk->m_nMaxFileSize,
00054 &(pDataSnk->m_nCurPos));
00055 return m_TiffToken != 0;
00056 }
00057
00058
00059 void PLTIFFEncoderEx::Dissociate()
00060 {
00061 if ( m_TiffToken )
00062 {
00063 TIFFClose( m_TiffToken );
00064 m_TiffToken = 0;
00065 }
00066 }
00067
00068
00069 void PLTIFFEncoderEx::DoEncode (PLBmp * pBmp, PLDataSink* )
00070 {
00071 PLASSERT( m_TiffToken );
00072
00073 PLTIFFEncoder::DoTiffEncode( pBmp, m_TiffToken );
00074 }
00075
00076
00077
00078
00079 int PLTIFFEncoderEx::SetBaseTags( PLBmp* pBmp )
00080 {
00081 return PLTIFFEncoder::SetBaseTags( m_TiffToken, pBmp );
00082 }
00083
00084
00085 int PLTIFFEncoderEx::SetField( int tag_id, ... )
00086 {
00087 int retv;
00088 va_list marker;
00089
00090 va_start( marker, tag_id );
00091 retv = TIFFVSetField( m_TiffToken, tag_id, marker );
00092 va_end( marker );
00093
00094 return retv;
00095 }
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126