eShop-server-simul.zip
1.jpg
eShop.zip
eShop.app
eShop.msp
eShop
.platforms
android
icon.png
splash.png
bada
Icon.png
Splash.png
symbian
icon.svg
splash.png
wm
splash.png
button.ms
header-img.jpg
homeView.ms
loading.png
main.ms
productView.ms
server.ms
SegoeWP-Black.ttf
SegoeWP-Bold.ttf
SegoeWP-Light.ttf
|
<%@ Page Language="C#" AutoEventWireup="true" Theme="" ContentType="image/jpeg" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Drawing" %>
<%@ Import Namespace="System.Drawing.Imaging" %>
<script runat="server">
void Page_Load()
{
try
{
Response.Clear();
string productId = Request["id"];
string path = Server.MapPath(Path.GetDirectoryName(Request.Path)) + "\\" + Request["id"] + ".jpg";
Bitmap bmp = CreateThumbnail(path, Int32.Parse(Request["w"]), Int32.Parse(Request["h"]));
bmp.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
bmp.Dispose();
}
catch (Exception ex)
{
Response.StatusDescription = ex.Message;
}
}
public static Bitmap CreateThumbnail(string lcFilename, int lnWidth, int lnHeight)
{
System.Drawing.Bitmap bmpOut = null;
Bitmap loBMP = new Bitmap(lcFilename);
ImageFormat loFormat = loBMP.RawFormat;
decimal lnRatio;
int lnNewWidth = 0;
int lnNewHeight = 0;
if (loBMP.Width < lnWidth && loBMP.Height < lnHeight)
return loBMP;
if (loBMP.Width > loBMP.Height)
{
lnRatio = (decimal)lnWidth / loBMP.Width;
lnNewWidth = lnWidth;
decimal lnTemp = loBMP.Height * lnRatio;
lnNewHeight = (int)lnTemp;
}
else
{
lnRatio = (decimal)lnHeight / loBMP.Height;
lnNewHeight = lnHeight;
decimal lnTemp = loBMP.Width * lnRatio;
lnNewWidth = (int)lnTemp;
}
bmpOut = new Bitmap(lnNewWidth, lnNewHeight);
Graphics g = Graphics.FromImage(bmpOut);
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.FillRectangle(Brushes.White, 0, 0, lnNewWidth, lnNewHeight);
g.DrawImage(loBMP, 0, 0, lnNewWidth, lnNewHeight);
loBMP.Dispose();
return bmpOut;
}
</script>
|
By viewing downloads associated with this article you agree to the Terms of use and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.