bool WindowsScreenGrabber::getScreenSizeChanged()
{
  BMI bmi;
  if (!getBMI(&bmi)) {
    return false;
  }

  int width = bmi.bmiHeader.biWidth;
  int height = bmi.bmiHeader.biHeight;

  if (width != m_fullScreenRect.getWidth() ||
      height != m_fullScreenRect.getHeight()) {
    return true;
  }

  int left = GetSystemMetrics(SM_XVIRTUALSCREEN);
  int top = GetSystemMetrics(SM_YVIRTUALSCREEN);

  if (left != m_fullScreenRect.left||
      top != m_fullScreenRect.top) {
    applyNewProperties();
  }

  return false;
}
Example #2
0
void Screen::update()
{
  BMI bmi;
  getBMI(&bmi, 0);

  fillPixelFormat(&bmi);
  fillScreenRect();
}
Example #3
0
File: lab2.cpp Project: timcsy/lab2
string BMI::getCategory()
{
	double bmi = getBMI();
	if(bmi < 15) return "Very severely underweight";
	else if(bmi >= 15 && bmi < 16) return "Severely underweight";
	else if(bmi >= 16 && bmi < 18.5) return "Underweight";
	else if(bmi >= 18.5 && bmi < 25) return "Normal";
	else if(bmi >= 25 && bmi < 30) return "Overweight";
	else if(bmi >= 30 && bmi < 35) return "Obese Class I (Moderately obese)";
	else if(bmi >= 35 || bmi < 40) return "Obese Class II (Severely obese)";
	else if(bmi >= 40) return "Obese Class III (Very severely obese)";
}
bool WindowsScreenGrabber::applyNewPixelFormat()
{
  BMI bmi;
  if (!getBMI(&bmi)) {
    return false;
  }

  PixelFormat pixelFormat;
  bool result = fillPixelFormat(&pixelFormat, &bmi);
  m_workFrameBuffer.setEmptyPixelFmt(&pixelFormat);

  return result;
}
bool WindowsScreenGrabber::openDIBSection()
{
  closeDIBSection();

  m_workFrameBuffer.setBuffer(0);

  m_screenDC = GetDC(0);
  if (m_screenDC == NULL) {
    return false;
  }

  if (getPropertiesChanged()) {
    return false;
  }

  BMI bmi;
  if (!getBMI(&bmi, m_screenDC)) {
    return false;
  }

  PixelFormat pixelFormat = m_workFrameBuffer.getPixelFormat();
  Dimension workDim = m_workFrameBuffer.getDimension();

  bmi.bmiHeader.biBitCount = pixelFormat.bitsPerPixel;
  bmi.bmiHeader.biWidth = workDim.width;
  bmi.bmiHeader.biHeight = -workDim.height;
  bmi.bmiHeader.biCompression = BI_BITFIELDS;
  bmi.red   = pixelFormat.redMax   << pixelFormat.redShift;
  bmi.green = pixelFormat.greenMax << pixelFormat.greenShift;
  bmi.blue  = pixelFormat.blueMax  << pixelFormat.blueShift;

  m_destDC = CreateCompatibleDC(NULL);
  if (m_destDC == NULL) {
    DeleteDC(m_screenDC);
    return false;
  }

  void *buffer;
  m_hbmDIB = CreateDIBSection(m_destDC, (BITMAPINFO *) &bmi, DIB_RGB_COLORS, &buffer, NULL, NULL);
  if (m_hbmDIB == 0) {
    DeleteDC(m_destDC);
    DeleteDC(m_screenDC);
    return false;
  }
  m_workFrameBuffer.setBuffer(buffer);
  m_dibSectionDim = workDim;

  m_hbmOld = (HBITMAP) SelectObject(m_destDC, m_hbmDIB);

  return true;
}
Example #6
0
File: 1.c Project: hdddt/C
int main(void){
	struct person data[100];
	int N,i=0;
	while((scanf("%s %d %lf %lf",data[i].name,&data[i].age,&data[i].height,&data[i].weight))!=EOF){
		data[i].BMI = getBMI(data[i]);
		data[i].standard = getStandard(data[i]);
		data[i].fatstate = getfatstate(data[i]);
		i++;
	}
	N=i;

	for(i=0;i<N;i++){
		printf("%15s %3d %3.1f %3.1f %3.1f %3.1f ",data[i].name,data[i].age,data[i].height,data[i].weight,
	                                data[i].BMI,data[i].standard);
		switch(data[i].fatstate){
			case 1:
			printf("  Light");
			break;

			case 2:
			printf(" Normal");
			break;

			case 3:
			printf("Heavy 1");
			break;

			case 4:
			printf("Heavy 2");
			break;

			case 5:
			printf("Heavy 3");
			break;

			case 6:
			printf("Heavy 4");
			break;

			default:
			printf("Error!!");
			break;
		}

		printf("\n");
	}

	return 0;
}
bool WindowsScreenGrabber::getPixelFormatChanged()
{
  BMI bmi;
  if (!getBMI(&bmi)) {
    return false;
  }

  PixelFormat currentPF;
  PixelFormat frameBufferPF = m_workFrameBuffer.getPixelFormat();
  fillPixelFormat(&currentPF, &bmi);

  if (!frameBufferPF.isEqualTo(&currentPF)) {
    return true;
  }

  return false;
}