Exemplo n.º 1
0
/**
**************************************************************************
*  This function performs loading of bitmap luma
*
* \param FileName		[IN] - Image name to load
* \param Stride			[IN] - Image stride
* \param ImSize			[IN] - Image size
* \param Img			[OUT] - Prepared buffer
*
* \return None
*/
void LoadBmpAsGray(char *FileName, int Stride, ROI ImSize, byte *Img)
{
	BMPFileHeader FileHeader;
	BMPInfoHeader InfoHeader;
	FILE *fh;
	fh = fopen(FileName, "rb");

	fread(&FileHeader, sizeof(BMPFileHeader), 1, fh);
	fread(&InfoHeader, sizeof(BMPInfoHeader), 1, fh);

	for (int i=ImSize.height-1; i>=0; i--)
	{
		for (int j=0; j<ImSize.width; j++)
		{
			int r=0, g=0, b=0;
			fread(&b, 1, 1, fh);
			fread(&g, 1, 1, fh);
			fread(&r, 1, 1, fh);
			int val = ( 313524*r + 615514*g + 119537*b + 524288) >> 20 ;
			Img[i*Stride+j] = (byte)clamp_0_255(val);
		}
	}

	fclose(fh);
	return;
}
Exemplo n.º 2
0
/**
**************************************************************************
*  Copies float plane to byte plane (with clamp)
*
* \param ImgSrc				[IN] - Source float plane
* \param StrideF			[IN] - Source plane stride
* \param ImgDst				[OUT] - Destination byte plane
* \param StrideB			[IN] - Destination plane stride
* \param Size				[IN] - Size of area to copy
*  
* \return None
*/
void CopyFloat2Byte(float *ImgSrc, int StrideF, byte *ImgDst, int StrideB, ROI Size)
{
	for (int i=0; i<Size.height; i++)
	{
		for (int j=0; j<Size.width; j++)
		{
			ImgDst[i*StrideB+j] = (byte)clamp_0_255((int)(round_f(ImgSrc[i*StrideF+j])));
		}
	}
}
Exemplo n.º 3
0
int cColor::c()
{
 return makecol(clamp_0_255((int)r), clamp_0_255((int)g), clamp_0_255((int)b));
}