Hi Riccardo,
Maxthon is not suggesting to pick a type during compile time, but instead use a
macro to generate both cases in your code. For your app it would be something
like this where the macro has the code, and the C preprocessor is used to
insert the code. In reality you still have duplicate code. I was aware of
this solution but was interested to see if there was any alternatives.
#define PROCESS_IMAGE(DATATYPE) \
DATATYPE *srcData; \
DATATYPE *destData; \
DATATYPE *p1; \
DATATYPE *p2; \
// etc.
if ([srcImageRep bitsPerSample] == 8)
{
PROCESS_IMAGE(unsigned char)
}
else if ([srcImageRep bitsPerSample] == 16)
{
PROCESS_IMAGE(unsigned short)
}