or
What would be the most optimized way to resize an image for a PictureBox in Itemdatabound or itemDatabinding for a report? I have quite a few images and am tying not to have to manually resize them.
I seem to be missing something
| private void detail_ItemDataBound(object sender, EventArgs e) |
| { |
| Telerik.Reporting.Processing.DetailSection procDetail = sender as Telerik.Reporting.Processing.DetailSection; |
| Telerik.Reporting.Processing.PictureBox procPictureBox = procDetail.Items["pictureBox1"] as Telerik.Reporting.Processing.PictureBox; |
| DataRowView row = procDetail.DataItem as DataRowView; |
| string strPath = HttpContext.Current.Server.MapPath(@"~\Img\Product\" + (string)row["ProdImgLRes"]); |
| using (Bitmap bmpIn = new Bitmap(System.Drawing.Image.FromFile(strPath))) |
| { |
| int w = bmpIn.Width; |
| int h = bmpIn.Height; |
| int intWidth = 90; |
| int intHeight = (int)(h * intWidth) / w; |
| Bitmap bmpOut = new Bitmap(intWidth, intHeight); |
| using (Graphics g = Graphics.FromImage(bmpIn)) |
| { |
| g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; |
| g.DrawImage(bmpOut, 0, 0, intWidth, intHeight); |
| } |
| MemoryStream ms = new MemoryStream(); |
| bmpOut.Save(ms, ImageFormat.Bmp); |
| procPictureBox.Image = Image.FromStream(ms); |
| } |
Thanks,
Dave
|
Requirements |
|
| RadControls version | Q3 2008 |
| .NET version | 3.5 SP1 |
| Visual Studio version | 2008 SP1 |
| programming language | ASP.NET, C# |
| browser support |
all browsers supported by RadControls |
| <sessionState mode="SQLServer" allowCustomSqlDatabase="true" sqlConnectionString="ADD YOUR SQL CONNECTIONSTRING HERE" cookieless="UseCookies" timeout="60" regenerateExpiredSessionId="true"/> |
| ... |
| <machineKey validationKey="ADD YOUR VALIDATION KEY HERE" decryptionKey="ADD YOUR DECRYPTION KEY HERE" validation="SHA1"/> |
| ... |
| <authentication mode="Forms"> |
| </authentication> |