chore : remove unused files
This commit is contained in:
parent
c390415b6e
commit
695525d24d
2 changed files with 0 additions and 97 deletions
|
|
@ -1,82 +0,0 @@
|
|||
using SixLabors.ImageSharp;
|
||||
using SixLabors.ImageSharp.PixelFormats;
|
||||
using SixLabors.ImageSharp.Processing;
|
||||
|
||||
namespace StitcherApi.Services.Utilities;
|
||||
|
||||
public class StitchProcessor
|
||||
{
|
||||
private readonly string _assetPath;
|
||||
private readonly ILogger<StitchProcessor> _logger;
|
||||
private const int TILE_SIZE = 720;
|
||||
|
||||
public StitchProcessor(string assetPath, ILogger<StitchProcessor> logger)
|
||||
{
|
||||
_assetPath = assetPath;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<byte[]> ProcessAsync(StitchRequest stitchRequest)
|
||||
{
|
||||
using Image<Rgba32> finalImage = new(stitchRequest.CropW, stitchRequest.CropH);
|
||||
|
||||
for (int r = stitchRequest.StartTileRow; r <= stitchRequest.EndTileRow; r++)
|
||||
{
|
||||
for (int c = stitchRequest.StartTileCol; c <= stitchRequest.EndTileCol; c++)
|
||||
{
|
||||
string tileFileName = TileHelper.GetTileFileName(r, c);
|
||||
string tileFilePath = Path.Combine(_assetPath, tileFileName);
|
||||
|
||||
if (!File.Exists(tileFilePath))
|
||||
{
|
||||
throw new FileNotFoundException($"Asset not found: {tileFileName}");
|
||||
}
|
||||
|
||||
using Image<Rgba32> tileImage = await Image.LoadAsync<Rgba32>(tileFilePath);
|
||||
|
||||
int tileOriginX = (c - stitchRequest.MinCol) * TILE_SIZE;
|
||||
int tileOriginY = (r - stitchRequest.MinRow) * TILE_SIZE;
|
||||
|
||||
int srcX = Math.Max(0, stitchRequest.CropX - tileOriginX);
|
||||
int srcY = Math.Max(0, stitchRequest.CropY - tileOriginY);
|
||||
int destX = Math.Max(0, tileOriginX - stitchRequest.CropX);
|
||||
int destY = Math.Max(0, tileOriginY - stitchRequest.CropY);
|
||||
|
||||
int overlapW = Math.Max(
|
||||
0,
|
||||
Math.Min(stitchRequest.CropX + stitchRequest.CropW, tileOriginX + TILE_SIZE)
|
||||
- Math.Max(stitchRequest.CropX, tileOriginX)
|
||||
);
|
||||
int overlapH = Math.Max(
|
||||
0,
|
||||
Math.Min(stitchRequest.CropY + stitchRequest.CropH, tileOriginY + TILE_SIZE)
|
||||
- Math.Max(stitchRequest.CropY, tileOriginY)
|
||||
);
|
||||
|
||||
if (overlapW > 0 && overlapH > 0)
|
||||
{
|
||||
Rectangle sourceRect = new Rectangle(srcX, srcY, overlapW, overlapH);
|
||||
finalImage.Mutate(ctx =>
|
||||
ctx.DrawImage(
|
||||
tileImage,
|
||||
new Point(destX, destY),
|
||||
sourceRect,
|
||||
new GraphicsOptions()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stitchRequest.OutputScale > 0 && stitchRequest.OutputScale < 1.0)
|
||||
{
|
||||
int newWidth = (int)(stitchRequest.CropW * stitchRequest.OutputScale);
|
||||
int newHeight = (int)(stitchRequest.CropH * stitchRequest.OutputScale);
|
||||
finalImage.Mutate(x => x.Resize(newWidth, newHeight, KnownResamplers.Bicubic));
|
||||
}
|
||||
|
||||
using MemoryStream memoryStream = new MemoryStream();
|
||||
await finalImage.SaveAsPngAsync(memoryStream);
|
||||
return memoryStream.ToArray();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
namespace StitcherApi.Services.Utilities;
|
||||
|
||||
public record StitchRequest(
|
||||
int MinRow,
|
||||
int MinCol,
|
||||
int StartTileRow,
|
||||
int StartTileCol,
|
||||
int EndTileRow,
|
||||
int EndTileCol,
|
||||
int CropX,
|
||||
int CropY,
|
||||
int CropW,
|
||||
int CropH,
|
||||
float OutputScale
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue