crop an Image
- Silvio.Falconi
- Posts: 7187
- Joined: Thu Oct 18, 2012 7:17 pm
- Been thanked: 9 times
crop an Image
IF I have an Image
I can crop a part of this image selecting with mouse and save this part cropped as new image ?
there is a sample ?
I can crop a part of this image selecting with mouse and save this part cropped as new image ?
there is a sample ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
- nageswaragunupudi
- Posts: 10733
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 11 times
- Contact:
Re: crop an Image
CropImage( hOriginalBmp, nTop, nLeft, nBottom , nRight ) --> hCroppedBmp
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: crop an Image
Silvio,
some month ago I used NCONVERT as a solution

It creates a image of the defined area with everything that is visible inside the selected area.
( Cropped screenshot )
I think it is possible to replace NCONVERT with
regards
Uwe
some month ago I used NCONVERT as a solution

It creates a image of the defined area with everything that is visible inside the selected area.
( Cropped screenshot )
I think it is possible to replace NCONVERT with
CropImage( hOriginalBmp, nTop, nLeft, nBottom , nRight ) --> hCroppedBmp
regards
Uwe

Last edited by ukoenig on Thu Nov 02, 2017 11:07 am, edited 3 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
i work with FW.
If you have any questions about special functions, maybe i can help.
- Silvio.Falconi
- Posts: 7187
- Joined: Thu Oct 18, 2012 7:17 pm
- Been thanked: 9 times
Re: crop an Image
nageswaragunupudi wrote:CropImage( hOriginalBmp, nTop, nLeft, nBottom , nRight ) --> hCroppedBmp
yes of cource but how I can make with mouse into an Image
How show the box and move angles with mouse ?
Last edited by Silvio.Falconi on Tue Nov 07, 2017 10:25 am, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Re: crop an Image
Silvio,
to define a area I use

move and resize
next save the selected area of a image
1. rightclick define the area jn design-mode
2. rightclick save the image
STATIC oDlg, oGroup, nClicked := 0
oDlg:bRClicked := {| nRow, nCol | nClicked++, ;
IIF( nClicked = 1, MAKE_GROUP( nRow, nCol ), ;
MAKE_IMAGE( cImgFile ) ) }
// --------------
FUNCTION MAKE_GROUP( nRow, nCol )
// ----------------------------------------------------------------------------
// first dialog-click creates a GROUP in design-mode
// second dialog-click saves the captured area
// ----------------------------------------------------------------------------
// Default
oGroup := TGroup():New( nRow, nCol, nRow + 150, nCol + 150, "", oDlg, NIL, NIL, .T. , .T. , NIL, .T. )
oGroup:l3D := .T.
// TGroup():New( nTop, nLeft, nBottom, nRight, cLabel, oWnd, nClrText,;
// nClrPane, lPixel, lDesign, oFont, lTransparent, nWidth, nHeight )
RETURN( NIL )
// -----------
FUNCTION MAKE_IMAGE( cImgFile )
oGroup:Hide()
oDlg:SaveToBmp( cImgFile ) // Screenshot of full dialogbackground
oGroup:Show()
RETURN( NIL )
regards
Uwe
How show the box and move angles with mouse ?
to define a area I use

move and resize
next save the selected area of a image
1. rightclick define the area jn design-mode
2. rightclick save the image
STATIC oDlg, oGroup, nClicked := 0
oDlg:bRClicked := {| nRow, nCol | nClicked++, ;
IIF( nClicked = 1, MAKE_GROUP( nRow, nCol ), ;
MAKE_IMAGE( cImgFile ) ) }
// --------------
FUNCTION MAKE_GROUP( nRow, nCol )
// ----------------------------------------------------------------------------
// first dialog-click creates a GROUP in design-mode
// second dialog-click saves the captured area
// ----------------------------------------------------------------------------
// Default
oGroup := TGroup():New( nRow, nCol, nRow + 150, nCol + 150, "", oDlg, NIL, NIL, .T. , .T. , NIL, .T. )
oGroup:l3D := .T.
// TGroup():New( nTop, nLeft, nBottom, nRight, cLabel, oWnd, nClrText,;
// nClrPane, lPixel, lDesign, oFont, lTransparent, nWidth, nHeight )
RETURN( NIL )
// -----------
FUNCTION MAKE_IMAGE( cImgFile )
oGroup:Hide()
oDlg:SaveToBmp( cImgFile ) // Screenshot of full dialogbackground
oGroup:Show()
RETURN( NIL )
regards
Uwe

Last edited by ukoenig on Fri Oct 13, 2017 11:29 am, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
i work with FW.
If you have any questions about special functions, maybe i can help.
- Silvio.Falconi
- Posts: 7187
- Joined: Thu Oct 18, 2012 7:17 pm
- Been thanked: 9 times
Re: crop an Image
sorry I not see anything
Last edited by Silvio.Falconi on Tue Nov 07, 2017 10:26 am, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Re: crop an Image
The captured area to be saved.
A new dialog is created from the cropped result.

There seems a adjustment needed ?
oGroup := TGroup():New( nRow, nCol, ; // nTop, nLeft
nRow + 150, ; // nBottom
nCol + 150, ; // nRight
"", ; // cLabel
oDlg, ; // oWnd
NIL, ; // nClrText
NIL, ; // nClrPane
.T. , ; // lPixel
.T. , ; // lDesign
NIL, ; // oFont
.T. ) // lTransparent

regards
Uwe
A new dialog is created from the cropped result.

There seems a adjustment needed ?
oGroup := TGroup():New( nRow, nCol, ; // nTop, nLeft
nRow + 150, ; // nBottom
nCol + 150, ; // nRight
"", ; // cLabel
oDlg, ; // oWnd
NIL, ; // nClrText
NIL, ; // nClrPane
.T. , ; // lPixel
.T. , ; // lDesign
NIL, ; // oFont
.T. ) // lTransparent

regards
Uwe

Last edited by ukoenig on Fri Oct 13, 2017 4:44 pm, edited 4 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
i work with FW.
If you have any questions about special functions, maybe i can help.
- Silvio.Falconi
- Posts: 7187
- Joined: Thu Oct 18, 2012 7:17 pm
- Been thanked: 9 times
Re: crop an Image
here not run
I have the last fwh and win10
I have the last fwh and win10
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Re: crop an Image
Silvio,
I'm using dialog background-brushes to define the area ( dialog-size adjusted to the image-size )!
NOT a image. That is the reason You don't get it working.
the full test
http://www.pflegeplus.com/DOWNLOADS/Croppimg1.zip
To get cropped images without border, I changed the dialog-result-style
DEFINE DIALOG oDlg1 FROM 0, 0 TO nHeight - 12, nWidth - 4 OF oDlg PIXEL TRUEPIXEL ;
STYLE nOr( WS_POPUP | WS_VISIBLE ) // to be used to save the image without border
You can close the result-dialog ( multiple tests )
with a right mouseclick on the main-image.

regards
Uwe
I'm using dialog background-brushes to define the area ( dialog-size adjusted to the image-size )!
NOT a image. That is the reason You don't get it working.
the full test
http://www.pflegeplus.com/DOWNLOADS/Croppimg1.zip
To get cropped images without border, I changed the dialog-result-style
DEFINE DIALOG oDlg1 FROM 0, 0 TO nHeight - 12, nWidth - 4 OF oDlg PIXEL TRUEPIXEL ;
STYLE nOr( WS_POPUP | WS_VISIBLE ) // to be used to save the image without border
You can close the result-dialog ( multiple tests )
with a right mouseclick on the main-image.

regards
Uwe

Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
i work with FW.
If you have any questions about special functions, maybe i can help.
Re: crop an Image
I just tested a solution cropping something from oversized images.
Because I want to see the full image ( NO scroll-area ),
I resized the original and saved the full size ( original ) of the cropped area.
I calculated a resize-factor in relation to the main-window-size.
I think searching inside a scroll-area of a image is not a good solution
see the result :

regards
Uwe
Because I want to see the full image ( NO scroll-area ),
I resized the original and saved the full size ( original ) of the cropped area.
I calculated a resize-factor in relation to the main-window-size.
I think searching inside a scroll-area of a image is not a good solution
see the result :

regards
Uwe

Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
i work with FW.
If you have any questions about special functions, maybe i can help.
- Silvio.Falconi
- Posts: 7187
- Joined: Thu Oct 18, 2012 7:17 pm
- Been thanked: 9 times
Re: crop an Image
Uwe,
I must create a badge
when I acquire the photo of user with webcam I must crop only the face to insert it on badge
any solution ?
I must create a badge
when I acquire the photo of user with webcam I must crop only the face to insert it on badge
any solution ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Re: crop an Image
Silvio,
it means You want to select a area of the focused dialog or windows and save it ?
I created 2 solutions :
1. selecting a area of a image
2. selecting a area / detail of a dialog or windows.
With the second solution I noticed a problem with using BringWindowToTop( oCSay:hWnd )
to show the DESIGN box on top of all other controls.

Drawing a area in design-mode
oCSay := TSAY():New( nRow, nCol, NIL, oDlg , NIL, NIL,;
NIL, NIL, .T., .T., NIL, NIL,;
150, 150, .T., .T., .T., NIL, .T. )
Is there a function to get the object-name ( oDlg ) of the focused dialog or windows ?
It must be detected because of opening the selection-box on any dialog or window with F5.
regards
Uwe
it means You want to select a area of the focused dialog or windows and save it ?
I created 2 solutions :
1. selecting a area of a image
2. selecting a area / detail of a dialog or windows.
With the second solution I noticed a problem with using BringWindowToTop( oCSay:hWnd )
to show the DESIGN box on top of all other controls.

Drawing a area in design-mode
oCSay := TSAY():New( nRow, nCol, NIL, oDlg , NIL, NIL,;
NIL, NIL, .T., .T., NIL, NIL,;
150, 150, .T., .T., .T., NIL, .T. )
Is there a function to get the object-name ( oDlg ) of the focused dialog or windows ?
It must be detected because of opening the selection-box on any dialog or window with F5.
regards
Uwe

Last edited by ukoenig on Tue Oct 31, 2017 10:17 am, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
i work with FW.
If you have any questions about special functions, maybe i can help.
- Silvio.Falconi
- Posts: 7187
- Joined: Thu Oct 18, 2012 7:17 pm
- Been thanked: 9 times
Re: crop an Image
I made a dialog

1. select the image
2. the Image is showed into big image (oImage) and on the small image ( Preview image)
3. there is a button "Crop" to cropped the image
I wish when "Crp" button is pressed show a box ( design) to cropped the image
when he image is cropped it must be show into small oImageCropped ( you see it at right od dialog on top )
How I can create this ?
I need only when I move the mouse into oImage the mouse must draw a Dotted box then it must crop the coordinates into oImageCropped
any solution ?

1. select the image
2. the Image is showed into big image (oImage) and on the small image ( Preview image)
3. there is a button "Crop" to cropped the image
I wish when "Crp" button is pressed show a box ( design) to cropped the image
when he image is cropped it must be show into small oImageCropped ( you see it at right od dialog on top )
How I can create this ?
I need only when I move the mouse into oImage the mouse must draw a Dotted box then it must crop the coordinates into oImageCropped
any solution ?
Last edited by Silvio.Falconi on Tue Nov 07, 2017 10:26 am, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
- Silvio.Falconi
- Posts: 7187
- Joined: Thu Oct 18, 2012 7:17 pm
- Been thanked: 9 times
Re: crop an Image
I made
oImage:bLButtonUp := { | x, y, z, k | RectDotted( oImage:getDc(), x, y, z, k )}
oImage:bMMoved := { | x, y, z, k | RectDotted( oImage:getDc(), x, y, z, k )}
oImage:bLClicked := { | x, y, z, k | RectDotted( oImage:getDc(), x, y, z, k )}
but it not run
oImage:bLButtonUp := { | x, y, z, k | RectDotted( oImage:getDc(), x, y, z, k )}
oImage:bMMoved := { | x, y, z, k | RectDotted( oImage:getDc(), x, y, z, k )}
oImage:bLClicked := { | x, y, z, k | RectDotted( oImage:getDc(), x, y, z, k )}
but it not run
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Re: crop an Image
Silvio,
have a look at the new relase 2.2
( just let me know about any possible improvements )
Load a image and resize if needed
Export the cropped image to another format
Full preview of a loaded image ( NO scrollarea )
The result of the cropped image is visible in full size on the left upper corner
( NOT adjusted to a fixed size )
Multiple captures are possible because of a file-counter.
Download
http://www.pflegeplus.com/DOWNLOADS/CroppImg2.zip
A sample cropping small images
The selected original is only 200 x 150 in size

Resized to 300 %
The cropped area will be saved with the same resize-factor

Are there still other working export-formats supported ?
//nExpformat := 0 "bmp"
IF cExtension = ".jpg"
nExpformat := 2
ELSEIF cExtension = ".png"
nExpformat := 13
ELSEIF cExtension = ".tiff"
nExpformat := 18
ELSEIF cExtension = ".ppm"
nExpformat := 14
ENDIF
oImage:SaveImage( c_path2 + "Full_" + ALLTRIM(STR(nFull)) + cExtension, nExpformat )
regards
Uwe
have a look at the new relase 2.2
( just let me know about any possible improvements )
Load a image and resize if needed
Export the cropped image to another format
Full preview of a loaded image ( NO scrollarea )
The result of the cropped image is visible in full size on the left upper corner
( NOT adjusted to a fixed size )
Multiple captures are possible because of a file-counter.
Download
http://www.pflegeplus.com/DOWNLOADS/CroppImg2.zip
A sample cropping small images
The selected original is only 200 x 150 in size

Resized to 300 %
The cropped area will be saved with the same resize-factor

Are there still other working export-formats supported ?
//nExpformat := 0 "bmp"
IF cExtension = ".jpg"
nExpformat := 2
ELSEIF cExtension = ".png"
nExpformat := 13
ELSEIF cExtension = ".tiff"
nExpformat := 18
ELSEIF cExtension = ".ppm"
nExpformat := 14
ENDIF
oImage:SaveImage( c_path2 + "Full_" + ALLTRIM(STR(nFull)) + cExtension, nExpformat )
regards
Uwe

Last edited by ukoenig on Tue Oct 31, 2017 10:54 am, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
i work with FW.
If you have any questions about special functions, maybe i can help.