The same is observed with the Thumbnail images in the RadImageGallery, which actually use such BinaryImages.
Note: The attached image should be the only file in a "Images" in the root of the application
protected void Page_Load(object sender, EventArgs e)
{
var binary = new RadBinaryImage();
binary.AutoAdjustImageControlSize = false;
binary.ResizeMode = BinaryImageResizeMode.Crop;
binary.ID = "BinaryImage";
binary.Width = Unit.Pixel(100);
binary.Height = Unit.Pixel(100);
var path = Directory.EnumerateFiles(Server.MapPath("~/Images")).First();
binary.DataValue = File.ReadAllBytes(path);
Form.Controls.Add(binary);
}
protected void Page_Load(object sender, EventArgs e)
{
var binary = new RadBinaryImage();
binary.ID = "BinaryImage1";
binary.ResizeMode = BinaryImageResizeMode.Crop;
binary.Width = Unit.Pixel(100);
binary.Height = Unit.Pixel(100);
var path = Directory.EnumerateFiles(Server.MapPath("~/Images")).First();
binary.DataValue = ImagePathToByteArray(path);
//binary.DataValue = File.ReadAllBytes(path);
Form.Controls.Add(binary);
}
public byte[] ImagePathToByteArray(string path)
{
System.Drawing.Image img = Bitmap.FromFile(path);
if (Array.IndexOf(img.PropertyIdList, 274) > -1)
{
var orientation = (int)img.GetPropertyItem(274).Value[0];
switch (orientation)
{
case 1:
// No rotation required.
break;
case 2:
img.RotateFlip(RotateFlipType.RotateNoneFlipX);
break;
case 3:
img.RotateFlip(RotateFlipType.Rotate180FlipNone);
break;
case 4:
img.RotateFlip(RotateFlipType.Rotate180FlipX);
break;
case 5:
img.RotateFlip(RotateFlipType.Rotate90FlipX);
break;
case 6:
img.RotateFlip(RotateFlipType.Rotate90FlipNone);
break;
case 7:
img.RotateFlip(RotateFlipType.Rotate270FlipX);
break;
case 8:
img.RotateFlip(RotateFlipType.Rotate270FlipNone);
break;
}
// This EXIF data is now invalid and should be removed.
img.RemovePropertyItem(274);
}
return ImageToByte(img);
}
public static byte[] ImageToByte(System.Drawing.Image img)
{
System.Drawing.ImageConverter converter = new System.Drawing.ImageConverter();
return (byte[])converter.ConvertTo(img, typeof(byte[]));
}
System.Threading.ThreadAbortException 2 Thread was being aborted. System.Threading.Thread.AbortInternal() System.Threading.Thread.Abort(System.Object) System.Web.HttpResponse.AbortCurrentThread() Telerik.Web.UI.RadBinaryImageHandler.ProcessRequestInternal() Telerik.Web.UI.HandlerRouter.ProcessHandler(System.String, System.Web.HttpContext) Telerik.Web.UI.WebResource.ProcessRequest(System.Web.HttpContext) System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef) System.Exception 1 <none> System.Threading.Thread.AbortInternal() System.Threading.Thread.Abort(System.Object) System.Web.HttpResponse.AbortCurrentThread() Telerik.Web.UI.RadBinaryImageHandler.ProcessRequestInternal() Telerik.Web.UI.HandlerRouter.ProcessHandler(System.String, System.Web.HttpContext) Telerik.Web.UI.WebResource.ProcessRequest(System.Web.HttpContext) System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef) System.OutOfMemoryException 1 <none> System.Threading.Thread.AbortInternal() System.Threading.Thread.Abort(System.Object) System.Web.HttpResponse.AbortCurrentThread() Telerik.Web.UI.RadBinaryImageHandler.ProcessRequestInternal() Telerik.Web.UI.HandlerRouter.ProcessHandler(System.String, System.Web.HttpContext) Telerik.Web.UI.WebResource.ProcessRequest(System.Web.HttpContext) System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef) System.StackOverflowException 1 <none> System.Threading.Thread.AbortInternal() System.Threading.Thread.Abort(System.Object) System.Web.HttpResponse.AbortCurrentThread() Telerik.Web.UI.RadBinaryImageHandler.ProcessRequestInternal() Telerik.Web.UI.HandlerRouter.ProcessHandler(System.String, System.Web.HttpContext) Telerik.Web.UI.WebResource.ProcessRequest(System.Web.HttpContext) System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef) System.ExecutionEngineException 1 <none> System.Threading.Thread.AbortInternal() System.Threading.Thread.Abort(System.Object) System.Web.HttpResponse.AbortCurrentThread() Telerik.Web.UI.RadBinaryImageHandler.ProcessRequestInternal() Telerik.Web.UI.HandlerRouter.ProcessHandler(System.String, System.Web.HttpContext) Telerik.Web.UI.WebResource.ProcessRequest(System.Web.HttpContext) System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef) System.Threading.ThreadAbortException 2 <none> System.Threading.Thread.AbortInternal() System.Threading.Thread.Abort(System.Object) System.Web.HttpResponse.AbortCurrentThread() Telerik.Web.UI.RadBinaryImageHandler.ProcessRequestInternal() Telerik.Web.UI.HandlerRouter.ProcessHandler(System.String, System.Web.HttpContext) Telerik.Web.UI.WebResource.ProcessRequest(System.Web.HttpContext) System.Web.HttpApplication+CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() System.Web.HttpApplication.ExecuteStep(IExecutionStep, Boolean ByRef)