From: rmagere
Subject: A few more questions on graphics  (specifically zooming and mpeg creation) [was Question about Jlinker and MemoryImageSource (more generally about graphics in lisp)]
Date: 
Message-ID: <b9vtu7$avv$1@news.ox.ac.uk>
Hi,

I have three more questions about graphics that have come up since the last
time I wrote on this topic (by the way thanks again to Kenny Tilton for
helping me out before and allowing me to get quite far in my research with
is initial indications).

So here are the questions:
a) is there a way to have zooming facility when using frame windows with a
bitmap pane as child? something along the line of what you get from the
typical "magnifying glass" in window. At the moment I haven't found anything
for this purpose so the only idea I have is to introduce a zoom factor and
multiply all my values drawn values by it, however it doesn't feel like a
particularly satisfactory solution.

b) is there a way to save a frame window to mpeg or some other (windows)
video format type? what I have at the moment is a window which gets updated
at regular intervals showing boxes moving in it, what I would like is to
save what is seen in the window till when it's closed in a file format that
I can keep stored and provide as result examples for my code. (or do I have
to save every instance of the window in a jpg/bmp - as I think I might have
seen a post about a graphics package in cliki.net though pointers would be
appreciated - and then generate a movie from those images).

c)is there a way to resize a window once it's created?
at the moment I create my window with the following code:

(defun run-agents (&optional (initialize nil))
  (when initialize (run-agents-initialize))
  (let* ((temp (make-window :agents-window
                 :class 'agents-window
                 :owner (development-main-window *system*)
                 :title "Moving Vehicles"
                 :page-width 4000
                 :page-height 4000
                 :exterior (make-box 10 10 1000 700)
                 :scrollbars t
                 :state :shrunk))
         (timer (my-timer)))
    (push (frame-child temp) (timer-info timer))
    (start-timer timer)
    (select-window temp)
    temp))

however once generated if I try to use: (setf (page-height (find-window
:agents-window)) 500) to resize the window drawable area (not just it's
exterior) I get appropriately enough > 500 from lisp, not an error, but
nothing happened.

Thanks in advance for any help, pointers you can provide me.

From: Kenny Tilton
Subject: Re: A few more questions on graphics  (specifically zooming and mpeg creation) [was Question about Jlinker and MemoryImageSource (more generally about graphics in lisp)]
Date: 
Message-ID: <3EC3BF12.3070300@nyc.rr.com>
rmagere wrote:
> So here are the questions:
> a) is there a way to have zooming facility when using frame windows with a
> bitmap pane as child? something along the line of what you get from the
> typical "magnifying glass" in window. At the moment I haven't found anything
> for this purpose so the only idea I have is to introduce a zoom factor and
> multiply all my values drawn values by it, however it doesn't feel like a
> particularly satisfactory solution.

IIRC, you are using ACL Common Graphics on win32? If so, and if you do 
not like your own app-level scaling, I believe you have to use win32 
calls (available IIRC from the ACL win: package) to let win32 GDI do the 
scaling (works great). Don't recall the API for that, but break out a 
win32 tome or hit the MSDN web site and you should be able to muddle 
thru. email me and i'll look those up, gotta run now.

> 
> b) is there a way to save a frame window to mpeg or some other (windows)
> video format type? 

ya got me. i think your JPEG/bmps first, MPEG later idea might be close.

> c)is there a way to resize a window once it's created?

resize-window? :) from the CG doc:

"resize-window

Arguments: window position

Sets the interior width and height of window to the x and y components 
of position respectively. Returns the actual size set if successful, or 
nil if unsuccessful. (See track-limits) "



-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Everything is a cell." -- Alan Kay
From: Kenny Tilton
Subject: Re: A few more questions on graphics  (specifically zooming and mpeg creation) [was Question about Jlinker and MemoryImageSource (more generally about graphics in lisp)]
Date: 
Message-ID: <3EC3F5B0.9030602@nyc.rr.com>
Kenny Tilton wrote:
> 
> 
> rmagere wrote:
> 
>> So here are the questions:
>> a) is there a way to have zooming facility when using frame windows 
>> with a
>> bitmap pane as child?

(win:SetViewportExtEx (device-context <window>) newX newY ct:hnull)

A larger snippet (with some stuff not shown, so you'll have to just take 
this as a rough guide):

(defmethod ix-paint :around ((self IXCanvas) gBox w)
   (let ((dc (device-context w))
         (oldext (ff:allocate-fobject 'win:point :c))
         )
     (win:SetViewportExtEx dc (targetRes self) (targetRes self) oldext)
     (with-target-resolution ((targetRes self))
       (call-next-method self (res-to-res gBox (enclosingres self) 
(targetRes self)) w)

       (win:SetViewportExtEx dc
         (point-slot oldext x)
         (point-slot oldext y) ct:hnull)
       (ff:free-fobject oldext)
       )))

>> b) is there a way to save a frame window to mpeg or some other (windows)
>> video format type? 
> 
> 
> ya got me. i think your JPEG/bmps first, MPEG later idea might be close.

btw, win32 does have an EMF (enhanced metafile format) but I am not sure 
  if that is any easier for your purposes than bitmaps.

-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Everything is a cell." -- Alan Kay
From: Rmagere
Subject: Re: A few more questions on graphics  (specifically zooming and mpeg creation) [was Question about Jlinker and MemoryImageSource (more generally about graphics in lisp)]
Date: 
Message-ID: <vca7qbbi8hdf2@corp.supernews.com>
----- Original Message -----
From: "Kenny Tilton" <·······@nyc.rr.com>
>
> IIRC, you are using ACL Common Graphics on win32? If so, and if you do
> not like your own app-level scaling, I believe you have to use win32
> calls (available IIRC from the ACL win: package) to let win32 GDI do the
> scaling (works great). Don't recall the API for that, but break out a
> win32 tome or hit the MSDN web site and you should be able to muddle
> thru. email me and i'll look those up, gotta run now.

Yeah you are right I am using ACL Common Graphics on win32. As I haven't
actually tried to implement yet my own app-level scaling I am not sure if I
don't like it (though I know I am not too keen of implementing it). However
thanks for the pointers on where to look for the built-in function in win32.
Now I'll get down and search for more info on it and see how I get on.

There is however one doubt I have in using the windows function as I have
this feeling that it might not be doing what I actually want from the
zooming facility: i.e. I suspect that what it will be doing is changing the
resolution of the window shown so e.g. if I have made a 40x40 window I might
get a 80x80 window with everything inside it twice as big with out providing
new informations. What instead I want to provide as zooming option is
something that changes the window to 80x80 and leaves everything inside it
the same size as in the 40x40 window or keeps the window at 40x40 and makes
smaller everything inside it so that if some of the boxes generated by the
program were before outside the
space of the window by zooming out I will see them. Kind of like a satellite
view of the earth moving from continent to state to city and viceversa.


> ya got me. i think your JPEG/bmps first, MPEG later idea might be close.
>
>btw, win32 does have an EMF (enhanced metafile format) but I am not sure
>if that is any easier for your purposes than bitmaps.

Here I thought of using a bmp as according to acl help file
"bitmap-pane
A class of window that can be drawn on and which has a backing store. It
remembers its contents in an attached bitmap and automatically redisplays
them from that memory bitmap when required (such as when the pane is hidden
and then exposed). This is the default-pane-class of the bitmap-window. If
you want the whole image in a bitmap-pane to change, consider making the
change in the body of a with-delayed-redraw macro. That macro handles bitmap
panes specially and can be used to have the redraw appear cleaner. See the
with-delayed-redraw for an example. "

And as I have all my drawing happening in

"defclass agents-window (frame-with-single-child) ())

(defclass agents-pane (bitmap-pane)())

(defmethod default-pane-class ((w agents-window)) 'agents-pane)

(defmethod move-agents-in-window ((window agents-pane) &optional
(agents-list *my-agents-list*))
  (with-delayed-redraw (window :invalidate t)
    (delete-old-agents window)
    (draw-new-agents window)
    (update-window window)))

I thought there should be away to get a dump of hte bmp generated
automatically by acl without having to use an external package (I do not
mind too much at the moment checking through all the bmp and making the
movie manually though I might change my mind at a later stage).
However I have at the moment not been able to find a way to save such bmp
(nor for the matter where it is stored or under what variable name).

>
> > c)is there a way to resize a window once it's created?
>
> resize-window? :) from the CG doc:

Doh, I actually didn't think of that I should have used aprops search.

Thanks for all the help you have already given me and for any future one.

Rmagere
From: Kenny Tilton
Subject: Re: A few more questions on graphics  (specifically zooming and mpeg creation) [was Question about Jlinker and MemoryImageSource (more generally about graphics in lisp)]
Date: 
Message-ID: <3EC5C9DF.2040201@nyc.rr.com>
Rmagere wrote:
> There is however one doubt I have in using the windows function as I have
> this feeling that it might not be doing what I actually want from the
> zooming facility: <snip>

No, I understand what you want, and SetViewPortExtEx will do it (but see 
this excerpt for the full story):

from 
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/cordspac_57w8.asp

"The viewport refers to the device coordinate system of the device 
space. The extent is the maximum value of an axis. This function sets 
the maximum values for the horizontal and vertical axes of the viewport 
in device coordinates (or pixels). When mapping between page space and 
device space, SetWindowExtEx and SetViewportExtEx determine the scaling 
factor between the window and the viewport. For more information, see 
Transformation of Coordinate Spaces.

When the following mapping modes are set, calls to the SetWindowExtEx 
and SetViewportExtEx functions are ignored.

     * MM_HIENGLISH
     * MM_HIMETRIC
     * MM_LOENGLISH
     * MM_LOMETRIC
     * MM_TEXT
     * MM_TWIPS

When MM_ISOTROPIC mode is set, an application must call the 
SetWindowExtEx function before it calls SetViewportExtEx. Note that for 
the MM_ISOTROPIC mode certain portions of a nonsquare screen may not be 
available for display because the logical units on both axes represent 
equal physical distances."




-- 

  kenny tilton
  clinisys, inc
  http://www.tilton-technology.com/
  ---------------------------------------------------------------
"Everything is a cell." -- Alan Kay
From: rmagere
Subject: Re: A few more questions on graphics  (specifically zooming and mpeg creation) [was Question about Jlinker and MemoryImageSource (more generally about graphics in lisp)]
Date: 
Message-ID: <bacqup$ltp$1@news.ox.ac.uk>
"Kenny Tilton" <·······@nyc.rr.com> wrote in message
·····················@nyc.rr.com...
> No, I understand what you want, and SetViewPortExtEx will do it (but see
> this excerpt for the full story):
> from
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/cordspac_57w8.asp
>
Thanks for the link, now I am going to leave for a while and see how for I
can get with using win32 commands,

Thanks again,
Rmagere