Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1420
Silverlight Image control
posted

Hi, I am Marko.

I have a doubt about silverlight <Image control. I am loading image from database image column into this control by converting data from DB image column into new BitmapImage variable and then I assign that BitmapImage variable to the   <Image control  source property for example like so:

BitmapImage bb = new BitmapImage();
bb = convertFromByteArrToBtmpImg(e.Result);

/* this is my conversion function from byte[] to BitmapImage*/
 imgPreviewSlika.Source = bb; // this will show pic 

/*  e.Result is from service method that gets image from database  */

  .. ok I am dealing with big pictures so I want to SHRINK them to fit the page, so my question is if I do this:

 imgPreviewSlika.Width = 680;

WILL THIS ADJUST HEIGHT AUTOMATICALLY - SHRINK HEIGHT ALSO ?

and IF NOT how do I shrink the height and width and preserve proportions  if I don't know image dimensions in the first place? (I load pics from database - that's why  I don't know their original dimensions) .

This issue of mine could be handled like this also: How do one get dimensions of an image that is stored in sql 2008 database in the image column ?

 

best regards,

Marko.

 

Parents
No Data
Reply
  • 1420
    posted

    No need to answer this I have found the solution. If I change dynamically height of the image control width will follow automatically preserving the aspect ratio of an image and wise versa.

    Marko

Children