I am trying to write a verb that will capture a plot using the
'media/platimg' Addon as described on the wiki page:
http://www.jsoftware.com/jwiki/Addons/media/platimg under the heading
"Capture Graphics"
The verb captureIsi below almost does the job, but although the
on-screen form seems to resize correctly, the captured image (although
the right size) doesn't quite seem to refresh the
myplot '' NB. Displays plot on isi form (don't close)
captureIsi '' NB. 800x600 tstcapture.png file written to ~temp OK
1024 768 captureIsi ''
NB. 1024x768 file is written but black is used to fill previous 800x600
image to required size.
1024 768 captureIsi '' NB. 1024x768 file is written & now looks fine
800 600 captureIsi '' NB. 800x600 file is written but iscropped
version of previous image.
800 600 captureIsi '' NB. 800x600 file is written & looks fine
Re-running the myplot verb inbetween doesn't change the behaviour
observed above.
How can I fix captureIsi to "refresh" the image to be captured without
running the verb twice?
NB.====script: capture.ijs=============
require 'plot'
myplot=: 3 :0
pd 'type bar'
pd 'axes 1 0'
pd 'xlabel ',":2001+i.6
pd 'title Bar Chart'
pd 0.6 0.8 1* _0.5+?.3#,:3 3 4 7 7 4
pd 'isi'
)
NB.*captureIsi v capture the contents of an isigraph form
NB. returns #bytes written to file or actual img file content
NB. y is character list (either filename to write to or format to
return)
NB. x is optional width and height in pixels. Defaults to 800 600.
NB. e.g. captureIsi jpath '~temp/myfile.gif'
NB. e.g. 1024 768 captureIsi 'png'
captureIsi=: 3 :0
800 600 captureIsi y
:
if. -.*#y do. y=.jpath '~temp/tstcapture.png' end.
require 'media/platimg'
coinsert 'jgl2'
glwh=: 3 : 'wd''pmovex '',(+0 0,[EMAIL PROTECTED]@#)&.".wd''qformx'''
glwh x
glqall=: (|. $ [:glqpixels 0 0&,)@glqwh
if. (<toupper y) e. ;:'BMP GIF JPEG PNG TIFF EXIF ICO WMF EMF' do.
y putimg~ glqall'' NB. or this to not write file
else.
y writeimg~ glqall'' NB. write to file
end.
)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm