Hi, all
I have installed UltraVNC mirror driver .
How to save myframebuffer as a bmp file ( such as c:\test.bmp) .
Thanks!
Celebrating the 22th anniversary of the UltraVNC: https://forum.uvnc.com/viewtopic.php?t=38031
Update: UltraVNC 1.4.3.6 and UltraVNC SC 1.4.3.6: https://forum.uvnc.com/viewtopic.php?t=37885
Important: Please update to latest version before to create a reply, a topic or an issue: https://forum.uvnc.com/viewtopic.php?t=37864
Join us on social networks and share our announcements:
- Website: https://uvnc.com/
- GitHub: https://github.com/ultravnc
- Mastodon: https://mastodon.social/@ultravnc
- Bluesky/AT Protocol: https://bsky.app/profile/ultravnc.bsky.social
- Facebook: https://www.facebook.com/ultravnc1
- X/Twitter: https://x.com/ultravnc1
- Reddit community: https://www.reddit.com/r/ultravnc
- OpenHub: https://openhub.net/p/ultravnc
Update: UltraVNC 1.4.3.6 and UltraVNC SC 1.4.3.6: https://forum.uvnc.com/viewtopic.php?t=37885
Important: Please update to latest version before to create a reply, a topic or an issue: https://forum.uvnc.com/viewtopic.php?t=37864
Join us on social networks and share our announcements:
- Website: https://uvnc.com/
- GitHub: https://github.com/ultravnc
- Mastodon: https://mastodon.social/@ultravnc
- Bluesky/AT Protocol: https://bsky.app/profile/ultravnc.bsky.social
- Facebook: https://www.facebook.com/ultravnc1
- X/Twitter: https://x.com/ultravnc1
- Reddit community: https://www.reddit.com/r/ultravnc
- OpenHub: https://openhub.net/p/ultravnc
How to save myframebuffer as a bmp file
-
- Posts: 2
- Joined: 2011-11-03 10:56
Re: How to save myframebuffer as a bmp file
Hey I was just playing and working on this.
I got this, it works for me:
http://pastebin.com/7LbCh1fW
Its hacked up from the examples of screentoavi and changed_screen_parts.
I got this, it works for me:
http://pastebin.com/7LbCh1fW
Code: Select all
// mirror.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "videodriver.h"
void trackChanges( PCHANGES_BUF, int );
void Draw( void );
BITMAPFILEHEADER *BitmapHeader = ( BITMAPFILEHEADER* ) malloc( sizeof( BITMAPFILEHEADER ) );
BITMAPINFOHEADER *BitmapInfo = ( BITMAPINFOHEADER* ) malloc( sizeof( BITMAPINFOHEADER ) );
int main(int argc, char* argv[])
{
VIDEODRIVER* vDriver = new VIDEODRIVER;
HDC hDisplayDC = CreateDC( _T( "DISPLAY" ), NULL, NULL, NULL );
int cxWidth = GetDeviceCaps( hDisplayDC, HORZRES ) ;
int cyHeight = GetDeviceCaps( hDisplayDC,VERTRES );
BitmapHeader->bfType = 'MB';
BitmapHeader->bfSize = 0;
BitmapHeader->bfReserved1 = 0;
BitmapHeader->bfReserved2 = 0;
BitmapHeader->bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
BitmapInfo->biSize = sizeof( BITMAPINFOHEADER );
BitmapInfo->biWidth = cxWidth;
BitmapInfo->biHeight = -cyHeight;
BitmapInfo->biPlanes = 1;
BitmapInfo->biBitCount = 32;
BitmapInfo->biCompression = BI_RGB;
BitmapInfo->biSizeImage= cyHeight * cxWidth * 4;
vDriver->VIDEODRIVER_start( 0, 0, cxWidth, cyHeight, 0 );
if ( !vDriver->mypVideoMemory ) return 0;
vDriver->HardwareCursor();
PCHANGES_BUF screenChanges = vDriver->mypchangebuf;
int previousCounter = 0, Counter = screenChanges->counter;
while ( true )
{
DWORD dwBytesWritten;
HANDLE hFile = CreateFile("C:\\FRAMEBUFFER.BMP", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
WriteFile(hFile, BitmapHeader, sizeof(BITMAPFILEHEADER), &dwBytesWritten, NULL);
WriteFile(hFile, BitmapInfo, sizeof(BITMAPINFOHEADER), &dwBytesWritten, NULL);
WriteFile(hFile, (char*)vDriver->myframebuffer, cxWidth * cyHeight * 4, &dwBytesWritten, NULL);
CloseHandle(hFile);
Counter = screenChanges->counter;
if ( previousCounter != Counter && ( Counter <= 1 || Counter <= 1999 ) )
{
previousCounter = Counter;
if ( previousCounter < Counter )
{
for ( int i = previousCounter + 1; i <= Counter; i++ )
{
trackChanges( screenChanges, i );
}
}
else
{
int x = 0;
for ( x = previousCounter + 1; x < MAXCHANGES_BUF; x++ )
{
trackChanges( screenChanges, x );
}
for ( x = 1; x <= Counter; x++ )
{
trackChanges( screenChanges, x );
}
}
}
}
vDriver->VIDEODRIVER_Stop();
delete vDriver;
return 0;
}
void trackChanges( PCHANGES_BUF Changes, int i )
{
POINT Point = Changes->pointrect[i].point;
RECT Rect = Changes->pointrect[i].rect;
switch ( Changes->pointrect[i].type )
{
case SCREEN_SCREEN:
{
printf( "screen2screen [X: %i, Y: %i], [Left: %i, Right: %i, Top: %i, Bottom: %i] \n", (int)Point.x, (int)Point.y, (int)Rect.left, (int)Rect.right, (int)Rect.top, (int)Rect.bottom );
}
break;
case BLIT:
{
printf( "blit [X: %i, Y: %i], [Left: %i, Right: %i, Top: %i, Bottom: %i] \n", (int)Point.x, (int)Point.y, (int)Rect.left, (int)Rect.right, (int)Rect.top, (int)Rect.bottom );
}
break;
default:
break;
}
}
-
- Posts: 2
- Joined: 2011-11-03 10:56
Re: How to save myframebuffer as a bmp file
Infact, Here's a slimmed version for your needs. (in the code i posted there ^ i was going to bitblit)
Code: Select all
// mirror.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "videodriver.h"
BITMAPFILEHEADER *BitmapHeader = ( BITMAPFILEHEADER* ) malloc( sizeof( BITMAPFILEHEADER ) );
BITMAPINFOHEADER *BitmapInfo = ( BITMAPINFOHEADER* ) malloc( sizeof( BITMAPINFOHEADER ) );
int main(int argc, char* argv[])
{
VIDEODRIVER* vDriver = new VIDEODRIVER;
HDC hDisplayDC = CreateDC( _T( "DISPLAY" ), NULL, NULL, NULL );
int cxWidth = GetDeviceCaps( hDisplayDC, HORZRES ) ;
int cyHeight = GetDeviceCaps( hDisplayDC,VERTRES );
BitmapHeader->bfType = 'MB';
BitmapHeader->bfSize = 0;
BitmapHeader->bfReserved1 = 0;
BitmapHeader->bfReserved2 = 0;
BitmapHeader->bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
BitmapInfo->biSize = sizeof( BITMAPINFOHEADER );
BitmapInfo->biWidth = cxWidth;
BitmapInfo->biHeight = -cyHeight;
BitmapInfo->biPlanes = 1;
BitmapInfo->biBitCount = 32;
BitmapInfo->biCompression = BI_RGB;
BitmapInfo->biSizeImage= cyHeight * cxWidth * 4;
vDriver->VIDEODRIVER_start( 0, 0, cxWidth, cyHeight, 0 );
if ( !vDriver->mypVideoMemory ) return 0;
vDriver->HardwareCursor();
PCHANGES_BUF screenChanges = vDriver->mypchangebuf;
int previousCounter = 0, Counter = screenChanges->counter;
DWORD dwBytesWritten;
HANDLE hFile = CreateFile("C:\\FRAMEBUFFER.BMP", GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
WriteFile(hFile, BitmapHeader, sizeof(BITMAPFILEHEADER), &dwBytesWritten, NULL);
WriteFile(hFile, BitmapInfo, sizeof(BITMAPINFOHEADER), &dwBytesWritten, NULL);
WriteFile(hFile, (char*)vDriver->myframebuffer, cxWidth * cyHeight * 4, &dwBytesWritten, NULL);
CloseHandle(hFile);
vDriver->VIDEODRIVER_Stop();
delete vDriver;
return 0;
}