www.pudn.com > colortracker.rar > MPColorTrackerImage.cpp
/*
* ffimage.cpp
*
*
* Created by Ian Fasel on Mon Nov 18 2002.
* Copyright (c) 2002 __MyCompanyName__. All rights reserved.
*
*/
#include "ffimage.h"
#include "mpisearch.h"
// Ideally, we'd have a subclass derived from ostream....
// In the meantime, we have this thingy
static void debug_message(const char* message){
#ifdef DEBUG_FFIMAGE
cout << message << endl;
#endif
}
// A fast RGBTRIPLE to MPISEARCH_PIXEL_TYPE converting copy constructor
FFImage::FFImage(const FFImage &source){
debug_message( "FFImage::FFImage(): Converting from RGBTRIPLE to MPISEARCH_PIXEL_TYPE" );
MPISEARCH_PIXEL_TYPE one_over_255 = 1.0f/255.0f;
setSize(source.width,source.height,FALSE);
int numpixels = width*height;
char message[256];
sprintf(message,"FFImage::FFImage(): Source image %d", source.isFlipped());
debug_message( message );
MPISEARCH_PIXEL_TYPE *dest_ptr = array;
RGBTRIPLE *source_ptr = source.array;
if(!source.isFlipped()){
for(int i = 0; i < numpixels; i++){
*(dest_ptr++) = static_cast((source_ptr->rgbtBlue*.11f
+ source_ptr->rgbtGreen*.59f
+ source_ptr->rgbtRed*.3f)*one_over_255);
source_ptr++;
}
} else{
RGBTRIPLE *temp;
for (int y=height-1; y >= 0; y--) {
temp = source_ptr + y * width;
for (int x = 0; x < width; x++, temp++) {
*(dest_ptr++) = static_cast(( temp->rgbtBlue*.11f +
temp->rgbtGreen*.59f +
temp->rgbtRed*.3f )*one_over_255);
}
}
}
//m_flipped = FALSE; // since we un-flipped it here, the resulting image is not flipped!
}