this is how my code look now:
System.Drawing.Image objImage = System.Drawing.Image.FromFile(Server.MapPath(\"aaa.jpg\"));
int height = objImage.Height;
int widt
Bitmap
is a subclass of Image
, so there no need to convert Bitmap
to Image
. It already is...
You can also try:
imgBig.ImageUrl = ResolveUrl(saveImagePath);
EDIT:
If saveImagePath is under the WebApplication Directory, doing some modifications on the directory structure i.e. modifying files, deleting and creating can cause the application pool to recycle, and once it reaches the maximum recycle count the application pool will be stopped causing "Server unavailable" error.
I would suggests to add/save/modify images on a separate directory (not under the Apps Directory) then create a Handler(ASHX) that will read the images, just an advice though.
Probably because saveImagePath
will be a local path (such as c:\somepath\aaa.jpg
) that is not reachable from the browser. You probably want to set the ImageUrl = "ImagesMerge/aaa.jpg"
instead.
like jmaglasang said, I would suggest to you to use an ashx file and if you don't need to keep the image, just send the image stream directly to the http without saving it on the disk
so you only need to do something like
<img src="Handler.ashx?action=merge&image1=blah.jpg&image2=bloh.jpg">
look at this code for an example of how to send an image made in memory that does not exist on the drive
You might be forgetting to set the Response.Headers. Check out the following example that shows how to create bar chart images and then display it on the screen:
http://www.highoncoding.com/Articles/399_Creating_Bar_Chart_Using__NET_Graphics_API.aspx
MapPath will give you a physycal address, not a virtual address which is what the browser needs to get to the image.