mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-09 18:12:32 +02:00
3130ebe0f2
- **Tools:** - (Add) PCB exposure: Converts a gerber file to a pixel perfect image given your printer LCD/resolution to exposure the copper traces. - (Improvement) Export settings now indent the XML to be more user friendly to edit - (Improvement) Layer import: Allow to have profiles - (Improvement) Layer import: Validates if selected files exists before execute - (Fix) Lithophane: Disallow having start threshold equal to end threshold - (Add) Windows explorer: Right-click on files will show "Open with UVtools" on context menu which opens the selected file on UVtools (Windows MSI only) - (Improvement) Island and overhang detection: Ignore detection on all layers that are in direct contact with the plate (On same first layer position) - (Improvement) Cmd: Better error messages for convert command when using shared extensions and no extension
115 lines
3.6 KiB
C#
115 lines
3.6 KiB
C#
using Emgu.CV;
|
|
using Emgu.CV.CvEnum;
|
|
using System;
|
|
using UVtools.Core.Layers;
|
|
using UVtools.Core.Operations;
|
|
using Size = System.Drawing.Size;
|
|
|
|
namespace UVtools.Core.FileFormats;
|
|
|
|
public class ImageFile : FileFormat
|
|
{
|
|
public override FileFormatType FileType => FileFormatType.Binary;
|
|
|
|
public override FileExtension[] FileExtensions { get; } =
|
|
{
|
|
new (typeof(ImageFile), "png", "PNG: Portable Network Graphics"),
|
|
new (typeof(ImageFile), "jpg", "JPG: Joint Photographic Experts Group"),
|
|
new (typeof(ImageFile), "jpeg", "JPEG: Joint Photographic Experts Group"),
|
|
new (typeof(ImageFile), "jp2", "JP2: Joint Photographic Experts Group (JPEG 2000)"),
|
|
//new (typeof(ImageFile), "tga", "TGA: Truevision"),
|
|
new (typeof(ImageFile), "tif", "TIF: Tag Image File Format"),
|
|
new (typeof(ImageFile), "tiff", "TIFF: Tag Image File Format"),
|
|
new (typeof(ImageFile), "bmp", "BMP: Bitmap"),
|
|
new (typeof(ImageFile), "pbm", "PBM: Portable Bitmap"),
|
|
new (typeof(ImageFile), "pgm", "PGM: Portable Greymap"),
|
|
//new (typeof(ImageFile), "gif", "GIF"),
|
|
new (typeof(ImageFile), "sr", "SR: Sun raster"),
|
|
new (typeof(ImageFile), "ras", "RAS: Sun raster"),
|
|
};
|
|
public override PrintParameterModifier[]? PrintParameterModifiers => null;
|
|
|
|
public override Size[]? ThumbnailsOriginalSize { get; } = {
|
|
Size.Empty,
|
|
Size.Empty,
|
|
Size.Empty,
|
|
Size.Empty
|
|
};
|
|
public override uint ResolutionX
|
|
{
|
|
get => (uint) ImageMat.Width;
|
|
set => throw new NotImplementedException();
|
|
}
|
|
|
|
public override uint ResolutionY
|
|
{
|
|
get => (uint) ImageMat.Height;
|
|
set => throw new NotImplementedException();
|
|
}
|
|
|
|
public override float DisplayWidth
|
|
{
|
|
get => ResolutionX;
|
|
set
|
|
{
|
|
ResolutionX = (uint) value;
|
|
RaisePropertyChanged();
|
|
}
|
|
}
|
|
|
|
public override float DisplayHeight
|
|
{
|
|
get => ResolutionY;
|
|
set
|
|
{
|
|
ResolutionY = (uint) value;
|
|
RaisePropertyChanged();
|
|
}
|
|
}
|
|
|
|
public override float LayerHeight { get; set; } = 0.01f;
|
|
/*public override float PrintTime { get; } = 0;
|
|
public override float UsedMaterial { get; } = 0;
|
|
public override float MaterialCost { get; } = 0;
|
|
public override string MaterialName { get; } = null;
|
|
public override string MachineName { get; } = null;*/
|
|
|
|
private Mat ImageMat { get; set; } = null!;
|
|
|
|
protected override void EncodeInternally(OperationProgress progress)
|
|
{
|
|
this[0].LayerMat.Save(TemporaryOutputFileFullPath);
|
|
}
|
|
|
|
protected override void DecodeInternally(OperationProgress progress)
|
|
{
|
|
ImageMat = CvInvoke.Imread(FileFullPath, ImreadModes.Grayscale);
|
|
const byte startDivisor = 2;
|
|
for (int i = 0; i < ThumbnailsCount; i++)
|
|
{
|
|
Thumbnails[i] = new Mat();
|
|
var divisor = (i + 1) * startDivisor;
|
|
CvInvoke.Resize(ImageMat, Thumbnails[i],
|
|
new Size(ImageMat.Width / divisor, ImageMat.Height / divisor));
|
|
}
|
|
|
|
/*if (ImageMat.NumberOfChannels > 1)
|
|
{
|
|
CvInvoke.CvtColor(ImageMat, ImageMat, ColorConversion.Bgr2Gray);
|
|
}*/
|
|
Init(1);
|
|
this[0] = new Layer(0, ImageMat, this);
|
|
}
|
|
|
|
protected override void PartialSaveInternally(OperationProgress progress)
|
|
{
|
|
this[0].LayerMat.Save(TemporaryOutputFileFullPath);
|
|
}
|
|
|
|
public override FileFormat Convert(Type to, string fileFullPath, uint version = 0, OperationProgress? progress = null)
|
|
{
|
|
throw new NotSupportedException();
|
|
}
|
|
|
|
|
|
} |