실행중인 화면을 jpeg 이미지로 저장 C++

Software/C++ Builder|2023. 3. 17. 17:17
반응형

실행중인 화면의 영역을 설정해서 jpeg 이미지 파일로 저장하기위한 코드 입니다. 

void __fastcall Save_Meas_Image(UnicodeString FileName)
{
	TImage *CAPTURE = new TImage(NULL) ;
	HDC hdHandle = GetWindowDC(this->Handle) ;

	try
	{
		CAPTURE->Width  = this->Width ;
		CAPTURE->Height = this->Height ;
		CAPTURE->Picture->Bitmap = NULL ;

		BitBlt(CAPTURE->Canvas->Handle, 0, 0, this->Width, this->Height, hdHandle, 0, 0, SRCCOPY) ;
		JpegSave(FileName, CAPTURE->Picture->Bitmap) ;
	}
	__finally
	{
		delete CAPTURE ;
	}
}
//---------------------------------------------------------------------------

void __fastcall JpegSave(UnicodeString Filename, Graphics::TBitmap *SaveBmp)
{
	TJPEGImage *Hjpeg = new TJPEGImage() ;

	try
	{
		Hjpeg->Assign(SaveBmp) ;
		Hjpeg->SaveToFile(Filename) ;
	}
	__finally
	{
		delete Hjpeg ;
	}
}
//---------------------------------------------------------------------------
반응형

댓글()