soccer jersey forums.silverfrost.com :: View topic - New %pl and export to jpg, gif, etc
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
Goto page 1, 2  Next
 
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: 252
Location: Matlock, Derbyshire, UK

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: 2593
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: 252
Location: Matlock, Derbyshire, UK

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: 726
Location: Hamilton, Lanarkshire, 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: 252
Location: Matlock, Derbyshire, UK

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
silicondale



Joined: 15 Mar 2007
Posts: 252
Location: Matlock, Derbyshire, UK

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
JohnCampbell



Joined: 16 Feb 2006
Posts: 2593
Location: Sydney

PostPosted: Wed Dec 20, 2017 8:33 am    Post subject: Reply with quote

My screen dump code has stopped working at Ver 8.20 /64.
Reverting to 8.10 /64 and it all works ok.

After calling Subroutine Dump_jpg_func, the .png file is successfully created (error_jpg = 1), then the screen is updated with the message, then the program hangs. Lots of scope for where the problem could be, but I suspect :
error_jpg = export_image@ (file_jpg)

Any ideas ?

John
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Dec 20, 2017 12:19 pm    Post subject: Reply with quote

John

I you can send me a demo then I will aim to identify the problem.
Back to top
View user's profile Send private message AIM Address
JohnCampbell



Joined: 16 Feb 2006
Posts: 2593
Location: Sydney

PostPosted: Fri Dec 22, 2017 10:14 am    Post subject: Reply with quote

Hi Paul,

I tried the program the next day (after restarting pc) and it worked ok !!
Clearly there was something that hung up the main menu thread, but it may have not been dumping a .png file dump.
At the moment it is not reproducible so I will keep more details if it happens again.

John
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2593
Location: Sydney

PostPosted: Sat Jan 13, 2018 12:31 pm    Post subject: Reply with quote

I am still getting this intermittent error, but not every time.
Using /64 version, after I select to dump the %gr region to .png file,
the return is error code = 1, then I report this to my .log file and control sort of returns to the %mn menu,
I can click on the menu or sub menus, but nothing works.
Other times all is ok, so not sure what is causing the hang.
I have not been changing this large program lately, so will take some time to get up to speed on what is happening.
Most of my interrupt functions return =1, although I notice there are =2 being discussed. Should I review this ?

John
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sat Jan 13, 2018 2:36 pm    Post subject: Reply with quote

John

Callback functions should normally return 2 unless you want the screen to update because of changes made within the callback. For an screen update return 1.

If you have a program that occasionally fails and you are able to make it available for testing then I could try it and maybe take a look to see if there is something that could be going wrong.
Back to top
View user's profile Send private message AIM Address
JohnCampbell



Joined: 16 Feb 2006
Posts: 2593
Location: Sydney

PostPosted: Sun Jan 14, 2018 6:24 am    Post subject: Reply with quote

Paul,

I shall review the interrupt functions that return to the menu and check their return values. (Are return values described in ftn95.chm ?)

Then if I can get a version that can repeat the failure then I will package up and send. There are about 250 .f90 file in the build, but hopefully the problem is limited to the .png file dumping and menu management (only a few) files.
It looks as if control is not being properly returned to the menu (thread?).
If the problem could be outside the .png routines, possibly in the image generation then I think I've found another breakout of Dan's devilry.

John
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Sun Jan 14, 2018 9:16 am    Post subject: Reply with quote

ftn95.chm>Clearwin+>Format Windows>Callback functions.
Back to top
View user's profile Send private message AIM Address
JohnCampbell



Joined: 16 Feb 2006
Posts: 2593
Location: Sydney

PostPosted: Fri Jan 26, 2018 12:26 pm    Post subject: Reply with quote

I have made a first pass at generating a simple test program, with %gr window and a few %mn options.
Runs no problems in Ver 8.20 !!
Not a simple error with export_image@

I need to make it more complex example or identify my program bug.
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2593
Location: Sydney

PostPosted: Wed Jan 31, 2018 1:56 am    Post subject: Reply with quote

Paul,

I have checked the compile options I am using. I have a mix of:
/64
/window /64
/window /64 /inhibit_check 16

The start of the build .bat is:
Code:
rem build
del *.obj
del *.mod
del saplot.exe
 
build_stamp

rem  menu routines

ftn95 ceasap_module        /64 >>ftn95.tce
ftn95 saplot       /window /64 /inhibit_check 16 >>ftn95.tce
ftn95 saplot_menu  /window /64 /inhibit_check 16 >>ftn95.tce
ftn95  open        /window /64 >>ftn95.tce
ftn95  range       /window /64 >>ftn95.tce
ftn95  input       /window /64 >>ftn95.tce
ftn95  view        /window /64 >>ftn95.tce
ftn95  rotate      /window /64 >>ftn95.tce
ftn95  dummy       /window /64 >>ftn95.tce
 
rem  input routines

ftn95 sapinput             /64 >>ftn95.tce
ftn95  joints              /64 >>ftn95.tce
ftn95  read_joints         /64 >>ftn95.tce
...
ftn95 dump             /windows /64 >>%tce%
...


My question is:
When do I need to use the /window option ?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
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