Page 1 of 2

Cut out an area of the screen

Posted: Tue Apr 16, 2019 12:49 pm
by Natter
How can I cut out an area of the screen and save it as a picture in the clipboard ?

Re: Cut out an area of the screen

Posted: Tue Apr 16, 2019 1:42 pm
by Silvio.Falconi

Re: Cut out an area of the screen

Posted: Tue Apr 16, 2019 2:02 pm
by Natter
Very nice, but I need to use bitblt()

Re: Cut out an area of the screen

Posted: Tue Apr 16, 2019 2:04 pm
by Silvio.Falconi
why ?

Re: Cut out an area of the screen

Posted: Tue Apr 16, 2019 2:06 pm
by Silvio.Falconi
I made a TcropImage class and I use bitblt()
https://github.com/silviofalconi/TCropImage

Re: Cut out an area of the screen

Posted: Wed Apr 17, 2019 2:02 am
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).

Re: Cut out an area of the screen

Posted: Wed Apr 17, 2019 5:27 am
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)

Re: Cut out an area of the screen

Posted: Wed Apr 17, 2019 7:06 am
by Silvio.Falconi
can you use HB_CROPPED I use in that class

Re: Cut out an area of the screen

Posted: Wed Apr 17, 2019 1:25 pm
by Natter
can you use HB_CROPPED I use in that class
it's like ? Can example

Re: Cut out an area of the screen

Posted: Wed Apr 17, 2019 1:32 pm
by Silvio.Falconi
see the class I post

Code: Select all

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

Re: Cut out an area of the screen

Posted: Fri Apr 19, 2019 9:17 pm
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

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

Re: Cut out an area of the screen

Posted: Sat Apr 20, 2019 5:51 am
by Natter
Thank you, Mr. Rao.
Is it possible to insert the cut fragment at the specified position of the screen ?

Re: Cut out an area of the screen

Posted: Sat Apr 20, 2019 6:11 am
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.

Re: Cut out an area of the screen

Posted: Sat Apr 20, 2019 6:50 am
by Natter
I drew something on the window - a line, a polygon, etc.. Then I want to erase the painting.

Re: Cut out an area of the screen

Posted: Sat Apr 20, 2019 6:56 am
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.