soccer jersey forums.silverfrost.com :: View topic - Is there a need for this capability?
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Is there a need for this capability?
Goto page Previous  1, 2, 3, 4, 5  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2593
Location: Sydney

PostPosted: Thu Mar 25, 2021 3:00 am    Post subject: Reply with quote

My approach is a "DUMP" menu option which dumps a .png file of the active window using export_image@ (file_png), where file_png is an automatically generated file name with an optional extension of .png, .jpg, .pcx, .gif or .bmp.
(check the latest documentation for export_image@)

I do find that .png is the best option and is what I always select.

"automatic" name generation can be a problem, as you can forget what file name refers to what image, which Bill did indicate he has better addressed.
Back to top
View user's profile Send private message
wahorger



Joined: 13 Oct 2014
Posts: 1227
Location: Morrison, CO, USA

PostPosted: Thu Mar 25, 2021 4:32 pm    Post subject: Reply with quote

Dan, what I did is exactly what you describe, but I assigned a function key to the callback. And, yes, currently for a non=%gr window, you have to emulate the Alt+PrntScrn key sequence (with delays), then can save only as BMP or PCX. Paul has said that PNG will be added at the next release.

John, from the documentation, the export_image@() is useful only for graphics windows (%gr) which I am not using. Therefore PNG etc. are not available to be saved. I did try the export_image@() call in my code (JIC), but nothing was saved and there was no error message or fault detected.

Here's a stripped down version of how I have the Alt+PrntScrn working.

Code:

        call keybd_event(VK_MENU,       z'45', KEYEVENTF_EXTENDEDKEY,                   0)!; //Alt Press
        call keybd_event(VK_SNAPSHOT,   z'45', KEYEVENTF_EXTENDEDKEY,                   0)!; //PrntScrn Press


        call keybd_event(VK_SNAPSHOT,   z'45', KEYEVENTF_KEYUP+KEYEVENTF_EXTENDEDKEY,   0)!; //PrntScrn Release
        call keybd_event(VK_MENU,       z'45', KEYEVENTF_KEYUP+KEYEVENTF_EXTENDEDKEY,   0)!; //Alt Release

        call set_cursor_waiting@(1)
        call sleep1@(2.0) ! sleep long enough to allow the image to be grabbed from the open window
        call set_cursor_waiting@(0)

        my_error=sizeof_clipboard_bitmap@(actual_width,actual_height) ! will detect if the capture actually did work
        if(my_error.ne.0) then ! the capture worked
                if(clipboard_to_screen_block@(hdib).ne.0) then ! this does the grab into local memory
                        call export_bmp@(hdib,NEW_FILENAME,my_error)
                        call release_screen_dib@(hdib) ! release the memory  clipboard_to_screen_block@()
                endif
        endif
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8036
Location: Salford, UK

PostPosted: Thu Mar 25, 2021 7:36 pm    Post subject: Reply with quote

Bill

Can you remind me about what is missing.
Back to top
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 1227
Location: Morrison, CO, USA

PostPosted: Thu Mar 25, 2021 8:13 pm    Post subject: Reply with quote

Paul,

I believe export_png@() and export_JPG@() using the arguments for HDIB, file name, and error code would be most helpful to round out the capability.

Bill
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8036
Location: Salford, UK

PostPosted: Fri Mar 26, 2021 8:29 am    Post subject: Reply with quote

Thanks. I have made a note of this request.
Back to top
View user's profile Send private message AIM Address
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8036
Location: Salford, UK

PostPosted: Mon Mar 29, 2021 3:05 pm    Post subject: Reply with quote

Bill

Here is a sample of what you can do at the moment. Can you post a similar program that illustrates what you want.

Code:
 WINAPP
 USE clrwin
 INTEGER hres,vres,nbbp,ercode,hdib,ctrl,i
 CHARACTER(*),PARAMETER :: file = "guest.bmp"
 CALL get_dib_size@(file,hres,vres,nbbp,ercode)
 IF(ercode /= 0)THEN; i = winio@('get_dib_size@ error'); STOP; ENDIF 
 hdib = import_bmp@(file,ercode)
 IF(ercode /= 0)THEN; i = winio@('import_bmp@ error'); STOP; ENDIF 
 i = winio@('%gr[rgb_colours]%lw',hres,vres,ctrl)
 ercode = dib_paint@(0,0,hdib,0,0)
 IF(ercode == 0)THEN; i = winio@('dib_paint@ error'); STOP; ENDIF 
 call draw_line_between@(0,0,hres,vres,RGB@(255,0,0))
 i = export_image@("guest1.png")
 IF(ercode == 0) i = winio@('export_image@ error')
 CALL release_screen_dib@(hdib)
 END
Back to top
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 1227
Location: Morrison, CO, USA

PostPosted: Tue Mar 30, 2021 11:50 pm    Post subject: Reply with quote

Paul,

I see what you have done by creating a window into which the image from a file is written,. then modified, and written to a PNG.

While I have not tried it, I would imagine that this technique would work with the clipboard image. I would also imagine that I could create the window as invisible to prevent the "flash" of the image to the user.

I will give this a try. I look at this as a stop-gap method, and your description of this in your code is much appreciated!

Thanks, Paul,
Bill
Back to top
View user's profile Send private message Visit poster's website
wahorger



Joined: 13 Oct 2014
Posts: 1227
Location: Morrison, CO, USA

PostPosted: Wed Mar 31, 2021 12:08 am    Post subject: Reply with quote

This does work well with the clipboard image. I did have to add a %ww[invisible] to prevent the "flash" of the graphics area to the user.

Thanks, Paul, for helping me better understand these capabilities, and an alternate way to get the job done!

Bill
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8036
Location: Salford, UK

PostPosted: Wed Mar 31, 2021 7:32 am    Post subject: Reply with quote

Bill

My purpose in posting the program was to ask you to modify it and post it back in a the form that you would like it to work. It wasn't clear to me what you were asking for. You can make up and write in the name of a new ClearWin+ routine if that is what is needed.
Back to top
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 1227
Location: Morrison, CO, USA

PostPosted: Wed Mar 31, 2021 3:15 pm    Post subject: Reply with quote

This would be how I would like to see it work with the simulated keystrokes and clipboard being used for the image source:

Code:

        call keybd_event(VK_MENU,       z'45', KEYEVENTF_EXTENDEDKEY, 0)!; //Alt Press
        call keybd_event(VK_SNAPSHOT,z'45', KEYEVENTF_EXTENDEDKEY, 0)!; //PrntScrn Press
        call keybd_event(VK_SNAPSHOT,z'45', KEYEVENTF_KEYUP+KEYEVENTF_EXTENDEDKEY,   0)!; //PrntScrn Release
        call keybd_event(VK_MENU,       z'45', KEYEVENTF_KEYUP+KEYEVENTF_EXTENDEDKEY,   0)!; //Alt Release

        call set_cursor_waiting@(1)
        call sleep1@(2.0) ! sleep long enough to allow the image to be grabbed from the open window
        call set_cursor_waiting@(0)

        my_error=sizeof_clipboard_bitmap@(actual_width,actual_height) ! will detect if the capture actually did work
        if(my_error.ne.0) then ! the capture worked
                if(clipboard_to_screen_block@(hdib).ne.0) then ! this does the grab into local memory
                        call export_png@(hdib,NEW_FILENAME,my_error) ! **** this is the routine that I would like to see ****
                        call release_screen_dib@(hdib) ! release the memory
                endif
        endif
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8036
Location: Salford, UK

PostPosted: Wed Mar 31, 2021 4:36 pm    Post subject: Reply with quote

Bill

Here is a way to do it with the existing routines...

Code:
        use clrwin
        integer, parameter::grhandle = 42
        integer(7) hdib
        integer actual_width,actual_height,my_error
        my_error=sizeof_clipboard_bitmap@(actual_width,actual_height)
        if(my_error.ne.0) then
           if(clipboard_to_screen_block@(hdib).ne.0) then
              my_error = create_graphics_region@(grhandle, actual_width,actual_height)
              my_error = dib_paint@(0,0,hdib,0,0)
              my_error = export_image@("image.png")
              my_error = delete_graphics_region@(grhandle)
              call release_screen_dib@(hdib)
           endif
        endif
        end
Back to top
View user's profile Send private message AIM Address
wahorger



Joined: 13 Oct 2014
Posts: 1227
Location: Morrison, CO, USA

PostPosted: Wed Mar 31, 2021 4:45 pm    Post subject: Reply with quote

Awesome! I'll give this a try today.

I would have not come up with this on my own; thank you for taking the time! I also hope it saves you additional work; I perceive you are busy enough as it is.

Thanks!
Bill
Back to top
View user's profile Send private message Visit poster's website
wahorger



Joined: 13 Oct 2014
Posts: 1227
Location: Morrison, CO, USA

PostPosted: Wed Mar 31, 2021 5:02 pm    Post subject: Reply with quote

P.S. Is the grhandle=42 a literary reference?
Back to top
View user's profile Send private message Visit poster's website
DanRRight



Joined: 10 Mar 2008
Posts: 2876
Location: South Pole, Antarctica

PostPosted: Wed Mar 31, 2021 6:38 pm    Post subject: Reply with quote

Paul,
Can you for simplicity create separate function
copy_entire_graphics_screen_to_clipboard@ or i miss something and it exists already?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8036
Location: Salford, UK

PostPosted: Wed Mar 31, 2021 7:19 pm    Post subject: Reply with quote

Dan

There is no such routine at the moment.

It would be possible to put Bill's method into a ClearWin+ routine but it is generally not good practice to highjack the user's clipboard. It would be necessary to copy the clipboard and restore it after use.

It appears that screen capture can be done directly in other contexts but not in C and the Windows API which is what ClearWin+ uses.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Goto page Previous  1, 2, 3, 4, 5  Next
Page 2 of 5

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group