<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to stretch a picturebox to a window while maintaining an aspect ratio? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-stretch-a-picturebox-to-a-window-while-maintaining-an/m-p/964849#M110374</link>
    <description>&lt;P&gt;Lets use min/max sizes of&amp;nbsp;100x100 to 800x800 on the picture, 200x300 to 1000x900 for the window.&lt;/P&gt;
&lt;P&gt;User can resize the window, not the picture (directly).&lt;/P&gt;
&lt;P&gt;Picture grows and shrinks with window size, maintaining it's square aspect ratio. That means there'll be some empty space if the window is short and wide or tall and thin.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Aug 2026 16:42:41 GMT</pubDate>
    <dc:creator>EOwl</dc:creator>
    <dc:date>2026-08-17T16:42:41Z</dc:date>
    <item>
      <title>How to stretch a picturebox to a window while maintaining an aspect ratio?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-stretch-a-picturebox-to-a-window-while-maintaining-an/m-p/964243#M110364</link>
      <description>&lt;P&gt;I'm writing a script that will generate a GUI for displaying images, using a rowstate handler to pass the images over to the window.&lt;/P&gt;
&lt;P&gt;Is there a way to set a picture box object to:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Stretch with window size (with a minimum and maximum size defined)&lt;/LI&gt;
&lt;LI&gt;Maintain it's original aspect ratio (e.g. square) (see script 2)&lt;/LI&gt;
&lt;LI&gt;Forbid direct user re-sizing.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Here's some JSL that uses the sample table of images.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Clear Globals();
Names Default To Here(1);

dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );

//Set the picture equal to selected row
rs_updateviewer = Expr(
	
	SelectedRows = (dt &amp;lt;&amp;lt; Get Selected Rows());
	i = If(N Items(SelectedRows) == 0, 1, SelectedRows[1]);
	
	img = column(dt, "pet")[i];
	pb &amp;lt;&amp;lt; Set Image(img);
);

//Viewer Window
Viewer = New Window(
	"Viewer",
	Show Menu( 0 ),
	&amp;lt;&amp;lt; On Close(Clear Globals(rs);
	),
	&amp;lt;&amp;lt; Size Window( 1000, 700),
	
	vb = V List Box("Center",
	H Center Box( Text Box( "Viewer" ) ),
	H List Box(
//	tb = dt &amp;lt;&amp;lt; New Data Box(),
	tb = Data Grid Box(),
	pb = Picture Box()
	)
	)
	,
	pb &amp;lt;&amp;lt; Set Stretch( "Fill", "Fill" );
	pb &amp;lt;&amp;lt; Border( 1 );
	
	tb &amp;lt;&amp;lt; Set Stretch( "Off", "Off" );
	tb &amp;lt;&amp;lt; Set Data Table( dt );
	tb &amp;lt;&amp;lt; Close Side Panels( 1 );
	
);

//Initiate image
rs_updateviewer;

// Define the handler function
f = Function( {a},
	rs_updateviewer
);

// Register the row state handler to the table
set_rowstate = Expr(
	rs = dt &amp;lt;&amp;lt; Make Row State Handler( f );
);

set_rowstate;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here's an script index example of a &lt;EM&gt;graph&lt;/EM&gt; with it's aspect ratio fixed, the behaviour I'd like on the picture&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder( Show Control Panel( 0 ), Variables( X( :height ), Y( :weight ) ), Elements( Points( X, Y ), Smoother( X, Y ) ) );
gb &amp;lt;&amp;lt; Fit to Window( "Maintain Aspect Ratio" );&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Aug 2026 14:44:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-stretch-a-picturebox-to-a-window-while-maintaining-an/m-p/964243#M110364</guid>
      <dc:creator>EOwl</dc:creator>
      <dc:date>2026-08-13T14:44:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to stretch a picturebox to a window while maintaining an aspect ratio?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-stretch-a-picturebox-to-a-window-while-maintaining-an/m-p/964298#M110365</link>
      <description>&lt;P&gt;Which min/max size has been determined (window or picture)? Should user be allowed to resize the window but not the picture? And is allowed to resize the window, should picture be able to resize to this new window size?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Aug 2026 03:48:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-stretch-a-picturebox-to-a-window-while-maintaining-an/m-p/964298#M110365</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2026-08-14T03:48:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to stretch a picturebox to a window while maintaining an aspect ratio?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-stretch-a-picturebox-to-a-window-while-maintaining-an/m-p/964849#M110374</link>
      <description>&lt;P&gt;Lets use min/max sizes of&amp;nbsp;100x100 to 800x800 on the picture, 200x300 to 1000x900 for the window.&lt;/P&gt;
&lt;P&gt;User can resize the window, not the picture (directly).&lt;/P&gt;
&lt;P&gt;Picture grows and shrinks with window size, maintaining it's square aspect ratio. That means there'll be some empty space if the window is short and wide or tall and thin.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Aug 2026 16:42:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-stretch-a-picturebox-to-a-window-while-maintaining-an/m-p/964849#M110374</guid>
      <dc:creator>EOwl</dc:creator>
      <dc:date>2026-08-17T16:42:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to stretch a picturebox to a window while maintaining an aspect ratio?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-stretch-a-picturebox-to-a-window-while-maintaining-an/m-p/964941#M110376</link>
      <description>&lt;P&gt;I don't think you can have min/max size for the window; you can only set the initial size.&lt;/P&gt;
&lt;P&gt;I think it might be easiest to Graph Builder and fill it with the picture as it can maintain the aspect ratio but I'm not sure how to set min/max size without testing it out. Other option could be to utilize graphic script to resize display elements as graphic script will re-trigger when window size changes.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Aug 2026 08:59:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-stretch-a-picturebox-to-a-window-while-maintaining-an/m-p/964941#M110376</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2026-08-18T08:59:07Z</dc:date>
    </item>
  </channel>
</rss>

