crop an Image

crop an Image

Postby Silvio.Falconi » Tue Oct 10, 2017 12:22 pm

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 ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7088
Joined: Thu Oct 18, 2012 7:17 pm

Re: crop an Image

Postby nageswaragunupudi » Tue Oct 10, 2017 5:42 pm

CropImage( hOriginalBmp, nTop, nLeft, nBottom , nRight ) --> hCroppedBmp
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10681
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: crop an Image

Postby ukoenig » Tue Oct 10, 2017 7:14 pm

Silvio,

some month ago I used NCONVERT as a solution

Image

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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: crop an Image

Postby Silvio.Falconi » Wed Oct 11, 2017 10:27 am

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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7088
Joined: Thu Oct 18, 2012 7:17 pm

Re: crop an Image

Postby ukoenig » Wed Oct 11, 2017 3:15 pm

Silvio,

How show the box and move angles with mouse ?


to define a area I use

Image

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 :D
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: crop an Image

Postby Silvio.Falconi » Wed Oct 11, 2017 6:50 pm

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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7088
Joined: Thu Oct 18, 2012 7:17 pm

Re: crop an Image

Postby ukoenig » Fri Oct 13, 2017 11:31 am

The captured area to be saved.

A new dialog is created from the cropped result.

Image

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

Image

regards
Uwe :D
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: crop an Image

Postby Silvio.Falconi » Fri Oct 13, 2017 11:34 am

here not run
I have the last fwh and win10
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7088
Joined: Thu Oct 18, 2012 7:17 pm

Re: crop an Image

Postby ukoenig » Fri Oct 13, 2017 11:50 am

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.

Image

regards
Uwe :D
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: crop an Image

Postby ukoenig » Sat Oct 14, 2017 9:59 am

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 :

Image

regards
Uwe :D
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: crop an Image

Postby Silvio.Falconi » Sat Oct 14, 2017 10:18 am

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 ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7088
Joined: Thu Oct 18, 2012 7:17 pm

Re: crop an Image

Postby ukoenig » Mon Oct 30, 2017 2:24 pm

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.

Image

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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: crop an Image

Postby Silvio.Falconi » Mon Oct 30, 2017 5:28 pm

I made a dialog

Image

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 November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7088
Joined: Thu Oct 18, 2012 7:17 pm

Re: crop an Image

Postby Silvio.Falconi » Tue Oct 31, 2017 8:52 am

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
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 7088
Joined: Thu Oct 18, 2012 7:17 pm

Re: crop an Image

Postby ukoenig » Tue Oct 31, 2017 9:57 am

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

Image

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

Image

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 :D
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 22 guests