77 lines
2.3 KiB
Plaintext
77 lines
2.3 KiB
Plaintext
<%@ WebHandler Language="C#" Class="photos" %>
|
|
|
|
using System;
|
|
using System.Web;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.Serialization.Json;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using System.Web.Services.Protocols;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
using System.Web.SessionState;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Drawing.Imaging;
|
|
using System.Drawing;
|
|
|
|
public class photos : IHttpHandler {
|
|
|
|
private string _path = System.Web.HttpContext.Current.Server.MapPath("~/");
|
|
|
|
public void ProcessRequest (HttpContext context) {
|
|
|
|
string id = (context.Request["id"] == null) ? "" : context.Request["id"].ToString().Replace(";","").Replace("=","");
|
|
string playBtn = (context.Request["play"] == null) ? "N" : context.Request["play"].ToString().Replace(";","").Replace("=","");
|
|
string photoStr = string.Format("select * from url where url_photoId = '{0}' and url_isRevoke = 'N'", id);
|
|
autoBindDataTable photoSQL = new autoBindDataTable(photoStr);
|
|
|
|
if (photoSQL.dataRows.Count == 0) {
|
|
context.Response.End();
|
|
return;
|
|
}
|
|
|
|
DataRow photoRow = photoSQL.dataRows[0];
|
|
|
|
Stream fileStream;
|
|
Stream waterStream;
|
|
|
|
fileStream = File.OpenRead(_path + photoRow["url_fbImage"].ToString());
|
|
waterStream = File.OpenRead(_path + "/pics/play.png");
|
|
|
|
Image originImg = globalClass.fileToImage(fileStream);
|
|
Image waterImg = globalClass.fileToImage(waterStream);
|
|
|
|
|
|
|
|
Image outImg;
|
|
|
|
if (playBtn == "Y") {
|
|
outImg = globalClass.markImage(originImg, waterImg);
|
|
} else {
|
|
outImg = originImg;
|
|
}
|
|
|
|
System.IO.MemoryStream outStream = new System.IO.MemoryStream();
|
|
outImg.Save(outStream, ImageFormat.Png);
|
|
|
|
context.Response.ClearHeaders();
|
|
context.Response.Clear();
|
|
context.Response.ClearContent();
|
|
context.Response.Expires = 0;
|
|
context.Response.Buffer = false;
|
|
context.Response.ContentType = "image/png";
|
|
//context.Response.Charset = "utf-8";
|
|
|
|
context.Response.BinaryWrite(outStream.ToArray());
|
|
context.Response.End();
|
|
outImg.Dispose();
|
|
}
|
|
|
|
public bool IsReusable {
|
|
get {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
} |