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

Commit

Permalink
Updated UsefulThings nuget package.
Browse files Browse the repository at this point in the history
Added comments for public functions.
  • Loading branch information
KFreon committed Aug 28, 2016
1 parent b1319b7 commit 4b3f224
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
15 changes: 9 additions & 6 deletions CSharpImageLibrary/CSharpImageLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{10E9F41A-45D2-4CC4-B625-76C295FFDF67}</ProjectGuid>
<OutputType>WinExe</OutputType>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CSharpImageLibrary</RootNamespace>
<AssemblyName>CSharpImageLibrary</AssemblyName>
Expand Down Expand Up @@ -59,6 +59,9 @@
<PropertyGroup>
<ApplicationIcon>ImageEngine.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.IO.RecyclableMemoryStream, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IO.RecyclableMemoryStream.1.1.0.0\lib\net45\Microsoft.IO.RecyclableMemoryStream.dll</HintPath>
Expand All @@ -76,19 +79,19 @@
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="UsefulThings, Version=1.5.6.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\UsefulThings\UsefulThings\bin\Debug\UsefulThings.dll</HintPath>
<Reference Include="UsefulThings, Version=1.6.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\UsefulCSharpThings.1.6.0.0\lib\net462\UsefulThings.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<None Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
</None>
<Compile Include="DDSGeneral.cs" />
<Compile Include="ImageEngineImage.cs" />
<Compile Include="MipMap.cs" />
Expand Down
4 changes: 4 additions & 0 deletions CSharpImageLibrary/DDSGeneral.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ namespace CSharpImageLibrary
public static class DDSGeneral
{
static byte V8U8Adjust = 128; // KFreon: This is for adjusting out of signed land. This gets removed on load and re-added on save.

/// <summary>
/// Value at which alpha is included in DXT1 conversions. i.e. pixels lower than this threshold are made 100% transparent, and pixels higher are made 100% opaque.
/// </summary>
public static float DXT1AlphaThreshold = 0.2f;

#region Header Stuff
Expand Down
24 changes: 19 additions & 5 deletions CSharpImageLibrary/ImageEngineImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ string EnumFlagStringify(Type enumType)
return flags;
}

/// <summary>
/// DDS header if existing.
/// </summary>
public DDSGeneral.DDS_HEADER header { get; set; }

public string HeaderdwFlags
Expand Down Expand Up @@ -179,6 +182,7 @@ public ImageEngineImage(Stream stream, string extension = null)
/// </summary>
/// <param name="imagePath">Path to image file.</param>
/// <param name="desiredMaxDimension">Max dimension to save.</param>
/// <param name="enforceResize">True = forcibly resizes image. False = attempts to find a suitably sized mipmap, but doesn't resize if none found.</param>
public ImageEngineImage(string imagePath, int desiredMaxDimension, bool enforceResize)
{
LoadFromFile(imagePath, desiredMaxDimension, enforceResize);
Expand All @@ -191,6 +195,7 @@ public ImageEngineImage(string imagePath, int desiredMaxDimension, bool enforceR
/// <param name="stream">Full image stream.</param>
/// <param name="extension">File extension of original image.</param>
/// <param name="desiredMaxDimension">Maximum dimension.</param>
/// <param name="enforceResize">True = forcibly resizes image. False = attempts to find a suitably sized mipmap, but doesn't resize if none found.</param>
public ImageEngineImage(Stream stream, string extension, int desiredMaxDimension, bool enforceResize)
{
LoadFromStream(stream, extension, desiredMaxDimension, enforceResize);
Expand All @@ -214,7 +219,7 @@ public ImageEngineImage(byte[] imageFileData)
/// </summary>
/// <param name="imageFileData">Full image file data.</param>
/// <param name="desiredMaxDimension">Maximum dimension.</param>
/// <param name="enforceResize">True = resizes to desiredMaxDimension if no suitable mipmap.</param>
/// <param name="enforceResize">True = forcibly resizes image. False = attempts to find a suitably sized mipmap, but doesn't resize if none found.</param>
/// <param name="mergeAlpha">ONLY valid when enforeResize = true. True = flattens alpha, directly affecting RGB.</param>
public ImageEngineImage(byte[] imageFileData, int desiredMaxDimension, bool enforceResize, bool mergeAlpha = false)
{
Expand Down Expand Up @@ -284,8 +289,8 @@ private void LoadFromStream(Stream stream, string extension = null, int desiredM
/// </summary>
/// <param name="destination">File to save to.</param>
/// <param name="format">Desired image format.</param>
/// <param name="GenerateMips">True = Generates all mipmaps. False = Uses largest available Mipmap.</param>
/// <param name="desiredMaxDimension">Maximum value of either image dimension.</param>
/// <param name="GenerateMips">Determines how mipmaps are handled during saving.</param>
/// <param name="desiredMaxDimension">Maximum size for saved image. Resizes if required, but uses mipmaps if available.</param>
/// <param name="mergeAlpha">DXT1 only. True = Uses threshold value and alpha values to mask RGB.</param>
/// <param name="mipToSave">Index of mipmap to save as single image.</param>
/// <returns>True if success.</returns>
Expand All @@ -301,8 +306,8 @@ public bool Save(string destination, ImageEngineFormat format, MipHandling Gener
/// </summary>
/// <param name="destination">Stream to save to.</param>
/// <param name="format">Format to save as.</param>
/// <param name="GenerateMips">True = Generates all mipmaps. False = Uses largest available Mipmap.</param>
/// <param name="desiredMaxDimension">Maximum value of either image dimension.</param>
/// <param name="GenerateMips">Determines how mipmaps are handled during saving.</param>
/// <param name="desiredMaxDimension">Maximum size for saved image. Resizes if required, but uses mipmaps if available.</param>
/// <param name="mergeAlpha">ONLY valid when desiredMaxDimension != 0. True = alpha flattened, directly affecting RGB.</param>
/// <param name="mipToSave">Selects a certain mip to save. 0 based.</param>
/// <returns>True if success</returns>
Expand All @@ -312,6 +317,15 @@ public bool Save(Stream destination, ImageEngineFormat format, MipHandling Gener
}


/// <summary>
/// Saves fully formatted image in specified format to byte array.
/// </summary>
/// <param name="format">Format to save as.</param>
/// <param name="GenerateMips">Determines how mipmaps are handled during saving.</param>
/// <param name="desiredMaxDimension">Maximum size for saved image. Resizes if required, but uses mipmaps if available.</param>
/// <param name="mipToSave">Index of mipmap to save directly.</param>
/// <param name="mergeAlpha">ONLY valid when desiredMaxDimension != 0. True = alpha flattened, directly affecting RGB.</param>
/// <returns></returns>
public byte[] Save(ImageEngineFormat format, MipHandling GenerateMips, int desiredMaxDimension = 0, int mipToSave = 0, bool mergeAlpha = false)
{
return ImageEngine.Save(MipMaps, format, GenerateMips, desiredMaxDimension, mipToSave, mergeAlpha);
Expand Down
1 change: 1 addition & 0 deletions CSharpImageLibrary/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.IO.RecyclableMemoryStream" version="1.1.0.0" targetFramework="net46" />
<package id="UsefulCSharpThings" version="1.6.0.0" targetFramework="net462" />
</packages>

0 comments on commit 4b3f224

Please sign in to comment.