示例#1
0
static u16
swap16 (u16 value)
{
	u8 l, h;

	conv16to8 (value, &l, &h);
	conv8to16 (h, l, &value);
	return value;
}
示例#2
0
/*

 load:
 
 loads a BlobImage into the window, converts from 16bpp to 8bp, repaints
 if autoBR is TRUE, will find a recommended background and range value for the image
 reasonable values for background and range are needed for good converion
 
*/
void ImageViewer::load(BlobImage* img, bool in_autoBR/*=FALSE*/)
{
#if VIEWER_DEBUG
	cerr << "[Viewer debug]: loading an image" << endl;
#endif
	loading = true;
	bimg = img;
	autoBR = in_autoBR;
	if (autoBR) img->AutoBackgroundAndRange();
	unsigned short background = img->GetBackground();
	unsigned short range = img->GetRange();
	unsigned short *data16 = img->GetImagePointer();
	
	for (int i=0; i<bimg->GetHeight(); i++) {
		unsigned char *qline = qimg->scanLine(i);
		unsigned short *bline = data16 + i*bimg->GetWidth();
		for (int j=0; j<bimg->GetWidth(); j++)
			*(qline+j) = conv16to8(*(bline+j),background, range);
	}
	bimg->setChanged(false);
	needsRepaint = true;
	loading = false;
	
}