Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Commit

Permalink
Fixed #9 - problem with scaling parameters weren't working.
Browse files Browse the repository at this point in the history
  • Loading branch information
KFreon committed Dec 29, 2016
1 parent 8bf6ff4 commit 8ac2da9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
10 changes: 5 additions & 5 deletions CSharpImageLibrary/DDS/DDSGeneral.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ private static MipMap ReadCompressedMipMap(MemoryStream compressed, int mipWidth
});

// Actually perform decompression using threading, no threading, or GPU.
if (ImageEngine.EnableGPUAcceleration)
/*if (ImageEngine.EnableGPUAcceleration)
Debugger.Break();
else if (ImageEngine.EnableThreading)
else */if (ImageEngine.EnableThreading)
Parallel.For(0, texelCount, new ParallelOptions { MaxDegreeOfParallelism = ImageEngine.NumThreads }, (texelIndex, loopstate) => action(texelIndex, loopstate));
else
for (int texelIndex = 0; texelIndex < texelCount; texelIndex++)
Expand Down Expand Up @@ -258,7 +258,7 @@ internal static byte[] Save(List<MipMap> mipMaps, ImageEngineFormat saveFormat,
compressor = DDS_Encoders.CompressBC5Block;
break;
case ImageEngineFormat.DDS_DX10:
Debugger.Break();
//Debugger.Break();
break; // TODO: NOT SUPPORTED YET. DX10
case ImageEngineFormat.DDS_DXT1:
compressor = DDS_Encoders.CompressBC1Block;
Expand Down Expand Up @@ -346,9 +346,9 @@ static int WriteCompressedMipMap(byte[] destination, int mipOffset, MipMap mipma
});

// Choose an acceleration method.
if (ImageEngine.EnableGPUAcceleration)
/*if (ImageEngine.EnableGPUAcceleration)
Debugger.Break();
else if (ImageEngine.EnableThreading)
else*/ if (ImageEngine.EnableThreading)
Parallel.For(0, destinationTexelCount, new ParallelOptions { MaxDegreeOfParallelism = ImageEngine.NumThreads }, mipWriter);
else
for (int i = 0; i < destinationTexelCount; i++)
Expand Down
13 changes: 12 additions & 1 deletion CSharpImageLibrary/WIC_Codecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ internal static List<MipMap> LoadWithCodecs(Stream stream, int decodeWidth, int
// KFreon: Skip mipmaps that are too big if asked to load a smaller image
if (alternateDecodeDimensions)
{
if (mipmap.Width > alternateWidth || mipmap.Height > alternateHeight)
if ((alternateWidth != 0 && mipmap.Width > alternateWidth) ||
(alternateHeight != 0 && mipmap.Height > alternateHeight))
continue;
}

Expand All @@ -122,6 +123,16 @@ internal static List<MipMap> LoadWithCodecs(Stream stream, int decodeWidth, int
// KFreon: Image has no mips, so resize largest
var frame = decoder.Frames[0];
var mip = new MipMap(frame.GetPixelsAsBGRA32(), frame.PixelWidth, frame.PixelHeight);

// Calculate scale if required
if (scale == 0)
{
double xScale = alternateWidth * 1.0 / frame.PixelWidth;
double yScale = alternateHeight * 1.0 / frame.PixelHeight;

scale = xScale == 0 ? yScale : xScale;
}

mip = ImageEngine.Resize(mip, scale);
mipmaps.Add(mip);
}
Expand Down
2 changes: 1 addition & 1 deletion UI_Project/NewMainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@
</Canvas>


<Label Content="Header Details" Grid.Column="1" FontWeight="Bold" FontSize="13" HorizontalAlignment="Center" IsHitTestVisible="False" Margin="128,0,128.333,0.333" Width="99"/>
<Label Content="Header Details" Grid.Column="1" FontWeight="Bold" FontSize="13" HorizontalAlignment="Center" IsHitTestVisible="False" VerticalAlignment="Top"/>
<ScrollViewer Grid.Column="1" Margin="1,25,0.333,0.333" HorizontalScrollBarVisibility="Auto">
<TextBox Text="{Binding HeaderDetails, Mode=OneWay}" Background="Transparent" Foreground="White" FontSize="10"/>
</ScrollViewer>
Expand Down

0 comments on commit 8ac2da9

Please sign in to comment.