Rectangle as bitmap
Rectangle as bitmap
Hi.
There is a dialog box with brush. I need to select a certain rectangle on this window and save it to a file as a bitmap. How to do it ?
There is a dialog box with brush. I need to select a certain rectangle on this window and save it to a file as a bitmap. How to do it ?
- Antonio Linares
- Site Admin
- Posts: 42516
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 75 times
- Contact:
Re: Rectangle as bitmap
You may start it this way:
Next is to create and save the bitmap
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local oDlg, oGrp
DEFINE DIALOG oDlg
@ 1, 2 GROUP oGrp TO 6, 12 OF oDlg
oGrp:bRClicked = { | nRow, nCol | ShowPopup( nRow, nCol, oGrp )}
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( oGrp:lDrag := .T., oGrp:CheckDots(), .T. )
return nil
function ShowPopup( nRow, nCol, oGrp )
local oPopup
MENU oPopup POPUP
MENUITEM "Save as BMP" ACTION MsgInfo( "ok" )
ENDMENU
ACTIVATE POPUP oPopup WINDOW oGrp AT nRow, nCol
return nil
Next is to create and save the bitmap
- Antonio Linares
- Site Admin
- Posts: 42516
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 75 times
- Contact:
Re: Rectangle as bitmap
Enhanced version:
Code: Select all | Expand
#include "FiveWin.ch"
function Main()
local oDlg, oGrp, oBrush
DEFINE BRUSH oBrush FILENAME "c:\fwh\bitmaps\olga1.jpg"
DEFINE DIALOG oDlg BRUSH oBrush SIZE 380, 400
@ 1, 2 GROUP oGrp TO 6, 12 OF oDlg TRANSPARENT
oGrp:bRClicked = { | nRow, nCol | ShowPopup( nRow, nCol, oGrp )}
ACTIVATE DIALOG oDlg CENTERED ;
ON INIT ( oGrp:lDrag := .T., oGrp:CheckDots(), .T. )
return nil
function ShowPopup( nRow, nCol, oGrp )
local oPopup
MENU oPopup POPUP
MENUITEM "Save as BMP" ACTION oGrp:SaveToBmp( "test.bmp" )
ENDMENU
ACTIVATE POPUP oPopup WINDOW oGrp AT nRow, nCol
return nil
Re: Rectangle as bitmap
Thank you, Antonio ! So I can use this solution not only for Group, but also for an arbitrary-form rectangle ?
- Antonio Linares
- Site Admin
- Posts: 42516
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 75 times
- Contact:
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Rectangle as bitmap
Code: Select all | Expand
oDlg:SaveAsImage( cImageFile, aRect )
cImageFile can be .bmp, .jpg. ,png, etc.
aRect is the rectangle you want to crop and save. : { nTop, nLeft, nBottom, nRight }
This works with Window, Dialog or any Control, to crop a rectangle inside and save.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: Rectangle as bitmap
Will this scheme work if the dialog is larger than the monitor screen and, accordingly, the allocated rectangle is also larger than the monitor screen ?
- Antonio Linares
- Site Admin
- Posts: 42516
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 75 times
- Contact:
Re: Rectangle as bitmap
I am trying to create a bmp file from an Activex control that is larger than the screen. I tried SaveToBmp(), SaveAsImage(). SaveWindow() . As a result, I get a bmp file of the appropriate size, but containing only the part of the control visible on the screen,.
https://cloud.mail.ru/public/ZDY3/19fCRaLfk
What can I do wrong ?
FW 09.2006
https://cloud.mail.ru/public/ZDY3/19fCRaLfk
What can I do wrong ?
FW 09.2006
Last edited by Natter on Thu Oct 07, 2021 10:27 am, edited 1 time in total.
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Re: Rectangle as bitmap
but containing only the part of the control visible on the screen,.
Yes.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Antonio Linares
- Site Admin
- Posts: 42516
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 75 times
- Contact: