Skip to content

Commit

Permalink
Fixed Image Preview
Browse files Browse the repository at this point in the history
  • Loading branch information
PodeCaradox committed Dec 18, 2020
1 parent 5eb893f commit 4b4185d
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Gm1KonverterCrossPlatform/Files/Palette.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private unsafe WriteableBitmap PalleteToImG(int palette,int pixelSize)
int height = 8 * pixelSize;
int width = 32 * pixelSize;
UInt32 colorByte=0;
WriteableBitmap bitmap = new WriteableBitmap(new Avalonia.PixelSize(width, height), new Avalonia.Vector(100, 100), Avalonia.Platform.PixelFormat.Bgra8888);// Bgra8888 is device-native and much faster.
WriteableBitmap bitmap = new WriteableBitmap(new Avalonia.PixelSize(width, height), new Avalonia.Vector(96, 96), Avalonia.Platform.PixelFormat.Bgra8888);// Bgra8888 is device-native and much faster.
using (var buf = bitmap.Lock())
{
for (int y = 0; y < height; y++)
Expand Down
6 changes: 3 additions & 3 deletions Gm1KonverterCrossPlatform/Files/TGXImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,14 @@ public unsafe void CreateImageFromByteArray(Palette palette,bool isTgxFile=false
{
width = this.width;
height = this.height;
bmp = new WriteableBitmap(new Avalonia.PixelSize(width, height), new Avalonia.Vector(100, 100), Avalonia.Platform.PixelFormat.Bgra8888);// Bgra8888 is device-native and much faster.
bmp = new WriteableBitmap(new Avalonia.PixelSize(width, height), new Avalonia.Vector(96, 96), Avalonia.Platform.PixelFormat.Bgra8888);// Bgra8888 is device-native and much faster.

}
else
{
width = (int)tgxwidth;
height = (int)tgxheight;
bmp = new WriteableBitmap(new Avalonia.PixelSize(width, height), new Avalonia.Vector(100, 100), Avalonia.Platform.PixelFormat.Bgra8888);// Bgra8888 is device-native and much faster.
bmp = new WriteableBitmap(new Avalonia.PixelSize(width, height), new Avalonia.Vector(96, 96), Avalonia.Platform.PixelFormat.Bgra8888);// Bgra8888 is device-native and much faster.

}

Expand Down Expand Up @@ -265,7 +265,7 @@ internal void ConvertImageWithPaletteToByteArray(List<ushort> colors, int width,
internal unsafe void CreateNoComppressionImageFromByteArray(Palette palette,int offset)
{
//-7 because the images only height -7 long idk why
bmp = new WriteableBitmap(new Avalonia.PixelSize(width, height - offset), new Avalonia.Vector(100, 100), Avalonia.Platform.PixelFormat.Bgra8888);// Bgra8888 is device-native and much faster.
bmp = new WriteableBitmap(new Avalonia.PixelSize(width, height - offset), new Avalonia.Vector(96, 96), Avalonia.Platform.PixelFormat.Bgra8888);// Bgra8888 is device-native and much faster.

using (var buf = bmp.Lock())
{
Expand Down
2 changes: 1 addition & 1 deletion Gm1KonverterCrossPlatform/Files/TilesImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ internal unsafe void CreateImagefromList()
minusHeight = Puffer;
}
height = height - minusHeight;
bmp = new WriteableBitmap(new Avalonia.PixelSize(width, height), new Avalonia.Vector(100, 100), Avalonia.Platform.PixelFormat.Bgra8888);// Bgra8888 is device-native and much faster.
bmp = new WriteableBitmap(new Avalonia.PixelSize(width, height), new Avalonia.Vector(96, 96), Avalonia.Platform.PixelFormat.Bgra8888);// Bgra8888 is device-native and much faster.

using (var buf = bmp.Lock())
{
Expand Down
7 changes: 6 additions & 1 deletion Gm1KonverterCrossPlatform/Gm1KonverterCrossPlatform.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net461</TargetFrameworks>
<RuntimeIdentifiers>win10-x64;osx;linux-x64</RuntimeIdentifiers>
<RuntimeIdentifiers>win10-x64;osx;linux-x64;win7-x32</RuntimeIdentifiers>
<LangVersion>7.2</LangVersion>
<ApplicationIcon>Assets\avalonia-logo.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net461|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Compile Update="**\*.xaml.cs">
Expand Down
4 changes: 2 additions & 2 deletions Gm1KonverterCrossPlatform/HelperClasses/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ internal unsafe static WriteableBitmap LoadImageAsBitmap(String filename, ref in
var image = Image.Load<Rgba32>(filename);
if (width == 0) width = image.Width;
if (height == 0) height = image.Height;
WriteableBitmap bitmap = new WriteableBitmap(new PixelSize(width, height),new Vector(300,300),Avalonia.Platform.PixelFormat.Rgba8888);
WriteableBitmap bitmap = new WriteableBitmap(new PixelSize(width, height),new Vector(96,96),Avalonia.Platform.PixelFormat.Rgba8888);
using (var bit = bitmap.Lock())
{
try
Expand Down Expand Up @@ -444,7 +444,7 @@ private static unsafe WriteableBitmap CreateBigImage(List<WriteableBitmap> bitma
}


WriteableBitmap bigImage = new WriteableBitmap(new Avalonia.PixelSize(maxwidth, maxheight), new Avalonia.Vector(100, 100), Avalonia.Platform.PixelFormat.Bgra8888);// Bgra8888 is device-native and much faster.
WriteableBitmap bigImage = new WriteableBitmap(new Avalonia.PixelSize(maxwidth, maxheight), new Avalonia.Vector(96, 96), Avalonia.Platform.PixelFormat.Bgra8888);// Bgra8888 is device-native and much faster.
using (var buf = bigImage.Lock())
{
int xoffset = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PublishDir>bin\Release\net461\publish\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net461</TargetFramework>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<RuntimeIdentifier>win7-x32</RuntimeIdentifier>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion Gm1KonverterCrossPlatform/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<MenuItem Header="{DynamicResource ImportImages}" Name="ImportImagesMenueItem" IsEnabled="{Binding ImportButtonEnabled}" Click="ImportImages"/>
<Separator/>
<MenuItem Header="{DynamicResource ImageSize}" Name="BigImageSizeMenueItem" IsEnabled="{Binding ButtonsEnabled}">
<TextBox Name="BigImageSizeTeytItem" Width="100" Text="{Binding BigImageWidth}"/>
<TextBox Name="BigImageSizeTeytItem" Width="100" Text="{Binding BigImageWidth}" />
</MenuItem>
<MenuItem Header="{DynamicResource ExportBigImage}" Name="ExportBigImageMenueItem" IsEnabled="{Binding ButtonsEnabled}" Click="ExportBigImage"/>
<MenuItem Header="{DynamicResource ImportBigImage}" Name="ImportBigImageMenueItem" IsEnabled="{Binding ImportButtonEnabled}" Click="ImportBigImage"/>
Expand Down

0 comments on commit 4b4185d

Please sign in to comment.