vconvert.h
Go to the documentation of this file.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 #define _PCONVERT
00080
00081
00082
#ifdef P_USE_PRAGMA
00083
#pragma interface
00084
#endif
00085
00086
00087
00088
class PColourConverter;
00089
00095 class PColourConverterRegistration :
public PCaselessString
00096 {
00097
PCLASSINFO(
PColourConverterRegistration,
PCaselessString);
00098
public:
00099
PColourConverterRegistration(
00100
const PString & srcColourFormat,
00101
const PString & destColourFormat
00102 );
00103
00104
virtual PColourConverter *
Create(
00105
unsigned width,
00106
unsigned height
00107 )
const = 0;
00108
00109
protected:
00110 PColourConverterRegistration *
link;
00111
00112
friend class PColourConverter;
00113 };
00114
00115
00119 class PColourConverter :
public PObject
00120 {
00121
PCLASSINFO(
PColourConverter,
PObject);
00122
public:
00125
PColourConverter(
00126
const PString &
srcColourFormat,
00127
const PString &
dstColourFormat,
00128
unsigned width,
00129
unsigned height
00130 );
00131
00134 BOOL
GetVFlipState()
00135 {
return doVFlip; }
00136
00139 void SetVFlipState(BOOL vFlipState)
00140 {
doVFlip = vFlipState; }
00141
00146
virtual BOOL SetFrameSize(
00147
unsigned width,
00148
unsigned height
00149 );
00150
00157
virtual BOOL SetSrcFrameSize(
00158
unsigned width,
00159
unsigned height
00160 );
00161
00168
virtual BOOL SetDstFrameSize(
00169
unsigned width,
00170
unsigned height,
00171 BOOL bScale
00172 );
00173
00176 const PString &
GetSrcColourFormat() {
return srcColourFormat; }
00177
00180 const PString &
GetDstColourFormat() {
return dstColourFormat; }
00181
00187 PINDEX
GetMaxSrcFrameBytes() {
return srcFrameBytes; }
00188
00194 PINDEX
GetMaxDstFrameBytes() {
return dstFrameBytes; }
00195
00196
00206
virtual BOOL Convert(
00207
const BYTE * srcFrameBuffer,
00208 BYTE * dstFrameBuffer,
00209 PINDEX * bytesReturned = NULL
00210 ) = 0;
00211
00228
virtual BOOL ConvertInPlace(
00229 BYTE * frameBuffer,
00230 PINDEX * bytesReturned = NULL,
00231 BOOL noIntermediateFrame = FALSE
00232 );
00233
00234
00239
static PColourConverter * Create(
00240
const PString & srcColourFormat,
00241
const PString & dstColourFormat,
00242
unsigned width,
00243
unsigned height
00244 );
00245
00248 BOOL GetDstFrameSize(
00249
unsigned & width,
00250
unsigned & height
00251 )
const;
00252
00255 BOOL GetSrcFrameSize(
00256
unsigned & width,
00257
unsigned & height
00258 )
const;
00259
00260
00261
protected:
00262 PString srcColourFormat;
00263 PString dstColourFormat;
00264 unsigned srcFrameWidth;
00265 unsigned srcFrameHeight;
00266 unsigned srcFrameBytes;
00267 unsigned dstFrameBytes;
00268
00269
00270 unsigned dstFrameWidth;
00271 unsigned dstFrameHeight;
00272 BOOL
scaleNotCrop;
00273
00274 BOOL
doVFlip;
00275
00276 PBYTEArray intermediateFrameStore;
00277
00278
friend class PColourConverterRegistration;
00279 };
00280
00281
00287 #define PCOLOUR_CONVERTER2(cls,ancestor,src,dst) \
00288
class cls : public ancestor { \
00289
public: \
00290
cls(const PString & srcFmt, const PString & dstFmt, unsigned w, unsigned h) \
00291
: ancestor(srcFmt, dstFmt, w, h) { } \
00292
virtual BOOL Convert(const BYTE *, BYTE *, PINDEX * = NULL); \
00293
}; \
00294
static class cls##_Registration : public PColourConverterRegistration { \
00295
public: \
00296
cls##_Registration() \
00297
: PColourConverterRegistration(src,dst) { } \
00298
virtual PColourConverter * Create(unsigned w, unsigned h) const; \
00299
} p_##cls##_registration_instance; \
00300
PColourConverter * cls##_Registration::Create(unsigned w, unsigned h) const \
00301
{ PINDEX tab = Find('\t'); return new cls(Left(tab), Mid(tab+1), w, h); } \
00302
BOOL cls::Convert(const BYTE *srcFrameBuffer, BYTE *dstFrameBuffer, PINDEX * bytesReturned)
00303
00304
00310 #define PCOLOUR_CONVERTER(cls,src,dst) \
00311
PCOLOUR_CONVERTER2(cls,PColourConverter,src,dst)
00312
00313
00314
00319 class PSynonymColour :
public PColourConverter {
00320
public:
00321 PSynonymColour(
00322
const PString & srcFmt,
00323
const PString & dstFmt,
00324
unsigned w,
unsigned h
00325 ) :
PColourConverter(srcFmt, dstFmt, w, h) { }
00326
virtual BOOL Convert(
const BYTE *, BYTE *, PINDEX * = NULL);
00327 };
00328
00329
00334 class PSynonymColourRegistration :
public PColourConverterRegistration {
00335
public:
00336 PSynonymColourRegistration(
00337
const char * srcFmt,
00338
const char * dstFmt
00339 ) :
PColourConverterRegistration(srcFmt,dstFmt) { }
00340
virtual PColourConverter * Create(
unsigned w,
unsigned h)
const;
00341 };
00342
00343
00348 #define PSYNONYM_COLOUR_CONVERTER(from,to) \
00349
static PSynonymColourRegistration p_##from##_##to##_registration_instance(#from,#to)
00350
00351
00352
Generated on Sat Jul 24 15:35:57 2004 for PWLib by
1.3.7