Files
UVtools/UVtools.Core/FileFormats/ImageFile.cs
T
Tiago Conceição f69a0f1175 v2.4.6
* **(Improvement) Calibration - Elephant Foot:** (#145)
   * Remove text from bottom layers to prevent islands from not adhering to plate
   * Add a option to extrude text up to a height
* **(Improvement) Calibration - Exposure time finder:** (#144)
   * Increase the left and right margin to 10mm
   * Allow to iterate over pixel brightness and generate dimmed objects to test multiple times at once
* **(Fix) File format PWS:**
   * Some files would produce black layers if pixels are not full whites, Antialiasing level was not inherit from source
   * Antialiasing level was forced 1 and not read the value from file properties
   * Antialiasing threshold pixel math was producing the wrong pixel value
* **(Fix) Raw images (jpg, png, etc):** (#146)
   * Set layer height to be 0.01mm by default to allow the use of some tools
   * When add layers by clone or other tool it don't update layers height, positions, indexes, leading to crashes
* **(Fix) Actions - Import Layers:** (#146, #147)
   * ROI calculation error leading to not process images that can potential fit inside the volumes
   * Out-of-bounds calculation for Stack type
   * Replace type was calculating out-of-bounds calculation like Stack type when is not required to and can lead to skip images
   * Better image ROI colection for Insert and Replace types instead of capture the center most
* (Fix) Settings window: Force a redraw on open to fix auto sizes
2021-02-15 22:30:26 +00:00

118 lines
3.5 KiB
C#

using System;
using Emgu.CV;
using Emgu.CV.CvEnum;
using UVtools.Core.Operations;
using Size = System.Drawing.Size;
namespace UVtools.Core.FileFormats
{
public class ImageFile : FileFormat
{
public override FileFormatType FileType { get; } = FileFormatType.Binary;
public override FileExtension[] FileExtensions { get; } =
{
new ("jpg", "JPG"),
new ("jpeg", "JPEG"),
new ("png", "PNG"),
new ("bmp", "BMP"),
new ("gif", "GIF"),
new ("tga", "TGA"),
};
public override PrintParameterModifier[] PrintParameterModifiers { get; } = null;
public override byte ThumbnailsCount { get; } = 4;
public override Size[] ThumbnailsOriginalSize { get; } = null;
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 bool MirrorDisplay
{
get => false;
set { }
}
public override byte AntiAliasing
{
get => 1;
set { }
}
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;*/
public override object[] Configs { get; } = null;
private Mat ImageMat { get; set; }
protected override void EncodeInternally(string fileFullPath, OperationProgress progress)
{
throw new NotSupportedException();
}
protected override void DecodeInternally(string fileFullPath, 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);
}*/
LayerManager = new LayerManager(1, this);
this[0] = new Layer(0, ImageMat, LayerManager);
}
public override void SaveAs(string filePath = null, OperationProgress progress = null)
{
this[0].LayerMat.Save(filePath ?? FileFullPath);
}
public override FileFormat Convert(Type to, string fileFullPath, OperationProgress progress = null)
{
throw new NotSupportedException();
}
}
}