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 #77830 is a reply to message #77829] Wed, 05 October 2011 10:26 Go to previous messageGo to previous message
Matthew is currently offline  Matthew
Messages: 18
Registered: February 2006
Junior Member
On Sep 30, 11:34 am, David Fanning <n...@dfanning.com> wrote:
> 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.")


Just a quick note... unless the aspect ratio of the postscript file is
the same as that of the display (e.g. as is the case when using
psCONFIG()), the variable pixel size will make the initial problem
here persist. To fix the problem,

x_size_old = !d.x_size
y_size_old = !d.y_size
set_plot, 'PS'

x_size_ps = !d.x_size
y_size_ps = !d.y_size

px_size_x = x_size_ps / x_size_old
px_size_y = y_size_ps / y_size_old

position[0] = floor(position[0] * !d.x_vsize)
position[1] = floor(position[1] * !d.y_vsize)
position[2] = ceil(position[2] * !d.x_vsize)
position[3] = ceil(position[3] * !d.y_vsize)
xsize = (position[2] - position[0]) - px_size_x
ysize = (position[3] - position[1]) - px_size_y
xstart = position[0] + px_size_x
ystart = position[1] + px_size_y


This has worked so far...
[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:50 PDT 2025

Total time taken to generate the page: 0.55838 seconds