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 

Export image of %pl or %dw

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
cluosh



Joined: 15 Mar 2013
Posts: 20

PostPosted: Tue Jun 17, 2014 10:19 am    Post subject: Export image of %pl or %dw Reply with quote

Greetings,

I have an application using Simpleplot and would like to export the plots preferably as PNG, or any other format, whatever is possible. I tried using create_graphics_region@/select_graphics_object@ in combination with export_image@, but I couldn't get any useful results.
Is it even possible to export from Simpeplot, and if so, how?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Tue Jun 17, 2014 12:17 pm    Post subject: Reply with quote

create_graphics_region@ and select_graphics_object@ relate to %gr only.

If you only need to do this a few times for your own use then just use the Print Screen key on the keyboard and paste in Microsoft Paint.
Back to top
View user's profile Send private message AIM Address
cluosh



Joined: 15 Mar 2013
Posts: 20

PostPosted: Tue Jun 17, 2014 1:00 pm    Post subject: Reply with quote

Unfortunately I'd need an automated way of exporting the plot. So you say it's not possible?
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Tue Jun 17, 2014 3:42 pm    Post subject: Reply with quote

I cannot think of a way to do this. Maybe you should try using %gr instead of %pl.

There will be lots of alternatives and perhaps others can advise.
Back to top
View user's profile Send private message AIM Address
aebolzan



Joined: 06 Jul 2007
Posts: 229
Location: La Plata, Argentina

PostPosted: Tue Jun 17, 2014 5:01 pm    Post subject: Reply with quote

You have two options using the Simpleplot subroutine DEVNAM (=device name):

a) if you like to use %pl, use it but with [user_drawn] option and Simpleplot_redraw@ subroutine
Code:
Program simple5
use mswin
      INTEGER winio@,i,StartCB
      EXTERNAL StartCB
      i=winio@('%sy[no_border]%ca[User drawn]&')
      i=winio@('%pl[user_drawn]&',800,800)
      i=winio@('%sc',StartCB)
      END
!--The start-up callback
      INTEGER FUNCTION StartCB()
      use mswin
      INTEGER N,i
      PARAMETER(N=101)
      REAL x(N),y(N)
!--Create the data.
      DO i=1,N
        x(i)=i-1
        y(i)=x(i)**2
      ENDDO
!--Call SIMPLEPLOT routines to plot the graph.
call devnam("windows_metafile")!shows in screen and creates a wmf file
call picpos(4.0,5.0) ! locate the graph in the page so that everything enters
CALL TITLE7('centre','Centre','Sample for Dan')
CALL SCALES(0.0,10.0,1,0.0,100.0,1)
call thckmg('LINE',1.0) !thickness of lines
CALL NEWPIC
CALL TITLE7('t','Centre','Sample')
call textmg(1.5)     !size of the text
call axsbtk('XC','I') !ticks inside for x axis
call axsbtk('YC','O') ! ticks outside for y axis
CALL AXLBJS('**', 'Centre') ! labels centred
call chset(8) ! character set
call cvtype(ctype) ! curve type
call thckmg('LINE',3.0) !thickness of lines
call pen(4) !pen colour
CALL AXIS7('XCartesian','x-axis')
CALL AXIS7('YCartesian',' ')
CALL AXLOCN('YCartesian', 'Following') ! locate a new y axis on right
call  axlban('yc','O') ! tick labels towards the outside
call axsbtk('yc','O') !ticks outside for y axis on the right
!call axclr('yc',1)! only axis is drawn without ticks if you prefer
CALL AXIS7('YCartesian','y-axis')
call axis7('YC',' ') ! draw the new y axis without title                     
CALL AXLOCN('XCartesian', 'Following') !locate a new x axis on top
call  axlban('xc','N') ! no tick labels                 
call axsbtk('xc','I') ! ticks inside
call axis7('XC','   ') ! no axis label                                                                                             
call thckmg('L',1.0) !line thickness = 1
call pen(2)!  colour red
CALL BRKNCV(x,y,N,-1)
CALL SIMPLEPLOT_REDRAW@
      StartCB=1
      END


2) or use Simpleplot routines directly
Code:
program Simpleplot_plots
!requires simpleplot.dll
implicit none
real*4,dimension(70) ::xarr,yarr
integer*4 :: narr,ltype,xscale,yscale
integer*4 :: ctype,i,ans
character(8) :: xlabel="x",ylabel="y"
real*4 :: minx,maxx,miny,maxy
narr=0
do i=1,70
  xarr(i)=2*i
  yarr(i)=i*i
  narr=narr+1
end do
!call devnam("window") !screen only
!call devnam("windows_printer")! prints directly to the default printer
!call devnam("windows_metafile")!shows in screen and creates a wmf file
call textmg(1.5)
call axsbtk('XC','I')
call axsbtk('YC','O')
call thckmg('L',2.0)
CALL AXLBJS('**', 'Centre')
minx=minval(xarr)
maxx=maxval(xarr)
miny=minval(yarr)
maxy=maxval(yarr)
xscale=1;yscale=1
CALL SCALES(minx,maxx,xscale,miny,maxy,yscale)
call axcrss('YC',minx)
call pen(2)
ltype=0
ctype=3
call chset(ans)
call cvtype(ctype)
CALL AXES7(xlabel, ylabel)
call pen(1)
call title7("t","c","A Simple......Plot")
call pen(4)
CALL BRKNCV(real(xarr,1),real(yarr,1),narr,ltype)
call endplt
end program simpleplot_plots


Hope this helps,
Back to top
View user's profile Send private message
cluosh



Joined: 15 Mar 2013
Posts: 20

PostPosted: Wed Jun 18, 2014 12:48 am    Post subject: Reply with quote

Thank you very much aebolzan, this seems to be exactly what I'm looking for. I'll try it out.
Back to top
View user's profile Send private message
jalih



Joined: 30 Jul 2012
Posts: 196

PostPosted: Wed Jun 18, 2014 10:21 am    Post subject: Re: Reply with quote

PaulLaidler wrote:
I cannot think of a way to do this. Maybe you should try using %gr instead of %pl.

If you can get a handle for the %pl window, you could probably get a snapshot from the window using something like (untested code and in MiniBASIC-syntax):

Code:

HDC hdc = GetWindowDC(hwnd)
if hdc
  HDC hdcMem = CreateCompatibleDC(hdc)
  if hdcMem
    RECT rc
    GetWindowRect(hwnd, &rc)

    HBITMAP hbitmap = CreateCompatibleBitmap(hdc, rc.right, rc.bottom)
    if hbitmap
      SelectObject(hdcMem, hbitmap)
      PrintWindow(hwnd, hdcMem, 0)

      ' Here do something with the bitmap or memory device context
      ' Save bitmap into file maybe?

      DeleteObject(hbitmap)
    endif
    DeleteObject(hdcMem)
  endif
  ReleaseDC(hwnd, hdc)
endif
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 -> Support 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