c# - Resizing image with MaxHeight and MaxWidth -
i want use answer question here: resize image proportionally maxheight , maxwidth constraints
but image .net image. wondering if there way resize image proportionally maxheight , maxwidth constraint .net image. here asp code looks like:
<asp:image id="image1" runat="server" height="445px" visible="false" width="640px" />
the code behind looks this:
image1.imageurl = "/images/" + image1link.tostring();
an asp.net image has same attributes of winforms image. still can use image1.height , image1.width. set height & width these attributes. check example:
protected void page_load(system.object sender, system.eventargs e) { if (!page.ispostback) { loadimage(); } } private void loadimage(){ image1.imageurl = loadurlfromdatabase(params); image1.width = (int)(image.width * ratio); image1.height = (int)(image.height * ratio); }
Comments
Post a Comment