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 

New %pl and export to jpg, gif, etc

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
silicondale



Joined: 15 Mar 2007
Posts: 174
Location: Matlock, Derbyshire

PostPosted: Sat Oct 14, 2017 10:53 am    Post subject: New %pl and export to jpg, gif, etc Reply with quote

I have been using %gr with recover_dib_block@ / put_dib_block@ to copy the graphics window to a jpeg file, and write_graphics_to_gif@ to write to a gif file.

I tried the same thing with %pl (both Simpleplot and native versions) but of course this doesn't work.

Can anyone advise how to write a %pl graphics window to jpeg or gif (or any other graphics file format for that matter)? I know I could use standard screen-grab programs to do the job but that is messy.

Would be good to have some general way of writing the contents of ANY graphic or text window to a graphics file. Perhaps it already exists but I've overlooked it?
Back to top
View user's profile Send private message Visit poster's website
JohnCampbell



Joined: 16 Feb 2006
Posts: 1810
Location: Sydney

PostPosted: Sat Oct 14, 2017 12:13 pm    Post subject: Reply with quote

I would recommend to use a .png format, rather than .gif, as the colour palette that is reproduced is much better.
The following code works for me for a %gr region, where the approach is for the "active selected region". This may be applied to the %pl region via i = select_graphics_object@ (w_handle), where w_handle is an I*4 handle provided to %gr. There may be an equivalent to %pl ?
Code:
    Subroutine Dump_jpg_func (message, prefix, ext)
!
!  dumps a .jpg, .png or .pcx file from active selected region
!
!    use mswin
    include <clearwin.ins>
!
    character message*(*), prefix*(*), ext*4
!
    integer*4 error_jpg, file_nn, nx, ny
    character file_jpg*80
    data file_nn / 0 /
!
!    develop a screen dump file name
!
      call get_next_dump_file (file_nn, file_jpg, prefix, ext)
       if (file_nn > 999) then
         error_jpg = -999
         goto 100
       end if
      write (*,*) 'Dumping screen to ',trim (file_jpg)
!
      error_jpg = export_image@ (file_jpg)
!
  100 call get_graphical_resolution@ ( nx, ny )
!
      write ( *,1000) ext, trim(file_jpg), nx, ny, error_jpg
      write (98,1000) ext, trim(file_jpg), nx, ny, error_jpg
 1000 format (a,' DUMP file ',a,  &
              ' Size : ',i0,' x ',i0,' (error=',i0,')')
!
      if (error_jpg > 0) then
         message = ext//' dump to '//file_jpg
      else if (error_jpg == -999) then
         message = 'Unable to open '//file_jpg
      else
         message = 'Unable to use '//file_jpg
      end if
!
      end subroutine Dump_jpg_func
 
      subroutine get_next_dump_file (file_nn, file_name, prefix, ext)
!
!    develop a screen dump file name
!
    integer*4 file_nn
    character file_name*(*), prefix*(*), ext*4
    integer*4 lu, get_file_unit
    external  get_file_unit
!
      lu = get_file_unit (90)
      close (unit=lu)
!
   11 file_nn = file_nn + 1
      if (file_nn > 999) return
!
      if (len_trim (prefix) > 0) then
         write (file_name, '(a,i3.3,a)') trim(prefix) // 'dump', file_nn, ext
      else
         write (file_name, '(a,i3.3,a)') 'dump', file_nn, ext
      end if
      open  (unit=lu, file=file_name, status='new', err=11)
      close (unit=lu, status='delete')
      end subroutine get_next_dump_file
Back to top
View user's profile Send private message
silicondale



Joined: 15 Mar 2007
Posts: 174
Location: Matlock, Derbyshire

PostPosted: Sat Oct 14, 2017 3:00 pm    Post subject: Reply with quote

Thanks for the quick reply, John. The only reason for GIF as an option is user demand. I also prefer PNG. I'll try out that code, but as you say it's probably dependent on being able to get a handle for the %pl graphics region
Back to top
View user's profile Send private message Visit poster's website
Kenneth_Smith



Joined: 18 May 2012
Posts: 148
Location: Glasgow, Scotland.

PostPosted: Sat Oct 14, 2017 4:26 pm    Post subject: Reply with quote

This should work as John has suggested.

Hidden at the bottom of the %pl help file (Paul had to point me to this):-

%`PL provides for a user indentifier for the %PL control that can be used in a call to SELECT_GRAPHIC_OBJECT@ but this call is not needed within a %^PL callback because the corresponding object will already be selected.

I have been able to dump %pl graphics simply using the call back function when the user right clicks on the %pl region.
Back to top
View user's profile Send private message Visit poster's website
silicondale



Joined: 15 Mar 2007
Posts: 174
Location: Matlock, Derbyshire

PostPosted: Sat Oct 14, 2017 7:17 pm    Post subject: Reply with quote

Magic! Inserted the code into my program and it worked a treat. I had been hitting my head against a brick wall with the DIB_BLOCK calls giving access violations. Many thanks, John.

Ken - yes, I saw that bit about %`pl but couldn't find any other documentation for it. So I put it in my %pl call and added an 'ighandle' argument at the end of the argument list - it didn't seem to object to that.

Now I just have to join the rest of you tackling the bugs in the native %pl.
Smile Wink
Back to top
View user's profile Send private message Visit poster's website
John-Silver



Joined: 30 Jul 2013
Posts: 603

PostPosted: Sun Oct 15, 2017 6:00 am    Post subject: Reply with quote

the 'export_inýmahge@' method finely demonstrated above by John C is fine for %gr ░(type) graphic regions but what about the general case

silicondale originally said:-
Quote:
Would be good to have some general way of writing the contents of ANY graphic or text window to a graphics file. Perhaps it already exists but I've overlooked it?
e

What about the general case of say for example a window containing several child windows ahich may contain (for example) some calculations in one, some messages in another, maybe 2 or more different %gr type windows ?

Will the %gr export_image@ method also work for any window if the window has the focus ?, and if so what will be the output - everythining or just things written directly to the main window (i.e. nothing in the child windows if they exist) ?

Ideally there should be a command of the type:-

export_image@(window_handle, op_options, image_op_filename)

where 'op_options' is/are an option(s) for how much info is included in the generated image
e.g.
-everything (including all child windows)content
-everything but no menus/controls
-only textual content
-only graphics windows content (all graphics of all child windows)
-only graphics windows content (all graphics + textual content child windows)
- or maybe a list of all the windows/sub-windows handles to be output in the image

... that's just a few ideas but I'm sure everyone could come up with their own list.

And of course similar for printing !!!!!!

The current 'methods' of course have generality in their favour but require a lot of development and user-programmed coding which is maybe prohibitive for the usual 'casual' user.
Back to top
View user's profile Send private message
silicondale



Joined: 15 Mar 2007
Posts: 174
Location: Matlock, Derbyshire

PostPosted: Sun Oct 15, 2017 8:22 am    Post subject: Reply with quote

Hi John-S

I can see the problems in producing a completely general 'export image' functionality, as you've pointed out! However, a simple-minded approach would be to export everything which is currently visible within the window, i.e. including any %gr-style child windows, text content, controls. Menus (in the menu bar at the top of the window) aren't generally going to be visible within the window if not being used at the time.

There is also the case of scrolling - anything that is scrolled out of view probably should not be exported - because it wouldn't fit within the window area! Of course for a Clearwin text window (such as the Fortran standard output stream) this can be done easily using get_clearwin_text@

So what I suggest is basically a "snapshot" capture of everything tat the user sees in the window, and nothing else.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
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