init commit

This commit is contained in:
2025-10-09 09:57:24 +09:00
commit 4d551bd74f
6636 changed files with 1218703 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
using MessagingToolkit.QRCode.Codec.Reader;
namespace MessagingToolkit.QRCode.Geom;
public class Axis
{
internal int sin;
internal int cos;
internal int modulePitch;
internal Point origin;
public virtual Point Origin
{
set
{
origin = value;
}
}
public virtual int ModulePitch
{
set
{
modulePitch = value;
}
}
public Axis(int[] angle, int modulePitch)
{
sin = angle[0];
cos = angle[1];
this.modulePitch = modulePitch;
origin = new Point();
}
public virtual Point translate(Point offset)
{
int x = offset.X;
int y = offset.Y;
return translate(x, y);
}
public virtual Point translate(Point origin, Point offset)
{
Origin = origin;
int x = offset.X;
int y = offset.Y;
return translate(x, y);
}
public virtual Point translate(Point origin, int moveX, int moveY)
{
Origin = origin;
return translate(moveX, moveY);
}
public virtual Point translate(Point origin, int modulePitch, int moveX, int moveY)
{
Origin = origin;
this.modulePitch = modulePitch;
return translate(moveX, moveY);
}
public virtual Point translate(int moveX, int moveY)
{
long num = QRCodeImageReader.DECIMAL_POINT;
Point point = new Point();
int num2 = ((moveX != 0) ? (modulePitch * moveX >> (int)num) : 0);
int num3 = ((moveY != 0) ? (modulePitch * moveY >> (int)num) : 0);
point.translate(num2 * cos - num3 * sin >> (int)num, num2 * sin + num3 * cos >> (int)num);
point.translate(origin.X, origin.Y);
return point;
}
}

View File

@@ -0,0 +1,173 @@
using System;
using MessagingToolkit.QRCode.Codec.Util;
namespace MessagingToolkit.QRCode.Geom;
public class Line
{
internal int x1;
internal int y1;
internal int x2;
internal int y2;
public virtual bool Horizontal
{
get
{
if (y1 == y2)
{
return true;
}
return false;
}
}
public virtual bool Vertical
{
get
{
if (x1 == x2)
{
return true;
}
return false;
}
}
public virtual Point Center
{
get
{
int x = (x1 + x2) / 2;
int y = (y1 + y2) / 2;
return new Point(x, y);
}
}
public virtual int Length
{
get
{
int num = Math.Abs(x2 - x1);
int num2 = Math.Abs(y2 - y1);
return QRCodeUtility.sqrt(num * num + num2 * num2);
}
}
public Line()
{
x1 = (y1 = (x2 = (y2 = 0)));
}
public Line(int x1, int y1, int x2, int y2)
{
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
}
public Line(Point p1, Point p2)
{
x1 = p1.X;
y1 = p1.Y;
x2 = p2.X;
y2 = p2.Y;
}
public virtual Point getP1()
{
return new Point(x1, y1);
}
public virtual Point getP2()
{
return new Point(x2, y2);
}
public virtual void setLine(int x1, int y1, int x2, int y2)
{
this.x1 = x1;
this.y1 = y1;
this.x2 = x2;
this.y2 = y2;
}
public virtual void setP1(Point p1)
{
x1 = p1.X;
y1 = p1.Y;
}
public virtual void setP1(int x1, int y1)
{
this.x1 = x1;
this.y1 = y1;
}
public virtual void setP2(Point p2)
{
x2 = p2.X;
y2 = p2.Y;
}
public virtual void setP2(int x2, int y2)
{
this.x2 = x2;
this.y2 = y2;
}
public virtual void translate(int dx, int dy)
{
x1 += dx;
y1 += dy;
x2 += dx;
y2 += dy;
}
public static bool isNeighbor(Line line1, Line line2)
{
if (Math.Abs(line1.getP1().X - line2.getP1().X) < 2 && Math.Abs(line1.getP1().Y - line2.getP1().Y) < 2 && Math.Abs(line1.getP2().X - line2.getP2().X) < 2 && Math.Abs(line1.getP2().Y - line2.getP2().Y) < 2)
{
return true;
}
return false;
}
public static bool isCross(Line line1, Line line2)
{
if (line1.Horizontal && line2.Vertical)
{
if (line1.getP1().Y > line2.getP1().Y && line1.getP1().Y < line2.getP2().Y && line2.getP1().X > line1.getP1().X && line2.getP1().X < line1.getP2().X)
{
return true;
}
}
else if (line1.Vertical && line2.Horizontal && line1.getP1().X > line2.getP1().X && line1.getP1().X < line2.getP2().X && line2.getP1().Y > line1.getP1().Y && line2.getP1().Y < line1.getP2().Y)
{
return true;
}
return false;
}
public static Line getLongest(Line[] lines)
{
Line line = new Line();
for (int i = 0; i < lines.Length; i++)
{
if (lines[i].Length > line.Length)
{
line = lines[i];
}
}
return line;
}
public override string ToString()
{
return "(" + Convert.ToString(x1) + "," + Convert.ToString(y1) + ")-(" + Convert.ToString(x2) + "," + Convert.ToString(y2) + ")";
}
}

View File

@@ -0,0 +1,93 @@
using System;
using MessagingToolkit.QRCode.Codec.Util;
namespace MessagingToolkit.QRCode.Geom;
public class Point
{
public const int RIGHT = 1;
public const int BOTTOM = 2;
public const int LEFT = 4;
public const int TOP = 8;
internal int x;
internal int y;
public virtual int X
{
get
{
return x;
}
set
{
x = value;
}
}
public virtual int Y
{
get
{
return y;
}
set
{
y = value;
}
}
public Point()
{
x = 0;
y = 0;
}
public Point(int x, int y)
{
this.x = x;
this.y = y;
}
public virtual void translate(int dx, int dy)
{
x += dx;
y += dy;
}
public virtual void set_Renamed(int x, int y)
{
this.x = x;
this.y = y;
}
public override string ToString()
{
return "(" + Convert.ToString(x) + "," + Convert.ToString(y) + ")";
}
public static Point getCenter(Point p1, Point p2)
{
return new Point((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2);
}
public bool equals(Point compare)
{
if (x == compare.x && y == compare.y)
{
return true;
}
return false;
}
public virtual int distanceOf(Point other)
{
int num = other.X;
int num2 = other.Y;
return QRCodeUtility.sqrt((x - num) * (x - num) + (y - num2) * (y - num2));
}
}

View File

@@ -0,0 +1,195 @@
namespace MessagingToolkit.QRCode.Geom;
public class SamplingGrid
{
private class AreaGrid
{
private SamplingGrid enclosingInstance;
private Line[] xLine;
private Line[] yLine;
public virtual int Width => xLine.Length;
public virtual int Height => yLine.Length;
public virtual Line[] XLines => xLine;
public virtual Line[] YLines => yLine;
public SamplingGrid Enclosing_Instance => enclosingInstance;
private void InitBlock(SamplingGrid enclosingInstance)
{
this.enclosingInstance = enclosingInstance;
}
public AreaGrid(SamplingGrid enclosingInstance, int width, int height)
{
InitBlock(enclosingInstance);
xLine = new Line[width];
yLine = new Line[height];
}
public virtual Line getXLine(int x)
{
return xLine[x];
}
public virtual Line getYLine(int y)
{
return yLine[y];
}
public virtual void setXLine(int x, Line line)
{
xLine[x] = line;
}
public virtual void setYLine(int y, Line line)
{
yLine[y] = line;
}
}
private AreaGrid[][] grid;
public virtual int TotalWidth
{
get
{
int num = 0;
for (int i = 0; i < grid.Length; i++)
{
num += grid[i][0].Width;
if (i > 0)
{
num--;
}
}
return num;
}
}
public virtual int TotalHeight
{
get
{
int num = 0;
for (int i = 0; i < grid[0].Length; i++)
{
num += grid[0][i].Height;
if (i > 0)
{
num--;
}
}
return num;
}
}
public SamplingGrid(int sqrtNumArea)
{
grid = new AreaGrid[sqrtNumArea][];
for (int i = 0; i < sqrtNumArea; i++)
{
grid[i] = new AreaGrid[sqrtNumArea];
}
}
public virtual void initGrid(int ax, int ay, int width, int height)
{
grid[ax][ay] = new AreaGrid(this, width, height);
}
public virtual void setXLine(int ax, int ay, int x, Line line)
{
grid[ax][ay].setXLine(x, line);
}
public virtual void setYLine(int ax, int ay, int y, Line line)
{
grid[ax][ay].setYLine(y, line);
}
public virtual Line getXLine(int ax, int ay, int x)
{
return grid[ax][ay].getXLine(x);
}
public virtual Line getYLine(int ax, int ay, int y)
{
return grid[ax][ay].getYLine(y);
}
public virtual Line[] getXLines(int ax, int ay)
{
return grid[ax][ay].XLines;
}
public virtual Line[] getYLines(int ax, int ay)
{
return grid[ax][ay].YLines;
}
public virtual int getWidth()
{
return grid[0].Length;
}
public virtual int getHeight()
{
return grid.Length;
}
public virtual int getWidth(int ax, int ay)
{
return grid[ax][ay].Width;
}
public virtual int getHeight(int ax, int ay)
{
return grid[ax][ay].Height;
}
public virtual int getX(int ax, int x)
{
int num = x;
for (int i = 0; i < ax; i++)
{
num += grid[i][0].Width - 1;
}
return num;
}
public virtual int getY(int ay, int y)
{
int num = y;
for (int i = 0; i < ay; i++)
{
num += grid[0][i].Height - 1;
}
return num;
}
public virtual void adjust(Point adjust)
{
int x = adjust.X;
int y = adjust.Y;
for (int i = 0; i < grid[0].Length; i++)
{
for (int j = 0; j < grid.Length; j++)
{
for (int k = 0; k < grid[j][i].XLines.Length; k++)
{
grid[j][i].XLines[k].translate(x, y);
}
for (int l = 0; l < grid[j][i].YLines.Length; l++)
{
grid[j][i].YLines[l].translate(x, y);
}
}
}
}
}