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

Commit 4b3f224

Browse files
committed
Updated UsefulThings nuget package.
Added comments for public functions.
1 parent b1319b7 commit 4b3f224

4 files changed

Lines changed: 33 additions & 11 deletions

File tree

CSharpImageLibrary/CSharpImageLibrary.csproj

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
66
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
77
<ProjectGuid>{10E9F41A-45D2-4CC4-B625-76C295FFDF67}</ProjectGuid>
8-
<OutputType>WinExe</OutputType>
8+
<OutputType>Library</OutputType>
99
<AppDesignerFolder>Properties</AppDesignerFolder>
1010
<RootNamespace>CSharpImageLibrary</RootNamespace>
1111
<AssemblyName>CSharpImageLibrary</AssemblyName>
@@ -59,6 +59,9 @@
5959
<PropertyGroup>
6060
<ApplicationIcon>ImageEngine.ico</ApplicationIcon>
6161
</PropertyGroup>
62+
<PropertyGroup>
63+
<StartupObject />
64+
</PropertyGroup>
6265
<ItemGroup>
6366
<Reference Include="Microsoft.IO.RecyclableMemoryStream, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
6467
<HintPath>..\packages\Microsoft.IO.RecyclableMemoryStream.1.1.0.0\lib\net45\Microsoft.IO.RecyclableMemoryStream.dll</HintPath>
@@ -76,19 +79,19 @@
7679
<Reference Include="System.Xaml">
7780
<RequiredTargetFramework>4.0</RequiredTargetFramework>
7881
</Reference>
79-
<Reference Include="UsefulThings, Version=1.5.6.0, Culture=neutral, processorArchitecture=MSIL">
80-
<SpecificVersion>False</SpecificVersion>
81-
<HintPath>..\..\UsefulThings\UsefulThings\bin\Debug\UsefulThings.dll</HintPath>
82+
<Reference Include="UsefulThings, Version=1.6.0.0, Culture=neutral, processorArchitecture=MSIL">
83+
<HintPath>..\packages\UsefulCSharpThings.1.6.0.0\lib\net462\UsefulThings.dll</HintPath>
84+
<Private>True</Private>
8285
</Reference>
8386
<Reference Include="WindowsBase" />
8487
<Reference Include="PresentationCore" />
8588
<Reference Include="PresentationFramework" />
8689
</ItemGroup>
8790
<ItemGroup>
88-
<ApplicationDefinition Include="App.xaml">
91+
<None Include="App.xaml">
8992
<Generator>MSBuild:Compile</Generator>
9093
<SubType>Designer</SubType>
91-
</ApplicationDefinition>
94+
</None>
9295
<Compile Include="DDSGeneral.cs" />
9396
<Compile Include="ImageEngineImage.cs" />
9497
<Compile Include="MipMap.cs" />

CSharpImageLibrary/DDSGeneral.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ namespace CSharpImageLibrary
1717
public static class DDSGeneral
1818
{
1919
static byte V8U8Adjust = 128; // KFreon: This is for adjusting out of signed land. This gets removed on load and re-added on save.
20+
21+
/// <summary>
22+
/// 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.
23+
/// </summary>
2024
public static float DXT1AlphaThreshold = 0.2f;
2125

2226
#region Header Stuff

CSharpImageLibrary/ImageEngineImage.cs

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ string EnumFlagStringify(Type enumType)
6161
return flags;
6262
}
6363

64+
/// <summary>
65+
/// DDS header if existing.
66+
/// </summary>
6467
public DDSGeneral.DDS_HEADER header { get; set; }
6568

6669
public string HeaderdwFlags
@@ -179,6 +182,7 @@ public ImageEngineImage(Stream stream, string extension = null)
179182
/// </summary>
180183
/// <param name="imagePath">Path to image file.</param>
181184
/// <param name="desiredMaxDimension">Max dimension to save.</param>
185+
/// <param name="enforceResize">True = forcibly resizes image. False = attempts to find a suitably sized mipmap, but doesn't resize if none found.</param>
182186
public ImageEngineImage(string imagePath, int desiredMaxDimension, bool enforceResize)
183187
{
184188
LoadFromFile(imagePath, desiredMaxDimension, enforceResize);
@@ -191,6 +195,7 @@ public ImageEngineImage(string imagePath, int desiredMaxDimension, bool enforceR
191195
/// <param name="stream">Full image stream.</param>
192196
/// <param name="extension">File extension of original image.</param>
193197
/// <param name="desiredMaxDimension">Maximum dimension.</param>
198+
/// <param name="enforceResize">True = forcibly resizes image. False = attempts to find a suitably sized mipmap, but doesn't resize if none found.</param>
194199
public ImageEngineImage(Stream stream, string extension, int desiredMaxDimension, bool enforceResize)
195200
{
196201
LoadFromStream(stream, extension, desiredMaxDimension, enforceResize);
@@ -214,7 +219,7 @@ public ImageEngineImage(byte[] imageFileData)
214219
/// </summary>
215220
/// <param name="imageFileData">Full image file data.</param>
216221
/// <param name="desiredMaxDimension">Maximum dimension.</param>
217-
/// <param name="enforceResize">True = resizes to desiredMaxDimension if no suitable mipmap.</param>
222+
/// <param name="enforceResize">True = forcibly resizes image. False = attempts to find a suitably sized mipmap, but doesn't resize if none found.</param>
218223
/// <param name="mergeAlpha">ONLY valid when enforeResize = true. True = flattens alpha, directly affecting RGB.</param>
219224
public ImageEngineImage(byte[] imageFileData, int desiredMaxDimension, bool enforceResize, bool mergeAlpha = false)
220225
{
@@ -284,8 +289,8 @@ private void LoadFromStream(Stream stream, string extension = null, int desiredM
284289
/// </summary>
285290
/// <param name="destination">File to save to.</param>
286291
/// <param name="format">Desired image format.</param>
287-
/// <param name="GenerateMips">True = Generates all mipmaps. False = Uses largest available Mipmap.</param>
288-
/// <param name="desiredMaxDimension">Maximum value of either image dimension.</param>
292+
/// <param name="GenerateMips">Determines how mipmaps are handled during saving.</param>
293+
/// <param name="desiredMaxDimension">Maximum size for saved image. Resizes if required, but uses mipmaps if available.</param>
289294
/// <param name="mergeAlpha">DXT1 only. True = Uses threshold value and alpha values to mask RGB.</param>
290295
/// <param name="mipToSave">Index of mipmap to save as single image.</param>
291296
/// <returns>True if success.</returns>
@@ -301,8 +306,8 @@ public bool Save(string destination, ImageEngineFormat format, MipHandling Gener
301306
/// </summary>
302307
/// <param name="destination">Stream to save to.</param>
303308
/// <param name="format">Format to save as.</param>
304-
/// <param name="GenerateMips">True = Generates all mipmaps. False = Uses largest available Mipmap.</param>
305-
/// <param name="desiredMaxDimension">Maximum value of either image dimension.</param>
309+
/// <param name="GenerateMips">Determines how mipmaps are handled during saving.</param>
310+
/// <param name="desiredMaxDimension">Maximum size for saved image. Resizes if required, but uses mipmaps if available.</param>
306311
/// <param name="mergeAlpha">ONLY valid when desiredMaxDimension != 0. True = alpha flattened, directly affecting RGB.</param>
307312
/// <param name="mipToSave">Selects a certain mip to save. 0 based.</param>
308313
/// <returns>True if success</returns>
@@ -312,6 +317,15 @@ public bool Save(Stream destination, ImageEngineFormat format, MipHandling Gener
312317
}
313318

314319

320+
/// <summary>
321+
/// Saves fully formatted image in specified format to byte array.
322+
/// </summary>
323+
/// <param name="format">Format to save as.</param>
324+
/// <param name="GenerateMips">Determines how mipmaps are handled during saving.</param>
325+
/// <param name="desiredMaxDimension">Maximum size for saved image. Resizes if required, but uses mipmaps if available.</param>
326+
/// <param name="mipToSave">Index of mipmap to save directly.</param>
327+
/// <param name="mergeAlpha">ONLY valid when desiredMaxDimension != 0. True = alpha flattened, directly affecting RGB.</param>
328+
/// <returns></returns>
315329
public byte[] Save(ImageEngineFormat format, MipHandling GenerateMips, int desiredMaxDimension = 0, int mipToSave = 0, bool mergeAlpha = false)
316330
{
317331
return ImageEngine.Save(MipMaps, format, GenerateMips, desiredMaxDimension, mipToSave, mergeAlpha);

CSharpImageLibrary/packages.config

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
33
<package id="Microsoft.IO.RecyclableMemoryStream" version="1.1.0.0" targetFramework="net46" />
4+
<package id="UsefulCSharpThings" version="1.6.0.0" targetFramework="net462" />
45
</packages>

0 commit comments

Comments
 (0)