(stream);
- Console.WriteLine($"Read the file as image: {img.ToString()}");
- var px = img[0, 0];
-
- if(img.Width > 128)
- {
- img.Mutate(x => x.Resize(128, 0));
- }
- else if(img.Height > 128)
- {
- img.Mutate(x => x.Resize(0, 128));
- }
- Console.WriteLine($"Resized image to {img.ToString()}");
- outputColumns = img.Width;
- outputRows = img.Height;
- var buffer = new TextureMetadata[outputColumns, outputRows];
- for(int x = 0; x < outputColumns; x++)
- {
- for(int y = 0; y < outputRows; y++)
- {
- buffer[x, y] = FindBestMatchingTexture(img[x, y]);
- }
- }
- Console.WriteLine("Done processing image.");
- outputTextures = buffer;
- img.Dispose();
- this.StateHasChanged();
- }
- catch(Exception ex)
- {
- Console.WriteLine(ex.Message);
+ imageReconstructor.ReadFile(selectedFile.OpenReadStream(fileSizeLimit));
}
}
- private TextureMetadata FindBestMatchingTexture(Rgba32 pixel)
- {
- RGB col = new() { r = pixel.R, g = pixel.G, b = pixel.B };
- return textureData.OrderBy(x => x.averageRGB.RGBDistance(col)).First();
- }
+ Task IHandleEvent.HandleEventAsync(EventCallbackWorkItem callback, object? arg)
+ => callback.InvokeAsync(arg);
}
-
-Index
-
-Hello, world!
-Welcome to your new app.
+Img2Mc
-
+
+ Max Size: @imageReconstructor.MaxOutputImageSize
+
+
+ Block Size: @blockSize
+
+
+ Contrast Bias: @imageReconstructor.ContrastBias
+
+Retry
-
-
+Please Select an image file:
-
+
-@if(outputTextures != null)
+ @if (imageReconstructor.OutputTextures != null)
{
Output texture is not null here
- @for(int row = 0; row < outputRows; row++)
+ @for (int row = 0; row < imageReconstructor.OutputRows; row++)
{
-
- @for(int column = 0; column < outputColumns; column ++)
- {
-
-
-
- |
- }
+
+ @for (int column = 0; column < imageReconstructor.OutputColumns; column++)
+ {
+ var tex = imageReconstructor.OutputTextures[column, row];
+
+
+
+
+
+ |
+ }
}
}
+Required blocks
+
+ @foreach (var pair in imageReconstructor.blockCounts.OrderByDescending(x => x.Value))
+ {
+ -
+ @pair.Key.blockName x @pair.Value
+
+ }
+
+
+