comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: positioning a TV image within plotting region
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: positioning a TV image within plotting region [message #77868 is a reply to message #77830] Fri, 30 September 2011 08:34 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Matthew writes:

> position = [x0, y0, x1, y1] ;position in normal
> coordinates
> position[0] = floor(position[0] * !d.x_vsize)
> position[1] = floor(position[1] * !d.y_vsize)
> position[2] = floor(position[2] * !d.x_vsize)
> position[3] = floor(position[3] * !d.y_vsize)
> xsize = (position[2] - position[0]) - 1
> ysize = (position[3] - position[1]) - 1
> xstart = position[0] + 1
> ystart = position[1] + 1

I think these two lines:

> position[2] = floor(position[2] * !d.x_vsize)
> position[3] = floor(position[3] * !d.y_vsize)

should use CEIL instead of FLOOR.

But, I think this is essentially correct. I've changed
the way I calculate the image size and start positions
in cgImage this morning to this, and I like the results
very much.

; Calculate the image size and start locations.
xsize = Ceil((position[2] - position[0]) * !D.X_VSIZE)-1
ysize = Ceil((position[3] - position[1]) * !D.Y_VSIZE)-1
xstart = Round(position[0] * !D.X_VSIZE)+1
ystart = Round(position[1] * !D.Y_VSIZE)+1

You can test the "fit" by typing these commands and resizing
the window:

Loadct, 0, NColors=20
cgImage, BytScl(Dist(20), TOP=19), /Axes, /Keep, $
Background='sky blue', /Erase, /Window

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Modern IDL Comments
Next Topic: positioning a TV image within plotting region

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 05:37:52 PDT 2025

Total time taken to generate the page: 0.16068 seconds