Cut out an area of the screen

Natter
Posts: 1241
Joined: Mon May 14, 2007 9:49 am

Cut out an area of the screen

Post by Natter »

How can I cut out an area of the screen and save it as a picture in the clipboard ?
User avatar
Silvio.Falconi
Posts: 7140
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: Cut out an area of the screen

Post by Silvio.Falconi »

the new Class xImage make this
viewtopic.php?f=3&t=36222&start=0
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
Natter
Posts: 1241
Joined: Mon May 14, 2007 9:49 am

Re: Cut out an area of the screen

Post by Natter »

Very nice, but I need to use bitblt()
User avatar
Silvio.Falconi
Posts: 7140
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: Cut out an area of the screen

Post by Silvio.Falconi »

why ?
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: 7140
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: Cut out an area of the screen

Post by Silvio.Falconi »

I made a TcropImage class and I use bitblt()
https://github.com/silviofalconi/TCropImage
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
rhlawek
Posts: 194
Joined: Sun Jul 22, 2012 7:01 pm

Re: Cut out an area of the screen

Post by rhlawek »

Do you mean taking the screen shot of an screen area within a FWH application itself, or just within a windows desktop in general? If the latter from Windows 7 on Windows has included a utility named Snipping Tool that works reasonably well. It has existed in Windows 10 for a while but it looks like Microsoft is moving the functionality to a tool they have named Snip & Sketch (which I just learned now when I started the Snipping Tool).
Natter
Posts: 1241
Joined: Mon May 14, 2007 9:49 am

Re: Cut out an area of the screen

Post by Natter »

Yes, I mean a screenshot of a part of the screen. I get his device context GetDc() and convert to bitmap (don't remember how to do it)
User avatar
Silvio.Falconi
Posts: 7140
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: Cut out an area of the screen

Post by Silvio.Falconi »

can you use HB_CROPPED I use in that class
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
Natter
Posts: 1241
Joined: Mon May 14, 2007 9:49 am

Re: Cut out an area of the screen

Post by Natter »

can you use HB_CROPPED I use in that class


it's like ? Can example
User avatar
Silvio.Falconi
Posts: 7140
Joined: Thu Oct 18, 2012 7:17 pm
Been thanked: 1 time

Re: Cut out an area of the screen

Post by Silvio.Falconi »

see the class I post


Code: Select all | Expand

Function  CutImage(nBoxTop,nBoxLeft,nBoxBottom,nBoxRight)
   local nType:= 2 //jpg
   Local cNameFileCropped:="cropped.jpg"
   Local nWBmp,nHBmp

    oImageCropped:hBitmap:=  CropImage( oImage:hBitmap,nBoxTop,nBoxLeft, nBoxBottom, nBoxRight)
    oImageCropped:SaveImage( cNameFileCropped, nType)
    oImageCropped:LoadBmp( cNameFileCropped )

        nWBmp   := alltrim(str(nBmpWidth( oImageCropped:hBitmap )))
        nHBmp   := alltrim(str(nBmpHeight( oImageCropped:hBitmap ) ))


        oGroupCropped:setText("Image Cropped : Dim. "+nWBmp+"X"+nHBmp )
        oGroupCropped:refresh()




return nil
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
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: Cut out an area of the screen

Post by nageswaragunupudi »

Natter wrote:How can I cut out an area of the screen and save it as a picture in the clipboard ?


Code: Select all | Expand

  hBmp  := FWSaveScreen( GetDesktopWindow(), nTop, nLeft, nBottom, nRight )
   DEFINE CLIPBOARD oClp FORMAT BITMAP OF oWnd
   oClp:Open()
   oClp:SetBitmap( hBmp )
   oClp:Close()
 
Regards

G. N. Rao.
Hyderabad, India
Natter
Posts: 1241
Joined: Mon May 14, 2007 9:49 am

Re: Cut out an area of the screen

Post by Natter »

Thank you, Mr. Rao.
Is it possible to insert the cut fragment at the specified position of the screen ?
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: Cut out an area of the screen

Post by nageswaragunupudi »

Natter wrote:Thank you, Mr. Rao.
Is it possible to insert the cut fragment at the specified position of the screen ?

Do you want to replace the desktop wallpaper?
Looks more like an academic question than of any practical application in software.

May I know what exactly you want to achieve?

It is possible to capture the entire desktop (as it appears) as a bitmap, copy a specified portion and paste it another location of the same bitmap and generate a new bitmap. Then if you like, you can replace the desktop wallpaper.
But, there is a catch. When you capture the desktop or any part of it, you also get the icons visible at that time.
Regards

G. N. Rao.
Hyderabad, India
Natter
Posts: 1241
Joined: Mon May 14, 2007 9:49 am

Re: Cut out an area of the screen

Post by Natter »

I drew something on the window - a line, a polygon, etc.. Then I want to erase the painting.
User avatar
nageswaragunupudi
Posts: 10721
Joined: Sun Nov 19, 2006 5:22 am
Location: India
Been thanked: 8 times
Contact:

Re: Cut out an area of the screen

Post by nageswaragunupudi »

Natter wrote:I drew something on the window - a line, a polygon, etc.. Then I want to erase the painting.

So, you are not talking about the desktop, but FWH application window.
If you let us see your code how are you drawing and displaying the line, polygon, etc, then we can help you how to clear the screen also.
Regards

G. N. Rao.
Hyderabad, India
Post Reply