In order for this site to work correctly we need to store a small file (called a cookie) on your computer. Most every site in the world does this, however since the 25th of May 2011, by law we have to get your permission first. Please abandon the forum if you disagree.

Para que este foro funcione correctamente es necesario guardar un pequeño fichero (llamado cookie) en su ordenador. La mayoría de los sitios de Internet lo hacen, no obstante desde el 25 de Marzo de 2011 y por ley, necesitamos de su permiso con antelación. Abandone este foro si no está conforme.

Saving a Canvas as an image file

Xailer professional forum in English
Responder
Guest

Saving a Canvas as an image file

Mensaje por Guest »

Hi,
After Creating a number of line graphs on a canvas, is there a way to
save the entire canvas as a graphics file? It doesn't matter whether
it's a bitmap or tiff or whatever.
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9469
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Saving a Canvas as an image file

Mensaje por ignacio »

Childers,
You may use: XA_CaptureBitmap( <hWnd>, [<aRect>] ) --> hBitmap
In case you are drawing into a Window (Form). If you want to do the same job
using a printer canvas is a not a good idea since the bitmap will normally
have a tremendous size.
Regards,
--
Ignacio Ortiz de Zúñiga
Xailer support / Soporte de Xailer
http://www.xailer.com
http://www.xailer.info
"Childers" <NoSpamPlease@nycap.rr.com> escribió en el mensaje
news:4a1dbebe$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
> Hi,
>
> After Creating a number of line graphs on a canvas, is there a way to save
> the entire canvas as a graphics file? It doesn't matter whether it's a
> bitmap or tiff or whatever.
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9469
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Saving a Canvas as an image file

Mensaje por ignacio »

Childers,
You may use: XA_CaptureBitmap( <hWnd>, [<aRect>] ) --> hBitmap
In case you are drawing into a Window (Form). If you want to do the same job
using a printer canvas is a not a good idea since the bitmap will normally
have a tremendous size.
Regards,
--
Ignacio Ortiz de Zúñiga
Xailer support / Soporte de Xailer
http://www.xailer.com
http://www.xailer.info
"Childers" <NoSpamPlease@nycap.rr.com> escribió en el mensaje
news:4a1dbebe$[email=1@svctag-j7w3v3j....]1@svctag-j7w3v3j....[/email]
> Hi,
>
> After Creating a number of line graphs on a canvas, is there a way to save
> the entire canvas as a graphics file? It doesn't matter whether it's a
> bitmap or tiff or whatever.
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Guest

Saving a Canvas as an image file

Mensaje por Guest »

>>You may use: XA_CaptureBitmap( <hWnd>, [<aRect>] ) --> hBitmap
In case you are drawing into a Window (Form). If you want to do the same
job using a printer canvas is a not a good idea since the bitmap will
normally have a tremendous size.
Regards,<<
Ok, thanks. Using the above suggestion, the following works:
hBitMapImage := XA_CaptureBitMap( GetActiveWindow() )
oGraphBitMap := TBitMap():CreateFromHandle( hBitMapImage )
oGraphBitMap:Save( "C:DownloadTestBitMap.bmp" )
, but it captures the form, which includes the canvas. That's workable.
But is there a way to capture only the canvas, without any of the other
objects on the form? How do we obtain the window handle for only the
canvas?
Guest

Saving a Canvas as an image file

Mensaje por Guest »

>>You may use: XA_CaptureBitmap( <hWnd>, [<aRect>] ) --> hBitmap
In case you are drawing into a Window (Form). If you want to do the same
job using a printer canvas is a not a good idea since the bitmap will
normally have a tremendous size.
Regards,<<
Ok, thanks. Using the above suggestion, the following works:
hBitMapImage := XA_CaptureBitMap( GetActiveWindow() )
oGraphBitMap := TBitMap():CreateFromHandle( hBitMapImage )
oGraphBitMap:Save( "C:DownloadTestBitMap.bmp" )
, but it captures the form, which includes the canvas. That's workable.
But is there a way to capture only the canvas, without any of the other
objects on the form? How do we obtain the window handle for only the
canvas?
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9469
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Saving a Canvas as an image file

Mensaje por ignacio »

Childers,
You may use aRect to only get the window client rectangle.
In order to capture the canvas, you need some C acknowledge. I include with
this message the code of XA_CaptureBitmap() that can serve you as a starting
point
Regards,
XA_FUNC( XA_CAPTUREBITMAP ) // XA_CaptureBitmap( <hWnd>, [<aRect>] ) -->
hBitmap
{
HWND hwnd = (HWND) hb_parnl( 1 );
RECT rect;
HDC hdc = GetDC( hwnd ), hdcBmp;
HBITMAP hBmp;
if ( hb_pcount() > 1 )
{
rect.left = hb_parnl( 2 );
rect.top = hb_parnl( 3 );
rect.bottom = hb_parnl( 4 );
rect.right = hb_parnl( 5 );
}
else
GetClientRect( hwnd, &rect );
hdcBmp = CreateCompatibleDC( hdc );
hBmp = CreateCompatibleBitmap( hdc, rect.right - rect.left, rect.bottom -
rect.top );
SelectObject( hdcBmp, hBmp );
BitBlt( hdcBmp, 0, 0, rect.right - rect.left, rect.bottom - rect.top,
hdc, rect.left, rect.top, SRCCOPY );
DeleteDC( hdcBmp );
ReleaseDC( hwnd, hdc );
hb_retnl( (long) hBmp );
}
--
Ignacio Ortiz de Zúñiga
Xailer support / Soporte de Xailer
http://www.xailer.com
http://www.xailer.info
"Childers" <NoSpamPlease@nycap.rr.com> escribió en el mensaje
news:4a1f0e3c$[email=2@svctag-j7w3v3j....]2@svctag-j7w3v3j....[/email]
> >>You may use: XA_CaptureBitmap( <hWnd>, [<aRect>] ) --> hBitmap
>
> In case you are drawing into a Window (Form). If you want to do the same
> job using a printer canvas is a not a good idea since the bitmap will
> normally have a tremendous size.
>
> Regards,<<
>
> Ok, thanks. Using the above suggestion, the following works:
>
>
> hBitMapImage := XA_CaptureBitMap( GetActiveWindow() )
> oGraphBitMap := TBitMap():CreateFromHandle( hBitMapImage )
> oGraphBitMap:Save( "C:DownloadTestBitMap.bmp" )
>
>
> , but it captures the form, which includes the canvas. That's workable.
>
> But is there a way to capture only the canvas, without any of the other
> objects on the form? How do we obtain the window handle for only the
> canvas?
>
>
>
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Avatar de Usuario
ignacio
Site Admin
Mensajes: 9469
Registrado: Lun Abr 06, 2015 8:00 pm
Ubicación: Madrid, Spain
Contactar:

Saving a Canvas as an image file

Mensaje por ignacio »

Childers,
You may use aRect to only get the window client rectangle.
In order to capture the canvas, you need some C acknowledge. I include with
this message the code of XA_CaptureBitmap() that can serve you as a starting
point
Regards,
XA_FUNC( XA_CAPTUREBITMAP ) // XA_CaptureBitmap( <hWnd>, [<aRect>] ) -->
hBitmap
{
HWND hwnd = (HWND) hb_parnl( 1 );
RECT rect;
HDC hdc = GetDC( hwnd ), hdcBmp;
HBITMAP hBmp;
if ( hb_pcount() > 1 )
{
rect.left = hb_parnl( 2 );
rect.top = hb_parnl( 3 );
rect.bottom = hb_parnl( 4 );
rect.right = hb_parnl( 5 );
}
else
GetClientRect( hwnd, &rect );
hdcBmp = CreateCompatibleDC( hdc );
hBmp = CreateCompatibleBitmap( hdc, rect.right - rect.left, rect.bottom -
rect.top );
SelectObject( hdcBmp, hBmp );
BitBlt( hdcBmp, 0, 0, rect.right - rect.left, rect.bottom - rect.top,
hdc, rect.left, rect.top, SRCCOPY );
DeleteDC( hdcBmp );
ReleaseDC( hwnd, hdc );
hb_retnl( (long) hBmp );
}
--
Ignacio Ortiz de Zúñiga
Xailer support / Soporte de Xailer
http://www.xailer.com
http://www.xailer.info
"Childers" <NoSpamPlease@nycap.rr.com> escribió en el mensaje
news:4a1f0e3c$[email=2@svctag-j7w3v3j....]2@svctag-j7w3v3j....[/email]
> >>You may use: XA_CaptureBitmap( <hWnd>, [<aRect>] ) --> hBitmap
>
> In case you are drawing into a Window (Form). If you want to do the same
> job using a printer canvas is a not a good idea since the bitmap will
> normally have a tremendous size.
>
> Regards,<<
>
> Ok, thanks. Using the above suggestion, the following works:
>
>
> hBitMapImage := XA_CaptureBitMap( GetActiveWindow() )
> oGraphBitMap := TBitMap():CreateFromHandle( hBitMapImage )
> oGraphBitMap:Save( "C:DownloadTestBitMap.bmp" )
>
>
> , but it captures the form, which includes the canvas. That's workable.
>
> But is there a way to capture only the canvas, without any of the other
> objects on the form? How do we obtain the window handle for only the
> canvas?
>
>
>
Ignacio Ortiz de Zúñiga
[OZ Software]
https://www.ozs.es
--
[Equipo de Xailer / Xailer team]
https://www.xailer.com
Responder