AnagramViewer will now gladly display all your PNGs, for great justice.
This commit is contained in:
parent
e020969df0
commit
bc9bc35c5b
29
GUIs/skyscraper8.AnagramViewer/Handlers/PngHandler.cs
Normal file
29
GUIs/skyscraper8.AnagramViewer/Handlers/PngHandler.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using skyscraper5.Skyscraper.IO;
|
||||
|
||||
namespace skyscraper8.AnagramViewer.Handlers
|
||||
{
|
||||
internal class PngHandler : IFileTypeHandler
|
||||
{
|
||||
public DataType CheckDataType(Stream input)
|
||||
{
|
||||
if (input.ReadUInt32LE() == 1196314761)
|
||||
return DataType.Image;
|
||||
return DataType.Unknown;
|
||||
}
|
||||
|
||||
public Image AsImage(Stream input)
|
||||
{
|
||||
return Image.FromStream(input);
|
||||
}
|
||||
|
||||
public string AsText(Stream input)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -61,17 +61,20 @@ namespace skyscraper8.AnagramViewer
|
||||
return;
|
||||
}
|
||||
|
||||
Form finalForm = null;
|
||||
switch (determiendDataType)
|
||||
{
|
||||
case DataType.Image:
|
||||
Image asImage = usableHandler.AsImage(bufferedStream);
|
||||
ImageViewer imageViewer = new ImageViewer(asImage);
|
||||
Application.Run(imageViewer);
|
||||
return;
|
||||
finalForm = new ImageViewer(asImage);
|
||||
break;
|
||||
default:
|
||||
MessageBox.Show(String.Format("Don't know how to handle files of type {0}", determiendDataType.ToString()));
|
||||
return;
|
||||
}
|
||||
|
||||
finalForm.Text = String.Format("Anagram Viewer - [{0}]", fi.Name);
|
||||
Application.Run(finalForm);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,7 @@
|
||||
"profiles": {
|
||||
"skyscraper8.AnagramViewer": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "\"C:\\Users\\Sascha Schiemann\\source\\repos\\skyscraper8\\skyscraper8\\bin\\Debug\\net8.0\\iq.bin\""
|
||||
"commandLineArgs": "\"Y:\\data\\outputs\\txt2img-images\\2025-07-20\\00025-394627821.png\""
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user