mirror of
https://github.com/riegera2412/UVtools.git
synced 2026-07-11 19:12:31 +02:00
6d661821b5
* (Add) Changelog description to the new version update dialog * (Add) Tool - Infill: Proper configurable infills * (Add) Pixel area as "px²" to the layer bounds and ROI at layer bottom information bar * (Add) Pixel dimming: Alternate pattern every x layers * (Add) Pixel dimming: Lattice infill * (Add) Solidify: Required minimum/maximum area to solidify found areas (Default values will produce the old behaviour) * (Add) Issues: Allow to hide and ignore selected issues * (Add) Issue - Touch boundary: Allow to configure Left, Top, Right, Bottom margins in pixels, defaults to 5px (#94) * (Add) UVJ: Allow convert to another formats (#96) * (Add) Setters to some internal Core properties for more abstraction * (Improvement) Issue - Touch boundary: Only check boundary pixels if layer bounds overlap the set margins, otherwise, it will not waste cycles on check individual rows of pixels when not need to * (Change) Place .ctb extension show first than .cbddlp due more popular this days * (Change) Pixel dimming: Text "Borders" to "Walls" * (Change) Issues: Remove "Remove" text from button, keep only the icon to free up space * (Change) Ungroup extensions on "covert to" menu (#97) * (Fix) Issues: Detect button has a incorrect "save" icon * (Fix) SL1: Increase NumSlow property limit * (Fix) UVJ: not decoding nor showing preview images * (Fix) "Convert to" menu shows same options than previous loaded file when current file dont support convertions (#96) * (Fix) Hides "Convert to" menu when unable to convert to another format (#96) * (Fix) Program crash when demo file is disabled and tries to load a file in * (Fix) Rare crash on startup when mouse dont move in startup period and user types a key in meanwhile * (Fix) On a slow startup on progress window it will show "Decoded layers" as default text, changed to "Initializing"
106 lines
3.4 KiB
C#
106 lines
3.4 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 FileExtension("jpg", "JPG"),
|
|
new FileExtension("jpeg", "JPEG"),
|
|
new FileExtension("png", "PNG"),
|
|
new FileExtension("bmp", "BMP"),
|
|
new FileExtension("gif", "GIF"),
|
|
new FileExtension("tga", "TGA"),
|
|
};
|
|
|
|
public override Type[] ConvertToFormats { get; } = null;
|
|
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 byte AntiAliasing { get; } = 1;
|
|
public override float LayerHeight { get; set; } = 0;
|
|
/*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; }
|
|
|
|
public override void Decode(string fileFullPath, OperationProgress progress = null)
|
|
{
|
|
base.Decode(fileFullPath, 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 bool Convert(Type to, string fileFullPath, OperationProgress progress = null)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
|
|
}
|
|
}
|