diff --git a/.editorconfig b/.editorconfig
index 33fd057..f579ff5 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,5 +1,5 @@
-# Version: 2.1.0 (Using https://semver.org/)
-# Updated: 2021-03-03
+# Version: 4.1.1 (Using https://semver.org/)
+# Updated: 2022-05-23
# See https://github.com/RehanSaeed/EditorConfig/releases for release notes.
# See https://github.com/RehanSaeed/EditorConfig for updates to this file.
# See http://EditorConfig.org for more information about .editorconfig files.
@@ -49,11 +49,11 @@ indent_size = 2
indent_size = 2
# Markdown Files
-[*.md]
+[*.{md,mdx}]
trim_trailing_whitespace = false
# Web Files
-[*.{htm,html,js,jsm,ts,tsx,css,sass,scss,less,svg,vue}]
+[*.{htm,html,js,jsm,ts,tsx,cjs,cts,ctsx,mjs,mts,mtsx,css,sass,scss,less,pcss,svg,vue}]
indent_size = 2
# Batch Files
@@ -75,7 +75,7 @@ indent_style = tab
[*.{cs,csx,cake,vb,vbx}]
# Default Severity for all .NET Code Style rules below
-dotnet_analyzer_diagnostic.category-style.severity = warning
+dotnet_analyzer_diagnostic.severity = warning
##########################################
# Language Rules
@@ -104,8 +104,8 @@ dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:war
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning
dotnet_style_parentheses_in_other_operators = always_for_clarity:suggestion
# Expression-level preferences
-dotnet_style_object_initializer = true:warning
-dotnet_style_collection_initializer = true:warning
+dotnet_style_object_initializer = true:error
+dotnet_style_collection_initializer = true:error
dotnet_style_explicit_tuple_names = true:warning
dotnet_style_prefer_inferred_tuple_names = true:warning
dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning
@@ -122,21 +122,22 @@ dotnet_style_coalesce_expression = true:warning
dotnet_style_null_propagation = true:warning
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
# File header preferences
-file_header_template = Copyright (c) Six Labors.\nLicensed under the Apache License, Version 2.0.
+file_header_template = Copyright (c) Six Labors.\nLicensed under the Six Labors Split License.
# SA1636: File header copyright text should match
# Justification: .editorconfig supports file headers. If this is changed to a value other than "none", a stylecop.json file will need to added to the project.
# dotnet_diagnostic.SA1636.severity = none
# Undocumented
-dotnet_style_operator_placement_when_wrapping = end_of_line
+dotnet_style_operator_placement_when_wrapping = end_of_line:warning
+csharp_style_prefer_null_check_over_type_check = true:warning
# C# Style Rules
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#c-style-rules
[*.{cs,csx,cake}]
# 'var' preferences
-csharp_style_var_for_built_in_types = never
-csharp_style_var_when_type_is_apparent = true:warning
-csharp_style_var_elsewhere = false:warning
+csharp_style_var_for_built_in_types = false:error
+csharp_style_var_when_type_is_apparent = false:error
+csharp_style_var_elsewhere = false:error
# Expression-bodied members
csharp_style_expression_bodied_methods = true:warning
csharp_style_expression_bodied_constructors = true:warning
@@ -159,7 +160,10 @@ csharp_style_pattern_local_over_anonymous_function = true:warning
csharp_style_deconstructed_variable_declaration = true:warning
csharp_style_prefer_index_operator = true:warning
csharp_style_prefer_range_operator = true:warning
-csharp_style_implicit_object_creation_when_type_is_apparent = true:warning
+csharp_style_implicit_object_creation_when_type_is_apparent = true:error
+# ReSharper inspection severities
+resharper_arrange_object_creation_when_type_evident_highlighting = error
+resharper_arrange_object_creation_when_type_not_evident_highlighting = error
# "Null" checking preferences
csharp_style_throw_expression = true:warning
csharp_style_conditional_delegate_call = true:warning
@@ -171,6 +175,11 @@ dotnet_diagnostic.IDE0063.severity = suggestion
csharp_using_directive_placement = outside_namespace:warning
# Modifier preferences
csharp_prefer_static_local_function = true:warning
+# Primary constructor preferences
+csharp_style_prefer_primary_constructors = false:none
+# Collection preferences
+dotnet_style_prefer_collection_expression = true:error
+resharper_use_collection_expression_highlighting =true:error
##########################################
# Unnecessary Code Rules
@@ -200,12 +209,15 @@ dotnet_diagnostic.IDE0059.severity = suggestion
# Organize using directives
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false
+# Dotnet namespace options
+dotnet_style_namespace_match_folder = true:suggestion
+dotnet_diagnostic.IDE0130.severity = suggestion
# C# formatting rules
# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#c-formatting-rules
[*.{cs,csx,cake}]
# Newline options
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#new-line-options
+# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#new-line-options
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
@@ -214,7 +226,7 @@ csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true
# Indentation options
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#indentation-options
+# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#indentation-options
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = no_change
@@ -222,7 +234,7 @@ csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents_when_block = false
# Spacing options
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#spacing-options
+# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#spacing-options
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_parentheses = false
@@ -246,9 +258,12 @@ csharp_space_before_open_square_brackets = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_square_brackets = false
# Wrap options
-# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#wrap-options
+# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#wrap-options
csharp_preserve_single_line_statements = false
csharp_preserve_single_line_blocks = true
+# Namespace options
+# https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#namespace-options
+csharp_style_namespace_declarations = file_scoped:warning
##########################################
# .NET Naming Rules
diff --git a/.gitattributes b/.gitattributes
index 70ced69..f7bd4d0 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -64,18 +64,19 @@
# Set explicit file behavior to:
# treat as text
# normalize to Unix-style line endings and
-# use a union merge when resoling conflicts
+# use a union merge when resolving conflicts
###############################################################################
*.csproj text eol=lf merge=union
*.dbproj text eol=lf merge=union
*.fsproj text eol=lf merge=union
*.ncrunchproject text eol=lf merge=union
*.vbproj text eol=lf merge=union
+*.shproj text eol=lf merge=union
###############################################################################
# Set explicit file behavior to:
# treat as text
# normalize to Windows-style line endings and
-# use a union merge when resoling conflicts
+# use a union merge when resolving conflicts
###############################################################################
*.sln text eol=crlf merge=union
###############################################################################
@@ -87,7 +88,6 @@
*.eot binary
*.exe binary
*.otf binary
-*.pbm binary
*.pdf binary
*.ppt binary
*.pptx binary
@@ -95,7 +95,6 @@
*.snk binary
*.ttc binary
*.ttf binary
-*.wbmp binary
*.woff binary
*.woff2 binary
*.xls binary
@@ -119,6 +118,7 @@
*.bmp filter=lfs diff=lfs merge=lfs -text
*.gif filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
+*.qoi filter=lfs diff=lfs merge=lfs -text
*.tif filter=lfs diff=lfs merge=lfs -text
*.tiff filter=lfs diff=lfs merge=lfs -text
*.tga filter=lfs diff=lfs merge=lfs -text
@@ -126,3 +126,20 @@
*.dds filter=lfs diff=lfs merge=lfs -text
*.ktx filter=lfs diff=lfs merge=lfs -text
*.ktx2 filter=lfs diff=lfs merge=lfs -text
+*.pam filter=lfs diff=lfs merge=lfs -text
+*.pbm filter=lfs diff=lfs merge=lfs -text
+*.pgm filter=lfs diff=lfs merge=lfs -text
+*.ppm filter=lfs diff=lfs merge=lfs -text
+*.pnm filter=lfs diff=lfs merge=lfs -text
+*.wbmp filter=lfs diff=lfs merge=lfs -text
+*.exr filter=lfs diff=lfs merge=lfs -text
+*.ico filter=lfs diff=lfs merge=lfs -text
+*.cur filter=lfs diff=lfs merge=lfs -text
+*.ani filter=lfs diff=lfs merge=lfs -text
+*.heic filter=lfs diff=lfs merge=lfs -text
+*.hif filter=lfs diff=lfs merge=lfs -text
+*.avif filter=lfs diff=lfs merge=lfs -text
+###############################################################################
+# Handle ICC files by git lfs
+###############################################################################
+*.icc filter=lfs diff=lfs merge=lfs -text
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
new file mode 100644
index 0000000..02f8ea1
--- /dev/null
+++ b/.github/CONTRIBUTING.md
@@ -0,0 +1,38 @@
+# How to contribute to SixLabors.ImageSharp.Textures
+
+#### **Did you find a bug?**
+
+- Please **ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/SixLabors/ImageSharp.Textures/issues).
+
+- If you're unable to find an open issue addressing the problem, please [open a new one](https://github.com/SixLabors/ImageSharp.Textures/issues/new). Be sure to include a **title, the applicable version, a clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring. Please do not hijack existing issues.
+
+#### **Did you write a patch that fixes a bug?**
+
+* Open a new GitHub pull request with the patch.
+
+* Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
+
+* Before submitting, please ensure that your code matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules :cop:.
+
+#### **Do you intend to add a new feature or change an existing one?**
+
+* Suggest your change in the [Ideas Discussions Channel](https://github.com/SixLabors/ImageSharp.Textures/discussions?discussions_q=category%3AIdeas) and start writing code.
+
+* Do not open an issue on GitHub until you have collected positive feedback about the change. GitHub issues are primarily intended for bug reports and fixes.
+
+#### **Building**
+
+ * When first cloning the repo, make sure to run `git submodule update --init --recursive` otherwise the submodules (e.g. `shared-infrastructure`) will be missing.
+
+ * Run `dotnet build` in the root of the repo, or open the ImageSharp.Textures.sln file in Visual Studio and build from there.
+
+#### **Do you have questions about consuming the library or the source code?**
+
+* Ask any question about how to use SixLabors.ImageSharp in the [Help Discussions Channel](https://github.com/SixLabors/ImageSharp.Textures/discussions?discussions_q=category%3AHelp).
+
+#### Code of Conduct
+This project has adopted the code of conduct defined by the [Contributor Covenant](https://contributor-covenant.org/) to clarify expected behavior in our community.
+
+And please remember. SixLabors.ImageSharp is the work of a very, very, small number of developers who struggle balancing time to contribute to the project with family time and work commitments. We encourage you to pitch in and help make our vision of simple accessible image processing available to all. Open Source can only exist with your help.
+
+Thanks for reading!
diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml
index 05df432..e5d7dbd 100644
--- a/.github/workflows/build-and-test.yml
+++ b/.github/workflows/build-and-test.yml
@@ -15,31 +15,15 @@ jobs:
matrix:
options:
- os: ubuntu-latest
- framework: net5.0
+ framework: net8.0
runtime: -x64
codecov: false
- os: macos-latest
- framework: net5.0
+ framework: net8.0
runtime: -x64
codecov: false
- os: windows-latest
- framework: net5.0
- runtime: -x64
- codecov: false
- - os: ubuntu-latest
- framework: netcoreapp3.1
- runtime: -x64
- codecov: true
- - os: macos-latest
- framework: netcoreapp3.1
- runtime: -x64
- codecov: false
- - os: windows-latest
- framework: netcoreapp3.1
- runtime: -x64
- codecov: false
- - os: windows-latest
- framework: netcoreapp2.1
+ framework: net8.0
runtime: -x64
codecov: false
@@ -47,7 +31,17 @@ jobs:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
steps:
- - uses: actions/checkout@v4
+ - name: Git Config
+ shell: bash
+ run: |
+ git config --global core.autocrlf false
+ git config --global core.longpaths true
+
+ - name: Git Checkout
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ submodules: recursive
# See https://github.com/actions/checkout/issues/165#issuecomment-657673315
- name: Create LFS file list
@@ -66,14 +60,6 @@ jobs:
- name: Install NuGet
uses: NuGet/setup-nuget@v2
- - name: Setup Git
- shell: bash
- run: |
- git config --global core.autocrlf false
- git config --global core.longpaths true
- git fetch --prune --unshallow
- git submodule -q update --init --recursive
-
- name: Setup NuGet Cache
uses: actions/cache@v4
id: nuget-cache
@@ -86,10 +72,7 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
- 6.0.x
- 5.0.x
- 3.1.x
- 2.1.x
+ 8.0.x
- name: Build
shell: pwsh
diff --git a/.gitignore b/.gitignore
index dd79bff..26cb9a2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -169,6 +169,7 @@ ClientBin/
*.publishsettings
node_modules/
bower_components/
+.DS_Store
# RIA/Silverlight projects
Generated_Code/
diff --git a/Directory.Build.props b/Directory.Build.props
index 3a133ef..f0af547 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -18,4 +18,16 @@
+
+ 12.0
+
+
+
+
+ true
+
+
diff --git a/LICENSE b/LICENSE
index 261eeb9..a68eb67 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,201 +1,43 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
+Six Labors Split License
+Version 1.0, June 2022
+Copyright (c) Six Labors
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
- 1. Definitions.
+1. Definitions.
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source
+ code, documentation source, and configuration files.
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including
+ but not limited to compiled object code, generated documentation, and conversions to other media types.
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
+ "Work" (or "Works") shall mean any Six Labors software made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work.
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
+ "Direct Package Dependency" shall mean any Work in Source or Object form that is installed directly by You.
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
+ "Transitive Package Dependency" shall mean any Work in Object form that is installed indirectly by a third party
+ dependency unrelated to Six Labors.
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
+2. License
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
+ Works in Source or Object form are split licensed and may be licensed under the Apache License, Version 2.0 or a
+ Six Labors Commercial Use License.
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
+ Licenses are granted based upon You meeting the qualified criteria as stated. Once granted,
+ You must reference the granted license only in all documentation.
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
+ Works in Source or Object form are licensed to You under the Apache License, Version 2.0 if.
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
+ - You are consuming the Work in for use in software licensed under an Open Source or Source Available license.
+ - You are consuming the Work as a Transitive Package Dependency.
+ - You are consuming the Work as a Direct Package Dependency in the capacity of a For-profit company/individual with
+ less than 1M USD annual gross revenue.
+ - You are consuming the Work as a Direct Package Dependency in the capacity of a Non-profit organization
+ or Registered Charity.
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
+ For all other scenarios, Works in Source or Object form are licensed to You under the Six Labors Commercial License
+ which may be purchased by visiting https://sixlabors.com/pricing/.
diff --git a/README.md b/README.md
index 2b60fcf..5be8e65 100644
--- a/README.md
+++ b/README.md
@@ -18,9 +18,9 @@ SixLabors.ImageSharp.Textures
Currently decoding the following texture formats are supported:
-- [DDS textures]()
-- [KTX textures](http://paulbourke.net/dataformats/ktx/)
-- [KTX2 textures](https://github.khronos.org/KTX-Specification/)
+- [DDS textures](https://learn.microsoft.com/en-us/windows/win32/direct3ddds/dx-graphics-dds)
+- [KTX textures](https://registry.khronos.org/KTX/specs/1.0/ktxspec.v1.html)
+- [KTX2 textures](https://registry.khronos.org/KTX/specs/2.0/ktxspec.v2.html)
with the following compressions:
@@ -38,7 +38,7 @@ Encoding textures is **not** yet supported. PR are of course very welcome.
## License
-- ImageSharp.Textures is licensed under the [Apache License, Version 2.0](https://opensource.org/licenses/Apache-2.0)
+- ImageSharp.Textures is licensed under the [Six Labors Split License, Version 1.0](https://github.com/SixLabors/ImageSharp.Textures/blob/main/LICENSE)
## Code of Conduct
This project has adopted the code of conduct defined by the [Contributor Covenant](https://contributor-covenant.org/) to clarify expected behavior in our community.
diff --git a/SixLabors.ImageSharp.props b/SixLabors.ImageSharp.props
new file mode 100644
index 0000000..46d8c23
--- /dev/null
+++ b/SixLabors.ImageSharp.props
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/codecov.yml b/codecov.yml
index 833fc0a..310eefb 100644
--- a/codecov.yml
+++ b/codecov.yml
@@ -9,3 +9,14 @@ codecov:
# Avoid Report Expired
# https://docs.codecov.io/docs/codecov-yaml#section-expired-reports
max_report_age: off
+
+coverage:
+ # Use integer precision
+ # https://docs.codecov.com/docs/codecovyml-reference#coverageprecision
+ precision: 0
+
+ # Explicitly control coverage status checks
+ # https://docs.codecov.com/docs/commit-status#disabling-a-status
+ status:
+ project: on
+ patch: off
diff --git a/shared-infrastructure b/shared-infrastructure
index a042aba..57699ff 160000
--- a/shared-infrastructure
+++ b/shared-infrastructure
@@ -1 +1 @@
-Subproject commit a042aba176cdb840d800c6ed4cfe41a54fb7b1e3
+Subproject commit 57699ffb797bc2389c5d6cbb3b1800f2eb5fb947
diff --git a/src/ImageSharp.Textures/Common/Exceptions/TextureFormatException.cs b/src/ImageSharp.Textures/Common/Exceptions/TextureFormatException.cs
index eb53a6b..8fd3c01 100644
--- a/src/ImageSharp.Textures/Common/Exceptions/TextureFormatException.cs
+++ b/src/ImageSharp.Textures/Common/Exceptions/TextureFormatException.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
diff --git a/src/ImageSharp.Textures/Common/Exceptions/TextureProcessingException.cs b/src/ImageSharp.Textures/Common/Exceptions/TextureProcessingException.cs
index 2d3f4f0..ba360be 100644
--- a/src/ImageSharp.Textures/Common/Exceptions/TextureProcessingException.cs
+++ b/src/ImageSharp.Textures/Common/Exceptions/TextureProcessingException.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
diff --git a/src/ImageSharp.Textures/Common/Exceptions/UnknownTextureFormatException.cs b/src/ImageSharp.Textures/Common/Exceptions/UnknownTextureFormatException.cs
index 466efcf..05bce3f 100644
--- a/src/ImageSharp.Textures/Common/Exceptions/UnknownTextureFormatException.cs
+++ b/src/ImageSharp.Textures/Common/Exceptions/UnknownTextureFormatException.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.Common.Exceptions
{
diff --git a/src/ImageSharp.Textures/Common/Extensions/StreamExtensions.cs b/src/ImageSharp.Textures/Common/Extensions/StreamExtensions.cs
index 0b992bc..274a022 100644
--- a/src/ImageSharp.Textures/Common/Extensions/StreamExtensions.cs
+++ b/src/ImageSharp.Textures/Common/Extensions/StreamExtensions.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Buffers;
diff --git a/src/ImageSharp.Textures/Common/Extensions/ToStringExtension.cs b/src/ImageSharp.Textures/Common/Extensions/ToStringExtension.cs
index 254b179..da8ec12 100644
--- a/src/ImageSharp.Textures/Common/Extensions/ToStringExtension.cs
+++ b/src/ImageSharp.Textures/Common/Extensions/ToStringExtension.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Text;
diff --git a/src/ImageSharp.Textures/Common/Helpers/FloatHelper.cs b/src/ImageSharp.Textures/Common/Helpers/FloatHelper.cs
index db2c28b..98b8de5 100644
--- a/src/ImageSharp.Textures/Common/Helpers/FloatHelper.cs
+++ b/src/ImageSharp.Textures/Common/Helpers/FloatHelper.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System.Runtime.CompilerServices;
diff --git a/src/ImageSharp.Textures/Common/Helpers/PixelUtils.cs b/src/ImageSharp.Textures/Common/Helpers/PixelUtils.cs
index c89db74..ed7907b 100644
--- a/src/ImageSharp.Textures/Common/Helpers/PixelUtils.cs
+++ b/src/ImageSharp.Textures/Common/Helpers/PixelUtils.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.PixelFormats;
diff --git a/src/ImageSharp.Textures/Configuration.cs b/src/ImageSharp.Textures/Configuration.cs
index f8a9920..d68b472 100644
--- a/src/ImageSharp.Textures/Configuration.cs
+++ b/src/ImageSharp.Textures/Configuration.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Collections.Generic;
diff --git a/src/ImageSharp.Textures/Formats/Dds/DdsConfigurationModule.cs b/src/ImageSharp.Textures/Formats/Dds/DdsConfigurationModule.cs
index aa5022a..c81d20b 100644
--- a/src/ImageSharp.Textures/Formats/Dds/DdsConfigurationModule.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/DdsConfigurationModule.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.Formats.Dds
{
diff --git a/src/ImageSharp.Textures/Formats/Dds/DdsConstants.cs b/src/ImageSharp.Textures/Formats/Dds/DdsConstants.cs
index 5574fa5..0caac84 100644
--- a/src/ImageSharp.Textures/Formats/Dds/DdsConstants.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/DdsConstants.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System.Collections.Generic;
diff --git a/src/ImageSharp.Textures/Formats/Dds/DdsDecoder.cs b/src/ImageSharp.Textures/Formats/Dds/DdsDecoder.cs
index a4a20f7..6291bf5 100644
--- a/src/ImageSharp.Textures/Formats/Dds/DdsDecoder.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/DdsDecoder.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System.IO;
diff --git a/src/ImageSharp.Textures/Formats/Dds/DdsDecoderCore.cs b/src/ImageSharp.Textures/Formats/Dds/DdsDecoderCore.cs
index 2186248..1bb1d0b 100644
--- a/src/ImageSharp.Textures/Formats/Dds/DdsDecoderCore.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/DdsDecoderCore.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Buffers.Binary;
@@ -108,7 +108,7 @@ public Texture DecodeTexture(Stream stream)
}
else if (this.ddsHeader.IsCubemap())
{
- DdsSurfaceType[] faces = this.ddsHeader.GetExistingCubemapFaces();
+ DdsSurfaceType[] faces = this.ddsHeader.GetExistingCubemapFaces() ?? Array.Empty();
var texture = new CubemapTexture();
for (int face = 0; face < faces.Length; face++)
diff --git a/src/ImageSharp.Textures/Formats/Dds/DdsFormat.cs b/src/ImageSharp.Textures/Formats/Dds/DdsFormat.cs
index 82cf2a7..7028ce0 100644
--- a/src/ImageSharp.Textures/Formats/Dds/DdsFormat.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/DdsFormat.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System.Collections.Generic;
diff --git a/src/ImageSharp.Textures/Formats/Dds/DdsFourCC.cs b/src/ImageSharp.Textures/Formats/Dds/DdsFourCC.cs
index e19136a..2f92233 100644
--- a/src/ImageSharp.Textures/Formats/Dds/DdsFourCC.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/DdsFourCC.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Textures.Formats.Dds
diff --git a/src/ImageSharp.Textures/Formats/Dds/DdsHeader.cs b/src/ImageSharp.Textures/Formats/Dds/DdsHeader.cs
index 864d974..27e1271 100644
--- a/src/ImageSharp.Textures/Formats/Dds/DdsHeader.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/DdsHeader.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Buffers.Binary;
diff --git a/src/ImageSharp.Textures/Formats/Dds/DdsHeaderDxt10.cs b/src/ImageSharp.Textures/Formats/Dds/DdsHeaderDxt10.cs
index dc6aff5..2549492 100644
--- a/src/ImageSharp.Textures/Formats/Dds/DdsHeaderDxt10.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/DdsHeaderDxt10.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Buffers.Binary;
diff --git a/src/ImageSharp.Textures/Formats/Dds/DdsImageFormatDetector.cs b/src/ImageSharp.Textures/Formats/Dds/DdsImageFormatDetector.cs
index ea6ea1a..0a35243 100644
--- a/src/ImageSharp.Textures/Formats/Dds/DdsImageFormatDetector.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/DdsImageFormatDetector.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Buffers.Binary;
@@ -15,7 +15,7 @@ public sealed class DdsImageFormatDetector : ITextureFormatDetector
public int HeaderSize => 8;
///
- public ITextureFormat DetectFormat(ReadOnlySpan header) => this.IsSupportedFileFormat(header) ? DdsFormat.Instance : null;
+ public ITextureFormat? DetectFormat(ReadOnlySpan header) => this.IsSupportedFileFormat(header) ? DdsFormat.Instance : null;
private bool IsSupportedFileFormat(ReadOnlySpan header)
{
diff --git a/src/ImageSharp.Textures/Formats/Dds/DdsPixelFormat.cs b/src/ImageSharp.Textures/Formats/Dds/DdsPixelFormat.cs
index 9b7409f..76c4c46 100644
--- a/src/ImageSharp.Textures/Formats/Dds/DdsPixelFormat.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/DdsPixelFormat.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Buffers.Binary;
diff --git a/src/ImageSharp.Textures/Formats/Dds/DdsProcessor.cs b/src/ImageSharp.Textures/Formats/Dds/DdsProcessor.cs
index e76dc30..2c976ff 100644
--- a/src/ImageSharp.Textures/Formats/Dds/DdsProcessor.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/DdsProcessor.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.IO;
@@ -50,83 +50,58 @@ public MipMap[] DecodeDds(Stream stream, int width, int height, int count)
{
Guard.MustBeGreaterThan(count, 0, nameof(count));
- switch (this.DdsHeader.PixelFormat.FourCC)
+ return this.DdsHeader.PixelFormat.FourCC switch
{
- case DdsFourCc.None:
- case DdsFourCc.R16FLOAT:
- case DdsFourCc.R16G16FLOAT:
- case DdsFourCc.R16G16B16A16SNORM:
- case DdsFourCc.R16G16B16A16UNORM:
- case DdsFourCc.R16G16B16A16FLOAT:
- case DdsFourCc.R32FLOAT:
- case DdsFourCc.R32G32FLOAT:
- case DdsFourCc.R32G32B32A32FLOAT:
- case DdsFourCc.YUY2:
- case DdsFourCc.RGBG:
- case DdsFourCc.GRGB:
- return this.ProcessUncompressed(stream, width, height, count);
- case DdsFourCc.DXT1:
- return this.AllocateMipMaps(stream, width, height, count);
- case DdsFourCc.DXT2:
- case DdsFourCc.DXT4:
- throw new NotSupportedException("Due to patentsCan, DXT2 or DXT4 cannot be supported.");
- case DdsFourCc.DXT3:
- return this.AllocateMipMaps(stream, width, height, count);
- case DdsFourCc.DXT5:
- return this.AllocateMipMaps(stream, width, height, count);
- case DdsFourCc.DX10:
- return this.GetDx10Dds(stream, width, height, count);
- case DdsFourCc.ATI1:
- case DdsFourCc.BC4U:
- return this.AllocateMipMaps(stream, width, height, count);
- case DdsFourCc.BC4S:
- return this.AllocateMipMaps(stream, width, height, count);
- case DdsFourCc.ATI2:
- case DdsFourCc.BC5U:
- return this.AllocateMipMaps(stream, width, height, count);
- case DdsFourCc.BC5S:
- return this.AllocateMipMaps(stream, width, height, count);
- default:
- throw new NotSupportedException($"FourCC: {this.DdsHeader.PixelFormat.FourCC.FourCcToString()} not supported.");
- }
+ DdsFourCc.None
+ or DdsFourCc.R16FLOAT
+ or DdsFourCc.R16G16FLOAT
+ or DdsFourCc.R16G16B16A16SNORM
+ or DdsFourCc.R16G16B16A16UNORM
+ or DdsFourCc.R16G16B16A16FLOAT
+ or DdsFourCc.R32FLOAT
+ or DdsFourCc.R32G32FLOAT
+ or DdsFourCc.R32G32B32A32FLOAT
+ or DdsFourCc.YUY2
+ or DdsFourCc.RGBG
+ or DdsFourCc.GRGB => this.ProcessUncompressed(stream, width, height, count),
+ DdsFourCc.DXT1 => AllocateMipMaps(stream, width, height, count),
+ DdsFourCc.DXT2 or DdsFourCc.DXT4 => throw new NotSupportedException("Due to patents Can, DXT2 or DXT4 cannot be supported."),
+ DdsFourCc.DXT3 => AllocateMipMaps(stream, width, height, count),
+ DdsFourCc.DXT5 => AllocateMipMaps(stream, width, height, count),
+ DdsFourCc.DX10 => this.GetDx10Dds(stream, width, height, count),
+ DdsFourCc.ATI1 or DdsFourCc.BC4U => AllocateMipMaps(stream, width, height, count),
+ DdsFourCc.BC4S => AllocateMipMaps(stream, width, height, count),
+ DdsFourCc.ATI2 or DdsFourCc.BC5U => AllocateMipMaps(stream, width, height, count),
+ DdsFourCc.BC5S => AllocateMipMaps(stream, width, height, count),
+ _ => throw new NotSupportedException($"FourCC: {this.DdsHeader.PixelFormat.FourCC.FourCcToString()} not supported."),
+ };
}
public MipMap[] ProcessUncompressed(Stream stream, int width, int height, int count)
{
uint bitsPerPixel = this.DdsHeader.PixelFormat.RGBBitCount;
- switch (bitsPerPixel)
+ return bitsPerPixel switch
{
- case 8:
- return this.EightBitImageFormat(stream, width, height, count);
- case 16:
- return this.SixteenBitImageFormat(stream, width, height, count);
- case 24:
- return this.TwentyFourBitImageFormat(stream, width, height, count);
- case 32:
- return this.ThirtyTwoBitImageFormat(stream, width, height, count);
- default:
- // For unknown reason some formats do not have the bitsPerPixel set in the header (its zero).
- switch (this.DdsHeader.PixelFormat.FourCC)
- {
- case DdsFourCc.R16FLOAT:
- return this.SixteenBitImageFormat(stream, width, height, count);
- case DdsFourCc.R32FLOAT:
- case DdsFourCc.R16G16FLOAT:
- case DdsFourCc.YUY2:
- case DdsFourCc.RGBG:
- case DdsFourCc.GRGB:
- return this.ThirtyTwoBitImageFormat(stream, width, height, count);
- case DdsFourCc.R16G16B16A16SNORM:
- case DdsFourCc.R16G16B16A16UNORM:
- case DdsFourCc.R16G16B16A16FLOAT:
- case DdsFourCc.R32G32FLOAT:
- return this.SixtyFourBitImageFormat(stream, width, height, count);
- case DdsFourCc.R32G32B32A32FLOAT:
- return this.HundredTwentyEightBitImageFormat(stream, width, height, count);
- }
-
- throw new Exception($"Unrecognized rgb bit count: {this.DdsHeader.PixelFormat.RGBBitCount}");
- }
+ 8 => this.EightBitImageFormat(stream, width, height, count),
+ 16 => this.SixteenBitImageFormat(stream, width, height, count),
+ 24 => this.TwentyFourBitImageFormat(stream, width, height, count),
+ 32 => this.ThirtyTwoBitImageFormat(stream, width, height, count),
+ _ => this.DdsHeader.PixelFormat.FourCC switch
+ {
+ DdsFourCc.R16FLOAT => this.SixteenBitImageFormat(stream, width, height, count),
+ DdsFourCc.R32FLOAT
+ or DdsFourCc.R16G16FLOAT
+ or DdsFourCc.YUY2
+ or DdsFourCc.RGBG
+ or DdsFourCc.GRGB => this.ThirtyTwoBitImageFormat(stream, width, height, count),
+ DdsFourCc.R16G16B16A16SNORM
+ or DdsFourCc.R16G16B16A16UNORM
+ or DdsFourCc.R16G16B16A16FLOAT
+ or DdsFourCc.R32G32FLOAT => this.SixtyFourBitImageFormat(stream, width, height, count),
+ DdsFourCc.R32G32B32A32FLOAT => this.HundredTwentyEightBitImageFormat(stream, width, height, count),
+ _ => throw new ArgumentOutOfRangeException($"Unrecognized rgb bit count: {this.DdsHeader.PixelFormat.RGBBitCount}"),
+ }, // For unknown reason some formats do not have the bitsPerPixel set in the header (its zero).
+ };
}
///
@@ -137,7 +112,7 @@ public MipMap[] ProcessUncompressed(Stream stream, int width, int height, int co
/// The height of the texture at level 0.
/// The mipmap count.
/// The decoded mipmaps.
- private MipMap[] AllocateMipMaps(Stream stream, int width, int height, int count)
+ private static MipMap[] AllocateMipMaps(Stream stream, int width, int height, int count)
where TBlock : struct, IBlock
{
var blockFormat = default(TBlock);
@@ -180,15 +155,15 @@ private MipMap[] EightBitImageFormat(Stream stream, int width, int height, int c
if (pixelFormat.RBitMask == 0x0 && pixelFormat.GBitMask == 0x0 && pixelFormat.BBitMask == 0x0)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (!hasAlpha && pixelFormat.RBitMask == 0xFF && pixelFormat.GBitMask == 0x0 && pixelFormat.BBitMask == 0x0)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
- throw new Exception("Unsupported 8 bit format");
+ throw new NotSupportedException("Unsupported 8 bit format");
}
private MipMap[] SixteenBitImageFormat(Stream stream, int width, int height, int count)
@@ -199,45 +174,45 @@ private MipMap[] SixteenBitImageFormat(Stream stream, int width, int height, int
if (hasAlpha && pixelFormat.RBitMask == 0xF00 && pixelFormat.GBitMask == 0xF0 && pixelFormat.BBitMask == 0xF)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (!hasAlpha && pixelFormat.RBitMask == 0x7C00 && pixelFormat.GBitMask == 0x3E0 && pixelFormat.BBitMask == 0x1F)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (hasAlpha && pixelFormat.RBitMask == 0x7C00 && pixelFormat.GBitMask == 0x3E0 && pixelFormat.BBitMask == 0x1F)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (!hasAlpha && pixelFormat.RBitMask == 0xF800 && pixelFormat.GBitMask == 0x7E0 && pixelFormat.BBitMask == 0x1F)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (hasAlpha && pixelFormat.RBitMask == 0xFF && pixelFormat.GBitMask == 0x0 && pixelFormat.BBitMask == 0x0)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (!hasAlpha && pixelFormat.RBitMask == 0xFFFF && pixelFormat.GBitMask == 0x0 && pixelFormat.BBitMask == 0x0)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (!hasAlpha && pixelFormat.RBitMask == 0xFF && pixelFormat.GBitMask == 0xFF00 && pixelFormat.BBitMask == 0x0)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (pixelFormat.FourCC == DdsFourCc.R16FLOAT)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
- throw new Exception("Unsupported 16 bit format");
+ throw new NotSupportedException("Unsupported 16 bit format");
}
private MipMap[] TwentyFourBitImageFormat(Stream stream, int width, int height, int count)
@@ -248,10 +223,10 @@ private MipMap[] TwentyFourBitImageFormat(Stream stream, int width, int height,
if (!hasAlpha && pixelFormat.RBitMask == 0xFF0000 && pixelFormat.GBitMask == 0xFF00 && pixelFormat.BBitMask == 0xFF)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
- throw new Exception("Unsupported 24 bit format");
+ throw new NotSupportedException("Unsupported 24 bit format");
}
private MipMap[] ThirtyTwoBitImageFormat(Stream stream, int width, int height, int count)
@@ -262,55 +237,55 @@ private MipMap[] ThirtyTwoBitImageFormat(Stream stream, int width, int height, i
if (hasAlpha && pixelFormat.RBitMask == 0xFF0000 && pixelFormat.GBitMask == 0xFF00 && pixelFormat.BBitMask == 0xFF)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (hasAlpha && pixelFormat.RBitMask == 0xFF && pixelFormat.GBitMask == 0xFF00 && pixelFormat.BBitMask == 0xFF0000)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (!hasAlpha && pixelFormat.RBitMask == 0xFF0000 && pixelFormat.GBitMask == 0xFF00 && pixelFormat.BBitMask == 0xFF)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (!hasAlpha && pixelFormat.RBitMask == 0xFF && pixelFormat.GBitMask == 0xFF00 && pixelFormat.BBitMask == 0xFF0000)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (!hasAlpha && pixelFormat.RBitMask == 0xFFFF && pixelFormat.GBitMask == 0xFFFF0000 && pixelFormat.BBitMask == 0x0)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (pixelFormat.FourCC == DdsFourCc.R32FLOAT)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (pixelFormat.FourCC == DdsFourCc.R16G16FLOAT)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (pixelFormat.FourCC == DdsFourCc.YUY2)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (pixelFormat.FourCC == DdsFourCc.RGBG)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (pixelFormat.FourCC == DdsFourCc.GRGB)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
- throw new Exception("Unsupported 32 bit format");
+ throw new NotSupportedException("Unsupported 32 bit format");
}
private MipMap[] SixtyFourBitImageFormat(Stream stream, int width, int height, int count)
@@ -319,20 +294,20 @@ private MipMap[] SixtyFourBitImageFormat(Stream stream, int width, int height, i
if (pixelFormat.FourCC == DdsFourCc.R16G16B16A16SNORM || pixelFormat.FourCC == DdsFourCc.R16G16B16A16UNORM)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (pixelFormat.FourCC == DdsFourCc.R32G32FLOAT)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
if (pixelFormat.FourCC == DdsFourCc.R16G16B16A16FLOAT)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
- throw new Exception("Unsupported 64 bit format");
+ throw new NotSupportedException("Unsupported 64 bit format");
}
private MipMap[] HundredTwentyEightBitImageFormat(Stream stream, int width, int height, int count)
@@ -341,10 +316,10 @@ private MipMap[] HundredTwentyEightBitImageFormat(Stream stream, int width, int
if (pixelFormat.FourCC == DdsFourCc.R32G32B32A32FLOAT || pixelFormat.FourCC == DdsFourCc.R32FLOAT)
{
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
}
- throw new Exception("Unsupported 128 bit format");
+ throw new NotSupportedException("Unsupported 128 bit format");
}
/*
@@ -359,34 +334,34 @@ private MipMap[] GetDx10Dds(Stream stream, int width, int height, int count)
case DxgiFormat.BC1_Typeless:
case DxgiFormat.BC1_UNorm_SRGB:
case DxgiFormat.BC1_UNorm:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.BC2_Typeless:
case DxgiFormat.BC2_UNorm:
case DxgiFormat.BC2_UNorm_SRGB:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.BC3_Typeless:
case DxgiFormat.BC3_UNorm:
case DxgiFormat.BC3_UNorm_SRGB:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.BC4_Typeless:
case DxgiFormat.BC4_UNorm:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.BC4_SNorm:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.BC5_Typeless:
case DxgiFormat.BC5_UNorm:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.BC5_SNorm:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.BC6H_Typeless:
case DxgiFormat.BC6H_UF16:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.BC6H_SF16:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.BC7_Typeless:
case DxgiFormat.BC7_UNorm:
case DxgiFormat.BC7_UNorm_SRGB:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R8G8B8A8_Typeless:
case DxgiFormat.R8G8B8A8_UNorm:
case DxgiFormat.R8G8B8A8_UNorm_SRGB:
@@ -396,99 +371,99 @@ private MipMap[] GetDx10Dds(Stream stream, int width, int height, int count)
case DxgiFormat.B8G8R8X8_Typeless:
case DxgiFormat.B8G8R8X8_UNorm:
case DxgiFormat.B8G8R8X8_UNorm_SRGB:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.B8G8R8A8_Typeless:
case DxgiFormat.B8G8R8A8_UNorm:
case DxgiFormat.B8G8R8A8_UNorm_SRGB:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R32G32B32A32_Float:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R32G32B32A32_Typeless:
case DxgiFormat.R32G32B32A32_UInt:
case DxgiFormat.R32G32B32A32_SInt:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R32G32B32_Float:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R32G32B32_Typeless:
case DxgiFormat.R32G32B32_UInt:
case DxgiFormat.R32G32B32_SInt:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R16G16B16A16_Typeless:
case DxgiFormat.R16G16B16A16_Float:
case DxgiFormat.R16G16B16A16_UNorm:
case DxgiFormat.R16G16B16A16_UInt:
case DxgiFormat.R16G16B16A16_SNorm:
case DxgiFormat.R16G16B16A16_SInt:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R32G32_Float:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R32G32_Typeless:
case DxgiFormat.R32G32_UInt:
case DxgiFormat.R32G32_SInt:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R10G10B10A2_Typeless:
case DxgiFormat.R10G10B10A2_UNorm:
case DxgiFormat.R10G10B10A2_UInt:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R16G16_Float:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R16G16_Typeless:
case DxgiFormat.R16G16_UNorm:
case DxgiFormat.R16G16_UInt:
case DxgiFormat.R16G16_SNorm:
case DxgiFormat.R16G16_SInt:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R32_Float:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R32_Typeless:
case DxgiFormat.R32_UInt:
case DxgiFormat.R32_SInt:
// Treating single channel format as 32 bit gray image.
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R8G8_Typeless:
case DxgiFormat.R8G8_UNorm:
case DxgiFormat.R8G8_UInt:
case DxgiFormat.R8G8_SNorm:
case DxgiFormat.R8G8_SInt:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R16_Float:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R16_Typeless:
case DxgiFormat.R16_UNorm:
case DxgiFormat.R16_UInt:
case DxgiFormat.R16_SNorm:
case DxgiFormat.R16_SInt:
// Treating single channel format as 16 bit gray image.
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R8_Typeless:
case DxgiFormat.R8_UNorm:
case DxgiFormat.R8_UInt:
case DxgiFormat.R8_SNorm:
case DxgiFormat.R8_SInt:
// Treating single channel format as 8 bit gray image.
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.A8_UNorm:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R1_UNorm:
- throw new Exception("not implemented");
+ throw new NotImplementedException($"{nameof(DxgiFormat.R1_UNorm)} is currently not implemented");
case DxgiFormat.R11G11B10_Float:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.Y410:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.Y416:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.Y210:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.Y216:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.AYUV:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.YUY2:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R8G8_B8G8_UNorm:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.G8R8_G8B8_UNorm:
- return this.AllocateMipMaps(stream, width, height, count);
+ return AllocateMipMaps(stream, width, height, count);
case DxgiFormat.R32G8X24_Typeless:
case DxgiFormat.D32_Float_S8X24_UInt:
case DxgiFormat.R32_Float_X8X24_Typeless:
diff --git a/src/ImageSharp.Textures/Formats/Dds/DdsSurfaceType.cs b/src/ImageSharp.Textures/Formats/Dds/DdsSurfaceType.cs
index 47c4831..187359e 100644
--- a/src/ImageSharp.Textures/Formats/Dds/DdsSurfaceType.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/DdsSurfaceType.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.Formats.Dds
{
diff --git a/src/ImageSharp.Textures/Formats/Dds/DdsTools.cs b/src/ImageSharp.Textures/Formats/Dds/DdsTools.cs
index 1e08505..7402f52 100644
--- a/src/ImageSharp.Textures/Formats/Dds/DdsTools.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/DdsTools.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using SixLabors.ImageSharp.Textures.Formats.Dds.Emums;
diff --git a/src/ImageSharp.Textures/Formats/Dds/Enums/D3d10ResourceDimension.cs b/src/ImageSharp.Textures/Formats/Dds/Enums/D3d10ResourceDimension.cs
index 8119ac3..056fb47 100644
--- a/src/ImageSharp.Textures/Formats/Dds/Enums/D3d10ResourceDimension.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/Enums/D3d10ResourceDimension.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.Formats.Dds.Emums
{
diff --git a/src/ImageSharp.Textures/Formats/Dds/Enums/D3d10ResourceMiscFlags.cs b/src/ImageSharp.Textures/Formats/Dds/Enums/D3d10ResourceMiscFlags.cs
index 590a80b..76dad60 100644
--- a/src/ImageSharp.Textures/Formats/Dds/Enums/D3d10ResourceMiscFlags.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/Enums/D3d10ResourceMiscFlags.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
diff --git a/src/ImageSharp.Textures/Formats/Dds/Enums/D3dFormat.cs b/src/ImageSharp.Textures/Formats/Dds/Enums/D3dFormat.cs
index f8a348d..37d63ea 100644
--- a/src/ImageSharp.Textures/Formats/Dds/Enums/D3dFormat.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/Enums/D3dFormat.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.Formats.Dds.Emums
{
diff --git a/src/ImageSharp.Textures/Formats/Dds/Enums/DdsCaps1.cs b/src/ImageSharp.Textures/Formats/Dds/Enums/DdsCaps1.cs
index 3cb4ea7..abd4d7e 100644
--- a/src/ImageSharp.Textures/Formats/Dds/Enums/DdsCaps1.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/Enums/DdsCaps1.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
diff --git a/src/ImageSharp.Textures/Formats/Dds/Enums/DdsCaps2.cs b/src/ImageSharp.Textures/Formats/Dds/Enums/DdsCaps2.cs
index 2e406eb..ae88ac0 100644
--- a/src/ImageSharp.Textures/Formats/Dds/Enums/DdsCaps2.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/Enums/DdsCaps2.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
diff --git a/src/ImageSharp.Textures/Formats/Dds/Enums/DdsFlags.cs b/src/ImageSharp.Textures/Formats/Dds/Enums/DdsFlags.cs
index 017eb47..ae311d0 100644
--- a/src/ImageSharp.Textures/Formats/Dds/Enums/DdsFlags.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/Enums/DdsFlags.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
diff --git a/src/ImageSharp.Textures/Formats/Dds/Enums/DdsPixelFormatFlags.cs b/src/ImageSharp.Textures/Formats/Dds/Enums/DdsPixelFormatFlags.cs
index 16f2837..4fc301c 100644
--- a/src/ImageSharp.Textures/Formats/Dds/Enums/DdsPixelFormatFlags.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/Enums/DdsPixelFormatFlags.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
diff --git a/src/ImageSharp.Textures/Formats/Dds/Enums/DxgiFormat.cs b/src/ImageSharp.Textures/Formats/Dds/Enums/DxgiFormat.cs
index 9c343f6..dc4be9a 100644
--- a/src/ImageSharp.Textures/Formats/Dds/Enums/DxgiFormat.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/Enums/DxgiFormat.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Textures.Formats.Dds.Emums
diff --git a/src/ImageSharp.Textures/Formats/Dds/Extensions/DdsHeaderExtensions.cs b/src/ImageSharp.Textures/Formats/Dds/Extensions/DdsHeaderExtensions.cs
index 07c17b2..faf92f8 100644
--- a/src/ImageSharp.Textures/Formats/Dds/Extensions/DdsHeaderExtensions.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/Extensions/DdsHeaderExtensions.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Textures.Formats.Dds.Emums;
@@ -156,7 +156,7 @@ public static int ComputeDepth(this DdsHeader ddsHeader)
///
/// Types of cube map faces stored in this cube map or null if this is not a cubemap.
///
- public static DdsSurfaceType[] GetExistingCubemapFaces(this DdsHeader ddsHeader)
+ public static DdsSurfaceType[]? GetExistingCubemapFaces(this DdsHeader ddsHeader)
{
int depth = ddsHeader.ComputeDepth();
var result = new DdsSurfaceType[depth];
diff --git a/src/ImageSharp.Textures/Formats/Dds/IDdsDecoderOptions.cs b/src/ImageSharp.Textures/Formats/Dds/IDdsDecoderOptions.cs
index 200a941..40a9b0c 100644
--- a/src/ImageSharp.Textures/Formats/Dds/IDdsDecoderOptions.cs
+++ b/src/ImageSharp.Textures/Formats/Dds/IDdsDecoderOptions.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.Formats.Dds
{
diff --git a/src/ImageSharp.Textures/Formats/ITextureDecoder.cs b/src/ImageSharp.Textures/Formats/ITextureDecoder.cs
index 2b7381b..c1e3498 100644
--- a/src/ImageSharp.Textures/Formats/ITextureDecoder.cs
+++ b/src/ImageSharp.Textures/Formats/ITextureDecoder.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.Formats
{
diff --git a/src/ImageSharp.Textures/Formats/ITextureEncoder.cs b/src/ImageSharp.Textures/Formats/ITextureEncoder.cs
index 931bae6..a58ad86 100644
--- a/src/ImageSharp.Textures/Formats/ITextureEncoder.cs
+++ b/src/ImageSharp.Textures/Formats/ITextureEncoder.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.Formats
{
diff --git a/src/ImageSharp.Textures/Formats/ITextureFormat.cs b/src/ImageSharp.Textures/Formats/ITextureFormat.cs
index ec48841..bfd5297 100644
--- a/src/ImageSharp.Textures/Formats/ITextureFormat.cs
+++ b/src/ImageSharp.Textures/Formats/ITextureFormat.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System.Collections.Generic;
diff --git a/src/ImageSharp.Textures/Formats/ITextureFormatDetector.cs b/src/ImageSharp.Textures/Formats/ITextureFormatDetector.cs
index dd203c8..3e24a6f 100644
--- a/src/ImageSharp.Textures/Formats/ITextureFormatDetector.cs
+++ b/src/ImageSharp.Textures/Formats/ITextureFormatDetector.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
@@ -21,6 +21,6 @@ public interface ITextureFormatDetector
///
/// The containing the file header.
/// returns the mime type of detected otherwise returns null
- ITextureFormat DetectFormat(ReadOnlySpan header);
+ ITextureFormat? DetectFormat(ReadOnlySpan header);
}
}
diff --git a/src/ImageSharp.Textures/Formats/ITextureFormatManager.cs b/src/ImageSharp.Textures/Formats/ITextureFormatManager.cs
index e351315..f551e7c 100644
--- a/src/ImageSharp.Textures/Formats/ITextureFormatManager.cs
+++ b/src/ImageSharp.Textures/Formats/ITextureFormatManager.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Collections.Concurrent;
@@ -83,10 +83,7 @@ public void AddImageFormat(ITextureFormat format)
lock (HashLock)
{
- if (!this.imageFormats.Contains(format))
- {
- this.imageFormats.Add(format);
- }
+ _ = this.imageFormats.Add(format);
}
}
@@ -95,7 +92,7 @@ public void AddImageFormat(ITextureFormat format)
///
/// The extension to discover
/// The if found otherwise null
- public ITextureFormat FindFormatByFileExtension(string extension)
+ public ITextureFormat? FindFormatByFileExtension(string extension)
{
Guard.NotNullOrWhiteSpace(extension, nameof(extension));
@@ -112,7 +109,7 @@ public ITextureFormat FindFormatByFileExtension(string extension)
///
/// The mime-type to discover
/// The if found; otherwise null
- public ITextureFormat FindFormatByMimeType(string mimeType) => this.imageFormats.FirstOrDefault(x => x.MimeTypes.Contains(mimeType, StringComparer.OrdinalIgnoreCase));
+ public ITextureFormat? FindFormatByMimeType(string mimeType) => this.imageFormats.FirstOrDefault(x => x.MimeTypes.Contains(mimeType, StringComparer.OrdinalIgnoreCase));
///
/// Sets a specific image encoder as the encoder for a specific image format.
@@ -161,11 +158,11 @@ public void AddImageFormatDetector(ITextureFormatDetector detector)
///
/// The format to discover
/// The if found otherwise null
- public ITextureDecoder FindDecoder(ITextureFormat format)
+ public ITextureDecoder? FindDecoder(ITextureFormat format)
{
Guard.NotNull(format, nameof(format));
- return this.mimeTypeDecoders.TryGetValue(format, out ITextureDecoder decoder)
+ return this.mimeTypeDecoders.TryGetValue(format, out ITextureDecoder? decoder)
? decoder
: null;
}
@@ -175,11 +172,11 @@ public ITextureDecoder FindDecoder(ITextureFormat format)
///
/// The format to discover
/// The if found otherwise null
- public ITextureEncoder FindEncoder(ITextureFormat format)
+ public ITextureEncoder? FindEncoder(ITextureFormat format)
{
Guard.NotNull(format, nameof(format));
- return this.mimeTypeEncoders.TryGetValue(format, out ITextureEncoder encoder)
+ return this.mimeTypeEncoders.TryGetValue(format, out ITextureEncoder? encoder)
? encoder
: null;
}
diff --git a/src/ImageSharp.Textures/Formats/ITextureInfoDetector.cs b/src/ImageSharp.Textures/Formats/ITextureInfoDetector.cs
index 947f20e..3865e17 100644
--- a/src/ImageSharp.Textures/Formats/ITextureInfoDetector.cs
+++ b/src/ImageSharp.Textures/Formats/ITextureInfoDetector.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System.IO;
diff --git a/src/ImageSharp.Textures/Formats/Ktx/Enums/GlBaseInternalPixelFormat.cs b/src/ImageSharp.Textures/Formats/Ktx/Enums/GlBaseInternalPixelFormat.cs
index 05f2eb4..bd585fe 100644
--- a/src/ImageSharp.Textures/Formats/Ktx/Enums/GlBaseInternalPixelFormat.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx/Enums/GlBaseInternalPixelFormat.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.Formats.Ktx.Enums
{
diff --git a/src/ImageSharp.Textures/Formats/Ktx/Enums/GlInternalPixelFormat.cs b/src/ImageSharp.Textures/Formats/Ktx/Enums/GlInternalPixelFormat.cs
index b7cb17d..0597c74 100644
--- a/src/ImageSharp.Textures/Formats/Ktx/Enums/GlInternalPixelFormat.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx/Enums/GlInternalPixelFormat.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.Formats.Ktx
{
diff --git a/src/ImageSharp.Textures/Formats/Ktx/Enums/GlPixelFormat.cs b/src/ImageSharp.Textures/Formats/Ktx/Enums/GlPixelFormat.cs
index b0bc286..c709c88 100644
--- a/src/ImageSharp.Textures/Formats/Ktx/Enums/GlPixelFormat.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx/Enums/GlPixelFormat.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.Formats.Ktx
{
diff --git a/src/ImageSharp.Textures/Formats/Ktx/Enums/GlType.cs b/src/ImageSharp.Textures/Formats/Ktx/Enums/GlType.cs
index 851d991..db93328 100644
--- a/src/ImageSharp.Textures/Formats/Ktx/Enums/GlType.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx/Enums/GlType.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.Formats.Ktx.Enums
{
diff --git a/src/ImageSharp.Textures/Formats/Ktx/Enums/KtxEndianness.cs b/src/ImageSharp.Textures/Formats/Ktx/Enums/KtxEndianness.cs
index e25eb84..4864d1a 100644
--- a/src/ImageSharp.Textures/Formats/Ktx/Enums/KtxEndianness.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx/Enums/KtxEndianness.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.Formats.Ktx
{
diff --git a/src/ImageSharp.Textures/Formats/Ktx/IKtxDecoderOptions.cs b/src/ImageSharp.Textures/Formats/Ktx/IKtxDecoderOptions.cs
index f9e31e6..e2b1c39 100644
--- a/src/ImageSharp.Textures/Formats/Ktx/IKtxDecoderOptions.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx/IKtxDecoderOptions.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.Formats.Ktx
{
diff --git a/src/ImageSharp.Textures/Formats/Ktx/KtxConfigurationModule.cs b/src/ImageSharp.Textures/Formats/Ktx/KtxConfigurationModule.cs
index 5fbcedf..81d2de6 100644
--- a/src/ImageSharp.Textures/Formats/Ktx/KtxConfigurationModule.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx/KtxConfigurationModule.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.Formats.Ktx
{
diff --git a/src/ImageSharp.Textures/Formats/Ktx/KtxConstants.cs b/src/ImageSharp.Textures/Formats/Ktx/KtxConstants.cs
index a912e0e..4b2fd31 100644
--- a/src/ImageSharp.Textures/Formats/Ktx/KtxConstants.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx/KtxConstants.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Collections.Generic;
diff --git a/src/ImageSharp.Textures/Formats/Ktx/KtxDecoder.cs b/src/ImageSharp.Textures/Formats/Ktx/KtxDecoder.cs
index 05184f5..4f7aa56 100644
--- a/src/ImageSharp.Textures/Formats/Ktx/KtxDecoder.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx/KtxDecoder.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System.IO;
diff --git a/src/ImageSharp.Textures/Formats/Ktx/KtxDecoderCore.cs b/src/ImageSharp.Textures/Formats/Ktx/KtxDecoderCore.cs
index 63fb110..8a6255b 100644
--- a/src/ImageSharp.Textures/Formats/Ktx/KtxDecoderCore.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx/KtxDecoderCore.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System.IO;
using SixLabors.ImageSharp.Memory;
diff --git a/src/ImageSharp.Textures/Formats/Ktx/KtxFormat.cs b/src/ImageSharp.Textures/Formats/Ktx/KtxFormat.cs
index 17d6c89..a46ba1a 100644
--- a/src/ImageSharp.Textures/Formats/Ktx/KtxFormat.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx/KtxFormat.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System.Collections.Generic;
diff --git a/src/ImageSharp.Textures/Formats/Ktx/KtxHeader.cs b/src/ImageSharp.Textures/Formats/Ktx/KtxHeader.cs
index 63c153a..67ccc7c 100644
--- a/src/ImageSharp.Textures/Formats/Ktx/KtxHeader.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx/KtxHeader.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Buffers.Binary;
@@ -137,7 +137,7 @@ public static KtxHeader Parse(ReadOnlySpan data)
{
if (data.Length < KtxConstants.KtxHeaderSize)
{
- throw new ArgumentException(nameof(data), $"Ktx header must be {KtxConstants.KtxHeaderSize} bytes. Was {data.Length} bytes.");
+ throw new ArgumentException($"Ktx header must be {KtxConstants.KtxHeaderSize} bytes. Was {data.Length} bytes.", nameof(data));
}
var endianness = (KtxEndianness)BinaryPrimitives.ReadUInt32LittleEndian(data);
diff --git a/src/ImageSharp.Textures/Formats/Ktx/KtxImageFormatDetector.cs b/src/ImageSharp.Textures/Formats/Ktx/KtxImageFormatDetector.cs
index 296ad71..4d4f9c7 100644
--- a/src/ImageSharp.Textures/Formats/Ktx/KtxImageFormatDetector.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx/KtxImageFormatDetector.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
@@ -14,7 +14,7 @@ public sealed class KtxImageFormatDetector : ITextureFormatDetector
public int HeaderSize => 12;
///
- public ITextureFormat DetectFormat(ReadOnlySpan header) => this.IsSupportedFileFormat(header) ? KtxFormat.Instance : null;
+ public ITextureFormat? DetectFormat(ReadOnlySpan header) => this.IsSupportedFileFormat(header) ? KtxFormat.Instance : null;
private bool IsSupportedFileFormat(ReadOnlySpan header)
{
diff --git a/src/ImageSharp.Textures/Formats/Ktx/KtxProcessor.cs b/src/ImageSharp.Textures/Formats/Ktx/KtxProcessor.cs
index 206fd8a..88ac7f2 100644
--- a/src/ImageSharp.Textures/Formats/Ktx/KtxProcessor.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx/KtxProcessor.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Buffers.Binary;
diff --git a/src/ImageSharp.Textures/Formats/Ktx2/Enums/VkFormat.cs b/src/ImageSharp.Textures/Formats/Ktx2/Enums/VkFormat.cs
index 741e06a..a3e8973 100644
--- a/src/ImageSharp.Textures/Formats/Ktx2/Enums/VkFormat.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx2/Enums/VkFormat.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Textures.Formats.Ktx2.Enums
diff --git a/src/ImageSharp.Textures/Formats/Ktx2/IKtx2DecoderOptions.cs b/src/ImageSharp.Textures/Formats/Ktx2/IKtx2DecoderOptions.cs
index 943cde5..b534ff2 100644
--- a/src/ImageSharp.Textures/Formats/Ktx2/IKtx2DecoderOptions.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx2/IKtx2DecoderOptions.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.Formats.Ktx2
{
diff --git a/src/ImageSharp.Textures/Formats/Ktx2/Ktx2ConfigurationModule.cs b/src/ImageSharp.Textures/Formats/Ktx2/Ktx2ConfigurationModule.cs
index 6490d5f..93e05c5 100644
--- a/src/ImageSharp.Textures/Formats/Ktx2/Ktx2ConfigurationModule.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx2/Ktx2ConfigurationModule.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.Formats.Ktx2
{
diff --git a/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Constants.cs b/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Constants.cs
index 459270e..0305799 100644
--- a/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Constants.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Constants.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Collections.Generic;
diff --git a/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Decoder.cs b/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Decoder.cs
index ea9c2c3..0442a62 100644
--- a/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Decoder.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Decoder.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System.IO;
diff --git a/src/ImageSharp.Textures/Formats/Ktx2/Ktx2DecoderCore.cs b/src/ImageSharp.Textures/Formats/Ktx2/Ktx2DecoderCore.cs
index eba5fdf..6decbef 100644
--- a/src/ImageSharp.Textures/Formats/Ktx2/Ktx2DecoderCore.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx2/Ktx2DecoderCore.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.IO;
diff --git a/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Format.cs b/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Format.cs
index 78f94c5..84a6ddf 100644
--- a/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Format.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Format.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System.Collections.Generic;
diff --git a/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Header.cs b/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Header.cs
index 4d5a7ba..341757f 100644
--- a/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Header.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Header.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Buffers.Binary;
@@ -105,7 +105,7 @@ public Ktx2Header(
///
/// Gets the supercompression scheme.
/// supercompressionScheme indicates if a supercompression scheme has been applied to the data in levelImages.
- /// It must be one of the values from Table 2, “Supercompression Schemes”. A value of 0 indicates no supercompression.
+ /// It must be one of the values from Table 2, “Supercompression Schemesâ€. A value of 0 indicates no supercompression.
///
public uint SupercompressionScheme { get; }
@@ -139,7 +139,7 @@ public Ktx2Header(
///
/// Gets the number of bytes of supercompressionGlobalData.
- /// For supercompression schemes for which no reference is provided in the Global Data Format column of Table 2, “Supercompression Schemes”. the value must be 0.
+ /// For supercompression schemes for which no reference is provided in the Global Data Format column of Table 2, “Supercompression Schemesâ€. the value must be 0.
///
public ulong SgdByteLength { get; }
@@ -147,7 +147,7 @@ public static Ktx2Header Parse(ReadOnlySpan data)
{
if (data.Length < Ktx2Constants.KtxHeaderSize)
{
- throw new ArgumentException(nameof(data), $"Ktx2 header must be {Ktx2Constants.KtxHeaderSize} bytes. Was {data.Length} bytes.");
+ throw new ArgumentException($"Ktx2 header must be {Ktx2Constants.KtxHeaderSize} bytes. Was {data.Length} bytes.", nameof(data));
}
return new Ktx2Header(
diff --git a/src/ImageSharp.Textures/Formats/Ktx2/Ktx2ImageFormatDetector.cs b/src/ImageSharp.Textures/Formats/Ktx2/Ktx2ImageFormatDetector.cs
index cf4468f..c1ab087 100644
--- a/src/ImageSharp.Textures/Formats/Ktx2/Ktx2ImageFormatDetector.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx2/Ktx2ImageFormatDetector.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
@@ -14,7 +14,7 @@ public sealed class Ktx2ImageFormatDetector : ITextureFormatDetector
public int HeaderSize => 12;
///
- public ITextureFormat DetectFormat(ReadOnlySpan header) => this.IsSupportedFileFormat(header) ? Ktx2Format.Instance : null;
+ public ITextureFormat? DetectFormat(ReadOnlySpan header) => this.IsSupportedFileFormat(header) ? Ktx2Format.Instance : null;
private bool IsSupportedFileFormat(ReadOnlySpan header)
{
diff --git a/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Processor.cs b/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Processor.cs
index 9522d7a..4dbd30d 100644
--- a/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Processor.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx2/Ktx2Processor.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.IO;
@@ -51,112 +51,112 @@ public MipMap[] DecodeMipMaps(Stream stream, int width, int height, LevelIndex[]
case VkFormat.VK_FORMAT_R8_SINT:
case VkFormat.VK_FORMAT_R8_SRGB:
// Single channel textures will be decoded to luminance image.
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R16_UNORM:
case VkFormat.VK_FORMAT_R16_SNORM:
case VkFormat.VK_FORMAT_R16_UINT:
case VkFormat.VK_FORMAT_R16_SINT:
// Single channel textures will be decoded to luminance image.
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R16_SFLOAT:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R8G8_UNORM:
case VkFormat.VK_FORMAT_R8G8_SNORM:
case VkFormat.VK_FORMAT_R8G8_UINT:
case VkFormat.VK_FORMAT_R8G8_SINT:
case VkFormat.VK_FORMAT_R8G8_SRGB:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R16G16_UNORM:
case VkFormat.VK_FORMAT_R16G16_SNORM:
case VkFormat.VK_FORMAT_R16G16_UINT:
case VkFormat.VK_FORMAT_R16G16_SINT:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R32G32_UINT:
case VkFormat.VK_FORMAT_R32G32_SINT:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R32G32_SFLOAT:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R16G16B16_UNORM:
case VkFormat.VK_FORMAT_R16G16B16_SNORM:
case VkFormat.VK_FORMAT_R16G16B16_UINT:
case VkFormat.VK_FORMAT_R16G16B16_SINT:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R16G16B16A16_UNORM:
case VkFormat.VK_FORMAT_R16G16B16A16_SNORM:
case VkFormat.VK_FORMAT_R16G16B16A16_UINT:
case VkFormat.VK_FORMAT_R16G16B16A16_SINT:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R16G16B16A16_SFLOAT:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R32G32B32_UINT:
case VkFormat.VK_FORMAT_R32G32B32_SINT:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R32G32B32_SFLOAT:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R32G32B32A32_UINT:
case VkFormat.VK_FORMAT_R32G32B32A32_SINT:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R32G32B32A32_SFLOAT:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_B8G8R8_UNORM:
case VkFormat.VK_FORMAT_B8G8R8_SNORM:
case VkFormat.VK_FORMAT_B8G8R8_UINT:
case VkFormat.VK_FORMAT_B8G8R8_SINT:
case VkFormat.VK_FORMAT_B8G8R8_SRGB:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R8G8B8_UNORM:
case VkFormat.VK_FORMAT_R8G8B8_SNORM:
case VkFormat.VK_FORMAT_R8G8B8_UINT:
case VkFormat.VK_FORMAT_R8G8B8_SINT:
case VkFormat.VK_FORMAT_R8G8B8_SRGB:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R5G6B5_UNORM_PACK16:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R4G4B4A4_UNORM_PACK16:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_B8G8R8A8_UNORM:
case VkFormat.VK_FORMAT_B8G8R8A8_SNORM:
case VkFormat.VK_FORMAT_B8G8R8A8_UINT:
case VkFormat.VK_FORMAT_B8G8R8A8_SINT:
case VkFormat.VK_FORMAT_B8G8R8A8_SRGB:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_B5G5R5A1_UNORM_PACK16:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_B5G6R5_UNORM_PACK16:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_B4G4R4A4_UNORM_PACK16:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R8G8B8A8_UNORM:
case VkFormat.VK_FORMAT_R8G8B8A8_SNORM:
case VkFormat.VK_FORMAT_R8G8B8A8_UINT:
case VkFormat.VK_FORMAT_R8G8B8A8_SINT:
case VkFormat.VK_FORMAT_R8G8B8A8_SRGB:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R5G5B5A1_UNORM_PACK16:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC1_RGB_UNORM_BLOCK:
case VkFormat.VK_FORMAT_BC1_RGBA_UNORM_BLOCK:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC2_UNORM_BLOCK:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC3_UNORM_BLOCK:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC4_UNORM_BLOCK:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC4_SNORM_BLOCK:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC5_UNORM_BLOCK:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC5_SNORM_BLOCK:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC6H_UFLOAT_BLOCK:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC6H_SFLOAT_BLOCK:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC7_UNORM_BLOCK:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
case VkFormat.VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
- return this.AllocateMipMaps(memoryStream, width, height, levelIndices);
+ return AllocateMipMaps(memoryStream, width, height, levelIndices);
}
throw new NotSupportedException("The pixel format is not supported");
@@ -183,109 +183,109 @@ public CubemapTexture DecodeCubeMap(Stream stream, int width, int height, LevelI
case VkFormat.VK_FORMAT_R8_UINT:
case VkFormat.VK_FORMAT_R8_SINT:
case VkFormat.VK_FORMAT_R8_SRGB:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R16_UNORM:
case VkFormat.VK_FORMAT_R16_SNORM:
case VkFormat.VK_FORMAT_R16_UINT:
case VkFormat.VK_FORMAT_R16_SINT:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R8G8_UNORM:
case VkFormat.VK_FORMAT_R8G8_SNORM:
case VkFormat.VK_FORMAT_R8G8_UINT:
case VkFormat.VK_FORMAT_R8G8_SINT:
case VkFormat.VK_FORMAT_R8G8_SRGB:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R16G16_UNORM:
case VkFormat.VK_FORMAT_R16G16_SNORM:
case VkFormat.VK_FORMAT_R16G16_UINT:
case VkFormat.VK_FORMAT_R16G16_SINT:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R16G16B16_UNORM:
case VkFormat.VK_FORMAT_R16G16B16_SNORM:
case VkFormat.VK_FORMAT_R16G16B16_UINT:
case VkFormat.VK_FORMAT_R16G16B16_SINT:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R16G16B16A16_UNORM:
case VkFormat.VK_FORMAT_R16G16B16A16_SNORM:
case VkFormat.VK_FORMAT_R16G16B16A16_UINT:
case VkFormat.VK_FORMAT_R16G16B16A16_SINT:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R16_SFLOAT:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R16G16B16A16_SFLOAT:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R32G32_UINT:
case VkFormat.VK_FORMAT_R32G32_SINT:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R32G32_SFLOAT:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R32G32B32_UINT:
case VkFormat.VK_FORMAT_R32G32B32_SINT:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R32G32B32_SFLOAT:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R32G32B32A32_UINT:
case VkFormat.VK_FORMAT_R32G32B32A32_SINT:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R32G32B32A32_SFLOAT:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_B8G8R8_UNORM:
case VkFormat.VK_FORMAT_B8G8R8_SNORM:
case VkFormat.VK_FORMAT_B8G8R8_UINT:
case VkFormat.VK_FORMAT_B8G8R8_SINT:
case VkFormat.VK_FORMAT_B8G8R8_SRGB:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R8G8B8_UNORM:
case VkFormat.VK_FORMAT_R8G8B8_SNORM:
case VkFormat.VK_FORMAT_R8G8B8_UINT:
case VkFormat.VK_FORMAT_R8G8B8_SINT:
case VkFormat.VK_FORMAT_R8G8B8_SRGB:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R5G6B5_UNORM_PACK16:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R4G4B4A4_UNORM_PACK16:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_B8G8R8A8_UNORM:
case VkFormat.VK_FORMAT_B8G8R8A8_SNORM:
case VkFormat.VK_FORMAT_B8G8R8A8_UINT:
case VkFormat.VK_FORMAT_B8G8R8A8_SINT:
case VkFormat.VK_FORMAT_B8G8R8A8_SRGB:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_B5G5R5A1_UNORM_PACK16:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_B5G6R5_UNORM_PACK16:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_B4G4R4A4_UNORM_PACK16:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R8G8B8A8_UNORM:
case VkFormat.VK_FORMAT_R8G8B8A8_SNORM:
case VkFormat.VK_FORMAT_R8G8B8A8_UINT:
case VkFormat.VK_FORMAT_R8G8B8A8_SINT:
case VkFormat.VK_FORMAT_R8G8B8A8_SRGB:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_R5G5B5A1_UNORM_PACK16:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC1_RGB_UNORM_BLOCK:
case VkFormat.VK_FORMAT_BC1_RGBA_UNORM_BLOCK:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC2_UNORM_BLOCK:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC4_UNORM_BLOCK:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC4_SNORM_BLOCK:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC5_UNORM_BLOCK:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC5_SNORM_BLOCK:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC6H_UFLOAT_BLOCK:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC6H_SFLOAT_BLOCK:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_BC7_UNORM_BLOCK:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
case VkFormat.VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
- return this.AllocateCubeMap(stream, width, height, levelIndices);
+ return AllocateCubeMap(stream, width, height, levelIndices);
}
throw new NotSupportedException("The pixel format is not supported");
@@ -299,7 +299,7 @@ public CubemapTexture DecodeCubeMap(Stream stream, int width, int height, LevelI
/// The height of the texture at level 0.
/// The start offsets and byte length of each texture.
/// The decoded mipmaps.
- private MipMap[] AllocateMipMaps(Stream stream, int width, int height, LevelIndex[] levelIndices)
+ private static MipMap[] AllocateMipMaps(Stream stream, int width, int height, LevelIndex[] levelIndices)
where TBlock : struct, IBlock
{
var blockFormat = default(TBlock);
@@ -318,7 +318,7 @@ private MipMap[] AllocateMipMaps(Stream stream, int width, int height, L
return mipMaps;
}
- private CubemapTexture AllocateCubeMap(Stream stream, int width, int height, LevelIndex[] levelIndices)
+ private static CubemapTexture AllocateCubeMap(Stream stream, int width, int height, LevelIndex[] levelIndices)
where TBlock : struct, IBlock
{
var numberOfMipMaps = levelIndices.Length;
diff --git a/src/ImageSharp.Textures/Formats/Ktx2/LevelIndex.cs b/src/ImageSharp.Textures/Formats/Ktx2/LevelIndex.cs
index 5877724..80d38f6 100644
--- a/src/ImageSharp.Textures/Formats/Ktx2/LevelIndex.cs
+++ b/src/ImageSharp.Textures/Formats/Ktx2/LevelIndex.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System.Runtime.InteropServices;
diff --git a/src/ImageSharp.Textures/Formats/TextureFormatManager.cs b/src/ImageSharp.Textures/Formats/TextureFormatManager.cs
index f970676..11d36fb 100644
--- a/src/ImageSharp.Textures/Formats/TextureFormatManager.cs
+++ b/src/ImageSharp.Textures/Formats/TextureFormatManager.cs
@@ -1,192 +1,211 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
-using System;
using System.Collections.Concurrent;
-using System.Collections.Generic;
-using System.Linq;
+using System.Diagnostics.CodeAnalysis;
+using System.Globalization;
+using System.Text;
+using SixLabors.ImageSharp.Textures.Common.Exceptions;
-namespace SixLabors.ImageSharp.Textures.Formats
+namespace SixLabors.ImageSharp.Textures.Formats;
+
+///
+/// Collection of Image Formats to be used in class.
+///
+public class TextureFormatManager
{
///
- /// Collection of Image Formats to be used in class.
+ /// Used for locking against as there is no ConcurrentSet type.
+ ///
+ ///
+ private static readonly object HashLock = new();
+
+ ///
+ /// The list of supported keyed to mime types.
///
- public class TextureFormatManager
+ private readonly ConcurrentDictionary mimeTypeEncoders = new();
+
+ ///
+ /// The list of supported keyed to mime types.
+ ///
+ private readonly ConcurrentDictionary mimeTypeDecoders = new();
+
+ ///
+ /// The list of supported s.
+ ///
+ private readonly HashSet imageFormats = [];
+
+ ///
+ /// The list of supported s.
+ ///
+ private ConcurrentBag imageFormatDetectors = [];
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public TextureFormatManager()
{
- ///
- /// Used for locking against as there is no ConcurrentSet type.
- ///
- ///
- private static readonly object HashLock = new object();
-
- ///
- /// The list of supported keyed to mime types.
- ///
- private readonly ConcurrentDictionary mimeTypeEncoders = new ConcurrentDictionary();
-
- ///
- /// The list of supported keyed to mime types.
- ///
- private readonly ConcurrentDictionary mimeTypeDecoders = new ConcurrentDictionary();
-
- ///
- /// The list of supported s.
- ///
- private readonly HashSet imageFormats = new HashSet();
-
- ///
- /// The list of supported s.
- ///
- private ConcurrentBag imageFormatDetectors = new ConcurrentBag();
-
- ///
- /// Initializes a new instance of the class.
- ///
- public TextureFormatManager()
+ }
+
+ ///
+ /// Gets the maximum header size of all the formats.
+ ///
+ internal int MaxHeaderSize { get; private set; }
+
+ ///
+ /// Gets the currently registered s.
+ ///
+ public IEnumerable ImageFormats => this.imageFormats;
+
+ ///
+ /// Gets the currently registered s.
+ ///
+ internal IEnumerable FormatDetectors => this.imageFormatDetectors;
+
+ ///
+ /// Gets the currently registered s.
+ ///
+ internal IEnumerable> ImageDecoders => this.mimeTypeDecoders;
+
+ ///
+ /// Gets the currently registered s.
+ ///
+ internal IEnumerable> ImageEncoders => this.mimeTypeEncoders;
+
+ ///
+ /// Registers a new format provider.
+ ///
+ /// The format to register as a known format.
+ public void AddImageFormat(ITextureFormat format)
+ {
+ Guard.NotNull(format, nameof(format));
+ Guard.NotNull(format.MimeTypes, nameof(format.MimeTypes));
+ Guard.NotNull(format.FileExtensions, nameof(format.FileExtensions));
+
+ lock (HashLock)
{
+ _ = this.imageFormats.Add(format);
}
+ }
+
+ ///
+ /// For the specified file extensions type find the e .
+ ///
+ /// The extension to discover
+ /// The if found otherwise null
+ public ITextureFormat? FindFormatByFileExtension(string extension)
+ {
+ Guard.NotNullOrWhiteSpace(extension, nameof(extension));
- ///
- /// Gets the maximum header size of all the formats.
- ///
- internal int MaxHeaderSize { get; private set; }
-
- ///
- /// Gets the currently registered s.
- ///
- public IEnumerable ImageFormats => this.imageFormats;
-
- ///
- /// Gets the currently registered s.
- ///
- internal IEnumerable FormatDetectors => this.imageFormatDetectors;
-
- ///
- /// Gets the currently registered s.
- ///
- internal IEnumerable> ImageDecoders => this.mimeTypeDecoders;
-
- ///
- /// Gets the currently registered s.
- ///
- internal IEnumerable> ImageEncoders => this.mimeTypeEncoders;
-
- ///
- /// Registers a new format provider.
- ///
- /// The format to register as a known format.
- public void AddImageFormat(ITextureFormat format)
+ if (extension[0] == '.')
{
- Guard.NotNull(format, nameof(format));
- Guard.NotNull(format.MimeTypes, nameof(format.MimeTypes));
- Guard.NotNull(format.FileExtensions, nameof(format.FileExtensions));
-
- lock (HashLock)
- {
- if (!this.imageFormats.Contains(format))
- {
- this.imageFormats.Add(format);
- }
- }
+ extension = extension.Substring(1);
}
- ///
- /// For the specified file extensions type find the e .
- ///
- /// The extension to discover
- /// The if found otherwise null
- public ITextureFormat FindFormatByFileExtension(string extension)
- {
- Guard.NotNullOrWhiteSpace(extension, nameof(extension));
+ return this.imageFormats.FirstOrDefault(x => x.FileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase));
+ }
- if (extension[0] == '.')
- {
- extension = extension.Substring(1);
- }
+ ///
+ /// For the specified mime type find the .
+ ///
+ /// The mime-type to discover
+ /// The if found; otherwise null
+ public ITextureFormat? FindFormatByMimeType(string mimeType) => this.imageFormats.FirstOrDefault(x => x.MimeTypes.Contains(mimeType, StringComparer.OrdinalIgnoreCase));
- return this.imageFormats.FirstOrDefault(x => x.FileExtensions.Contains(extension, StringComparer.OrdinalIgnoreCase));
- }
+ ///
+ /// Sets a specific image encoder as the encoder for a specific image format.
+ ///
+ /// The image format to register the encoder for.
+ /// The encoder to use,
+ public void SetEncoder(ITextureFormat imageFormat, ITextureEncoder encoder)
+ {
+ Guard.NotNull(imageFormat, nameof(imageFormat));
+ Guard.NotNull(encoder, nameof(encoder));
+ this.AddImageFormat(imageFormat);
+ this.mimeTypeEncoders.AddOrUpdate(imageFormat, encoder, (s, e) => encoder);
+ }
- ///
- /// For the specified mime type find the .
- ///
- /// The mime-type to discover
- /// The if found; otherwise null
- public ITextureFormat FindFormatByMimeType(string mimeType) => this.imageFormats.FirstOrDefault(x => x.MimeTypes.Contains(mimeType, StringComparer.OrdinalIgnoreCase));
-
- ///
- /// Sets a specific image encoder as the encoder for a specific image format.
- ///
- /// The image format to register the encoder for.
- /// The encoder to use,
- public void SetEncoder(ITextureFormat imageFormat, ITextureEncoder encoder)
- {
- Guard.NotNull(imageFormat, nameof(imageFormat));
- Guard.NotNull(encoder, nameof(encoder));
- this.AddImageFormat(imageFormat);
- this.mimeTypeEncoders.AddOrUpdate(imageFormat, encoder, (s, e) => encoder);
- }
+ ///
+ /// Sets a specific image decoder as the decoder for a specific image format.
+ ///
+ /// The image format to register the encoder for.
+ /// The decoder to use,
+ public void SetDecoder(ITextureFormat imageFormat, ITextureDecoder decoder)
+ {
+ Guard.NotNull(imageFormat, nameof(imageFormat));
+ Guard.NotNull(decoder, nameof(decoder));
+ this.AddImageFormat(imageFormat);
+ this.mimeTypeDecoders.AddOrUpdate(imageFormat, decoder, (s, e) => decoder);
+ }
- ///
- /// Sets a specific image decoder as the decoder for a specific image format.
- ///
- /// The image format to register the encoder for.
- /// The decoder to use,
- public void SetDecoder(ITextureFormat imageFormat, ITextureDecoder decoder)
+ ///
+ /// Removes all the registered image format detectors.
+ ///
+ public void ClearImageFormatDetectors() => this.imageFormatDetectors = new ConcurrentBag();
+
+ ///
+ /// Adds a new detector for detecting mime types.
+ ///
+ /// The detector to add
+ public void AddImageFormatDetector(ITextureFormatDetector detector)
+ {
+ Guard.NotNull(detector, nameof(detector));
+ this.imageFormatDetectors.Add(detector);
+ this.SetMaxHeaderSize();
+ }
+
+ ///
+ /// For the specified mime type find the decoder.
+ ///
+ /// The format to discover
+ /// The if found otherwise null
+ /// The input format is not recognized.
+ public ITextureDecoder FindDecoder(ITextureFormat format)
+ {
+ Guard.NotNull(format, nameof(format));
+
+ if (!this.mimeTypeDecoders.TryGetValue(format, out ITextureDecoder? decoder))
{
- Guard.NotNull(imageFormat, nameof(imageFormat));
- Guard.NotNull(decoder, nameof(decoder));
- this.AddImageFormat(imageFormat);
- this.mimeTypeDecoders.AddOrUpdate(imageFormat, decoder, (s, e) => decoder);
+ ThrowInvalidDecoder(this);
}
- ///
- /// Removes all the registered image format detectors.
- ///
- public void ClearImageFormatDetectors() => this.imageFormatDetectors = new ConcurrentBag();
+ return decoder;
+ }
+
+ ///
+ /// For the specified mime type find the encoder.
+ ///
+ /// The format to discover
+ /// The if found otherwise null
+ /// The input format is not recognized.
+ public ITextureEncoder FindEncoder(ITextureFormat format)
+ {
+ Guard.NotNull(format, nameof(format));
- ///
- /// Adds a new detector for detecting mime types.
- ///
- /// The detector to add
- public void AddImageFormatDetector(ITextureFormatDetector detector)
+ if (!this.mimeTypeEncoders.TryGetValue(format, out ITextureEncoder? encoder))
{
- Guard.NotNull(detector, nameof(detector));
- this.imageFormatDetectors.Add(detector);
- this.SetMaxHeaderSize();
+ ThrowInvalidDecoder(this);
}
- ///
- /// For the specified mime type find the decoder.
- ///
- /// The format to discover
- /// The if found otherwise null
- public ITextureDecoder FindDecoder(ITextureFormat format)
- {
- Guard.NotNull(format, nameof(format));
+ return encoder;
+ }
- return this.mimeTypeDecoders.TryGetValue(format, out ITextureDecoder decoder)
- ? decoder
- : null;
- }
+ ///
+ /// Sets the max header size.
+ ///
+ private void SetMaxHeaderSize() => this.MaxHeaderSize = this.imageFormatDetectors.Max(x => x.HeaderSize);
- ///
- /// For the specified mime type find the encoder.
- ///
- /// The format to discover
- /// The if found otherwise null
- public ITextureEncoder FindEncoder(ITextureFormat format)
- {
- Guard.NotNull(format, nameof(format));
+ [DoesNotReturn]
+ internal static void ThrowInvalidDecoder(TextureFormatManager manager)
+ {
+ StringBuilder sb = new();
+ sb = sb.AppendLine("Texture cannot be loaded. Available decoders:");
- return this.mimeTypeEncoders.TryGetValue(format, out ITextureEncoder encoder)
- ? encoder
- : null;
+ foreach (KeyValuePair val in manager.ImageDecoders)
+ {
+ sb = sb.AppendFormat(CultureInfo.InvariantCulture, " - {0} : {1}{2}", val.Key.Name, val.Value.GetType().Name, Environment.NewLine);
}
- ///
- /// Sets the max header size.
- ///
- private void SetMaxHeaderSize() => this.MaxHeaderSize = this.imageFormatDetectors.Max(x => x.HeaderSize);
+ throw new UnknownTextureFormatException(sb.ToString());
}
}
diff --git a/src/ImageSharp.Textures/Formats/TextureTypeInfo.cs b/src/ImageSharp.Textures/Formats/TextureTypeInfo.cs
index 9f9ba88..ab63201 100644
--- a/src/ImageSharp.Textures/Formats/TextureTypeInfo.cs
+++ b/src/ImageSharp.Textures/Formats/TextureTypeInfo.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.Formats
{
diff --git a/src/ImageSharp.Textures/IConfigurationModule.cs b/src/ImageSharp.Textures/IConfigurationModule.cs
index fd149b6..1336239 100644
--- a/src/ImageSharp.Textures/IConfigurationModule.cs
+++ b/src/ImageSharp.Textures/IConfigurationModule.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures
{
diff --git a/src/ImageSharp.Textures/IO/IFileSystem.cs b/src/ImageSharp.Textures/IO/IFileSystem.cs
index 197ccb9..a36fd7e 100644
--- a/src/ImageSharp.Textures/IO/IFileSystem.cs
+++ b/src/ImageSharp.Textures/IO/IFileSystem.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.IO
{
diff --git a/src/ImageSharp.Textures/IO/LocalFileSystem.cs b/src/ImageSharp.Textures/IO/LocalFileSystem.cs
index fd04b76..1ff7fb9 100644
--- a/src/ImageSharp.Textures/IO/LocalFileSystem.cs
+++ b/src/ImageSharp.Textures/IO/LocalFileSystem.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.IO
{
diff --git a/src/ImageSharp.Textures/ITexture.cs b/src/ImageSharp.Textures/ITexture.cs
index e1ae4ce..8c97835 100644
--- a/src/ImageSharp.Textures/ITexture.cs
+++ b/src/ImageSharp.Textures/ITexture.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
diff --git a/src/ImageSharp.Textures/ITextureInfo.cs b/src/ImageSharp.Textures/ITextureInfo.cs
index db63a53..35443f6 100644
--- a/src/ImageSharp.Textures/ITextureInfo.cs
+++ b/src/ImageSharp.Textures/ITextureInfo.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Textures.Formats;
diff --git a/src/ImageSharp.Textures/ImageSharp.Textures.csproj b/src/ImageSharp.Textures/ImageSharp.Textures.csproj
index 696c86a..38c21b9 100644
--- a/src/ImageSharp.Textures/ImageSharp.Textures.csproj
+++ b/src/ImageSharp.Textures/ImageSharp.Textures.csproj
@@ -7,32 +7,39 @@
SixLabors.ImageSharp.Textures
SixLabors.ImageSharp.Textures
sixlabors.imagesharp.textures.128.png
- Apache-2.0
+ LICENSE
https://github.com/SixLabors/ImageSharp.Textures/
$(RepositoryUrl)
Texture Surface BASIS DDS KTX KTX2 ETC1 ETC2 DXT1 DXT3 DXT5 BC5 BC6 BC7
A texture loading and manipulation library; written in C#
+
+
+ enable
+ Nullable
+
+
-
+
- net5.0;netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0
+ net8.0;net9.0
- netcoreapp3.1;netcoreapp2.1;netstandard2.1;netstandard2.0
+ net8.0
-
+
+
-
+
diff --git a/src/ImageSharp.Textures/MipMap.cs b/src/ImageSharp.Textures/MipMap.cs
index 20b78b7..c0e5a51 100644
--- a/src/ImageSharp.Textures/MipMap.cs
+++ b/src/ImageSharp.Textures/MipMap.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures
{
diff --git a/src/ImageSharp.Textures/MipMap{TBlock}.cs b/src/ImageSharp.Textures/MipMap{TBlock}.cs
index 47abf4a..9d51b59 100644
--- a/src/ImageSharp.Textures/MipMap{TBlock}.cs
+++ b/src/ImageSharp.Textures/MipMap{TBlock}.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Textures.TextureFormats.Decoding;
diff --git a/src/ImageSharp.Textures/PixelFormats/Ayuv.cs b/src/ImageSharp.Textures/PixelFormats/Ayuv.cs
index ef44891..f31800b 100644
--- a/src/ImageSharp.Textures/PixelFormats/Ayuv.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Ayuv.cs
@@ -1,7 +1,8 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
+using System.Diagnostics.CodeAnalysis;
using System.Numerics;
using System.Runtime.CompilerServices;
using SixLabors.ImageSharp.PixelFormats;
@@ -22,15 +23,33 @@ public struct Ayuv : IPixel, IPackedVector
public uint Yuv
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- readonly get => Unsafe.As(ref Unsafe.AsRef(this));
+ readonly get => Unsafe.As(ref Unsafe.AsRef(in this));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set => Unsafe.As(ref this) = value;
}
- ///
+ ///
+ /// Compares two objects for equality.
+ ///
+ /// The on the left side of the operand.
+ /// The on the right side of the operand.
+ ///
+ /// True if the parameter is equal to the parameter; otherwise, false.
+ ///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public readonly bool Equals(Ayuv other) => this.Yuv.Equals(other.Yuv);
+ public static bool operator ==(Ayuv left, Ayuv right) => left.Equals(right);
+
+ ///
+ /// Compares two objects for equality.
+ ///
+ /// The on the left side of the operand.
+ /// The on the right side of the operand.
+ ///
+ /// True if the parameter is not equal to the parameter; otherwise, false.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool operator !=(Ayuv left, Ayuv right) => !left.Equals(right);
///
public override readonly string ToString()
@@ -122,5 +141,12 @@ public readonly Vector4 ToVector4()
// B = 1.1644Y' + 2.0172Cb'
return ColorSpaceConversion.YuvToRgba8Bit(y, u, v, a);
}
+
+ ///
+ public override readonly bool Equals(object? obj) => obj is Ayuv ayuv && this.Equals(ayuv);
+
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public readonly bool Equals(Ayuv other) => this.Yuv.Equals(other.Yuv);
}
}
diff --git a/src/ImageSharp.Textures/PixelFormats/ColorSpaceConversion.cs b/src/ImageSharp.Textures/PixelFormats/ColorSpaceConversion.cs
index d81967b..36f78ee 100644
--- a/src/ImageSharp.Textures/PixelFormats/ColorSpaceConversion.cs
+++ b/src/ImageSharp.Textures/PixelFormats/ColorSpaceConversion.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
diff --git a/src/ImageSharp.Textures/PixelFormats/Fp32.cs b/src/ImageSharp.Textures/PixelFormats/Fp32.cs
index 3a42cea..828dd0f 100644
--- a/src/ImageSharp.Textures/PixelFormats/Fp32.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Fp32.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -31,6 +31,28 @@ public Fp32(float x)
///
public float PackedValue { get; set; }
+ ///
+ /// Compares two objects for equality.
+ ///
+ /// The on the left side of the operand.
+ /// The on the right side of the operand.
+ ///
+ /// True if the parameter is equal to the parameter; otherwise, false.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool operator ==(Fp32 left, Fp32 right) => left.Equals(right);
+
+ ///
+ /// Compares two objects for equality.
+ ///
+ /// The on the left side of the operand.
+ /// The on the right side of the operand.
+ ///
+ /// True if the parameter is not equal to the parameter; otherwise, false.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool operator !=(Fp32 left, Fp32 right) => !left.Equals(right);
+
///
public PixelOperations CreatePixelOperations() => new();
@@ -90,22 +112,21 @@ public Fp32(float x)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void FromRgb24(Rgb24 source) => this.FromScaledVector4(source.ToScaledVector4());
- ///
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public void FromRgba32(Rgba32 source) => this.FromScaledVector4(source.ToScaledVector4());
-
- ///
+ ///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public void ToRgba32(ref Rgba32 dest) => dest.FromScaledVector4(this.ToScaledVector4());
+ public void FromRgb48(Rgb48 source) => this.FromScaledVector4(source.ToScaledVector4());
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public void FromRgb48(Rgb48 source) => this.FromScaledVector4(source.ToScaledVector4());
+ public void FromRgba32(Rgba32 source) => this.FromScaledVector4(source.ToScaledVector4());
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
+ ///
+ public void ToRgba32(ref Rgba32 dest) => throw new NotImplementedException();
+
///
/// Expands the packed representation into a .
/// The vector components are typically expanded in least to greatest significance order.
@@ -115,11 +136,11 @@ public Fp32(float x)
public Vector ToVector() => new Vector(this.PackedValue);
///
- public override bool Equals(object obj) => obj is Fp32 other && this.Equals(other);
+ public override readonly bool Equals(object? obj) => obj is Fp32 other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public bool Equals(Fp32 other) => this.PackedValue.Equals(other.PackedValue);
+ public readonly bool Equals(Fp32 other) => this.PackedValue.Equals(other.PackedValue);
///
public override string ToString()
@@ -130,7 +151,7 @@ public override string ToString()
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public override int GetHashCode() => this.PackedValue.GetHashCode();
+ public override readonly int GetHashCode() => this.PackedValue.GetHashCode();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static float Pack(Vector vector) => vector[0];
diff --git a/src/ImageSharp.Textures/PixelFormats/Generated/Bgr32.cs b/src/ImageSharp.Textures/PixelFormats/Generated/Bgr32.cs
index ec689f2..bac1a29 100644
--- a/src/ImageSharp.Textures/PixelFormats/Generated/Bgr32.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Generated/Bgr32.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -145,7 +145,7 @@ public void FromVector4(Vector4 vector)
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Bgr32 other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Bgr32 other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/Generated/Bgr555.cs b/src/ImageSharp.Textures/PixelFormats/Generated/Bgr555.cs
index 0a1c300..3eb78bc 100644
--- a/src/ImageSharp.Textures/PixelFormats/Generated/Bgr555.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Generated/Bgr555.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -145,7 +145,7 @@ public void FromVector4(Vector4 vector)
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Bgr555 other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Bgr555 other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/Generated/D32_FLOAT_S8X24_UINT.cs b/src/ImageSharp.Textures/PixelFormats/Generated/D32_FLOAT_S8X24_UINT.cs
index 0b8afd4..5c8c2fb 100644
--- a/src/ImageSharp.Textures/PixelFormats/Generated/D32_FLOAT_S8X24_UINT.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Generated/D32_FLOAT_S8X24_UINT.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -16,7 +16,9 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
/// Ranges from [0, 0] to [1, 1] in vector form.
///
///
+#pragma warning disable CA1707 // Identifiers should not contain underscores
public partial struct D32_FLOAT_S8X24_UINT : IPixel, IPackedVector
+#pragma warning restore CA1707 // Identifiers should not contain underscores
{
///
/// Initializes a new instance of the struct.
@@ -148,7 +150,7 @@ public Vector4 ToVector4()
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is D32_FLOAT_S8X24_UINT other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is D32_FLOAT_S8X24_UINT other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/Generated/PixelGenerator.ignore b/src/ImageSharp.Textures/PixelFormats/Generated/PixelGenerator.ignore
index d7cbbf6..a36f7e8 100644
--- a/src/ImageSharp.Textures/PixelFormats/Generated/PixelGenerator.ignore
+++ b/src/ImageSharp.Textures/PixelFormats/Generated/PixelGenerator.ignore
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -169,7 +169,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rgba128Float other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rgba128Float other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -187,7 +187,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
}
}
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -357,7 +357,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rgba128 other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rgba128 other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -375,7 +375,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
}
}
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -536,7 +536,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rgb96Float other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rgb96Float other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -554,7 +554,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
}
}
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -715,7 +715,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rgb96 other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rgb96 other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -733,7 +733,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
}
}
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -883,7 +883,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rgba64Float other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rgba64Float other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -913,7 +913,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
}
}
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -1061,7 +1061,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rg32Float other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rg32Float other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -1089,7 +1089,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
}
}
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -1241,7 +1241,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rg64Float other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rg64Float other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -1259,7 +1259,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
}
}
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -1411,7 +1411,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rg64 other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rg64 other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -1429,7 +1429,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
}
}
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -1577,7 +1577,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is D32_FLOAT_S8X24_UINT other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is D32_FLOAT_S8X24_UINT other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -1605,7 +1605,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
}
}
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -1753,7 +1753,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Bgr555 other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Bgr555 other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -1782,7 +1782,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
}
}
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -1931,7 +1931,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rgba5551 other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rgba5551 other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -1961,7 +1961,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
}
}
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
diff --git a/src/ImageSharp.Textures/PixelFormats/Generated/PixelGenerator.tt b/src/ImageSharp.Textures/PixelFormats/Generated/PixelGenerator.tt
index 1ac6761..4ab4fe6 100644
--- a/src/ImageSharp.Textures/PixelFormats/Generated/PixelGenerator.tt
+++ b/src/ImageSharp.Textures/PixelFormats/Generated/PixelGenerator.tt
@@ -192,7 +192,7 @@
manager.StartNewFile($"{pixelInfo.Name}.cs");
#>// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
<#= Helper.GenerateUsings(pixelInfo) #>
@@ -296,7 +296,7 @@ namespace SixLabors.ImageSharp.Textures.PixelFormats
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is <#= pixelInfo.Name #> other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is <#= pixelInfo.Name #> other && this.Equals(other);
<#= Helper.GenerateEquals(pixelInfo, 8) #>
diff --git a/src/ImageSharp.Textures/PixelFormats/Generated/R11G11B10Float.cs b/src/ImageSharp.Textures/PixelFormats/Generated/R11G11B10Float.cs
index 19c9d08..0be3301 100644
--- a/src/ImageSharp.Textures/PixelFormats/Generated/R11G11B10Float.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Generated/R11G11B10Float.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -152,7 +152,7 @@ public void ToRgba32(ref Rgba32 dest)
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is R11G11B10Float other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is R11G11B10Float other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/Generated/Rg32Float.cs b/src/ImageSharp.Textures/PixelFormats/Generated/Rg32Float.cs
index 908129d..36100cf 100644
--- a/src/ImageSharp.Textures/PixelFormats/Generated/Rg32Float.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Generated/Rg32Float.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -145,7 +145,7 @@ public void FromVector4(Vector4 vector)
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rg32Float other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rg32Float other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/Generated/Rg64.cs b/src/ImageSharp.Textures/PixelFormats/Generated/Rg64.cs
index 7b04ada..fd44428 100644
--- a/src/ImageSharp.Textures/PixelFormats/Generated/Rg64.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Generated/Rg64.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -149,7 +149,7 @@ public void FromVector4(Vector4 vector)
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rg64 other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rg64 other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/Generated/Rg64Float.cs b/src/ImageSharp.Textures/PixelFormats/Generated/Rg64Float.cs
index f09b314..7eb39b5 100644
--- a/src/ImageSharp.Textures/PixelFormats/Generated/Rg64Float.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Generated/Rg64Float.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -149,7 +149,7 @@ public void FromVector4(Vector4 vector)
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rg64Float other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rg64Float other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/Generated/Rgb32.cs b/src/ImageSharp.Textures/PixelFormats/Generated/Rgb32.cs
index 769e84d..4791df5 100644
--- a/src/ImageSharp.Textures/PixelFormats/Generated/Rgb32.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Generated/Rgb32.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -145,7 +145,7 @@ public void FromVector4(Vector4 vector)
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rgb32 other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rgb32 other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/Generated/Rgb565.cs b/src/ImageSharp.Textures/PixelFormats/Generated/Rgb565.cs
index be62de3..1eff83a 100644
--- a/src/ImageSharp.Textures/PixelFormats/Generated/Rgb565.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Generated/Rgb565.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -148,7 +148,7 @@ public void ToRgba32(ref Rgba32 dest)
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rgb565 other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rgb565 other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/Generated/Rgb96.cs b/src/ImageSharp.Textures/PixelFormats/Generated/Rgb96.cs
index 34e101e..13fac46 100644
--- a/src/ImageSharp.Textures/PixelFormats/Generated/Rgb96.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Generated/Rgb96.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -158,7 +158,7 @@ public void FromVector4(Vector4 vector)
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rgb96 other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rgb96 other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/Generated/Rgb96Float.cs b/src/ImageSharp.Textures/PixelFormats/Generated/Rgb96Float.cs
index f63bef7..ab1cd9d 100644
--- a/src/ImageSharp.Textures/PixelFormats/Generated/Rgb96Float.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Generated/Rgb96Float.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -158,7 +158,7 @@ public void FromVector4(Vector4 vector)
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rgb96Float other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rgb96Float other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/Generated/Rgba128.cs b/src/ImageSharp.Textures/PixelFormats/Generated/Rgba128.cs
index 8398c1d..c4728c3 100644
--- a/src/ImageSharp.Textures/PixelFormats/Generated/Rgba128.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Generated/Rgba128.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -167,7 +167,7 @@ public void FromVector4(Vector4 vector)
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rgba128 other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rgba128 other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/Generated/Rgba128Float.cs b/src/ImageSharp.Textures/PixelFormats/Generated/Rgba128Float.cs
index eab0e6a..f21a864 100644
--- a/src/ImageSharp.Textures/PixelFormats/Generated/Rgba128Float.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Generated/Rgba128Float.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -167,7 +167,7 @@ public void FromVector4(Vector4 vector)
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rgba128Float other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rgba128Float other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/Generated/Rgba4444.cs b/src/ImageSharp.Textures/PixelFormats/Generated/Rgba4444.cs
index f929bcc..64b7d7d 100644
--- a/src/ImageSharp.Textures/PixelFormats/Generated/Rgba4444.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Generated/Rgba4444.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -146,7 +146,7 @@ public void FromVector4(Vector4 vector)
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rgba4444 other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rgba4444 other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/Generated/Rgba5551.cs b/src/ImageSharp.Textures/PixelFormats/Generated/Rgba5551.cs
index d5914b0..7c99ac4 100644
--- a/src/ImageSharp.Textures/PixelFormats/Generated/Rgba5551.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Generated/Rgba5551.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -146,7 +146,7 @@ public void FromVector4(Vector4 vector)
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rgba5551 other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rgba5551 other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/Generated/Rgba64Float.cs b/src/ImageSharp.Textures/PixelFormats/Generated/Rgba64Float.cs
index 045bb8c..8cd8db4 100644
--- a/src/ImageSharp.Textures/PixelFormats/Generated/Rgba64Float.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Generated/Rgba64Float.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -150,7 +150,7 @@ public void ToRgba32(ref Rgba32 dest)
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is Rgba64Float other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rgba64Float other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/L32.cs b/src/ImageSharp.Textures/PixelFormats/L32.cs
index 0c3e37b..97caeef 100644
--- a/src/ImageSharp.Textures/PixelFormats/L32.cs
+++ b/src/ImageSharp.Textures/PixelFormats/L32.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System.Numerics;
using System.Runtime.CompilerServices;
@@ -150,7 +150,7 @@ public void ToRgba32(ref Rgba32 dest)
public PixelOperations CreatePixelOperations() => new();
///
- public override readonly bool Equals(object obj) => obj is L16 other && this.Equals(other);
+ public override readonly bool Equals(object? obj) => obj is L16 other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/R16Float.cs b/src/ImageSharp.Textures/PixelFormats/R16Float.cs
index b7d74a5..d951de2 100644
--- a/src/ImageSharp.Textures/PixelFormats/R16Float.cs
+++ b/src/ImageSharp.Textures/PixelFormats/R16Float.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -127,7 +127,7 @@ public void FromVector4(Vector4 vector)
public void FromRgba64(Rgba64 source) => this.FromScaledVector4(source.ToScaledVector4());
///
- public override bool Equals(object obj) => obj is R16Float other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is R16Float other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/Rg16.cs b/src/ImageSharp.Textures/PixelFormats/Rg16.cs
index 980f43d..70a4ef6 100644
--- a/src/ImageSharp.Textures/PixelFormats/Rg16.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Rg16.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -147,7 +147,7 @@ public void FromVector4(Vector4 vector)
public Vector2 ToVector2() => new Vector2(this.PackedValue & 0xFF, (this.PackedValue >> 8) & 0xFF) / Max;
///
- public override bool Equals(object obj) => obj is Rg16 other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rg16 other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/Rg32.cs b/src/ImageSharp.Textures/PixelFormats/Rg32.cs
index 8164651..d87dc6b 100644
--- a/src/ImageSharp.Textures/PixelFormats/Rg32.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Rg32.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -147,7 +147,7 @@ public void FromVector4(Vector4 vector)
public Vector2 ToVector2() => new Vector2(this.PackedValue & 0xFF, (this.PackedValue >> 8) & 0xFF) / Max;
///
- public override bool Equals(object obj) => obj is Rg32 other && this.Equals(other);
+ public override bool Equals(object? obj) => obj is Rg32 other && this.Equals(other);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/ImageSharp.Textures/PixelFormats/Y410.cs b/src/ImageSharp.Textures/PixelFormats/Y410.cs
index 07b17dd..701a145 100644
--- a/src/ImageSharp.Textures/PixelFormats/Y410.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Y410.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -22,12 +22,37 @@ public struct Y410 : IPixel, IPackedVector
public uint Yuv
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- readonly get => Unsafe.As(ref Unsafe.AsRef(this));
+ readonly get => Unsafe.As(ref Unsafe.AsRef(in this));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set => Unsafe.As(ref this) = value;
}
+ ///
+ /// Compares two objects for equality.
+ ///
+ /// The on the left side of the operand.
+ /// The on the right side of the operand.
+ ///
+ /// True if the parameter is equal to the parameter; otherwise, false.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool operator ==(Y410 left, Y410 right) => left.Equals(right);
+
+ ///
+ /// Compares two objects for equality.
+ ///
+ /// The on the left side of the operand.
+ /// The on the right side of the operand.
+ ///
+ /// True if the parameter is not equal to the parameter; otherwise, false.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool operator !=(Y410 left, Y410 right) => !left.Equals(right);
+
+ ///
+ public override readonly bool Equals(object? obj) => obj is Y410 other && this.Equals(other);
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool Equals(Y410 other) => this.Yuv.Equals(other.Yuv);
diff --git a/src/ImageSharp.Textures/PixelFormats/Y416.cs b/src/ImageSharp.Textures/PixelFormats/Y416.cs
index fb65ec3..33887f0 100644
--- a/src/ImageSharp.Textures/PixelFormats/Y416.cs
+++ b/src/ImageSharp.Textures/PixelFormats/Y416.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
@@ -22,12 +22,37 @@ public struct Y416 : IPixel, IPackedVector
public ulong Yuv
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- readonly get => Unsafe.As(ref Unsafe.AsRef(this));
+ readonly get => Unsafe.As(ref Unsafe.AsRef(in this));
[MethodImpl(MethodImplOptions.AggressiveInlining)]
set => Unsafe.As(ref this) = value;
}
+ ///
+ /// Compares two objects for equality.
+ ///
+ /// The on the left side of the operand.
+ /// The on the right side of the operand.
+ ///
+ /// True if the parameter is equal to the parameter; otherwise, false.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool operator ==(Y416 left, Y416 right) => left.Equals(right);
+
+ ///
+ /// Compares two objects for equality.
+ ///
+ /// The on the left side of the operand.
+ /// The on the right side of the operand.
+ ///
+ /// True if the parameter is not equal to the parameter; otherwise, false.
+ ///
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static bool operator !=(Y416 left, Y416 right) => !left.Equals(right);
+
+ ///
+ public override readonly bool Equals(object? obj) => obj is Y416 other && this.Equals(other);
+
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public readonly bool Equals(Y416 other) => this.Yuv.Equals(other.Yuv);
diff --git a/src/ImageSharp.Textures/Texture.Decode.cs b/src/ImageSharp.Textures/Texture.Decode.cs
index 2b7ea4b..b08b6a0 100644
--- a/src/ImageSharp.Textures/Texture.Decode.cs
+++ b/src/ImageSharp.Textures/Texture.Decode.cs
@@ -1,99 +1,102 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
-using System;
-using System.IO;
-using System.Linq;
using SixLabors.ImageSharp.Memory;
+using SixLabors.ImageSharp.Textures.Common.Exceptions;
using SixLabors.ImageSharp.Textures.Common.Extensions;
using SixLabors.ImageSharp.Textures.Formats;
-namespace SixLabors.ImageSharp.Textures
+namespace SixLabors.ImageSharp.Textures;
+
+///
+/// Adds static methods allowing the decoding of new images.
+///
+public abstract partial class Texture
{
- ///
- /// Adds static methods allowing the decoding of new images.
- ///
- public abstract partial class Texture
+ ///
+ /// By reading the header on the provided stream this calculates the images format.
+ ///
+ /// The image stream to read the header from.
+ /// The configuration.
+ /// The mime type.
+ /// The input format is not recognized.
+ private static ITextureFormat InternalDetectFormat(Stream stream, Configuration config)
{
- ///
- /// By reading the header on the provided stream this calculates the images format.
- ///
- /// The image stream to read the header from.
- /// The configuration.
- /// The mime type or null if none found.
- private static ITextureFormat InternalDetectFormat(Stream stream, Configuration config)
+ // We take a minimum of the stream length vs the max header size and always check below
+ // to ensure that only formats that headers fit within the given buffer length are tested.
+ int headerSize = (int)Math.Min(config.MaxHeaderSize, stream.Length);
+ if (headerSize <= 0)
{
- // We take a minimum of the stream length vs the max header size and always check below
- // to ensure that only formats that headers fit within the given buffer length are tested.
- int headerSize = (int)Math.Min(config.MaxHeaderSize, stream.Length);
- if (headerSize <= 0)
- {
- return null;
- }
+ TextureFormatManager.ThrowInvalidDecoder(config.ImageFormatsManager);
+ }
- using System.Buffers.IMemoryOwner buffer = config.MemoryAllocator.Allocate(headerSize, AllocationOptions.Clean);
- long startPosition = stream.Position;
- Span bufferSpan = buffer.Memory.Span;
- stream.Read(bufferSpan, 0, headerSize);
- stream.Position = startPosition;
+ using System.Buffers.IMemoryOwner buffer = config.MemoryAllocator.Allocate(headerSize, AllocationOptions.Clean);
+ long startPosition = stream.Position;
+ Span bufferSpan = buffer.Memory.Span;
+ stream.Read(bufferSpan, 0, headerSize);
+ stream.Position = startPosition;
- // Does the given stream contain enough data to fit in the header for the format
- // and does that data match the format specification?
- // Individual formats should still check since they are public.
- return config.ImageFormatsManager.FormatDetectors
- .Where(x => x.HeaderSize <= headerSize)
- .Select(x => x.DetectFormat(buffer.Memory.Span)).LastOrDefault(x => x != null);
- }
+ // Does the given stream contain enough data to fit in the header for the format
+ // and does that data match the format specification?
+ // Individual formats should still check since they are public.
+ ITextureFormat? format = config.ImageFormatsManager.FormatDetectors
+ .Where(x => x.HeaderSize <= headerSize)
+ .Select(x => x.DetectFormat(buffer.Memory.Span))
+ .LastOrDefault(x => x is not null);
- ///
- /// By reading the header on the provided stream this calculates the images format.
- ///
- /// The image stream to read the header from.
- /// The configuration.
- /// The IImageFormat.
- /// The image format or null if none found.
- private static ITextureDecoder DiscoverDecoder(Stream stream, Configuration config, out ITextureFormat format)
+ if (format is null)
{
- format = InternalDetectFormat(stream, config);
-
- return format != null
- ? config.ImageFormatsManager.FindDecoder(format)
- : null;
+ TextureFormatManager.ThrowInvalidDecoder(config.ImageFormatsManager);
}
- ///
- /// Decodes the image stream to the current image.
- ///
- /// The stream.
- /// the configuration.
- private static (Texture Texture, ITextureFormat Format) DecodeTexture(Stream stream, Configuration config)
- {
- ITextureDecoder decoder = DiscoverDecoder(stream, config, out ITextureFormat format);
- if (decoder is null)
- {
- return (null, null);
- }
+ return format;
+ }
- Texture texture = decoder.DecodeTexture(config, stream);
- return (texture, format);
- }
+ ///
+ /// By reading the header on the provided stream this calculates the images format.
+ ///
+ /// The image stream to read the header from.
+ /// The configuration.
+ /// The IImageFormat.
+ /// The image format.
+ /// The input format is not recognized.
+ private static ITextureDecoder DiscoverDecoder(Stream stream, Configuration config, out ITextureFormat format)
+ {
+ format = InternalDetectFormat(stream, config);
- ///
- /// Reads the raw image information from the specified stream.
- ///
- /// The stream.
- /// the configuration.
- ///
- /// The or null if suitable info detector not found.
- ///
- private static (ITextureInfo Info, ITextureFormat Format) InternalIdentity(Stream stream, Configuration config)
- {
- if (DiscoverDecoder(stream, config, out ITextureFormat format) is not ITextureInfoDetector detector)
- {
- return (null, null);
- }
+ return config.ImageFormatsManager.FindDecoder(format);
+ }
+
+ ///
+ /// Decodes the image stream to the current image.
+ ///
+ /// The stream.
+ /// the configuration.
+ /// The input format is not recognized.
+ private static (Texture Texture, ITextureFormat Format) DecodeTexture(Stream stream, Configuration config)
+ {
+ ITextureDecoder decoder = DiscoverDecoder(stream, config, out ITextureFormat? format);
+
+ Texture texture = decoder.DecodeTexture(config, stream);
+ return (texture, format);
+ }
- return (detector?.Identify(config, stream), format);
+ ///
+ /// Reads the raw image information from the specified stream.
+ ///
+ /// The stream.
+ /// the configuration.
+ ///
+ /// The .
+ ///
+ /// The input format is not recognized.
+ private static (ITextureInfo Info, ITextureFormat Format) InternalIdentity(Stream stream, Configuration config)
+ {
+ if (DiscoverDecoder(stream, config, out ITextureFormat? format) is not ITextureInfoDetector detector)
+ {
+ throw new UnknownTextureFormatException("No suitable info detector found for the given stream.");
}
+
+ return (detector.Identify(config, stream), format);
}
}
diff --git a/src/ImageSharp.Textures/Texture.FromBytes.cs b/src/ImageSharp.Textures/Texture.FromBytes.cs
index aacc72b..53e994e 100644
--- a/src/ImageSharp.Textures/Texture.FromBytes.cs
+++ b/src/ImageSharp.Textures/Texture.FromBytes.cs
@@ -1,245 +1,240 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
-using System;
-using System.IO;
+using SixLabors.ImageSharp.Textures.Common.Exceptions;
using SixLabors.ImageSharp.Textures.Formats;
-namespace SixLabors.ImageSharp.Textures
+namespace SixLabors.ImageSharp.Textures;
+
+///
+/// Adds static methods allowing the creation of new image from a byte array.
+///
+public abstract partial class Texture
{
- ///
- /// Adds static methods allowing the creation of new image from a byte array.
- ///
- public abstract partial class Texture
+ ///
+ /// By reading the header on the provided byte array this calculates the images format.
+ ///
+ /// The byte array containing encoded texture data to read the header from.
+ /// The format.
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static ITextureFormat DetectFormat(byte[] data) => DetectFormat(Configuration.Default, data);
+
+ ///
+ /// By reading the header on the provided byte array this calculates the images format.
+ ///
+ /// The byte array containing encoded texture data to read the header from.
+ /// The format.
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static ITextureFormat DetectFormat(ReadOnlySpan data) => DetectFormat(Configuration.Default, data);
+
+ ///
+ /// By reading the header on the provided byte array this calculates the images format.
+ ///
+ /// The configuration.
+ /// The byte array containing encoded texture data to read the header from.
+ /// The mime type.
+ /// The options are null.
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static unsafe ITextureFormat DetectFormat(Configuration config, ReadOnlySpan buffer)
{
- ///
- /// By reading the header on the provided byte array this calculates the images format.
- ///
- /// The byte array containing encoded texture data to read the header from.
- /// The format or null if none found.
- public static ITextureFormat DetectFormat(byte[] data) => DetectFormat(Configuration.Default, data);
-
- ///
- /// By reading the header on the provided byte array this calculates the images format.
- ///
- /// The configuration.
- /// The byte array containing encoded texture data to read the header from.
- /// The mime type or null if none found.
- public static ITextureFormat DetectFormat(Configuration config, byte[] data)
- {
- using (var stream = new MemoryStream(data))
- {
- return DetectFormat(config, stream);
- }
- }
+ Guard.NotNull(config, nameof(config));
- ///
- /// By reading the header on the provided byte array this calculates the images format.
- ///
- /// The byte array containing encoded texture data to read the header from.
- /// The format or null if none found.
- public static ITextureFormat DetectFormat(ReadOnlySpan data) => DetectFormat(Configuration.Default, data);
-
- ///
- /// By reading the header on the provided byte array this calculates the images format.
- ///
- /// The configuration.
- /// The byte array containing encoded texture data to read the header from.
- /// The mime type or null if none found.
- public static ITextureFormat DetectFormat(Configuration config, ReadOnlySpan data)
+ fixed (byte* ptr = buffer)
{
- int maxHeaderSize = config.MaxHeaderSize;
- if (maxHeaderSize <= 0)
- {
- return null;
- }
-
- foreach (ITextureFormatDetector detector in config.ImageFormatsManager.FormatDetectors)
- {
- ITextureFormat f = detector.DetectFormat(data);
-
- if (f != null)
- {
- return f;
- }
- }
-
- return default;
+ using UnmanagedMemoryStream stream = new(ptr, buffer.Length);
+ return DetectFormat(config, stream);
}
+ }
- ///
- /// Reads the raw texture information from the specified stream without fully decoding it.
- ///
- /// The byte array containing encoded texture data to read the header from.
- /// The data is null.
- /// The data is not readable.
- ///
- /// The or null if suitable info detector not found.
- ///
- public static ITextureInfo Identify(byte[] data) => Identify(data, out ITextureFormat _);
-
- ///
- /// Reads the raw image information from the specified stream without fully decoding it.
- ///
- /// The byte array containing encoded texture data to read the header from.
- /// The format type of the decoded texture.
- /// The data is null.
- /// The data is not readable.
- ///
- /// The or null if suitable info detector not found.
- ///
- public static ITextureInfo Identify(byte[] data, out ITextureFormat format) => Identify(Configuration.Default, data, out format);
-
- ///
- /// Reads the raw texture information from the specified stream without fully decoding it.
- ///
- /// The configuration.
- /// The byte array containing encoded texture data to read the header from.
- /// The format type of the decoded texture.
- /// The configuration is null.
- /// The data is null.
- /// The data is not readable.
- ///
- /// The or null if suitable info detector is not found.
- ///
- public static ITextureInfo Identify(Configuration configuration, byte[] data, out ITextureFormat format)
- {
- Guard.NotNull(data, nameof(data));
+ ///
+ /// Reads the raw texture information from the specified stream without fully decoding it.
+ ///
+ /// The byte array containing encoded texture data to read the header from.
+ ///
+ /// The .
+ ///
+ /// The data is null.
+ /// The data is not readable.
+ /// Texture cannot be loaded.
+ public static ITextureInfo Identify(byte[] data) => Identify(data, out ITextureFormat? _);
+
+ ///
+ /// Reads the raw image information from the specified stream without fully decoding it.
+ ///
+ /// The byte array containing encoded texture data to read the header from.
+ /// The format type of the decoded texture.
+ ///
+ /// The .
+ ///
+ /// The data is null.
+ /// The data is not readable.
+ /// Texture cannot be loaded.
+ public static ITextureInfo Identify(byte[] data, out ITextureFormat? format) => Identify(Configuration.Default, data, out format);
+
+ ///
+ /// Reads the raw texture information from the specified stream without fully decoding it.
+ ///
+ /// The configuration.
+ /// The byte array containing encoded texture data to read the header from.
+ /// The format type of the decoded texture.
+ ///
+ /// The or null if suitable info detector is not found.
+ ///
+ /// The data or configuration is null.
+ /// The data is not readable.
+ /// Texture cannot be loaded.
+ public static ITextureInfo Identify(Configuration configuration, byte[] data, out ITextureFormat? format)
+ {
+ Guard.NotNull(data, nameof(data));
- using (var stream = new MemoryStream(data, 0, data.Length, false, true))
- {
- return Identify(configuration, stream, out format);
- }
- }
+ using MemoryStream stream = new(data, 0, data.Length, false, true);
+ return Identify(configuration, stream, out format);
+ }
- ///
- /// Load a new instance of from the given encoded byte array.
- ///
- /// The byte array containing texture data.
- /// The detected format.
- /// The .
- public static Texture Load(byte[] data, out ITextureFormat format) =>
- Load(Configuration.Default, data, out format);
-
- ///
- /// Load a new instance of from the given encoded byte array.
- ///
- /// The byte array containing encoded texture data.
- /// The decoder.
- /// The .
- public static Texture Load(byte[] data, ITextureDecoder decoder) => Load(Configuration.Default, data, decoder);
-
- ///
- /// Load a new instance of from the given encoded byte array.
- ///
- /// The config for the decoder.
- /// The byte array containing encoded texture data.
- /// The .
- public static Texture Load(Configuration config, byte[] data) => Load(config, data, out _);
-
- ///
- /// Load a new instance of from the given encoded byte array.
- ///
- /// The config for the decoder.
- /// The byte array containing texture data.
- /// The decoder.
- /// The .
- public static Texture Load(Configuration config, byte[] data, ITextureDecoder decoder)
- {
- using (var stream = new MemoryStream(data))
- {
- return Load(config, stream, decoder);
- }
- }
+ ///
+ /// Load a new instance of from the given encoded byte array.
+ ///
+ /// The byte array containing texture data.
+ /// The detected format.
+ /// The .
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(byte[] data, out ITextureFormat? format) =>
+ Load(Configuration.Default, data, out format);
+
+ ///
+ /// Load a new instance of from the given encoded byte array.
+ ///
+ /// The byte array containing encoded texture data.
+ /// The decoder.
+ /// The .
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(byte[] data, ITextureDecoder decoder) => Load(Configuration.Default, data, decoder);
+
+ ///
+ /// Load a new instance of from the given encoded byte array.
+ ///
+ /// The config for the decoder.
+ /// The byte array containing encoded texture data.
+ /// The .
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(Configuration config, byte[] data) => Load(config, data, out _);
+
+ ///
+ /// Load a new instance of from the given encoded byte array.
+ ///
+ /// The config for the decoder.
+ /// The byte array containing texture data.
+ /// The decoder.
+ /// The .
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(Configuration config, byte[] data, ITextureDecoder decoder)
+ {
+ using MemoryStream stream = new(data);
+ return Load(config, stream, decoder);
+ }
- ///
- /// Load a new instance of from the given encoded byte array.
- ///
- /// The config for the decoder.
- /// The byte array containing texture data.
- /// The mime type of the decoded texture.
- /// The .
- public static Texture Load(Configuration config, byte[] data, out ITextureFormat format)
- {
- using (var stream = new MemoryStream(data))
- {
- return Load(config, stream, out format);
- }
- }
+ ///
+ /// Load a new instance of from the given encoded byte array.
+ ///
+ /// The config for the decoder.
+ /// The byte array containing texture data.
+ /// The mime type of the decoded texture.
+ /// The .
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(Configuration config, byte[] data, out ITextureFormat? format)
+ {
+ using MemoryStream stream = new(data);
+ return Load(config, stream, out format);
+ }
- ///
- /// Load a new instance of from the given encoded byte span.
- ///
- /// The byte span containing texture data.
- /// The .
- public static Texture Load(ReadOnlySpan data) => Load(Configuration.Default, data);
-
- ///
- /// Load a new instance of from the given encoded byte span.
- ///
- /// The byte span containing texture data.
- /// The decoder.
- /// The .
- public static Texture Load(ReadOnlySpan data, ITextureDecoder decoder) =>
- Load(Configuration.Default, data, decoder);
-
- ///
- /// Load a new instance of from the given encoded byte array.
- ///
- /// The byte span containing texture data.
- /// The detected format.
- /// The .
- public static Texture Load(ReadOnlySpan data, out ITextureFormat format) =>
- Load(Configuration.Default, data, out format);
-
- ///
- /// Decodes a new instance of from the given encoded byte span.
- ///
- /// The configuration options.
- /// The byte span containing texture data.
- /// The .
- public static Texture Load(Configuration config, ReadOnlySpan data) => Load(config, data, out _);
-
- ///
- /// Load a new instance of from the given encoded byte span.
- ///
- /// The Configuration.
- /// The byte span containing texture data.
- /// The decoder.
- /// The .
- public static unsafe Texture Load(
- Configuration config,
- ReadOnlySpan data,
- ITextureDecoder decoder)
+ ///
+ /// Load a new instance of from the given encoded byte span.
+ ///
+ /// The byte span containing texture data.
+ /// The .
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(ReadOnlySpan data) => Load(Configuration.Default, data);
+
+ ///
+ /// Load a new instance of from the given encoded byte span.
+ ///
+ /// The byte span containing texture data.
+ /// The decoder.
+ /// The .
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(ReadOnlySpan data, ITextureDecoder decoder) =>
+ Load(Configuration.Default, data, decoder);
+
+ ///
+ /// Load a new instance of from the given encoded byte array.
+ ///
+ /// The byte span containing texture data.
+ /// The detected format.
+ /// The .
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(ReadOnlySpan data, out ITextureFormat? format) =>
+ Load(Configuration.Default, data, out format);
+
+ ///
+ /// Decodes a new instance of from the given encoded byte span.
+ ///
+ /// The configuration options.
+ /// The byte span containing texture data.
+ /// The .
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(Configuration config, ReadOnlySpan data) => Load(config, data, out _);
+
+ ///
+ /// Load a new instance of from the given encoded byte span.
+ ///
+ /// The Configuration.
+ /// The byte span containing texture data.
+ /// The decoder.
+ /// The .
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static unsafe Texture Load(
+ Configuration config,
+ ReadOnlySpan data,
+ ITextureDecoder decoder)
+ {
+ fixed (byte* ptr = &data.GetPinnableReference())
{
- fixed (byte* ptr = &data.GetPinnableReference())
- {
- using (var stream = new UnmanagedMemoryStream(ptr, data.Length))
- {
- return Load(config, stream, decoder);
- }
- }
+ using UnmanagedMemoryStream stream = new(ptr, data.Length);
+ return Load(config, stream, decoder);
}
+ }
- ///
- /// Load a new instance of from the given encoded byte span.
- ///
- /// The configuration options.
- /// The byte span containing texture data.
- /// The of the decoded texture.>
- /// The .
- public static unsafe Texture Load(
- Configuration config,
- ReadOnlySpan data,
- out ITextureFormat format)
+ ///
+ /// Load a new instance of from the given encoded byte span.
+ ///
+ /// The configuration options.
+ /// The byte span containing texture data.
+ /// The of the decoded texture.>
+ /// The .
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static unsafe Texture Load(
+ Configuration config,
+ ReadOnlySpan data,
+ out ITextureFormat? format)
+ {
+ fixed (byte* ptr = &data.GetPinnableReference())
{
- fixed (byte* ptr = &data.GetPinnableReference())
- {
- using (var stream = new UnmanagedMemoryStream(ptr, data.Length))
- {
- return Load(config, stream, out format);
- }
- }
+ using UnmanagedMemoryStream stream = new(ptr, data.Length);
+ return Load(config, stream, out format);
}
}
}
diff --git a/src/ImageSharp.Textures/Texture.FromFile.cs b/src/ImageSharp.Textures/Texture.FromFile.cs
index 02761d7..eb7cc67 100644
--- a/src/ImageSharp.Textures/Texture.FromFile.cs
+++ b/src/ImageSharp.Textures/Texture.FromFile.cs
@@ -1,157 +1,153 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
-using System;
-using System.IO;
+using SixLabors.ImageSharp.Textures.Common.Exceptions;
using SixLabors.ImageSharp.Textures.Formats;
-namespace SixLabors.ImageSharp.Textures
+namespace SixLabors.ImageSharp.Textures;
+
+///
+/// Adds static methods allowing the creation of new image from a given file.
+///
+public abstract partial class Texture
{
- ///
- /// Adds static methods allowing the creation of new image from a given file.
- ///
- public abstract partial class Texture
- {
- ///
- /// By reading the header on the provided file this calculates the images mime type.
- ///
- /// The image file to open and to read the header from.
- /// The mime type or null if none found.
- public static ITextureFormat DetectFormat(string filePath) => DetectFormat(Configuration.Default, filePath);
+ ///
+ /// By reading the header on the provided file this calculates the images mime type.
+ ///
+ /// The image file to open and to read the header from.
+ /// The mime type.
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static ITextureFormat DetectFormat(string filePath) => DetectFormat(Configuration.Default, filePath);
- ///
- /// By reading the header on the provided file this calculates the images mime type.
- ///
- /// The configuration.
- /// The image file to open and to read the header from.
- /// The mime type or null if none found.
- public static ITextureFormat DetectFormat(Configuration config, string filePath)
- {
- config ??= Configuration.Default;
- using (Stream file = config.FileSystem.OpenRead(filePath))
- {
- return DetectFormat(config, file);
- }
- }
+ ///
+ /// By reading the header on the provided file this calculates the images mime type.
+ ///
+ /// The configuration.
+ /// The image file to open and to read the header from.
+ /// The mime type.
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static ITextureFormat DetectFormat(Configuration config, string filePath)
+ {
+ config ??= Configuration.Default;
+ using Stream file = config.FileSystem.OpenRead(filePath);
+ return DetectFormat(config, file);
+ }
- ///
- /// Reads the raw texture information from the specified stream without fully decoding it.
- ///
- /// The texture file to open and to read the header from.
- ///
- /// The or null if suitable info detector not found.
- ///
- public static ITextureInfo Identify(string filePath)
- => Identify(filePath, out ITextureFormat _);
+ ///
+ /// Reads the raw texture information from the specified stream without fully decoding it.
+ ///
+ /// The texture file to open and to read the header from.
+ ///
+ /// The .
+ ///
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static ITextureInfo Identify(string filePath)
+ => Identify(filePath, out ITextureFormat? _);
- ///
- /// Reads the raw texture information from the specified stream without fully decoding it.
- ///
- /// The image file to open and to read the header from.
- /// The format type of the decoded texture.
- ///
- /// The or null if suitable info detector not found.
- ///
- public static ITextureInfo Identify(string filePath, out ITextureFormat format)
- => Identify(Configuration.Default, filePath, out format);
+ ///
+ /// Reads the raw texture information from the specified stream without fully decoding it.
+ ///
+ /// The image file to open and to read the header from.
+ /// The format type of the decoded texture.
+ ///
+ /// The .
+ ///
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static ITextureInfo Identify(string filePath, out ITextureFormat? format)
+ => Identify(Configuration.Default, filePath, out format);
- ///
- /// Reads the raw texture information from the specified stream without fully decoding it.
- ///
- /// The configuration.
- /// The image file to open and to read the header from.
- /// The format type of the decoded texture.
- /// The configuration is null.
- ///
- /// The or null if suitable info detector is not found.
- ///
- public static ITextureInfo Identify(Configuration configuration, string filePath, out ITextureFormat format)
- {
- Guard.NotNull(configuration, nameof(configuration));
- using (Stream file = configuration.FileSystem.OpenRead(filePath))
- {
- return Identify(configuration, file, out format);
- }
- }
+ ///
+ /// Reads the raw texture information from the specified stream without fully decoding it.
+ ///
+ /// The configuration.
+ /// The image file to open and to read the header from.
+ /// The format type of the decoded texture.
+ ///
+ /// The .
+ ///
+ /// The configuration is null.
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static ITextureInfo Identify(Configuration configuration, string filePath, out ITextureFormat? format)
+ {
+ Guard.NotNull(configuration, nameof(configuration));
+ using Stream file = configuration.FileSystem.OpenRead(filePath);
+ return Identify(configuration, file, out format);
+ }
- ///
- /// Create a new instance of the class from the given file.
- ///
- /// The file path to the image.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The .
- public static Texture Load(string path) => Load(Configuration.Default, path);
+ ///
+ /// Create a new instance of the class from the given file.
+ ///
+ /// The file path to the image.
+ /// The .
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(string path) => Load(Configuration.Default, path);
- ///
- /// Create a new instance of the class from the given file.
- ///
- /// The file path to the image.
- /// The mime type of the decoded image.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// A new .
- public static Texture Load(string path, out ITextureFormat format) => Load(Configuration.Default, path, out format);
+ ///
+ /// Create a new instance of the class from the given file.
+ ///
+ /// The file path to the image.
+ /// The mime type of the decoded image.
+ /// A new .
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(string path, out ITextureFormat? format) => Load(Configuration.Default, path, out format);
- ///
- /// Create a new instance of the class from the given file.
- ///
- /// The config for the decoder.
- /// The file path to the image.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The .
- public static Texture Load(Configuration config, string path) => Load(config, path, out _);
+ ///
+ /// Create a new instance of the class from the given file.
+ ///
+ /// The config for the decoder.
+ /// The file path to the image.
+ /// The .
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(Configuration config, string path) => Load(config, path, out _);
- ///
- /// Create a new instance of the class from the given file.
- ///
- /// The Configuration.
- /// The file path to the image.
- /// The decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The .
- public static Texture Load(Configuration config, string path, ITextureDecoder decoder)
+ ///
+ /// Create a new instance of the class from the given file.
+ ///
+ /// The Configuration.
+ /// The file path to the image.
+ /// The decoder.
+ /// The .
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(Configuration config, string path, ITextureDecoder decoder)
+ {
+ using (Stream stream = config.FileSystem.OpenRead(path))
{
- using (Stream stream = config.FileSystem.OpenRead(path))
- {
- return Load(config, stream, decoder);
- }
+ return Load(config, stream, decoder);
}
+ }
- ///
- /// Create a new instance of the class from the given file.
- ///
- /// The file path to the image.
- /// The decoder.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The .
- public static Texture Load(string path, ITextureDecoder decoder) => Load(Configuration.Default, path, decoder);
+ ///
+ /// Create a new instance of the class from the given file.
+ ///
+ /// The file path to the image.
+ /// The decoder.
+ /// The .
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(string path, ITextureDecoder decoder) => Load(Configuration.Default, path, decoder);
- ///
- /// Create a new instance of the class from the given file.
- /// The pixel type is selected by the decoder.
- ///
- /// The configuration options.
- /// The file path to the image.
- /// The mime type of the decoded image.
- ///
- /// Thrown if the stream is not readable nor seekable.
- ///
- /// The .
- public static Texture Load(Configuration config, string path, out ITextureFormat format)
- {
- using (Stream stream = config.FileSystem.OpenRead(path))
- {
- return Load(config, stream, out format);
- }
- }
+ ///
+ /// Create a new instance of the class from the given file.
+ /// The pixel type is selected by the decoder.
+ ///
+ /// The configuration options.
+ /// The file path to the image.
+ /// The mime type of the decoded image.
+ /// The .
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(Configuration config, string path, out ITextureFormat? format)
+ {
+ using Stream stream = config.FileSystem.OpenRead(path);
+ return Load(config, stream, out format);
}
}
diff --git a/src/ImageSharp.Textures/Texture.FromStream.cs b/src/ImageSharp.Textures/Texture.FromStream.cs
index ce9db69..fcd7dfd 100644
--- a/src/ImageSharp.Textures/Texture.FromStream.cs
+++ b/src/ImageSharp.Textures/Texture.FromStream.cs
@@ -1,188 +1,190 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Text;
using SixLabors.ImageSharp.Textures.Common.Exceptions;
using SixLabors.ImageSharp.Textures.Formats;
-namespace SixLabors.ImageSharp.Textures
+namespace SixLabors.ImageSharp.Textures;
+
+///
+/// Adds static methods allowing the creation of new image from a given stream.
+///
+public abstract partial class Texture
{
- ///
- /// Adds static methods allowing the creation of new image from a given stream.
- ///
- public abstract partial class Texture
+ ///
+ /// By reading the header on the provided stream this calculates the images format type.
+ ///
+ /// The image stream to read the header from.
+ /// The format type.
+ /// Thrown if the stream is not readable.
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static ITextureFormat DetectFormat(Stream stream) => DetectFormat(Configuration.Default, stream);
+
+ ///
+ /// By reading the header on the provided stream this calculates the images format type.
+ ///
+ /// The configuration.
+ /// The image stream to read the header from.
+ /// The format type.
+ /// Thrown if the stream is not readable.
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static ITextureFormat DetectFormat(Configuration config, Stream stream)
+ => WithSeekableStream(config, stream, s => InternalDetectFormat(s, config));
+
+ ///
+ /// By reading the header on the provided stream this reads the raw image information.
+ ///
+ /// The image stream to read the header from.
+ ///
+ /// The .
+ ///
+ /// Thrown if the stream is not readable.
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static ITextureInfo Identify(Stream stream) => Identify(stream, out ITextureFormat? _);
+
+ ///
+ /// By reading the header on the provided stream this reads the raw image information.
+ ///
+ /// The image stream to read the header from.
+ /// The format type of the decoded image.
+ ///
+ /// The .
+ ///
+ /// Thrown if the stream is not readable.
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static ITextureInfo Identify(Stream stream, out ITextureFormat? format) => Identify(Configuration.Default, stream, out format);
+
+ ///
+ /// Reads the raw image information from the specified stream without fully decoding it.
+ ///
+ /// The configuration.
+ /// The image stream to read the information from.
+ /// The format type of the decoded image.
+ ///
+ /// The .
+ ///
+ /// Thrown if the stream is not readable.
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static ITextureInfo Identify(Configuration config, Stream stream, out ITextureFormat format)
{
- ///
- /// By reading the header on the provided stream this calculates the images format type.
- ///
- /// The image stream to read the header from.
- /// Thrown if the stream is not readable.
- /// The format type or null if none found.
- public static ITextureFormat DetectFormat(Stream stream) => DetectFormat(Configuration.Default, stream);
-
- ///
- /// By reading the header on the provided stream this calculates the images format type.
- ///
- /// The configuration.
- /// The image stream to read the header from.
- /// Thrown if the stream is not readable.
- /// The format type or null if none found.
- public static ITextureFormat DetectFormat(Configuration config, Stream stream)
- => WithSeekableStream(config, stream, s => InternalDetectFormat(s, config));
-
- ///
- /// By reading the header on the provided stream this reads the raw image information.
- ///
- /// The image stream to read the header from.
- /// Thrown if the stream is not readable.
- ///
- /// The or null if suitable info detector not found.
- ///
- public static ITextureInfo Identify(Stream stream) => Identify(stream, out ITextureFormat _);
-
- ///
- /// By reading the header on the provided stream this reads the raw image information.
- ///
- /// The image stream to read the header from.
- /// The format type of the decoded image.
- /// Thrown if the stream is not readable.
- ///
- /// The or null if suitable info detector not found.
- ///
- public static ITextureInfo Identify(Stream stream, out ITextureFormat format) => Identify(Configuration.Default, stream, out format);
-
- ///
- /// Reads the raw image information from the specified stream without fully decoding it.
- ///
- /// The configuration.
- /// The image stream to read the information from.
- /// The format type of the decoded image.
- /// Thrown if the stream is not readable.
- ///
- /// The or null if suitable info detector is not found.
- ///
- public static ITextureInfo Identify(Configuration config, Stream stream, out ITextureFormat format)
- {
- (ITextureInfo Info, ITextureFormat Format) data = WithSeekableStream(config, stream, s => InternalIdentity(s, config ?? Configuration.Default));
-
- format = data.Format;
- return data.Info;
- }
+ (ITextureInfo info, format) = WithSeekableStream(config, stream, s => InternalIdentity(s, config ?? Configuration.Default));
- ///
- /// Decode a new instance of the class from the given stream.
- /// The pixel format is selected by the decoder.
- ///
- /// The stream containing image information.
- /// The format type of the decoded image.
- /// Thrown if the stream is not readable.
- /// Image cannot be loaded.
- /// The .
- public static Texture Load(Stream stream, out ITextureFormat format) => Load(Configuration.Default, stream, out format);
-
- ///
- /// Decode a new instance of the class from the given stream.
- /// The pixel format is selected by the decoder.
- ///
- /// The stream containing image information.
- /// Thrown if the stream is not readable.
- /// Image cannot be loaded.
- /// The .
- public static Texture Load(Stream stream) => Load(Configuration.Default, stream);
-
- ///
- /// Decode a new instance of the class from the given stream.
- /// The pixel format is selected by the decoder.
- ///
- /// The stream containing image information.
- /// The decoder.
- /// Thrown if the stream is not readable.
- /// Image cannot be loaded.
- /// The .
- public static Texture Load(Stream stream, ITextureDecoder decoder) => Load(Configuration.Default, stream, decoder);
-
- ///
- /// Decode a new instance of the class from the given stream.
- /// The pixel format is selected by the decoder.
- ///
- /// The config for the decoder.
- /// The stream containing image information.
- /// The decoder.
- /// Thrown if the stream is not readable.
- /// Image cannot be loaded.
- /// A new .>
- public static Texture Load(Configuration config, Stream stream, ITextureDecoder decoder) =>
- WithSeekableStream(config, stream, s => decoder.DecodeTexture(config, s));
-
- ///
- /// Decode a new instance of the class from the given stream.
- ///
- /// The config for the decoder.
- /// The stream containing image information.
- /// Thrown if the stream is not readable.
- /// Image cannot be loaded.
- /// A new .>
- public static Texture Load(Configuration config, Stream stream) => Load(config, stream, out _);
-
- ///
- /// Decode a new instance of the class from the given stream.
- /// The pixel format is selected by the decoder.
- ///
- /// The configuration options.
- /// The stream containing image information.
- /// The format type of the decoded image.
- /// Thrown if the stream is not readable.
- /// Image cannot be loaded.
- /// A new .
- public static Texture Load(Configuration config, Stream stream, out ITextureFormat format)
- {
- config ??= Configuration.Default;
- (Texture Img, ITextureFormat Format) data = WithSeekableStream(config, stream, s => DecodeTexture(s, config));
+ return info;
+ }
- format = data.Format;
+ ///
+ /// Decode a new instance of the class from the given stream.
+ /// The pixel format is selected by the decoder.
+ ///
+ /// The stream containing image information.
+ /// The format type of the decoded image.
+ /// The .
+ /// Thrown if the stream is not readable.
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(Stream stream, out ITextureFormat? format) => Load(Configuration.Default, stream, out format);
+
+ ///
+ /// Decode a new instance of the class from the given stream.
+ /// The pixel format is selected by the decoder.
+ ///
+ /// The stream containing image information.
+ /// The .
+ /// Thrown if the stream is not readable.
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(Stream stream) => Load(Configuration.Default, stream);
+
+ ///
+ /// Decode a new instance of the class from the given stream.
+ /// The pixel format is selected by the decoder.
+ ///
+ /// The stream containing image information.
+ /// The decoder.
+ /// The .
+ /// Thrown if the stream is not readable.
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(Stream stream, ITextureDecoder decoder) => Load(Configuration.Default, stream, decoder);
+
+ ///
+ /// Decode a new instance of the class from the given stream.
+ /// The pixel format is selected by the decoder.
+ ///
+ /// The config for the decoder.
+ /// The stream containing image information.
+ /// The decoder.
+ /// A new .
+ /// Thrown if the stream is not readable.
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(Configuration config, Stream stream, ITextureDecoder decoder) =>
+ WithSeekableStream(config, stream, s => decoder.DecodeTexture(config, s));
+
+ ///
+ /// Decode a new instance of the class from the given stream.
+ ///
+ /// The config for the decoder.
+ /// The stream containing image information.
+ /// A new .
+ /// Thrown if the stream is not readable.
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(Configuration config, Stream stream) => Load(config, stream, out _);
+
+ ///
+ /// Decode a new instance of the class from the given stream.
+ /// The pixel format is selected by the decoder.
+ ///
+ /// The configuration options.
+ /// The stream containing image information.
+ /// The format type of the decoded image.
+ /// A new .
+ /// Thrown if the stream is not readable.
+ /// The image format is not supported.
+ /// The encoded texture format is unknown.
+ public static Texture Load(Configuration config, Stream stream, out ITextureFormat? format)
+ {
+ config ??= Configuration.Default;
+ (Texture texture, ITextureFormat textureFormat) = WithSeekableStream(config, stream, s => DecodeTexture(s, config));
- if (data.Img != null)
- {
- return data.Img;
- }
+ format = textureFormat;
- var sb = new StringBuilder();
- sb.AppendLine("Image cannot be loaded. Available decoders:");
+ if (texture is null)
+ {
+ TextureFormatManager.ThrowInvalidDecoder(config.ImageFormatsManager);
+ }
- foreach (KeyValuePair val in config.ImageFormatsManager.ImageDecoders)
- {
- sb.AppendLine($" - {val.Key.Name} : {val.Value.GetType().Name}");
- }
+ return texture;
+ }
- throw new UnknownTextureFormatException(sb.ToString());
+ private static T WithSeekableStream(Configuration config, Stream stream, Func action)
+ {
+ if (!stream.CanRead)
+ {
+ throw new NotSupportedException("Cannot read from the stream.");
}
- private static T WithSeekableStream(Configuration config, Stream stream, Func action)
+ if (stream.CanSeek)
{
- if (!stream.CanRead)
+ if (config.ReadOrigin == ReadOrigin.Begin)
{
- throw new NotSupportedException("Cannot read from the stream.");
+ stream.Position = 0;
}
- if (stream.CanSeek)
- {
- if (config.ReadOrigin == ReadOrigin.Begin)
- {
- stream.Position = 0;
- }
-
- return action(stream);
- }
+ return action(stream);
+ }
- // We want to be able to load images from things like HttpContext.Request.Body
- using var memoryStream = new MemoryStream();
- stream.CopyTo(memoryStream);
- memoryStream.Position = 0;
+ // We want to be able to load images from things like HttpContext.Request.Body
+ using var memoryStream = new MemoryStream();
+ stream.CopyTo(memoryStream);
+ memoryStream.Position = 0;
- return action(memoryStream);
- }
+ return action(memoryStream);
}
}
diff --git a/src/ImageSharp.Textures/Texture.cs b/src/ImageSharp.Textures/Texture.cs
index 9484e76..c4f97e4 100644
--- a/src/ImageSharp.Textures/Texture.cs
+++ b/src/ImageSharp.Textures/Texture.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
diff --git a/src/ImageSharp.Textures/TextureFormats/CubemapTexture.cs b/src/ImageSharp.Textures/TextureFormats/CubemapTexture.cs
index 0dac106..fc51a3d 100644
--- a/src/ImageSharp.Textures/TextureFormats/CubemapTexture.cs
+++ b/src/ImageSharp.Textures/TextureFormats/CubemapTexture.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
@@ -79,11 +79,6 @@ protected override void Dispose(bool disposing)
///
internal override void EnsureNotDisposed()
- {
- if (this.isDisposed)
- {
- throw new ObjectDisposedException("Trying to execute an operation on a disposed image.");
- }
- }
+ => ObjectDisposedException.ThrowIf(this.isDisposed, "Trying to execute an operation on a disposed image.");
}
}
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/A8.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/A8.cs
index b247cad..98be4a8 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/A8.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/A8.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Ayuv.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Ayuv.cs
index 344db71..7277cba 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Ayuv.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Ayuv.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc4.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc4.cs
index 8b55a52..9fc8045 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc4.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc4.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System.Runtime.CompilerServices;
@@ -35,7 +35,7 @@ public Image GetImage(byte[] blockData, int width, int height)
///
public byte[] Decompress(byte[] blockData, int width, int height)
{
- IBlock self = this;
+ Bc4 self = this;
return Helper.InMemoryDecode(blockData, width, height, (stream, data, streamIndex, dataIndex, stride) =>
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc4s.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc4s.cs
index da7992e..e70f157 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc4s.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc4s.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System.Runtime.CompilerServices;
@@ -37,7 +37,7 @@ public Image GetImage(byte[] blockData, int width, int height)
///
public byte[] Decompress(byte[] blockData, int width, int height)
{
- IBlock self = this;
+ Bc4s self = this;
return Helper.InMemoryDecode(blockData, width, height, (stream, data, streamIndex, dataIndex, stride) =>
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc5.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc5.cs
index b9dafe6..d1f535f 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc5.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc5.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Runtime.CompilerServices;
@@ -38,7 +38,7 @@ public Image GetImage(byte[] blockData, int width, int height)
///
public byte[] Decompress(byte[] blockData, int width, int height)
{
- IBlock self = this;
+ Bc5 self = this;
byte[] firstGradient = new byte[8];
byte[] secondGradient = new byte[8];
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc5s.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc5s.cs
index d6175b3..abd1b52 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc5s.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc5s.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
@@ -35,7 +35,7 @@ public Image GetImage(byte[] blockData, int width, int height)
///
public byte[] Decompress(byte[] blockData, int width, int height)
{
- IBlock self = this;
+ Bc5s self = this;
return Helper.InMemoryDecode(blockData, width, height, (stream, data, streamIndex, dataIndex, stride) =>
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6h.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6h.cs
index 5e99a49..6636c9f 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6h.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6h.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Diagnostics;
@@ -293,7 +293,7 @@ public Image GetImage(byte[] blockData, int width, int height)
///
public byte[] Decompress(byte[] blockData, int width, int height)
{
- IBlock self = this;
+ Bc6h self = this;
byte[] currentBlock = new byte[this.CompressedBytesPerBlock];
return Helper.InMemoryDecode(blockData, width, height, (stream, data, streamIndex, dataIndex, stride) =>
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hEField.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hEField.cs
index 7be85a5..fd26730 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hEField.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hEField.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hModeDescriptor.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hModeDescriptor.cs
index d02b3fe..3bc2f8b 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hModeDescriptor.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hModeDescriptor.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hModeInfo.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hModeInfo.cs
index 2d3bf63..4a460ce 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hModeInfo.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hModeInfo.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Textures.TextureFormats.Decoding.PixelFormats;
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hs.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hs.cs
index 694d618..0de87e6 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hs.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hs.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Diagnostics;
@@ -293,7 +293,7 @@ public Image GetImage(byte[] blockData, int width, int height)
///
public byte[] Decompress(byte[] blockData, int width, int height)
{
- IBlock self = this;
+ Bc6hs self = this;
byte[] currentBlock = new byte[this.CompressedBytesPerBlock];
return Helper.InMemoryDecode(blockData, width, height, (stream, data, streamIndex, dataIndex, stride) =>
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hsModeDescriptor.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hsModeDescriptor.cs
index 72cbc7c..97e2fd8 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hsModeDescriptor.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hsModeDescriptor.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hsModeInfo.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hsModeInfo.cs
index 034b88f..0c9047e 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hsModeInfo.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc6hsModeInfo.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Textures.TextureFormats.Decoding.PixelFormats;
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc7.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc7.cs
index 66e7184..a10234f 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc7.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc7.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Diagnostics;
@@ -67,7 +67,7 @@ public Image GetImage(byte[] blockData, int width, int height)
public byte[] Decompress(byte[] blockData, int width, int height)
{
byte[] currentBlock = new byte[this.CompressedBytesPerBlock];
- IBlock self = this;
+ Bc7 self = this;
return Helper.InMemoryDecode(blockData, width, height, (stream, data, streamIndex, dataIndex, stride) =>
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc7ModeInfo.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc7ModeInfo.cs
index ad6a07c..e3debea 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bc7ModeInfo.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bc7ModeInfo.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Textures.TextureFormats.Decoding.PixelFormats;
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bgr24.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bgr24.cs
index 88e8597..d349a91 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bgr24.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bgr24.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bgr32.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bgr32.cs
index 1d91d2b..b3374ce 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bgr32.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bgr32.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bgr555.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bgr555.cs
index 053b389..1d0ddbe 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bgr555.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bgr555.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bgr565.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bgr565.cs
index 56604bc..e8d1ee2 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bgr565.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bgr565.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bgra16.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bgra16.cs
index 436fee9..0ff9443 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bgra16.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bgra16.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bgra32.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bgra32.cs
index 7e24ee0..a2f5e85 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bgra32.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bgra32.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bgra4444.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bgra4444.cs
index bf730be..97b6796 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bgra4444.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bgra4444.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Bgra5551.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Bgra5551.cs
index 4ae23b7..a52919e 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Bgra5551.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Bgra5551.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Dxt1.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Dxt1.cs
index 3ec5680..635826c 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Dxt1.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Dxt1.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Textures.Common.Helpers;
@@ -35,7 +35,7 @@ public Image GetImage(byte[] blockData, int width, int height)
///
public byte[] Decompress(byte[] blockData, int width, int height)
{
- IBlock self = this;
+ Dxt1 self = this;
var colors = new ImageSharp.PixelFormats.Rgb24[4];
return Helper.InMemoryDecode(blockData, width, height, (stream, data, streamIndex, dataIndex, stride) =>
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Dxt3.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Dxt3.cs
index b30f6a9..c00291d 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Dxt3.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Dxt3.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Textures.Common.Helpers;
@@ -35,7 +35,7 @@ public Image GetImage(byte[] blockData, int width, int height)
///
public byte[] Decompress(byte[] blockData, int width, int height)
{
- IBlock self = this;
+ Dxt3 self = this;
var colors = new ImageSharp.PixelFormats.Rgb24[4];
return Helper.InMemoryDecode(blockData, width, height, (stream, data, streamIndex, dataIndex, stride) =>
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Dxt5.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Dxt5.cs
index 3bddba5..f16df74 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Dxt5.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Dxt5.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Textures.Common.Helpers;
@@ -35,7 +35,7 @@ public Image GetImage(byte[] blockData, int width, int height)
///
public byte[] Decompress(byte[] blockData, int width, int height)
{
- IBlock self = this;
+ Dxt5 self = this;
byte[] alpha = new byte[8];
var colors = new ImageSharp.PixelFormats.Rgb24[4];
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Etc1.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Etc1.cs
index aa52afa..7ce1acb 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Etc1.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Etc1.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Etc2.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Etc2.cs
index d7efc80..0b59fa3 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Etc2.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Etc2.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/EtcDecoder.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/EtcDecoder.cs
index 89d7823..32b1a65 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/EtcDecoder.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/EtcDecoder.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Buffers.Binary;
@@ -192,7 +192,7 @@ public static void DecodeEtc2Block(Span payload, Span decodedPixelSp
int b = payload[2] & 0xF8;
b += Complement3BitShifted(payload[2] & 7);
- decodedPixelSpan.Fill(0);
+ decodedPixelSpan.Clear();
if ((r & 0xFF07) != 0)
{
ProcessBlockEtc2TMode(payload, decodedPixelSpan);
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Fp32.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Fp32.cs
index e152d96..2e5d553 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Fp32.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Fp32.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Grgb32.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Grgb32.cs
index c81fb12..bf02c55 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Grgb32.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Grgb32.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Runtime.InteropServices;
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Helper.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Helper.cs
index 1e99884..e755cc8 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Helper.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Helper.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Runtime.CompilerServices;
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/IBlock.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/IBlock.cs
index 41e855c..99edf38 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/IBlock.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/IBlock.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/IBlock{TSelf}.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/IBlock{TSelf}.cs
index 0e5f1ad..d656dc1 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/IBlock{TSelf}.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/IBlock{TSelf}.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/L16.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/L16.cs
index 1029ef5..8951fa6 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/L16.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/L16.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/L32.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/L32.cs
index 1e20487..32813f6 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/L32.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/L32.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/L8.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/L8.cs
index a537953..e43d7d8 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/L8.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/L8.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/La16.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/La16.cs
index 892f64c..98aa5ff 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/La16.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/La16.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/Constants.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/Constants.cs
index a73e0af..60fc792 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/Constants.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/Constants.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
// ReSharper disable InconsistentNaming
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding.PixelFormats
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/Helpers.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/Helpers.cs
index 53eb2ec..0b3ce4f 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/Helpers.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/Helpers.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/IntColor.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/IntColor.cs
index 7a92776..7bceb86 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/IntColor.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/IntColor.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding.PixelFormats
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/IntEndPntPair.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/IntEndPntPair.cs
index 3d3fb96..50dd10d 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/IntEndPntPair.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/IntEndPntPair.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding.PixelFormats
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/LdrColorA.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/LdrColorA.cs
index 86c9749..f7e1ce3 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/LdrColorA.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/PixelFormats/LdrColorA.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Diagnostics;
@@ -52,22 +52,14 @@ public LdrColorA(byte r, byte g, byte b, byte a)
public byte this[int uElement]
{
- get
+ get => uElement switch
{
- switch (uElement)
- {
- case 0:
- return this.R;
- case 1:
- return this.G;
- case 2:
- return this.B;
- case 3:
- return this.A;
- default:
- throw new IndexOutOfRangeException();
- }
- }
+ 0 => this.R,
+ 1 => this.G,
+ 2 => this.B,
+ 3 => this.A,
+ _ => throw new ArgumentOutOfRangeException(nameof(uElement)),
+ };
set
{
@@ -86,7 +78,7 @@ public byte this[int uElement]
this.A = value;
break;
default:
- throw new IndexOutOfRangeException();
+ throw new ArgumentOutOfRangeException(nameof(uElement));
}
}
}
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/R16Float.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/R16Float.cs
index 53dedaa..6701581 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/R16Float.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/R16Float.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rg16.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rg16.cs
index ed692c9..a9747f0 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rg16.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rg16.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rg32.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rg32.cs
index 5284935..f3df0a7 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rg32.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rg32.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rg32Float.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rg32Float.cs
index 06fe416..b825362 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rg32Float.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rg32Float.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rg64.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rg64.cs
index e00b5f9..ef5cacb 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rg64.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rg64.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rg64Float.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rg64Float.cs
index b4c0482..216a1b9 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rg64Float.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rg64Float.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb111110Float.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb111110Float.cs
index 0f5ec84..2eed524 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb111110Float.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb111110Float.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb24.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb24.cs
index 8d47318..905cfd8 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb24.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb24.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb32.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb32.cs
index 2c0934a..76f4a80 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb32.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb32.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb48.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb48.cs
index e95016f..70de61e 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb48.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb48.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb565.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb565.cs
index 7ddbde1..7d245e8 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb565.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb565.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb96.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb96.cs
index b695385..5e3557b 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb96.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb96.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb96Float.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb96Float.cs
index 76d6a6d..0260a2f 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb96Float.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgb96Float.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba1010102.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba1010102.cs
index 47b2b3f..c1fab15 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba1010102.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba1010102.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba128.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba128.cs
index d5ed7c5..06bfe86 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba128.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba128.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba128Float.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba128Float.cs
index c89d1f6..2e2329d 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba128Float.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba128Float.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba32.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba32.cs
index 11a95c6..af7859e 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba32.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba32.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba4444.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba4444.cs
index 0fefba7..25a1c4d 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba4444.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba4444.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba5551.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba5551.cs
index 4cf37e9..8e56023 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba5551.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba5551.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba64.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba64.cs
index f092a81..1022896 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba64.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba64.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba64Float.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba64Float.cs
index 6006b55..ec517a8 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba64Float.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgba64Float.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Textures.PixelFormats;
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgbg32.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgbg32.cs
index c9b5e02..71612c4 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Rgbg32.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Rgbg32.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Runtime.InteropServices;
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Y210.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Y210.cs
index 0b9a087..e924fc3 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Y210.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Y210.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Y216.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Y216.cs
index 50e3ae0..88e0945 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Y216.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Y216.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Y410.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Y410.cs
index 2f6b79b..6679bb7 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Y410.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Y410.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Y416.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Y416.cs
index 36b9f09..aee555b 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Y416.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Y416.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
namespace SixLabors.ImageSharp.Textures.TextureFormats.Decoding
{
diff --git a/src/ImageSharp.Textures/TextureFormats/Decoding/Yuy2.cs b/src/ImageSharp.Textures/TextureFormats/Decoding/Yuy2.cs
index 8e92061..275e52e 100644
--- a/src/ImageSharp.Textures/TextureFormats/Decoding/Yuy2.cs
+++ b/src/ImageSharp.Textures/TextureFormats/Decoding/Yuy2.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Numerics;
diff --git a/src/ImageSharp.Textures/TextureFormats/FlatTexture.cs b/src/ImageSharp.Textures/TextureFormats/FlatTexture.cs
index 2de5b48..b1f0183 100644
--- a/src/ImageSharp.Textures/TextureFormats/FlatTexture.cs
+++ b/src/ImageSharp.Textures/TextureFormats/FlatTexture.cs
@@ -1,5 +1,5 @@
// Copyright (c) Six Labors.
-// Licensed under the Apache License, Version 2.0.
+// Licensed under the Six Labors Split License.
using System;
using System.Collections.Generic;
@@ -45,11 +45,6 @@ protected override void Dispose(bool disposing)
///