migrate to new git

This commit is contained in:
2025-08-29 01:27:25 +08:00
parent 946eb9961e
commit af2c152ef6
8623 changed files with 1000453 additions and 1 deletions

View File

@@ -0,0 +1,106 @@
<%@ WebHandler Language="C#" Class="generator" %>
using System;
using System.Web;
using System.IO;
using BarcodeLib;
using System.Drawing;
using System.Drawing.Imaging;
public class generator : IHttpHandler {
MyWeb.function f = new MyWeb.function();
public void ProcessRequest (HttpContext context) {
if (!f.isStrNull(context.Request["val"]))
{
try
{
MemoryStream oStream = new MemoryStream();
CreateValidateCodeImage(ref oStream);
context.Response.ClearContent();
context.Response.ContentType = "image/Gif";
context.Response.BinaryWrite(oStream.ToArray());
}
catch (Exception ex)
{
context.Response.ContentType = "text/plain";
context.Response.Write(ex.Message);
}
}
else
{
context.Response.ContentType = "text/plain";
context.Response.Write("No data");
}
}
public void CreateValidateCodeImage(ref MemoryStream MemoryStream)
{
Bitmap oBmp = CreateValidateCodeImage();
try
{
oBmp.Save(MemoryStream, ImageFormat.Gif);
}
catch (Exception)
{
}
finally
{
oBmp.Dispose();
}
}
public Bitmap CreateValidateCodeImage()
{
//設定字型
int FontSize = 10;
if ( !f.isStrNull(HttpContext.Current.Request["fontsize"]) && f.IsNumeric(HttpContext.Current.Request["fontsize"]))
FontSize = f.Val(HttpContext.Current.Request["fontsize"]);
Font oFont = new Font("Times New Roman", FontSize, FontStyle.Regular);
Barcode bc = new Barcode();
bc.IncludeLabel = true;
bc.Alignment = AlignmentPositions.CENTER;
bc.Width =!f.isStrNull(HttpContext.Current.Request["w"]) && f.IsNumeric(HttpContext.Current.Request["w"])?f.Val(HttpContext.Current.Request["w"]):400;
bc.Height =!f.isStrNull(HttpContext.Current.Request["h"]) && f.IsNumeric(HttpContext.Current.Request["h"])?f.Val(HttpContext.Current.Request["h"]):200;
bc.RotateFlipType = RotateFlipType.RotateNoneFlipNone;
bc.LabelFont = oFont;
bc.BackColor = Color.White;
bc.ForeColor = Color.Black;
string data = f.ValString(HttpContext.Current.Request["val"]);
string type = f.ValString(HttpContext.Current.Request["type"]);
if (type == "39")
return (Bitmap)bc.Encode(TYPE.CODE39, data);
else if (type == "128")
return (Bitmap)bc.Encode(TYPE.CODE128, data);
else if (type == "ISBN")
return (Bitmap)bc.Encode(TYPE.ISBN, data);
else if (type == "ITF")
return (Bitmap)bc.Encode(TYPE.ITF14, data);
else if (type == "EAN13")
return (Bitmap)bc.Encode(TYPE.EAN13, data);
else if (type == "EAN8")
return (Bitmap)bc.Encode(TYPE.EAN8, data);
else
return (Bitmap)bc.Encode(TYPE.CODE39, data);
}
public bool IsReusable {
get {
return false;
}
}
}

View File

@@ -0,0 +1,75 @@
<%@ WebHandler Language="C#" Class="qrcode" %>
using System;
using System.Web;
using Gma.QrCodeNet.Encoding;
using Gma.QrCodeNet.Encoding.Windows.Render;
using System.Drawing;
public class qrcode : IHttpHandler {
public void ProcessRequest (HttpContext context) {
MyWeb.function f = new MyWeb.function();
if (!f.isStrNull(context.Request.QueryString["val"]))
{
string picType = "Image/jpeg";
context.Response.ContentType = picType;
context.Response.Clear();
/*
Level L (Low) 7% of codewords can be restored.
Level M (Medium) 15% of codewords can be restored.
Level Q (Quartile) 25% of codewords can be restored.
Level H (High) 30% of codewords can be restored.
*/
QrEncoder encoder = new QrEncoder(ErrorCorrectionLevel.L); //設定錯誤修正容量(請參考上面註解)
string codeString = context.Request.QueryString["val"];
QrCode code = encoder.Encode(codeString);
int moduleSizeInPixels = 12; //定義線條寬度
GraphicsRenderer renderer = new GraphicsRenderer(new FixedModuleSize(moduleSizeInPixels, QuietZoneModules.Two), Brushes.Black, Brushes.White);
//留白區大小
Point padding = new Point(10, 16);
//取得條碼圖大小
DrawingSize dSize = renderer.SizeCalculator.GetSize(code.Matrix.Width);
int imgWidth = dSize.CodeWidth + 2 * padding.X;
int imgHeight = dSize.CodeWidth+2 * padding.Y;
//設定影像大小
Image img = new Bitmap(imgWidth, imgHeight);
//繪製二維條碼圖
Graphics g = Graphics.FromImage(img);
renderer.Draw(g, code.Matrix, padding);
//下方設定使JPG質量
MyWeb.global global = new MyWeb.global();
System.Drawing.Imaging.EncoderParameters EPS = new System.Drawing.Imaging.EncoderParameters();
System.Drawing.Imaging.EncoderParameter EP = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, Convert.ToInt64(global.ImageCompressionQuality));
EPS.Param[0] = EP;
System.Drawing.Imaging.ImageCodecInfo[] codecs = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders();
System.Drawing.Imaging.ImageCodecInfo ICI = null;
foreach (System.Drawing.Imaging.ImageCodecInfo codec in codecs)
if (codec.MimeType.ToLower() ==picType.ToLower())
ICI = codec;
img.Save(context.Response.OutputStream, ICI, EPS);
img.Dispose();
g.Dispose();
}
else
{
context.Response.ContentType = "text/plain";
}
}
public bool IsReusable {
get {
return false;
}
}
}