diff --git a/resources/LICENSE b/resources/LICENSE deleted file mode 100644 index 7cdbe0b..0000000 --- a/resources/LICENSE +++ /dev/null @@ -1,438 +0,0 @@ -Attribution-NonCommercial-ShareAlike 4.0 International - -======================================================================= - -Creative Commons Corporation ("Creative Commons") is not a law firm and -does not provide legal services or legal advice. Distribution of -Creative Commons public licenses does not create a lawyer-client or -other relationship. Creative Commons makes its licenses and related -information available on an "as-is" basis. Creative Commons gives no -warranties regarding its licenses, any material licensed under their -terms and conditions, or any related information. Creative Commons -disclaims all liability for damages resulting from their use to the -fullest extent possible. - -Using Creative Commons Public Licenses - -Creative Commons public licenses provide a standard set of terms and -conditions that creators and other rights holders may use to share -original works of authorship and other material subject to copyright -and certain other rights specified in the public license below. The -following considerations are for informational purposes only, are not -exhaustive, and do not form part of our licenses. - - Considerations for licensors: Our public licenses are - intended for use by those authorized to give the public - permission to use material in ways otherwise restricted by - copyright and certain other rights. Our licenses are - irrevocable. Licensors should read and understand the terms - and conditions of the license they choose before applying it. - Licensors should also secure all rights necessary before - applying our licenses so that the public can reuse the - material as expected. Licensors should clearly mark any - material not subject to the license. This includes other CC- - licensed material, or material used under an exception or - limitation to copyright. More considerations for licensors: - wiki.creativecommons.org/Considerations_for_licensors - - Considerations for the public: By using one of our public - licenses, a licensor grants the public permission to use the - licensed material under specified terms and conditions. If - the licensor's permission is not necessary for any reason--for - example, because of any applicable exception or limitation to - copyright--then that use is not regulated by the license. Our - licenses grant only permissions under copyright and certain - other rights that a licensor has authority to grant. Use of - the licensed material may still be restricted for other - reasons, including because others have copyright or other - rights in the material. A licensor may make special requests, - such as asking that all changes be marked or described. - Although not required by our licenses, you are encouraged to - respect those requests where reasonable. More considerations - for the public: - wiki.creativecommons.org/Considerations_for_licensees - -======================================================================= - -Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International -Public License - -By exercising the Licensed Rights (defined below), You accept and agree -to be bound by the terms and conditions of this Creative Commons -Attribution-NonCommercial-ShareAlike 4.0 International Public License -("Public License"). To the extent this Public License may be -interpreted as a contract, You are granted the Licensed Rights in -consideration of Your acceptance of these terms and conditions, and the -Licensor grants You such rights in consideration of benefits the -Licensor receives from making the Licensed Material available under -these terms and conditions. - - -Section 1 -- Definitions. - - a. Adapted Material means material subject to Copyright and Similar - Rights that is derived from or based upon the Licensed Material - and in which the Licensed Material is translated, altered, - arranged, transformed, or otherwise modified in a manner requiring - permission under the Copyright and Similar Rights held by the - Licensor. For purposes of this Public License, where the Licensed - Material is a musical work, performance, or sound recording, - Adapted Material is always produced where the Licensed Material is - synched in timed relation with a moving image. - - b. Adapter's License means the license You apply to Your Copyright - and Similar Rights in Your contributions to Adapted Material in - accordance with the terms and conditions of this Public License. - - c. BY-NC-SA Compatible License means a license listed at - creativecommons.org/compatiblelicenses, approved by Creative - Commons as essentially the equivalent of this Public License. - - d. Copyright and Similar Rights means copyright and/or similar rights - closely related to copyright including, without limitation, - performance, broadcast, sound recording, and Sui Generis Database - Rights, without regard to how the rights are labeled or - categorized. For purposes of this Public License, the rights - specified in Section 2(b)(1)-(2) are not Copyright and Similar - Rights. - - e. Effective Technological Measures means those measures that, in the - absence of proper authority, may not be circumvented under laws - fulfilling obligations under Article 11 of the WIPO Copyright - Treaty adopted on December 20, 1996, and/or similar international - agreements. - - f. Exceptions and Limitations means fair use, fair dealing, and/or - any other exception or limitation to Copyright and Similar Rights - that applies to Your use of the Licensed Material. - - g. License Elements means the license attributes listed in the name - of a Creative Commons Public License. The License Elements of this - Public License are Attribution, NonCommercial, and ShareAlike. - - h. Licensed Material means the artistic or literary work, database, - or other material to which the Licensor applied this Public - License. - - i. Licensed Rights means the rights granted to You subject to the - terms and conditions of this Public License, which are limited to - all Copyright and Similar Rights that apply to Your use of the - Licensed Material and that the Licensor has authority to license. - - j. Licensor means the individual(s) or entity(ies) granting rights - under this Public License. - - k. NonCommercial means not primarily intended for or directed towards - commercial advantage or monetary compensation. For purposes of - this Public License, the exchange of the Licensed Material for - other material subject to Copyright and Similar Rights by digital - file-sharing or similar means is NonCommercial provided there is - no payment of monetary compensation in connection with the - exchange. - - l. Share means to provide material to the public by any means or - process that requires permission under the Licensed Rights, such - as reproduction, public display, public performance, distribution, - dissemination, communication, or importation, and to make material - available to the public including in ways that members of the - public may access the material from a place and at a time - individually chosen by them. - - m. Sui Generis Database Rights means rights other than copyright - resulting from Directive 96/9/EC of the European Parliament and of - the Council of 11 March 1996 on the legal protection of databases, - as amended and/or succeeded, as well as other essentially - equivalent rights anywhere in the world. - - n. You means the individual or entity exercising the Licensed Rights - under this Public License. Your has a corresponding meaning. - - -Section 2 -- Scope. - - a. License grant. - - 1. Subject to the terms and conditions of this Public License, - the Licensor hereby grants You a worldwide, royalty-free, - non-sublicensable, non-exclusive, irrevocable license to - exercise the Licensed Rights in the Licensed Material to: - - a. reproduce and Share the Licensed Material, in whole or - in part, for NonCommercial purposes only; and - - b. produce, reproduce, and Share Adapted Material for - NonCommercial purposes only. - - 2. Exceptions and Limitations. For the avoidance of doubt, where - Exceptions and Limitations apply to Your use, this Public - License does not apply, and You do not need to comply with - its terms and conditions. - - 3. Term. The term of this Public License is specified in Section - 6(a). - - 4. Media and formats; technical modifications allowed. The - Licensor authorizes You to exercise the Licensed Rights in - all media and formats whether now known or hereafter created, - and to make technical modifications necessary to do so. The - Licensor waives and/or agrees not to assert any right or - authority to forbid You from making technical modifications - necessary to exercise the Licensed Rights, including - technical modifications necessary to circumvent Effective - Technological Measures. For purposes of this Public License, - simply making modifications authorized by this Section 2(a) - (4) never produces Adapted Material. - - 5. Downstream recipients. - - a. Offer from the Licensor -- Licensed Material. Every - recipient of the Licensed Material automatically - receives an offer from the Licensor to exercise the - Licensed Rights under the terms and conditions of this - Public License. - - b. Additional offer from the Licensor -- Adapted Material. - Every recipient of Adapted Material from You - automatically receives an offer from the Licensor to - exercise the Licensed Rights in the Adapted Material - under the conditions of the Adapter's License You apply. - - c. No downstream restrictions. You may not offer or impose - any additional or different terms or conditions on, or - apply any Effective Technological Measures to, the - Licensed Material if doing so restricts exercise of the - Licensed Rights by any recipient of the Licensed - Material. - - 6. No endorsement. Nothing in this Public License constitutes or - may be construed as permission to assert or imply that You - are, or that Your use of the Licensed Material is, connected - with, or sponsored, endorsed, or granted official status by, - the Licensor or others designated to receive attribution as - provided in Section 3(a)(1)(A)(i). - - b. Other rights. - - 1. Moral rights, such as the right of integrity, are not - licensed under this Public License, nor are publicity, - privacy, and/or other similar personality rights; however, to - the extent possible, the Licensor waives and/or agrees not to - assert any such rights held by the Licensor to the limited - extent necessary to allow You to exercise the Licensed - Rights, but not otherwise. - - 2. Patent and trademark rights are not licensed under this - Public License. - - 3. To the extent possible, the Licensor waives any right to - collect royalties from You for the exercise of the Licensed - Rights, whether directly or through a collecting society - under any voluntary or waivable statutory or compulsory - licensing scheme. In all other cases the Licensor expressly - reserves any right to collect such royalties, including when - the Licensed Material is used other than for NonCommercial - purposes. - - -Section 3 -- License Conditions. - -Your exercise of the Licensed Rights is expressly made subject to the -following conditions. - - a. Attribution. - - 1. If You Share the Licensed Material (including in modified - form), You must: - - a. retain the following if it is supplied by the Licensor - with the Licensed Material: - - i. identification of the creator(s) of the Licensed - Material and any others designated to receive - attribution, in any reasonable manner requested by - the Licensor (including by pseudonym if - designated); - - ii. a copyright notice; - - iii. a notice that refers to this Public License; - - iv. a notice that refers to the disclaimer of - warranties; - - v. a URI or hyperlink to the Licensed Material to the - extent reasonably practicable; - - b. indicate if You modified the Licensed Material and - retain an indication of any previous modifications; and - - c. indicate the Licensed Material is licensed under this - Public License, and include the text of, or the URI or - hyperlink to, this Public License. - - 2. You may satisfy the conditions in Section 3(a)(1) in any - reasonable manner based on the medium, means, and context in - which You Share the Licensed Material. For example, it may be - reasonable to satisfy the conditions by providing a URI or - hyperlink to a resource that includes the required - information. - 3. If requested by the Licensor, You must remove any of the - information required by Section 3(a)(1)(A) to the extent - reasonably practicable. - - b. ShareAlike. - - In addition to the conditions in Section 3(a), if You Share - Adapted Material You produce, the following conditions also apply. - - 1. The Adapter's License You apply must be a Creative Commons - license with the same License Elements, this version or - later, or a BY-NC-SA Compatible License. - - 2. You must include the text of, or the URI or hyperlink to, the - Adapter's License You apply. You may satisfy this condition - in any reasonable manner based on the medium, means, and - context in which You Share Adapted Material. - - 3. You may not offer or impose any additional or different terms - or conditions on, or apply any Effective Technological - Measures to, Adapted Material that restrict exercise of the - rights granted under the Adapter's License You apply. - - -Section 4 -- Sui Generis Database Rights. - -Where the Licensed Rights include Sui Generis Database Rights that -apply to Your use of the Licensed Material: - - a. for the avoidance of doubt, Section 2(a)(1) grants You the right - to extract, reuse, reproduce, and Share all or a substantial - portion of the contents of the database for NonCommercial purposes - only; - - b. if You include all or a substantial portion of the database - contents in a database in which You have Sui Generis Database - Rights, then the database in which You have Sui Generis Database - Rights (but not its individual contents) is Adapted Material, - including for purposes of Section 3(b); and - - c. You must comply with the conditions in Section 3(a) if You Share - all or a substantial portion of the contents of the database. - -For the avoidance of doubt, this Section 4 supplements and does not -replace Your obligations under this Public License where the Licensed -Rights include other Copyright and Similar Rights. - - -Section 5 -- Disclaimer of Warranties and Limitation of Liability. - - a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE - EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS - AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF - ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS, - IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION, - WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR - PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS, - ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT - KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT - ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU. - - b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE - TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION, - NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT, - INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES, - COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR - USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN - ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR - DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR - IN PART, THIS LIMITATION MAY NOT APPLY TO YOU. - - c. The disclaimer of warranties and limitation of liability provided - above shall be interpreted in a manner that, to the extent - possible, most closely approximates an absolute disclaimer and - waiver of all liability. - - -Section 6 -- Term and Termination. - - a. This Public License applies for the term of the Copyright and - Similar Rights licensed here. However, if You fail to comply with - this Public License, then Your rights under this Public License - terminate automatically. - - b. Where Your right to use the Licensed Material has terminated under - Section 6(a), it reinstates: - - 1. automatically as of the date the violation is cured, provided - it is cured within 30 days of Your discovery of the - violation; or - - 2. upon express reinstatement by the Licensor. - - For the avoidance of doubt, this Section 6(b) does not affect any - right the Licensor may have to seek remedies for Your violations - of this Public License. - - c. For the avoidance of doubt, the Licensor may also offer the - Licensed Material under separate terms or conditions or stop - distributing the Licensed Material at any time; however, doing so - will not terminate this Public License. - - d. Sections 1, 5, 6, 7, and 8 survive termination of this Public - License. - - -Section 7 -- Other Terms and Conditions. - - a. The Licensor shall not be bound by any additional or different - terms or conditions communicated by You unless expressly agreed. - - b. Any arrangements, understandings, or agreements regarding the - Licensed Material not stated herein are separate from and - independent of the terms and conditions of this Public License. - - -Section 8 -- Interpretation. - - a. For the avoidance of doubt, this Public License does not, and - shall not be interpreted to, reduce, limit, restrict, or impose - conditions on any use of the Licensed Material that could lawfully - be made without permission under this Public License. - - b. To the extent possible, if any provision of this Public License is - deemed unenforceable, it shall be automatically reformed to the - minimum extent necessary to make it enforceable. If the provision - cannot be reformed, it shall be severed from this Public License - without affecting the enforceability of the remaining terms and - conditions. - - c. No term or condition of this Public License will be waived and no - failure to comply consented to unless expressly agreed to by the - Licensor. - - d. Nothing in this Public License constitutes or may be interpreted - as a limitation upon, or waiver of, any privileges and immunities - that apply to the Licensor or You, including from the legal - processes of any jurisdiction or authority. - -======================================================================= - -Creative Commons is not a party to its public -licenses. Notwithstanding, Creative Commons may elect to apply one of -its public licenses to material it publishes and in those instances -will be considered the “Licensor.” The text of the Creative Commons -public licenses is dedicated to the public domain under the CC0 Public -Domain Dedication. Except for the limited purpose of indicating that -material is shared under a Creative Commons public license or as -otherwise permitted by the Creative Commons policies published at -creativecommons.org/policies, Creative Commons does not authorize the -use of the trademark "Creative Commons" or any other trademark or logo -of Creative Commons without its prior written consent including, -without limitation, in connection with any unauthorized modifications -to any of its public licenses or any other arrangements, -understandings, or agreements concerning use of licensed material. For -the avoidance of doubt, this paragraph does not form part of the -public licenses. - -Creative Commons may be contacted at creativecommons.org. - diff --git a/resources/LICENSE.md b/resources/LICENSE.md new file mode 100644 index 0000000..865d04b --- /dev/null +++ b/resources/LICENSE.md @@ -0,0 +1,159 @@ +# Creative Commons Attribution-NonCommercial 4.0 International + +Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. + +**Using Creative Commons Public Licenses** + +Creative Commons public licenses provide a standard set of terms and conditions that creators and other rights holders may use to share original works of authorship and other material subject to copyright and certain other rights specified in the public license below. The following considerations are for informational purposes only, are not exhaustive, and do not form part of our licenses. + +* __Considerations for licensors:__ Our public licenses are intended for use by those authorized to give the public permission to use material in ways otherwise restricted by copyright and certain other rights. Our licenses are irrevocable. Licensors should read and understand the terms and conditions of the license they choose before applying it. Licensors should also secure all rights necessary before applying our licenses so that the public can reuse the material as expected. Licensors should clearly mark any material not subject to the license. This includes other CC-licensed material, or material used under an exception or limitation to copyright. [More considerations for licensors](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensors). + +* __Considerations for the public:__ By using one of our public licenses, a licensor grants the public permission to use the licensed material under specified terms and conditions. If the licensor’s permission is not necessary for any reason–for example, because of any applicable exception or limitation to copyright–then that use is not regulated by the license. Our licenses grant only permissions under copyright and certain other rights that a licensor has authority to grant. Use of the licensed material may still be restricted for other reasons, including because others have copyright or other rights in the material. A licensor may make special requests, such as asking that all changes be marked or described. Although not required by our licenses, you are encouraged to respect those requests where reasonable. [More considerations for the public](http://wiki.creativecommons.org/Considerations_for_licensors_and_licensees#Considerations_for_licensees). + +## Creative Commons Attribution-NonCommercial 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree to be bound by the terms and conditions of this Creative Commons Attribution-NonCommercial 4.0 International Public License ("Public License"). To the extent this Public License may be interpreted as a contract, You are granted the Licensed Rights in consideration of Your acceptance of these terms and conditions, and the Licensor grants You such rights in consideration of benefits the Licensor receives from making the Licensed Material available under these terms and conditions. + +### Section 1 – Definitions. + +a. __Adapted Material__ means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image. + +b. __Adapter's License__ means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License. + +c. __Copyright and Similar Rights__ means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. + +d. __Effective Technological Measures__ means those measures that, in the absence of proper authority, may not be circumvented under laws fulfilling obligations under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, and/or similar international agreements. + +e. __Exceptions and Limitations__ means fair use, fair dealing, and/or any other exception or limitation to Copyright and Similar Rights that applies to Your use of the Licensed Material. + +f. __Licensed Material__ means the artistic or literary work, database, or other material to which the Licensor applied this Public License. + +g. __Licensed Rights__ means the rights granted to You subject to the terms and conditions of this Public License, which are limited to all Copyright and Similar Rights that apply to Your use of the Licensed Material and that the Licensor has authority to license. + +h. __Licensor__ means the individual(s) or entity(ies) granting rights under this Public License. + +i. __NonCommercial__ means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Public License, the exchange of the Licensed Material for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is NonCommercial provided there is no payment of monetary compensation in connection with the exchange. + +j. __Share__ means to provide material to the public by any means or process that requires permission under the Licensed Rights, such as reproduction, public display, public performance, distribution, dissemination, communication, or importation, and to make material available to the public including in ways that members of the public may access the material from a place and at a time individually chosen by them. + +k. __Sui Generis Database Rights__ means rights other than copyright resulting from Directive 96/9/EC of the European Parliament and of the Council of 11 March 1996 on the legal protection of databases, as amended and/or succeeded, as well as other essentially equivalent rights anywhere in the world. + +l. __You__ means the individual or entity exercising the Licensed Rights under this Public License. __Your__ has a corresponding meaning. + +### Section 2 – Scope. + +a. ___License grant.___ + + 1. Subject to the terms and conditions of this Public License, the Licensor hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, irrevocable license to exercise the Licensed Rights in the Licensed Material to: + + A. reproduce and Share the Licensed Material, in whole or in part, for NonCommercial purposes only; and + + B. produce, reproduce, and Share Adapted Material for NonCommercial purposes only. + + 2. __Exceptions and Limitations.__ For the avoidance of doubt, where Exceptions and Limitations apply to Your use, this Public License does not apply, and You do not need to comply with its terms and conditions. + + 3. __Term.__ The term of this Public License is specified in Section 6(a). + + 4. __Media and formats; technical modifications allowed.__ The Licensor authorizes You to exercise the Licensed Rights in all media and formats whether now known or hereafter created, and to make technical modifications necessary to do so. The Licensor waives and/or agrees not to assert any right or authority to forbid You from making technical modifications necessary to exercise the Licensed Rights, including technical modifications necessary to circumvent Effective Technological Measures. For purposes of this Public License, simply making modifications authorized by this Section 2(a)(4) never produces Adapted Material. + + 5. __Downstream recipients.__ + + A. __Offer from the Licensor – Licensed Material.__ Every recipient of the Licensed Material automatically receives an offer from the Licensor to exercise the Licensed Rights under the terms and conditions of this Public License. + + B. __No downstream restrictions.__ You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, the Licensed Material if doing so restricts exercise of the Licensed Rights by any recipient of the Licensed Material. + + 6. __No endorsement.__ Nothing in this Public License constitutes or may be construed as permission to assert or imply that You are, or that Your use of the Licensed Material is, connected with, or sponsored, endorsed, or granted official status by, the Licensor or others designated to receive attribution as provided in Section 3(a)(1)(A)(i). + +b. ___Other rights.___ + + 1. Moral rights, such as the right of integrity, are not licensed under this Public License, nor are publicity, privacy, and/or other similar personality rights; however, to the extent possible, the Licensor waives and/or agrees not to assert any such rights held by the Licensor to the limited extent necessary to allow You to exercise the Licensed Rights, but not otherwise. + + 2. Patent and trademark rights are not licensed under this Public License. + + 3. To the extent possible, the Licensor waives any right to collect royalties from You for the exercise of the Licensed Rights, whether directly or through a collecting society under any voluntary or waivable statutory or compulsory licensing scheme. In all other cases the Licensor expressly reserves any right to collect such royalties, including when the Licensed Material is used other than for NonCommercial purposes. + +### Section 3 – License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the following conditions. + +a. ___Attribution.___ + + 1. If You Share the Licensed Material (including in modified form), You must: + + A. retain the following if it is supplied by the Licensor with the Licensed Material: + + i. identification of the creator(s) of the Licensed Material and any others designated to receive attribution, in any reasonable manner requested by the Licensor (including by pseudonym if designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of warranties; + + v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; + + B. indicate if You modified the Licensed Material and retain an indication of any previous modifications; and + + C. indicate the Licensed Material is licensed under this Public License, and include the text of, or the URI or hyperlink to, this Public License. + + 2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner based on the medium, means, and context in which You Share the Licensed Material. For example, it may be reasonable to satisfy the conditions by providing a URI or hyperlink to a resource that includes the required information. + + 3. If requested by the Licensor, You must remove any of the information required by Section 3(a)(1)(A) to the extent reasonably practicable. + + 4. If You Share Adapted Material You produce, the Adapter's License You apply must not prevent recipients of the Adapted Material from complying with this Public License. + +### Section 4 – Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that apply to Your use of the Licensed Material: + +a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, reuse, reproduce, and Share all or a substantial portion of the contents of the database for NonCommercial purposes only; + +b. if You include all or a substantial portion of the database contents in a database in which You have Sui Generis Database Rights, then the database in which You have Sui Generis Database Rights (but not its individual contents) is Adapted Material; and + +c. You must comply with the conditions in Section 3(a) if You Share all or a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not replace Your obligations under this Public License where the Licensed Rights include other Copyright and Similar Rights. + +### Section 5 – Disclaimer of Warranties and Limitation of Liability. + +a. __Unless otherwise separately undertaken by the Licensor, to the extent possible, the Licensor offers the Licensed Material as-is and as-available, and makes no representations or warranties of any kind concerning the Licensed Material, whether express, implied, statutory, or other. This includes, without limitation, warranties of title, merchantability, fitness for a particular purpose, non-infringement, absence of latent or other defects, accuracy, or the presence or absence of errors, whether or not known or discoverable. Where disclaimers of warranties are not allowed in full or in part, this disclaimer may not apply to You.__ + +b. __To the extent possible, in no event will the Licensor be liable to You on any legal theory (including, without limitation, negligence) or otherwise for any direct, special, indirect, incidental, consequential, punitive, exemplary, or other losses, costs, expenses, or damages arising out of this Public License or use of the Licensed Material, even if the Licensor has been advised of the possibility of such losses, costs, expenses, or damages. Where a limitation of liability is not allowed in full or in part, this limitation may not apply to You.__ + +c. The disclaimer of warranties and limitation of liability provided above shall be interpreted in a manner that, to the extent possible, most closely approximates an absolute disclaimer and waiver of all liability. + +### Section 6 – Term and Termination. + +a. This Public License applies for the term of the Copyright and Similar Rights licensed here. However, if You fail to comply with this Public License, then Your rights under this Public License terminate automatically. + +b. Where Your right to use the Licensed Material has terminated under Section 6(a), it reinstates: + + 1. automatically as of the date the violation is cured, provided it is cured within 30 days of Your discovery of the violation; or + + 2. upon express reinstatement by the Licensor. + + For the avoidance of doubt, this Section 6(b) does not affect any right the Licensor may have to seek remedies for Your violations of this Public License. + +c. For the avoidance of doubt, the Licensor may also offer the Licensed Material under separate terms or conditions or stop distributing the Licensed Material at any time; however, doing so will not terminate this Public License. + +d. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. + +### Section 7 – Other Terms and Conditions. + +a. The Licensor shall not be bound by any additional or different terms or conditions communicated by You unless expressly agreed. + +b. Any arrangements, understandings, or agreements regarding the Licensed Material not stated herein are separate from and independent of the terms and conditions of this Public License. + +### Section 8 – Interpretation. + +a. For the avoidance of doubt, this Public License does not, and shall not be interpreted to, reduce, limit, restrict, or impose conditions on any use of the Licensed Material that could lawfully be made without permission under this Public License. + +b. To the extent possible, if any provision of this Public License is deemed unenforceable, it shall be automatically reformed to the minimum extent necessary to make it enforceable. If the provision cannot be reformed, it shall be severed from this Public License without affecting the enforceability of the remaining terms and conditions. + +c. No term or condition of this Public License will be waived and no failure to comply consented to unless expressly agreed to by the Licensor. + +d. Nothing in this Public License constitutes or may be interpreted as a limitation upon, or waiver of, any privileges and immunities that apply to the Licensor or You, including from the legal processes of any jurisdiction or authority. + +> Creative Commons is not a party to its public licenses. Notwithstanding, Creative Commons may elect to apply one of its public licenses to material it publishes and in those instances will be considered the “Licensor.” Except for the limited purpose of indicating that material is shared under a Creative Commons public license or as otherwise permitted by the Creative Commons policies published at [creativecommons.org/policies](http://creativecommons.org/policies), Creative Commons does not authorize the use of the trademark “Creative Commons” or any other trademark or logo of Creative Commons without its prior written consent including, without limitation, in connection with any unauthorized modifications to any of its public licenses or any other arrangements, understandings, or agreements concerning use of licensed material. For the avoidance of doubt, this paragraph does not form part of the public licenses. +> +> Creative Commons may be contacted at creativecommons.org \ No newline at end of file diff --git a/resources/blueprints/house001.json b/resources/blueprints/house001.json index 12366f8..9c00774 100644 --- a/resources/blueprints/house001.json +++ b/resources/blueprints/house001.json @@ -1,5 +1,6 @@ { "house": { + "version": 3, "size": 64, "category": 0, "world": { @@ -17047,4 +17048,4 @@ "group": 0 } ] -} \ No newline at end of file +} diff --git a/server/FSO.Server.Common/FSO.Server.Common.csproj b/server/FSO.Server.Common/FSO.Server.Common.csproj index 891c90a..e80b478 100644 --- a/server/FSO.Server.Common/FSO.Server.Common.csproj +++ b/server/FSO.Server.Common/FSO.Server.Common.csproj @@ -1,6 +1,6 @@  - net45;net8.0 + net8.0 Library false true diff --git a/server/FSO.Server.Common/Session/IGluonSession.cs b/server/FSO.Server.Common/Session/IGluonSession.cs index ef3c138..52c3eeb 100755 --- a/server/FSO.Server.Common/Session/IGluonSession.cs +++ b/server/FSO.Server.Common/Session/IGluonSession.cs @@ -1,4 +1,4 @@ -using FSO.Common.Security; +/* using FSO.Common.Security; using FSO.Server.Framework.Aries; namespace FSO.Server.Framework.Gluon @@ -10,3 +10,4 @@ namespace FSO.Server.Framework.Gluon string InternalHost { get; } } } + */ \ No newline at end of file diff --git a/server/FSO.Server.Database/FSO.Server.Database.csproj b/server/FSO.Server.Database/FSO.Server.Database.csproj index 9c02794..3052da7 100755 --- a/server/FSO.Server.Database/FSO.Server.Database.csproj +++ b/server/FSO.Server.Database/FSO.Server.Database.csproj @@ -1,6 +1,6 @@  - net45 + net8.0 Library false true diff --git a/server/FSO.Server.Domain/FSO.Server.Domain.csproj b/server/FSO.Server.Domain/FSO.Server.Domain.csproj index 29cb890..da57bc0 100755 --- a/server/FSO.Server.Domain/FSO.Server.Domain.csproj +++ b/server/FSO.Server.Domain/FSO.Server.Domain.csproj @@ -1,6 +1,6 @@  - net45 + net8.0 Library false true diff --git a/server/FSO.Server.Protocol/FSO.Server.Protocol.csproj b/server/FSO.Server.Protocol/FSO.Server.Protocol.csproj index 008a4c8..ba29999 100755 --- a/server/FSO.Server.Protocol/FSO.Server.Protocol.csproj +++ b/server/FSO.Server.Protocol/FSO.Server.Protocol.csproj @@ -1,6 +1,6 @@  - net45 + net8.0 Library false true diff --git a/server/LICENSE b/server/LICENSE.md similarity index 61% rename from server/LICENSE rename to server/LICENSE.md index a612ad9..3759302 100644 --- a/server/LICENSE +++ b/server/LICENSE.md @@ -1,62 +1,59 @@ Mozilla Public License Version 2.0 ================================== -1. Definitions --------------- +### 1. Definitions -1.1. "Contributor" +**1.1. “Contributor”** means each individual or legal entity that creates, contributes to the creation of, or owns Covered Software. -1.2. "Contributor Version" +**1.2. “Contributor Version”** means the combination of the Contributions of others (if any) used by a Contributor and that particular Contributor's Contribution. -1.3. "Contribution" +**1.3. “Contribution”** means Covered Software of a particular Contributor. -1.4. "Covered Software" +**1.4. “Covered Software”** means Source Code Form to which the initial Contributor has attached the notice in Exhibit A, the Executable Form of such Source Code Form, and Modifications of such Source Code Form, in each case including portions thereof. -1.5. "Incompatible With Secondary Licenses" +**1.5. “Incompatible With Secondary Licenses”** means - (a) that the initial Contributor has attached the notice described - in Exhibit B to the Covered Software; or +* **(a)** that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or +* **(b)** that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. - (b) that the Covered Software was made available under the terms of - version 1.1 or earlier of the License, but not also under the - terms of a Secondary License. - -1.6. "Executable Form" +**1.6. “Executable Form”** means any form of the work other than Source Code Form. -1.7. "Larger Work" - means a work that combines Covered Software with other material, in +**1.7. “Larger Work”** + means a work that combines Covered Software with other material, in a separate file or files, that is not Covered Software. -1.8. "License" +**1.8. “License”** means this document. -1.9. "Licensable" +**1.9. “Licensable”** means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently, any and all of the rights conveyed by this License. -1.10. "Modifications" +**1.10. “Modifications”** means any of the following: - (a) any file in Source Code Form that results from an addition to, - deletion from, or modification of the contents of Covered - Software; or +* **(a)** any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or +* **(b)** any new file in Source Code Form that contains any Covered + Software. - (b) any new file in Source Code Form that contains any Covered - Software. - -1.11. "Patent Claims" of a Contributor +**1.11. “Patent Claims” of a Contributor** means any patent claim(s), including without limitation, method, process, and apparatus claims, in any patent Licensable by such Contributor that would be infringed, but for the grant of the @@ -64,50 +61,49 @@ Mozilla Public License Version 2.0 made, import, or transfer of either its Contributions or its Contributor Version. -1.12. "Secondary License" +**1.12. “Secondary License”** means either the GNU General Public License, Version 2.0, the GNU Lesser General Public License, Version 2.1, the GNU Affero General Public License, Version 3.0, or any later versions of those licenses. -1.13. "Source Code Form" +**1.13. “Source Code Form”** means the form of the work preferred for making modifications. -1.14. "You" (or "Your") +**1.14. “You” (or “Your”)** means an individual or a legal entity exercising rights under this - License. For legal entities, "You" includes any entity that + License. For legal entities, “You” includes any entity that controls, is controlled by, or is under common control with You. For - purposes of this definition, "control" means (a) the power, direct + purposes of this definition, “control” means **(a)** the power, direct or indirect, to cause the direction or management of such entity, - whether by contract or otherwise, or (b) ownership of more than + whether by contract or otherwise, or **(b)** ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. -2. License Grants and Conditions --------------------------------- -2.1. Grants +### 2. License Grants and Conditions + +#### 2.1. Grants Each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: -(a) under intellectual property rights (other than patent or trademark) +* **(a)** under intellectual property rights (other than patent or trademark) Licensable by such Contributor to use, reproduce, make available, modify, display, perform, distribute, and otherwise exploit its Contributions, either on an unmodified basis, with Modifications, or as part of a Larger Work; and - -(b) under Patent Claims of such Contributor to make, use, sell, offer +* **(b)** under Patent Claims of such Contributor to make, use, sell, offer for sale, have made, import, and otherwise transfer either its Contributions or its Contributor Version. -2.2. Effective Date +#### 2.2. Effective Date The licenses granted in Section 2.1 with respect to any Contribution become effective for each Contribution on the date the Contributor first distributes such Contribution. -2.3. Limitations on Grant Scope +#### 2.3. Limitations on Grant Scope The licenses granted in this Section 2 are the only rights granted under this License. No additional rights or licenses will be implied from the @@ -115,49 +111,47 @@ distribution or licensing of Covered Software under this License. Notwithstanding Section 2.1(b) above, no patent license is granted by a Contributor: -(a) for any code that a Contributor has removed from Covered Software; +* **(a)** for any code that a Contributor has removed from Covered Software; or - -(b) for infringements caused by: (i) Your and any other third party's - modifications of Covered Software, or (ii) the combination of its +* **(b)** for infringements caused by: **(i)** Your and any other third party's + modifications of Covered Software, or **(ii)** the combination of its Contributions with other software (except as part of its Contributor Version); or - -(c) under Patent Claims infringed by Covered Software in the absence of +* **(c)** under Patent Claims infringed by Covered Software in the absence of its Contributions. This License does not grant any rights in the trademarks, service marks, or logos of any Contributor (except as may be necessary to comply with the notice requirements in Section 3.4). -2.4. Subsequent Licenses +#### 2.4. Subsequent Licenses No Contributor makes additional grants as a result of Your choice to distribute the Covered Software under a subsequent version of this License (see Section 10.2) or under the terms of a Secondary License (if permitted under the terms of Section 3.3). -2.5. Representation +#### 2.5. Representation Each Contributor represents that the Contributor believes its Contributions are its original creation(s) or it has sufficient rights to grant the rights to its Contributions conveyed by this License. -2.6. Fair Use +#### 2.6. Fair Use This License is not intended to limit any rights You have under applicable copyright doctrines of fair use, fair dealing, or other equivalents. -2.7. Conditions +#### 2.7. Conditions Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in Section 2.1. -3. Responsibilities -------------------- -3.1. Distribution of Source Form +### 3. Responsibilities + +#### 3.1. Distribution of Source Form All distribution of Covered Software in Source Code Form, including any Modifications that You create or to which You contribute, must be under @@ -167,22 +161,22 @@ License, and how they can obtain a copy of this License. You may not attempt to alter or restrict the recipients' rights in the Source Code Form. -3.2. Distribution of Executable Form +#### 3.2. Distribution of Executable Form If You distribute Covered Software in Executable Form then: -(a) such Covered Software must also be made available in Source Code +* **(a)** such Covered Software must also be made available in Source Code Form, as described in Section 3.1, and You must inform recipients of the Executable Form how they can obtain a copy of such Source Code Form by reasonable means in a timely manner, at a charge no more than the cost of distribution to the recipient; and -(b) You may distribute such Executable Form under the terms of this +* **(b)** You may distribute such Executable Form under the terms of this License, or sublicense it under different terms, provided that the license for the Executable Form does not attempt to limit or alter the recipients' rights in the Source Code Form under this License. -3.3. Distribution of a Larger Work +#### 3.3. Distribution of a Larger Work You may create and distribute a Larger Work under terms of Your choice, provided that You also comply with the requirements of this License for @@ -195,7 +189,7 @@ the Larger Work may, at their option, further distribute the Covered Software under the terms of either this License or such Secondary License(s). -3.4. Notices +#### 3.4. Notices You may not remove or alter the substance of any license notices (including copyright notices, patent notices, disclaimers of warranty, @@ -203,7 +197,7 @@ or limitations of liability) contained within the Source Code Form of the Covered Software, except that You may alter any license notices to the extent required to remedy known factual inaccuracies. -3.5. Application of Additional Terms +#### 3.5. Application of Additional Terms You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered @@ -216,27 +210,27 @@ indemnity or liability terms You offer. You may include additional disclaimers of warranty and limitations of liability specific to any jurisdiction. -4. Inability to Comply Due to Statute or Regulation ---------------------------------------------------- + +### 4. Inability to Comply Due to Statute or Regulation If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Software due to -statute, judicial order, or regulation then You must: (a) comply with -the terms of this License to the maximum extent possible; and (b) +statute, judicial order, or regulation then You must: **(a)** comply with +the terms of this License to the maximum extent possible; and **(b)** describe the limitations and the code they affect. Such description must be placed in a text file included with all distributions of the Covered Software under this License. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it. -5. Termination --------------- -5.1. The rights granted under this License will terminate automatically +### 5. Termination + +**5.1.** The rights granted under this License will terminate automatically if You fail to comply with any of its terms. However, if You become compliant, then the rights granted under this License from a particular -Contributor are reinstated (a) provisionally, unless and until such -Contributor explicitly and finally terminates Your grants, and (b) on an +Contributor are reinstated **(a)** provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and **(b)** on an ongoing basis, if such Contributor fails to notify You of the non-compliance by some reasonable means prior to 60 days after You have come back into compliance. Moreover, Your grants from a particular @@ -246,62 +240,53 @@ first time You have received notice of non-compliance with this License from such Contributor, and You become compliant prior to 30 days after Your receipt of the notice. -5.2. If You initiate litigation against any entity by asserting a patent +**5.2.** If You initiate litigation against any entity by asserting a patent infringement claim (excluding declaratory judgment actions, counter-claims, and cross-claims) alleging that a Contributor Version directly or indirectly infringes any patent, then the rights granted to You by any and all Contributors for the Covered Software under Section 2.1 of this License shall terminate. -5.3. In the event of termination under Sections 5.1 or 5.2 above, all +**5.3.** In the event of termination under Sections 5.1 or 5.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or Your distributors under this License prior to termination shall survive termination. -************************************************************************ -* * -* 6. Disclaimer of Warranty * -* ------------------------- * -* * -* Covered Software is provided under this License on an "as is" * -* basis, without warranty of any kind, either expressed, implied, or * -* statutory, including, without limitation, warranties that the * -* Covered Software is free of defects, merchantable, fit for a * -* particular purpose or non-infringing. The entire risk as to the * -* quality and performance of the Covered Software is with You. * -* Should any Covered Software prove defective in any respect, You * -* (not any Contributor) assume the cost of any necessary servicing, * -* repair, or correction. This disclaimer of warranty constitutes an * -* essential part of this License. No use of any Covered Software is * -* authorized under this License except under this disclaimer. * -* * -************************************************************************ -************************************************************************ -* * -* 7. Limitation of Liability * -* -------------------------- * -* * -* Under no circumstances and under no legal theory, whether tort * -* (including negligence), contract, or otherwise, shall any * -* Contributor, or anyone who distributes Covered Software as * -* permitted above, be liable to You for any direct, indirect, * -* special, incidental, or consequential damages of any character * -* including, without limitation, damages for lost profits, loss of * -* goodwill, work stoppage, computer failure or malfunction, or any * -* and all other commercial damages or losses, even if such party * -* shall have been informed of the possibility of such damages. This * -* limitation of liability shall not apply to liability for death or * -* personal injury resulting from such party's negligence to the * -* extent applicable law prohibits such limitation. Some * -* jurisdictions do not allow the exclusion or limitation of * -* incidental or consequential damages, so this exclusion and * -* limitation may not apply to You. * -* * -************************************************************************ +### 6. Disclaimer of Warranty -8. Litigation -------------- +> Covered Software is provided under this License on an “as is” +> basis, without warranty of any kind, either expressed, implied, or +> statutory, including, without limitation, warranties that the +> Covered Software is free of defects, merchantable, fit for a +> particular purpose or non-infringing. The entire risk as to the +> quality and performance of the Covered Software is with You. +> Should any Covered Software prove defective in any respect, You +> (not any Contributor) assume the cost of any necessary servicing, +> repair, or correction. This disclaimer of warranty constitutes an +> essential part of this License. No use of any Covered Software is +> authorized under this License except under this disclaimer. + +### 7. Limitation of Liability + +> Under no circumstances and under no legal theory, whether tort +> (including negligence), contract, or otherwise, shall any +> Contributor, or anyone who distributes Covered Software as +> permitted above, be liable to You for any direct, indirect, +> special, incidental, or consequential damages of any character +> including, without limitation, damages for lost profits, loss of +> goodwill, work stoppage, computer failure or malfunction, or any +> and all other commercial damages or losses, even if such party +> shall have been informed of the possibility of such damages. This +> limitation of liability shall not apply to liability for death or +> personal injury resulting from such party's negligence to the +> extent applicable law prohibits such limitation. Some +> jurisdictions do not allow the exclusion or limitation of +> incidental or consequential damages, so this exclusion and +> limitation may not apply to You. + + +### 8. Litigation Any litigation relating to this License may be brought only in the courts of a jurisdiction where the defendant maintains its principal @@ -310,8 +295,8 @@ jurisdiction, without reference to its conflict-of-law provisions. Nothing in this Section shall prevent a party's ability to bring cross-claims or counter-claims. -9. Miscellaneous ----------------- + +### 9. Miscellaneous This License represents the complete agreement concerning the subject matter hereof. If any provision of this License is held to be @@ -320,24 +305,24 @@ necessary to make it enforceable. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not be used to construe this License against a Contributor. -10. Versions of the License ---------------------------- -10.1. New Versions +### 10. Versions of the License + +#### 10.1. New Versions Mozilla Foundation is the license steward. Except as provided in Section 10.3, no one other than the license steward has the right to modify or publish new versions of this License. Each version will be given a distinguishing version number. -10.2. Effect of New Versions +#### 10.2. Effect of New Versions You may distribute the Covered Software under the terms of the version of the License under which You originally received the Covered Software, or under the terms of any subsequent version published by the license steward. -10.3. Modified Versions +#### 10.3. Modified Versions If you create software not governed by this License, and you want to create a new license for such software, you may create and use a @@ -345,19 +330,17 @@ modified version of this License if you rename the license and remove any references to the name of the license steward (except to note that such modified license differs from this License). -10.4. Distributing Source Code Form that is Incompatible With Secondary -Licenses +#### 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses If You choose to distribute Source Code Form that is Incompatible With Secondary Licenses under the terms of this version of the License, the notice described in Exhibit B of this License must be attached. -Exhibit A - Source Code Form License Notice -------------------------------------------- +## Exhibit A - Source Code Form License Notice - This Source Code Form is subject to the terms of the Mozilla Public - License, v. 2.0. If a copy of the MPL was not distributed with this - file, You can obtain one at http://mozilla.org/MPL/2.0/. + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE @@ -366,8 +349,8 @@ for such a notice. You may add additional accurate notices of copyright ownership. -Exhibit B - "Incompatible With Secondary Licenses" Notice ---------------------------------------------------------- +## Exhibit B - “Incompatible With Secondary Licenses” Notice + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. - This Source Code Form is "Incompatible With Secondary Licenses", as - defined by the Mozilla Public License, v. 2.0. diff --git a/server/MySim.Server.sln b/server/MySim.Server.sln index f5c0a8a..15d770d 100644 --- a/server/MySim.Server.sln +++ b/server/MySim.Server.sln @@ -11,8 +11,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FSO.Server.Common", "FSO.Se EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FSO.Server.Database", "FSO.Server.Database\FSO.Server.Database.csproj", "{430ACD60-E798-43F0-AD61-8B5A35DF6AB2}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FSO.Server.Debug", "FSO.Server.Debug\FSO.Server.Debug.csproj", "{7296CCEC-F459-4071-A9D2-9A07DCC29210}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FSO.Server.Domain", "FSO.Server.Domain\FSO.Server.Domain.csproj", "{A1D9ABA0-0105-436D-8F8C-2418DB768080}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FSO.Server.Protocol", "FSO.Server.Protocol\FSO.Server.Protocol.csproj", "{A08ADE32-27E2-44F4-BC52-11A16C56BAA8}" @@ -39,10 +37,6 @@ Global {430ACD60-E798-43F0-AD61-8B5A35DF6AB2}.Debug|Any CPU.Build.0 = Debug|Any CPU {430ACD60-E798-43F0-AD61-8B5A35DF6AB2}.Release|Any CPU.ActiveCfg = Release|Any CPU {430ACD60-E798-43F0-AD61-8B5A35DF6AB2}.Release|Any CPU.Build.0 = Release|Any CPU - {7296CCEC-F459-4071-A9D2-9A07DCC29210}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7296CCEC-F459-4071-A9D2-9A07DCC29210}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7296CCEC-F459-4071-A9D2-9A07DCC29210}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7296CCEC-F459-4071-A9D2-9A07DCC29210}.Release|Any CPU.Build.0 = Release|Any CPU {A1D9ABA0-0105-436D-8F8C-2418DB768080}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A1D9ABA0-0105-436D-8F8C-2418DB768080}.Debug|Any CPU.Build.0 = Debug|Any CPU {A1D9ABA0-0105-436D-8F8C-2418DB768080}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/server/TargaImage/CPOL.html b/server/TargaImage/CPOL.html new file mode 100644 index 0000000..e5fe0d1 --- /dev/null +++ b/server/TargaImage/CPOL.html @@ -0,0 +1,251 @@ + + +The Code Project Open License (COPL) + + + + +

The Code Project Open License (CPOL) 1.02

+
+ +
+
+ +

Preamble

+

+ This License governs Your use of the Work. This License is intended to allow developers + to use the Source Code and Executable Files provided as part of the Work in any + application in any form. +

+

+ The main points subject to the terms of the License are:

+
    +
  • Source Code and Executable Files can be used in commercial applications;
  • +
  • Source Code and Executable Files can be redistributed; and
  • +
  • Source Code can be modified to create derivative works.
  • +
  • No claim of suitability, guarantee, or any warranty whatsoever is provided. The software is + provided "as-is".
  • +
  • The Article accompanying the Work may not be distributed or republished without the + Author's consent
  • +
+ +

+ This License is entered between You, the individual or other entity reading or otherwise + making use of the Work licensed pursuant to this License and the individual or other + entity which offers the Work under the terms of this License ("Author").

+ +

License

+

+ THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CODE PROJECT OPEN + LICENSE ("LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE + LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT + LAW IS PROHIBITED.

+

+ BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HEREIN, YOU ACCEPT AND AGREE TO BE + BOUND BY THE TERMS OF THIS LICENSE. THE AUTHOR GRANTS YOU THE RIGHTS CONTAINED HEREIN + IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. IF YOU DO NOT + AGREE TO ACCEPT AND BE BOUND BY THE TERMS OF THIS LICENSE, YOU CANNOT MAKE ANY + USE OF THE WORK.

+ +
    +
  1. Definitions. + +
      +
    1. "Articles" means, collectively, all articles written by Author + which describes how the Source Code and Executable Files for the Work may be used + by a user.
    2. +
    3. "Author" means the individual or entity that offers the Work under the terms + of this License.
    4. +
    5. "Derivative Work" means a work based upon the Work or upon the + Work and other pre-existing works.
    6. +
    7. "Executable Files" refer to the executables, binary files, configuration + and any required data files included in the Work.
    8. +
    9. "Publisher" means the provider of the website, magazine, CD-ROM, DVD or other + medium from or by which the Work is obtained by You.
    10. +
    11. "Source Code" refers to the collection of source code and configuration files + used to create the Executable Files.
    12. +
    13. "Standard Version" refers to such a Work if it has not been modified, or + has been modified in accordance with the consent of the Author, such consent being + in the full discretion of the Author.
    14. +
    15. "Work" refers to the collection of files distributed by the Publisher, including + the Source Code, Executable Files, binaries, data files, documentation, whitepapers + and the Articles.
    16. +
    17. "You" is you, an individual or entity wishing to use the Work and exercise + your rights under this License. +
    18. +
    +
  2. + +
  3. Fair Use/Fair Use Rights. Nothing in this License is intended to + reduce, limit, or restrict any rights arising from fair use, fair dealing, first + sale or other limitations on the exclusive rights of the copyright owner under copyright + law or other applicable laws. +
  4. + +
  5. License Grant. Subject to the terms and conditions of this License, + the Author hereby grants You a worldwide, royalty-free, non-exclusive, perpetual + (for the duration of the applicable copyright) license to exercise the rights in + the Work as stated below: + +
      +
    1. You may use the standard version of the Source Code or Executable Files in Your + own applications.
    2. +
    3. You may apply bug fixes, portability fixes and other modifications obtained from + the Public Domain or from the Author. A Work modified in such a way shall still + be considered the standard version and will be subject to this License.
    4. +
    5. You may otherwise modify Your copy of this Work (excluding the Articles) in any + way to create a Derivative Work, provided that You insert a prominent notice in + each changed file stating how, when and where You changed that file.
    6. +
    7. You may distribute the standard version of the Executable Files and Source Code + or Derivative Work in aggregate with other (possibly commercial) programs as part + of a larger (possibly commercial) software distribution.
    8. +
    9. The Articles discussing the Work published in any form by the author may not be + distributed or republished without the Author's consent. The author retains + copyright to any such Articles. You may use the Executable Files and Source Code + pursuant to this License but you may not repost or republish or otherwise distribute + or make available the Articles, without the prior written consent of the Author.
    10. +
    + + Any subroutines or modules supplied by You and linked into the Source Code or Executable + Files this Work shall not be considered part of this Work and will not be subject + to the terms of this License. +
  6. + +
  7. Patent License. Subject to the terms and conditions of this License, + each Author 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, import, + and otherwise transfer the Work.
  8. + +
  9. Restrictions. The license granted in Section 3 above is expressly + made subject to and limited by the following restrictions: + +
      +
    1. You agree not to remove any of the original copyright, patent, trademark, and + attribution notices and associated disclaimers that may appear in the Source Code + or Executable Files.
    2. +
    3. You agree not to advertise or in any way imply that this Work is a product of Your + own.
    4. +
    5. The name of the Author may not be used to endorse or promote products derived from + the Work without the prior written consent of the Author.
    6. +
    7. You agree not to sell, lease, or rent any part of the Work. This does not restrict + you from including the Work or any part of the Work inside a larger software + distribution that itself is being sold. The Work by itself, though, cannot be sold, + leased or rented.
    8. +
    9. You may distribute the Executable Files and Source Code only under the terms of + this License, and You must include a copy of, or the Uniform Resource Identifier + for, this License with every copy of the Executable Files or Source Code You distribute + and ensure that anyone receiving such Executable Files and Source Code agrees that + the terms of this License apply to such Executable Files and/or Source Code. You + may not offer or impose any terms on the Work that alter or restrict the terms of + this License or the recipients' exercise of the rights granted hereunder. You + may not sublicense the Work. You must keep intact all notices that refer to this + License and to the disclaimer of warranties. You may not distribute the Executable + Files or Source Code with any technological measures that control access or use + of the Work in a manner inconsistent with the terms of this License.
    10. +
    11. You agree not to use the Work for illegal, immoral or improper purposes, or on pages + containing illegal, immoral or improper material. The Work is subject to applicable + export laws. You agree to comply with all such laws and regulations that may apply + to the Work after Your receipt of the Work. +
    12. +
    +
  10. + +
  11. Representations, Warranties and Disclaimer. THIS WORK IS PROVIDED + "AS IS", "WHERE IS" AND "AS AVAILABLE", WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES + OR CONDITIONS OR GUARANTEES. YOU, THE USER, ASSUME ALL RISK IN ITS USE, INCLUDING + COPYRIGHT INFRINGEMENT, PATENT INFRINGEMENT, SUITABILITY, ETC. AUTHOR EXPRESSLY + DISCLAIMS ALL EXPRESS, IMPLIED OR STATUTORY WARRANTIES OR CONDITIONS, INCLUDING + WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF MERCHANTABILITY, MERCHANTABLE QUALITY + OR FITNESS FOR A PARTICULAR PURPOSE, OR ANY WARRANTY OF TITLE OR NON-INFRINGEMENT, + OR THAT THE WORK (OR ANY PORTION THEREOF) IS CORRECT, USEFUL, BUG-FREE OR FREE OF + VIRUSES. YOU MUST PASS THIS DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE WORK OR DERIVATIVE + WORKS. +
  12. + +
  13. Indemnity. You agree to defend, indemnify and hold harmless the Author and + the Publisher from and against any claims, suits, losses, damages, liabilities, + costs, and expenses (including reasonable legal or attorneys fees) resulting from + or relating to any use of the Work by You. +
  14. + +
  15. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE + LAW, IN NO EVENT WILL THE AUTHOR OR THE PUBLISHER BE LIABLE TO YOU ON ANY LEGAL + THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES + ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK OR OTHERWISE, EVEN IF THE AUTHOR + OR THE PUBLISHER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. +
  16. + +
  17. Termination. + +
      +
    1. This License and the rights granted hereunder will terminate automatically upon + any breach by You of any term of this License. Individuals or entities who have + received Derivative Works from You under this License, however, will not have their + licenses terminated provided such individuals or entities remain in full compliance + with those licenses. Sections 1, 2, 6, 7, 8, 9, 10 and 11 will survive any termination + of this License.
    2. + +
    3. If You bring a copyright, trademark, patent or any other infringement claim against + any contributor over infringements You claim are made by the Work, your License + from such contributor to the Work ends automatically.
    4. + +
    5. Subject to the above terms and conditions, this License is perpetual (for the duration + of the applicable copyright in the Work). Notwithstanding the above, the Author + reserves the right to release the Work under different license terms or to stop + distributing the Work at any time; provided, however that any such election will + not serve to withdraw this License (or any other license that has been, or is required + to be, granted under the terms of this License), and this License will continue + in full force and effect unless terminated as stated above. +
    6. +
    +
  18. + +
  19. Publisher. The parties hereby confirm that the Publisher shall + not, under any circumstances, be responsible for and shall not have any liability + in respect of the subject matter of this License. The Publisher makes no warranty + whatsoever in connection with the Work and shall not be liable to You or any party + on any legal theory for any damages whatsoever, including without limitation any + general, special, incidental or consequential damages arising in connection to this + license. The Publisher reserves the right to cease making the Work available to + You at any time without notice
  20. + +
  21. Miscellaneous + +
      +
    1. This License shall be governed by the laws of the location of the head office of + the Author or if the Author is an individual, the laws of location of the principal + place of residence of the Author.
    2. +
    3. If any provision of this License is invalid or unenforceable under applicable law, + it shall not affect the validity or enforceability of the remainder of the terms + of this License, and without further action by the parties to this License, such + provision shall be reformed to the minimum extent necessary to make such provision + valid and enforceable.
    4. +
    5. No term or provision of this License shall be deemed waived and no breach consented + to unless such waiver or consent shall be in writing and signed by the party to + be charged with such waiver or consent.
    6. +
    7. This License constitutes the entire agreement between the parties with respect to + the Work licensed herein. There are no understandings, agreements or representations + with respect to the Work not specified herein. The Author shall not be bound by + any additional provisions that may appear in any communication from You. This License + may not be modified without the mutual written agreement of the Author and You. +
    8. +
    + +
  22. +
+ +
+
+ + + diff --git a/server/TargaImage/Color.cs b/server/TargaImage/Color.cs new file mode 100644 index 0000000..358e556 --- /dev/null +++ b/server/TargaImage/Color.cs @@ -0,0 +1,33 @@ +namespace TargaImagePCL +{ + public struct Color + { + public static Color Empty = Color.FromArgb(0, 0, 0, 0); + + public byte R; + public byte G; + public byte B; + public byte A; + public static Color FromArgb(int a, int r, int g, int b) + { + return new Color() + { + R = (byte)r, + G = (byte)g, + B = (byte)b, + A = (byte)a + }; + } + + public static Color FromArgb(int r, int g, int b) + { + return new Color() + { + R = (byte)r, + G = (byte)g, + B = (byte)b, + A = (byte)255 + }; + } + } +} diff --git a/server/TargaImage/Properties/AssemblyInfo.cs b/server/TargaImage/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8361fae --- /dev/null +++ b/server/TargaImage/Properties/AssemblyInfo.cs @@ -0,0 +1,30 @@ +using System.Resources; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("TargaImagePCL")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TargaImagePCL")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/server/TargaImage/RawTGABitmap.cs b/server/TargaImage/RawTGABitmap.cs new file mode 100644 index 0000000..47c8c70 --- /dev/null +++ b/server/TargaImage/RawTGABitmap.cs @@ -0,0 +1,74 @@ +using System; + +namespace TargaImagePCL +{ + public class RawTGABitmap + { + public int Width; + public int Height; + public byte[] Data; + public TGAPixelFormat Format; + + public RawTGABitmap(int width, int height, byte[] data, TGAPixelFormat format) + { + Width = width; + Height = height; + Data = data; + Format = format; + } + + public byte[] ToBGRA(bool premultiply) + { + //bitorder output: bbbbbbbb gggggggg rrrrrrrr aaaaaaaa + byte[] result = null; + if (Format == TGAPixelFormat.RGB_32bpp || Format == TGAPixelFormat.ARGB_32bpp) + { + bool useAlpha = Format == TGAPixelFormat.ARGB_32bpp; + result = new byte[Data.Length]; + for (int i = 0; i < Data.Length; i += 4) + { //flip red and blue and premultiply alpha + result[i + 3] = (useAlpha)?Data[i + 3]:(byte)255; + float a = (premultiply) ? (Data[i + 3] / 255f) : 1; + result[i + 2] = (byte)(Data[i] * a); + result[i + 1] = (byte)(Data[i + 1] * a); + result[i] = (byte)(Data[i + 2] * a); + } + } + else if (Format == TGAPixelFormat.RGB_24bpp) + { + result = new byte[Width*Height*4]; + var j = 0; + for (int i = 0; i < Data.Length; i += 3) + { //flip red and blue and remove key colour + var a = (byte)((Data[i] > 0xFD && Data[i + 1] < 3 && Data[i + 2] > 0xFD)?0:255); + result[j + 3] = a; + result[j + 2] = (byte)(Data[i] & a); + result[j + 1] = (byte)(Data[i + 1] & a); + result[j] = (byte)(Data[i + 2] & a); + j += 4; + } + } + else if (Format == TGAPixelFormat.ARGB1555_16bpp || Format == TGAPixelFormat.RGB555_16bpp) + { + bool useAlpha = Format == TGAPixelFormat.ARGB1555_16bpp; + result = new byte[Width * Height * 4]; + throw new NotImplementedException("16-bit TGA not yet implemented."); + } + else if (Format == TGAPixelFormat.Grayscale_8bpp) + { + result = new byte[Width * Height * 4]; + for (int i = 0; i < Data.Length; i ++) + { //fill with gray + var g = Data[i]; + result[i + 3] = 255; + result[i + 2] = g; + result[i + 1] = g; + result[i] = g; + } + } + //else undefined. return null. + + return result; + } + } +} diff --git a/server/TargaImage/TargaImage.cs b/server/TargaImage/TargaImage.cs new file mode 100644 index 0000000..760bbe6 --- /dev/null +++ b/server/TargaImage/TargaImage.cs @@ -0,0 +1,2283 @@ +// ========================================================== +// TargaImagePCL +// A cross platform targa reader, for use with Monogame generally. +// +// Extended to not use System.Drawing by +// - Rhys Simpson (RHY3756547) +// +// Design and implementation by +// - David Polomis (paloma_sw@cox.net) +// +// +// This source code, along with any associated files, is licensed under +// The Code Project Open License (CPOL) 1.02 +// A copy of this license can be found in the CPOL.html file +// which was downloaded with this source code +// or at http://www.codeproject.com/info/cpol10.aspx +// +// +// COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, +// WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, +// INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS +// FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR +// NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE +// OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE +// DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY +// OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, +// REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN +// ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS +// AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. +// +// Use at your own risk! +// +// ========================================================== + + +using System; +using System.Collections.Generic; +using System.IO; + +namespace TargaImagePCL +{ + internal static class TargaConstants + { + // constant byte lengths for various fields in the Targa format + internal const int HeaderByteLength = 18; + internal const int FooterByteLength = 26; + internal const int FooterSignatureOffsetFromEnd = 18; + internal const int FooterSignatureByteLength = 16; + internal const int FooterReservedCharByteLength = 1; + internal const int ExtensionAreaAuthorNameByteLength = 41; + internal const int ExtensionAreaAuthorCommentsByteLength = 324; + internal const int ExtensionAreaJobNameByteLength = 41; + internal const int ExtensionAreaSoftwareIDByteLength = 41; + internal const int ExtensionAreaSoftwareVersionLetterByteLength = 1; + internal const int ExtensionAreaColorCorrectionTableValueLength = 256; + internal const string TargaFooterASCIISignature = "TRUEVISION-XFILE"; + } + + + /// + /// The Targa format of the file. + /// + public enum TGAFormat + { + /// + /// Unknown Targa Image format. + /// + UNKNOWN = 0, + + /// + /// Original Targa Image format. + /// + /// Targa Image does not have a Signature of ""TRUEVISION-XFILE"". + ORIGINAL_TGA = 100, + + /// + /// New Targa Image format + /// + /// Targa Image has a TargaFooter with a Signature of ""TRUEVISION-XFILE"". + NEW_TGA = 200 + } + + + /// + /// Indicates the type of color map, if any, included with the image file. + /// + public enum ColorMapType : byte + { + /// + /// No color map was included in the file. + /// + NO_COLOR_MAP = 0, + + /// + /// Color map was included in the file. + /// + COLOR_MAP_INCLUDED = 1 + } + + + /// + /// The type of image read from the file. + /// + public enum ImageType : byte + { + /// + /// No image data was found in file. + /// + NO_IMAGE_DATA = 0, + + /// + /// Image is an uncompressed, indexed color-mapped image. + /// + UNCOMPRESSED_COLOR_MAPPED = 1, + + /// + /// Image is an uncompressed, RGB image. + /// + UNCOMPRESSED_TRUE_COLOR = 2, + + /// + /// Image is an uncompressed, Greyscale image. + /// + UNCOMPRESSED_BLACK_AND_WHITE = 3, + + /// + /// Image is a compressed, indexed color-mapped image. + /// + RUN_LENGTH_ENCODED_COLOR_MAPPED = 9, + + /// + /// Image is a compressed, RGB image. + /// + RUN_LENGTH_ENCODED_TRUE_COLOR = 10, + + /// + /// Image is a compressed, Greyscale image. + /// + RUN_LENGTH_ENCODED_BLACK_AND_WHITE = 11 + } + + + /// + /// The top-to-bottom ordering in which pixel data is transferred from the file to the screen. + /// + public enum VerticalTransferOrder + { + /// + /// Unknown transfer order. + /// + UNKNOWN = -1, + + /// + /// Transfer order of pixels is from the bottom to top. + /// + BOTTOM = 0, + + /// + /// Transfer order of pixels is from the top to bottom. + /// + TOP = 1 + } + + + /// + /// The left-to-right ordering in which pixel data is transferred from the file to the screen. + /// + public enum HorizontalTransferOrder + { + /// + /// Unknown transfer order. + /// + UNKNOWN = -1, + + /// + /// Transfer order of pixels is from the right to left. + /// + RIGHT = 0, + + /// + /// Transfer order of pixels is from the left to right. + /// + LEFT = 1 + } + + + /// + /// Screen destination of first pixel based on the VerticalTransferOrder and HorizontalTransferOrder. + /// + public enum FirstPixelDestination + { + /// + /// Unknown first pixel destination. + /// + UNKNOWN = 0, + + /// + /// First pixel destination is the top-left corner of the image. + /// + TOP_LEFT = 1, + + /// + /// First pixel destination is the top-right corner of the image. + /// + TOP_RIGHT = 2, + + /// + /// First pixel destination is the bottom-left corner of the image. + /// + BOTTOM_LEFT = 3, + + /// + /// First pixel destination is the bottom-right corner of the image. + /// + BOTTOM_RIGHT = 4 + } + + + /// + /// The RLE packet type used in a RLE compressed image. + /// + public enum RLEPacketType + { + /// + /// A raw RLE packet type. + /// + RAW = 0, + + /// + /// A run-length RLE packet type. + /// + RUN_LENGTH = 1 + } + + + /// + /// Reads and loads a Truevision TGA Format image file. + /// + public class TargaImage : IDisposable + + { + private TargaHeader objTargaHeader = null; + private TargaExtensionArea objTargaExtensionArea = null; + private TargaFooter objTargaFooter = null; + private RawTGABitmap bmpTargaImage = null; + private RawTGABitmap bmpImageThumbnail = null; + private TGAFormat eTGAFormat = TGAFormat.UNKNOWN; + private string strFileName = string.Empty; + private int intStride = 0; + private int intPadding = 0; + private System.Collections.Generic.List> rows = new System.Collections.Generic.List>(); + private System.Collections.Generic.List row = new System.Collections.Generic.List(); + + + // Track whether Dispose has been called. + private bool disposed = false; + + + /// + /// Creates a new instance of the TargaImage object. + /// + public TargaImage() + { + this.objTargaFooter = new TargaFooter(); + this.objTargaHeader = new TargaHeader(); + this.objTargaExtensionArea = new TargaExtensionArea(); + this.bmpTargaImage = null; + this.bmpImageThumbnail = null; + } + + + /// + /// Gets a TargaHeader object that holds the Targa Header information of the loaded file. + /// + public TargaHeader Header + { + get { return this.objTargaHeader; } + } + + + /// + /// Gets a TargaExtensionArea object that holds the Targa Extension Area information of the loaded file. + /// + public TargaExtensionArea ExtensionArea + { + get { return this.objTargaExtensionArea; } + } + + + /// + /// Gets a TargaExtensionArea object that holds the Targa Footer information of the loaded file. + /// + public TargaFooter Footer + { + get { return this.objTargaFooter; } + } + + + /// + /// Gets the Targa format of the loaded file. + /// + public TGAFormat Format + { + get { return this.eTGAFormat; } + } + + + /// + /// Gets a Bitmap representation of the loaded file. + /// + public RawTGABitmap Image + { + get { return this.bmpTargaImage; } + } + + /// + /// Gets the thumbnail of the loaded file if there is one in the file. + /// + public RawTGABitmap Thumbnail + { + get { return this.bmpImageThumbnail; } + } + + /// + /// Gets the full path and filename of the loaded file. + /// + public string FileName + { + get { return this.strFileName; } + } + + + /// + /// Gets the byte offset between the beginning of one scan line and the next. Used when loading the image into the Image Bitmap. + /// + /// + /// The memory allocated for Microsoft Bitmaps must be aligned on a 32bit boundary. + /// The stride refers to the number of bytes allocated for one scanline of the bitmap. + /// + public int Stride + { + get { return this.intStride; } + } + + + /// + /// Gets the number of bytes used to pad each scan line to meet the Stride value. Used when loading the image into the Image Bitmap. + /// + /// + /// The memory allocated for Microsoft Bitmaps must be aligned on a 32bit boundary. + /// The stride refers to the number of bytes allocated for one scanline of the bitmap. + /// In your loop, you copy the pixels one scanline at a time and take into + /// consideration the amount of padding that occurs due to memory alignment. + /// + public int Padding + { + get { return this.intPadding; } + } + + + // Use C# destructor syntax for finalization code. + // This destructor will run only if the Dispose method + // does not get called. + // It gives your base class the opportunity to finalize. + // Do not provide destructors in types derived from this class. + /// + /// TargaImage deconstructor. + /// + ~TargaImage() + { + // Do not re-create Dispose clean-up code here. + // Calling Dispose(false) is optimal in terms of + // readability and maintainability. + Dispose(false); + } + + public TargaImage(Stream filestream) : this() + { + BinaryReader binReader = null; + if (filestream != null && filestream.Length > 0 && filestream.CanSeek == true) + { + // create a BinaryReader used to read the Targa file + using (binReader = new BinaryReader(filestream)) + { + this.LoadTGAFooterInfo(binReader); + this.LoadTGAHeaderInfo(binReader); + this.LoadTGAExtensionArea(binReader); + this.LoadTGAImage(binReader); + } + } + else + throw new Exception(@"Error loading file"); + } + + private string GetStringFromBytes(byte[] dat) + { + return System.Text.Encoding.UTF8.GetString(dat, 0, dat.Length).TrimEnd('\0'); + } + + /// + /// Loads the Targa Footer information from the file. + /// + /// A BinaryReader that points the loaded file byte stream. + private void LoadTGAFooterInfo(BinaryReader binReader) + { + + if (binReader != null && binReader.BaseStream != null && binReader.BaseStream.Length > 0 && binReader.BaseStream.CanSeek == true) + { + + try + { + // set the cursor at the beginning of the signature string. + binReader.BaseStream.Seek((TargaConstants.FooterSignatureOffsetFromEnd * -1), SeekOrigin.End); + + // read the signature bytes and convert to ascii string + string Signature = GetStringFromBytes(binReader.ReadBytes(TargaConstants.FooterSignatureByteLength)).TrimEnd('\0'); + + // do we have a proper signature + if (string.Compare(Signature, TargaConstants.TargaFooterASCIISignature) == 0) + { + // this is a NEW targa file. + // create the footer + this.eTGAFormat = TGAFormat.NEW_TGA; + + // set cursor to beginning of footer info + binReader.BaseStream.Seek((TargaConstants.FooterByteLength * -1), SeekOrigin.End); + + // read the Extension Area Offset value + int ExtOffset = binReader.ReadInt32(); + + // read the Developer Directory Offset value + int DevDirOff = binReader.ReadInt32(); + + // skip the signature we have already read it. + binReader.ReadBytes(TargaConstants.FooterSignatureByteLength); + + // read the reserved character + string ResChar = GetStringFromBytes(binReader.ReadBytes(TargaConstants.FooterReservedCharByteLength)).TrimEnd('\0'); + + // set all values to our TargaFooter class + this.objTargaFooter.SetExtensionAreaOffset(ExtOffset); + this.objTargaFooter.SetDeveloperDirectoryOffset(DevDirOff); + this.objTargaFooter.SetSignature(Signature); + this.objTargaFooter.SetReservedCharacter(ResChar); + } + else + { + // this is not an ORIGINAL targa file. + this.eTGAFormat = TGAFormat.ORIGINAL_TGA; + } + } + catch (Exception ex) + { + // clear all + this.ClearAll(); + throw ex; + } + } + else + { + this.ClearAll(); + throw new Exception(@"Error loading file, could not read file from disk."); + } + + + } + + + /// + /// Loads the Targa Header information from the file. + /// + /// A BinaryReader that points the loaded file byte stream. + private void LoadTGAHeaderInfo(BinaryReader binReader) + { + + if (binReader != null && binReader.BaseStream != null && binReader.BaseStream.Length > 0 && binReader.BaseStream.CanSeek == true) + { + try + { + // set the cursor at the beginning of the file. + binReader.BaseStream.Seek(0, SeekOrigin.Begin); + + // read the header properties from the file + this.objTargaHeader.SetImageIDLength(binReader.ReadByte()); + this.objTargaHeader.SetColorMapType((ColorMapType)binReader.ReadByte()); + this.objTargaHeader.SetImageType((ImageType)binReader.ReadByte()); + + this.objTargaHeader.SetColorMapFirstEntryIndex(binReader.ReadInt16()); + this.objTargaHeader.SetColorMapLength(binReader.ReadInt16()); + this.objTargaHeader.SetColorMapEntrySize(binReader.ReadByte()); + + this.objTargaHeader.SetXOrigin(binReader.ReadInt16()); + this.objTargaHeader.SetYOrigin(binReader.ReadInt16()); + this.objTargaHeader.SetWidth(binReader.ReadInt16()); + this.objTargaHeader.SetHeight(binReader.ReadInt16()); + + byte pixeldepth = binReader.ReadByte(); + switch (pixeldepth) + { + case 8: + case 16: + case 24: + case 32: + this.objTargaHeader.SetPixelDepth(pixeldepth); + break; + + default: + this.ClearAll(); + throw new Exception("Targa Image only supports 8, 16, 24, or 32 bit pixel depths."); + } + + + byte ImageDescriptor = binReader.ReadByte(); + this.objTargaHeader.SetAttributeBits((byte)Utilities.GetBits(ImageDescriptor, 0, 4)); + + this.objTargaHeader.SetVerticalTransferOrder((VerticalTransferOrder)Utilities.GetBits(ImageDescriptor, 5, 1)); + this.objTargaHeader.SetHorizontalTransferOrder((HorizontalTransferOrder)Utilities.GetBits(ImageDescriptor, 4, 1)); + + // load ImageID value if any + if (this.objTargaHeader.ImageIDLength > 0) + { + byte[] ImageIDValueBytes = binReader.ReadBytes(this.objTargaHeader.ImageIDLength); + this.objTargaHeader.SetImageIDValue(GetStringFromBytes(ImageIDValueBytes).TrimEnd('\0')); + } + } + catch (Exception ex) + { + this.ClearAll(); + throw ex; + } + + + // load color map if it's included and/or needed + // Only needed for UNCOMPRESSED_COLOR_MAPPED and RUN_LENGTH_ENCODED_COLOR_MAPPED + // image types. If color map is included for other file types we can ignore it. + if (this.objTargaHeader.ColorMapType == ColorMapType.COLOR_MAP_INCLUDED) + { + if (this.objTargaHeader.ImageType == ImageType.UNCOMPRESSED_COLOR_MAPPED || + this.objTargaHeader.ImageType == ImageType.RUN_LENGTH_ENCODED_COLOR_MAPPED) + { + if (this.objTargaHeader.ColorMapLength > 0) + { + try + { + for (int i = 0; i < this.objTargaHeader.ColorMapLength; i++) + { + int a = 0; + int r = 0; + int g = 0; + int b = 0; + + // load each color map entry based on the ColorMapEntrySize value + switch (this.objTargaHeader.ColorMapEntrySize) + { + case 15: + byte[] color15 = binReader.ReadBytes(2); + // remember that the bytes are stored in reverse oreder + this.objTargaHeader.ColorMap.Add(Utilities.GetColorFrom2Bytes(color15[1], color15[0])); + break; + case 16: + byte[] color16 = binReader.ReadBytes(2); + // remember that the bytes are stored in reverse oreder + this.objTargaHeader.ColorMap.Add(Utilities.GetColorFrom2Bytes(color16[1], color16[0])); + break; + case 24: + b = Convert.ToInt32(binReader.ReadByte()); + g = Convert.ToInt32(binReader.ReadByte()); + r = Convert.ToInt32(binReader.ReadByte()); + this.objTargaHeader.ColorMap.Add(Color.FromArgb(r, g, b)); + break; + case 32: + a = Convert.ToInt32(binReader.ReadByte()); + b = Convert.ToInt32(binReader.ReadByte()); + g = Convert.ToInt32(binReader.ReadByte()); + r = Convert.ToInt32(binReader.ReadByte()); + this.objTargaHeader.ColorMap.Add(Color.FromArgb(a, r, g, b)); + break; + default: + this.ClearAll(); + throw new Exception("TargaImage only supports ColorMap Entry Sizes of 15, 16, 24 or 32 bits."); + + } + + + } + } + catch (Exception ex) + { + this.ClearAll(); + throw ex; + } + + + + } + else + { + this.ClearAll(); + throw new Exception("Image Type requires a Color Map and Color Map Length is zero."); + } + } + + + } + else + { + if (this.objTargaHeader.ImageType == ImageType.UNCOMPRESSED_COLOR_MAPPED || + this.objTargaHeader.ImageType == ImageType.RUN_LENGTH_ENCODED_COLOR_MAPPED) + { + this.ClearAll(); + throw new Exception("Image Type requires a Color Map and there was not a Color Map included in the file."); + } + } + + + } + else + { + this.ClearAll(); + throw new Exception(@"Error loading file, could not read file from disk."); + } + } + + + /// + /// Loads the Targa Extension Area from the file, if it exists. + /// + /// A BinaryReader that points the loaded file byte stream. + private void LoadTGAExtensionArea(BinaryReader binReader) + { + + if (binReader != null && binReader.BaseStream != null && binReader.BaseStream.Length > 0 && binReader.BaseStream.CanSeek == true) + { + // is there an Extension Area in file + if (this.objTargaFooter.ExtensionAreaOffset > 0) + { + try + { + // set the cursor at the beginning of the Extension Area using ExtensionAreaOffset. + binReader.BaseStream.Seek(this.objTargaFooter.ExtensionAreaOffset, SeekOrigin.Begin); + + // load the extension area fields from the file + + this.objTargaExtensionArea.SetExtensionSize((int)(binReader.ReadInt16())); + this.objTargaExtensionArea.SetAuthorName(GetStringFromBytes(binReader.ReadBytes(TargaConstants.ExtensionAreaAuthorNameByteLength)).TrimEnd('\0')); + this.objTargaExtensionArea.SetAuthorComments(GetStringFromBytes(binReader.ReadBytes(TargaConstants.ExtensionAreaAuthorCommentsByteLength)).TrimEnd('\0')); + + + // get the date/time stamp of the file + Int16 iMonth = binReader.ReadInt16(); + Int16 iDay = binReader.ReadInt16(); + Int16 iYear = binReader.ReadInt16(); + Int16 iHour = binReader.ReadInt16(); + Int16 iMinute = binReader.ReadInt16(); + Int16 iSecond = binReader.ReadInt16(); + DateTime dtstamp; + string strStamp = iMonth.ToString() + @"/" + iDay.ToString() + @"/" + iYear.ToString() + @" "; + strStamp += iHour.ToString() + @":" + iMinute.ToString() + @":" + iSecond.ToString(); + if (DateTime.TryParse(strStamp, out dtstamp) == true) + this.objTargaExtensionArea.SetDateTimeStamp(dtstamp); + + + this.objTargaExtensionArea.SetJobName(GetStringFromBytes(binReader.ReadBytes(TargaConstants.ExtensionAreaJobNameByteLength)).TrimEnd('\0')); + + + // get the job time of the file + iHour = binReader.ReadInt16(); + iMinute = binReader.ReadInt16(); + iSecond = binReader.ReadInt16(); + TimeSpan ts = new TimeSpan((int)iHour, (int)iMinute, (int)iSecond); + this.objTargaExtensionArea.SetJobTime(ts); + + + this.objTargaExtensionArea.SetSoftwareID(GetStringFromBytes(binReader.ReadBytes(TargaConstants.ExtensionAreaSoftwareIDByteLength)).TrimEnd('\0')); + + + // get the version number and letter from file + float iVersionNumber = (float)binReader.ReadInt16() / 100.0F; + string strVersionLetter = GetStringFromBytes(binReader.ReadBytes(TargaConstants.ExtensionAreaSoftwareVersionLetterByteLength)).TrimEnd('\0'); + + + this.objTargaExtensionArea.SetSoftwareID(iVersionNumber.ToString(@"F2") + strVersionLetter); + + + // get the color key of the file + int a = (int)binReader.ReadByte(); + int r = (int)binReader.ReadByte(); + int b = (int)binReader.ReadByte(); + int g = (int)binReader.ReadByte(); + this.objTargaExtensionArea.SetKeyColor(Color.FromArgb(a, r, g, b)); + + + this.objTargaExtensionArea.SetPixelAspectRatioNumerator((int)binReader.ReadInt16()); + this.objTargaExtensionArea.SetPixelAspectRatioDenominator((int)binReader.ReadInt16()); + this.objTargaExtensionArea.SetGammaNumerator((int)binReader.ReadInt16()); + this.objTargaExtensionArea.SetGammaDenominator((int)binReader.ReadInt16()); + this.objTargaExtensionArea.SetColorCorrectionOffset(binReader.ReadInt32()); + this.objTargaExtensionArea.SetPostageStampOffset(binReader.ReadInt32()); + this.objTargaExtensionArea.SetScanLineOffset(binReader.ReadInt32()); + this.objTargaExtensionArea.SetAttributesType((int)binReader.ReadByte()); + + + // load Scan Line Table from file if any + if (this.objTargaExtensionArea.ScanLineOffset > 0) + { + binReader.BaseStream.Seek(this.objTargaExtensionArea.ScanLineOffset, SeekOrigin.Begin); + for (int i = 0; i < this.objTargaHeader.Height; i++) + { + this.objTargaExtensionArea.ScanLineTable.Add(binReader.ReadInt32()); + } + } + + + // load Color Correction Table from file if any + if (this.objTargaExtensionArea.ColorCorrectionOffset > 0) + { + binReader.BaseStream.Seek(this.objTargaExtensionArea.ColorCorrectionOffset, SeekOrigin.Begin); + for (int i = 0; i < TargaConstants.ExtensionAreaColorCorrectionTableValueLength; i++) + { + a = (int)binReader.ReadInt16(); + r = (int)binReader.ReadInt16(); + b = (int)binReader.ReadInt16(); + g = (int)binReader.ReadInt16(); + this.objTargaExtensionArea.ColorCorrectionTable.Add(Color.FromArgb(a, r, g, b)); + } + } + } + catch (Exception ex) + { + this.ClearAll(); + throw ex; + } + } + } + else + { + this.ClearAll(); + throw new Exception(@"Error loading file, could not read file from disk."); + } + } + + /// + /// Reads the image data bytes from the file. Handles Uncompressed and RLE Compressed image data. + /// Uses FirstPixelDestination to properly align the image. + /// + /// A BinaryReader that points the loaded file byte stream. + /// An array of bytes representing the image data in the proper alignment. + private byte[] LoadImageBytes(BinaryReader binReader) + { + + // read the image data into a byte array + // take into account stride has to be a multiple of 4 + // use padding to make sure multiple of 4 + + byte[] data = null; + if (binReader != null && binReader.BaseStream != null && binReader.BaseStream.Length > 0 && binReader.BaseStream.CanSeek == true) + { + if (this.objTargaHeader.ImageDataOffset > 0) + { + // padding bytes + byte[] padding = new byte[this.intPadding]; + MemoryStream msData = null; + + // seek to the beginning of the image data using the ImageDataOffset value + binReader.BaseStream.Seek(this.objTargaHeader.ImageDataOffset, SeekOrigin.Begin); + + + // get the size in bytes of each row in the image + int intImageRowByteSize = (int)this.objTargaHeader.Width * ((int)this.objTargaHeader.BytesPerPixel); + + // get the size in bytes of the whole image + int intImageByteSize = intImageRowByteSize * (int)this.objTargaHeader.Height; + + // is this a RLE compressed image type + if (this.objTargaHeader.ImageType == ImageType.RUN_LENGTH_ENCODED_BLACK_AND_WHITE || + this.objTargaHeader.ImageType == ImageType.RUN_LENGTH_ENCODED_COLOR_MAPPED || + this.objTargaHeader.ImageType == ImageType.RUN_LENGTH_ENCODED_TRUE_COLOR) + { + + #region COMPRESSED + + // RLE Packet info + byte bRLEPacket = 0; + int intRLEPacketType = -1; + int intRLEPixelCount = 0; + byte[] bRunLengthPixel = null; + + // used to keep track of bytes read + int intImageBytesRead = 0; + int intImageRowBytesRead = 0; + + // keep reading until we have the all image bytes + while (intImageBytesRead < intImageByteSize) + { + // get the RLE packet + bRLEPacket = binReader.ReadByte(); + intRLEPacketType = Utilities.GetBits(bRLEPacket, 7, 1); + intRLEPixelCount = Utilities.GetBits(bRLEPacket, 0, 7) + 1; + + // check the RLE packet type + if ((RLEPacketType)intRLEPacketType == RLEPacketType.RUN_LENGTH) + { + // get the pixel color data + bRunLengthPixel = binReader.ReadBytes((int)this.objTargaHeader.BytesPerPixel); + + // add the number of pixels specified using the read pixel color + for (int i = 0; i < intRLEPixelCount; i++) + { + foreach (byte b in bRunLengthPixel) + row.Add(b); + + // increment the byte counts + intImageRowBytesRead += bRunLengthPixel.Length; + intImageBytesRead += bRunLengthPixel.Length; + + // if we have read a full image row + // add the row to the row list and clear it + // restart row byte count + if (intImageRowBytesRead == intImageRowByteSize) + { + rows.Add(row); + row = new System.Collections.Generic.List(); + intImageRowBytesRead = 0; + + } + } + + } + + else if ((RLEPacketType)intRLEPacketType == RLEPacketType.RAW) + { + // get the number of bytes to read based on the read pixel count + int intBytesToRead = intRLEPixelCount * (int)this.objTargaHeader.BytesPerPixel; + + // read each byte + for (int i = 0; i < intBytesToRead; i++) + { + row.Add(binReader.ReadByte()); + + // increment the byte counts + intImageBytesRead++; + intImageRowBytesRead++; + + // if we have read a full image row + // add the row to the row list and clear it + // restart row byte count + if (intImageRowBytesRead == intImageRowByteSize) + { + rows.Add(row); + row = new System.Collections.Generic.List(); + intImageRowBytesRead = 0; + } + + } + + } + } + + #endregion + + } + + else + { + #region NON-COMPRESSED + + // loop through each row in the image + for (int i = 0; i < (int)this.objTargaHeader.Height; i++) + { + // loop through each byte in the row + for (int j = 0; j < intImageRowByteSize; j++) + { + // add the byte to the row + row.Add(binReader.ReadByte()); + } + + // add row to the list of rows + rows.Add(row); + + // create a new row + row = new System.Collections.Generic.List(); + } + + + #endregion + } + + // flag that states whether or not to reverse the location of all rows. + bool blnRowsReverse = false; + + // flag that states whether or not to reverse the bytes in each row. + bool blnEachRowReverse = false; + + // use FirstPixelDestination to determine the alignment of the + // image data byte + switch (this.objTargaHeader.FirstPixelDestination) + { + case FirstPixelDestination.TOP_LEFT: + blnRowsReverse = false; + blnEachRowReverse = true; + break; + + case FirstPixelDestination.TOP_RIGHT: + blnRowsReverse = false; + blnEachRowReverse = false; + break; + + case FirstPixelDestination.BOTTOM_LEFT: + blnRowsReverse = true; + blnEachRowReverse = true; + break; + + case FirstPixelDestination.BOTTOM_RIGHT: + case FirstPixelDestination.UNKNOWN: + blnRowsReverse = true; + blnEachRowReverse = false; + + break; + } + + // write the bytes from each row into a memory stream and get the + // resulting byte array + + try + { + using (msData = new MemoryStream()) + { + + // do we reverse the rows in the row list. + if (blnRowsReverse == true) + rows.Reverse(); + + // go through each row + for (int i = 0; i < rows.Count; i++) + { + // do we reverse the bytes in the row + if (blnEachRowReverse == true) + rows[i].Reverse(); + + // get the byte array for the row + byte[] brow = rows[i].ToArray(); + + // write the row bytes and padding bytes to the memory streem + msData.Write(brow, 0, brow.Length); + msData.Write(padding, 0, padding.Length); + } + // get the image byte array + data = msData.ToArray(); + } + } catch (Exception e) + { + throw new Exception("something bad happened" + rows.Count); + } + + } + else + { + this.ClearAll(); + throw new Exception(@"Error loading file, No image data in file."); + } + } + else + { + this.ClearAll(); + throw new Exception(@"Error loading file, could not read file from disk."); + } + + // return the image byte array + return data; + + } + + /// + /// Reads the image data bytes from the file and loads them into the Image Bitmap object. + /// Also loads the color map, if any, into the Image Bitmap. + /// + /// A BinaryReader that points the loaded file byte stream. + private void LoadTGAImage(BinaryReader binReader) + { + //************** NOTE ******************* + // The memory allocated for Microsoft Bitmaps must be aligned on a 32bit boundary. + // The stride refers to the number of bytes allocated for one scanline of the bitmap. + // In your loop, you copy the pixels one scanline at a time and take into + // consideration the amount of padding that occurs due to memory alignment. + // calculate the stride, in bytes, of the image (32bit aligned width of each image row) + this.intStride = (((int)this.objTargaHeader.Width * (int)this.objTargaHeader.PixelDepth + 31) & ~31) >> 3; // width in bytes + + // calculate the padding, in bytes, of the image + // number of bytes to add to make each row a 32bit aligned row + // padding in bytes + this.intPadding = this.intStride - ((((int)this.objTargaHeader.Width * (int)this.objTargaHeader.PixelDepth) + 7) / 8); + + // get the image data bytes + byte[] bimagedata = this.LoadImageBytes(binReader); + + // get the Pixel format to use with the Bitmap object + TGAPixelFormat pf = this.GetPixelFormat(); + + // create a Bitmap object using the image Width, Height, + // Stride, PixelFormat and the pointer to the pinned byte array. + this.bmpTargaImage = new RawTGABitmap((int)this.objTargaHeader.Width, + (int)this.objTargaHeader.Height, + bimagedata, + pf); + + + this.LoadThumbnail(binReader, pf); + + + /* + // load the color map into the Bitmap, if it exists + if (this.objTargaHeader.ColorMap.Count > 0) + { + // get the Bitmap's current palette + ColorPalette pal = this.bmpTargaImage.Palette; + + // loop trough each color in the loaded file's color map + for (int i = 0; i < this.objTargaHeader.ColorMap.Count; i++) + { + // is the AttributesType 0 or 1 bit + if (this.objTargaExtensionArea.AttributesType == 0 || + this.objTargaExtensionArea.AttributesType == 1) + // use 255 for alpha ( 255 = opaque/visible ) so we can see the image + pal.Entries[i] = Color.FromArgb(255, this.objTargaHeader.ColorMap[i].R, this.objTargaHeader.ColorMap[i].G, this.objTargaHeader.ColorMap[i].B); + + else + // use whatever value is there + pal.Entries[i] = this.objTargaHeader.ColorMap[i]; + + } + + // set the new palette back to the Bitmap object + this.bmpTargaImage.Palette = pal; + + // set the palette to the thumbnail also, if there is one + if (this.bmpImageThumbnail != null) + { + this.bmpImageThumbnail.Palette = pal; + } + } + */ + + + // check to see if this is a Black and White (Greyscale) + //if (this.objTargaHeader.PixelDepth == 8 && (this.objTargaHeader.ImageType == ImageType.UNCOMPRESSED_BLACK_AND_WHITE || + // this.objTargaHeader.ImageType == ImageType.RUN_LENGTH_ENCODED_BLACK_AND_WHITE)) + + } + + /// + /// Gets the PixelFormat to be used by the Image based on the Targa file's attributes + /// + /// + private TGAPixelFormat GetPixelFormat() + { + + TGAPixelFormat pfTargaPixelFormat = TGAPixelFormat.Undefined; + + // first off what is our Pixel Depth (bits per pixel) + switch (this.objTargaHeader.PixelDepth) + { + case 8: + pfTargaPixelFormat = TGAPixelFormat.Grayscale_8bpp; + break; + + case 16: + //PixelFormat.Format16bppArgb1555 + //PixelFormat.Format16bppRgb555 + if (this.Format == TGAFormat.NEW_TGA) + { + switch (this.objTargaExtensionArea.AttributesType) + { + case 0: + case 1: + case 2: // no alpha data + pfTargaPixelFormat = TGAPixelFormat.RGB555_16bpp; + break; + + case 3: // useful alpha data + pfTargaPixelFormat = TGAPixelFormat.ARGB1555_16bpp; + break; + } + } + else + { + pfTargaPixelFormat = TGAPixelFormat.RGB555_16bpp; + } + + break; + + case 24: + pfTargaPixelFormat = TGAPixelFormat.RGB_24bpp; + break; + + case 32: + //PixelFormat.Format32bppArgb + //PixelFormat.Format32bppPArgb + //PixelFormat.Format32bppRgb + if (this.Format == TGAFormat.NEW_TGA) + { + switch (this.objTargaExtensionArea.AttributesType) + { + + case 1: + case 2: // no alpha data + pfTargaPixelFormat = TGAPixelFormat.RGB_32bpp; + break; + + case 0: + case 3: // useful alpha data + pfTargaPixelFormat = TGAPixelFormat.ARGB_32bpp; + break; + + case 4: // premultiplied alpha data + pfTargaPixelFormat = TGAPixelFormat.ARGB_32bpp; + break; + + } + } + else + { + pfTargaPixelFormat = TGAPixelFormat.RGB_32bpp; + break; + } + + + + break; + + } + + + return pfTargaPixelFormat; + } + + + /// + /// Loads the thumbnail of the loaded image file, if any. + /// + /// A BinaryReader that points the loaded file byte stream. + /// A PixelFormat value indicating what pixel format to use when loading the thumbnail. + private void LoadThumbnail(BinaryReader binReader, TGAPixelFormat pfPixelFormat) + { + + // read the Thumbnail image data into a byte array + // take into account stride has to be a multiple of 4 + // use padding to make sure multiple of 4 + + byte[] data = null; + if (binReader != null && binReader.BaseStream != null && binReader.BaseStream.Length > 0 && binReader.BaseStream.CanSeek == true) + { + if (this.ExtensionArea.PostageStampOffset > 0) + { + + // seek to the beginning of the image data using the ImageDataOffset value + binReader.BaseStream.Seek(this.ExtensionArea.PostageStampOffset, SeekOrigin.Begin); + + int iWidth = (int)binReader.ReadByte(); + int iHeight = (int)binReader.ReadByte(); + + int iStride = ((iWidth * (int)this.objTargaHeader.PixelDepth + 31) & ~31) >> 3; // width in bytes + int iPadding = iStride - (((iWidth * (int)this.objTargaHeader.PixelDepth) + 7) / 8); + + System.Collections.Generic.List> objRows = new System.Collections.Generic.List>(); + System.Collections.Generic.List objRow = new System.Collections.Generic.List(); + + byte[] padding = new byte[iPadding]; + MemoryStream msData = null; + bool blnEachRowReverse = false; + bool blnRowsReverse = false; + + + using (msData = new MemoryStream()) + { + // get the size in bytes of each row in the image + int intImageRowByteSize = iWidth * ((int)this.objTargaHeader.PixelDepth / 8); + + // get the size in bytes of the whole image + int intImageByteSize = intImageRowByteSize * iHeight; + + // thumbnails are never compressed + for (int i = 0; i < iHeight; i++) + { + for (int j = 0; j < intImageRowByteSize; j++) + { + objRow.Add(binReader.ReadByte()); + } + objRows.Add(objRow); + objRow = new System.Collections.Generic.List(); + } + + switch (this.objTargaHeader.FirstPixelDestination) + { + case FirstPixelDestination.TOP_LEFT: + break; + + case FirstPixelDestination.TOP_RIGHT: + blnRowsReverse = false; + blnEachRowReverse = false; + break; + + case FirstPixelDestination.BOTTOM_LEFT: + break; + + case FirstPixelDestination.BOTTOM_RIGHT: + case FirstPixelDestination.UNKNOWN: + blnRowsReverse = true; + blnEachRowReverse = false; + + break; + } + + if (blnRowsReverse == true) + objRows.Reverse(); + + for (int i = 0; i < objRows.Count; i++) + { + if (blnEachRowReverse == true) + objRows[i].Reverse(); + + byte[] brow = objRows[i].ToArray(); + msData.Write(brow, 0, brow.Length); + msData.Write(padding, 0, padding.Length); + } + data = msData.ToArray(); + } + + if (data != null && data.Length > 0) + { + this.bmpImageThumbnail = new RawTGABitmap(iWidth, iHeight, data, pfPixelFormat); + + } + + + } + } + + } + + /// + /// Clears out all objects and resources. + /// + private void ClearAll() + { + + this.objTargaHeader = new TargaHeader(); + this.objTargaExtensionArea = new TargaExtensionArea(); + this.objTargaFooter = new TargaFooter(); + this.eTGAFormat = TGAFormat.UNKNOWN; + this.intStride = 0; + this.intPadding = 0; + this.rows.Clear(); + this.row.Clear(); + this.strFileName = string.Empty; + + } + + #region IDisposable Members + + /// + /// Disposes all resources used by this instance of the TargaImage class. + /// + public void Dispose() + { + Dispose(true); + // Take yourself off the Finalization queue + // to prevent finalization code for this object + // from executing a second time. + GC.SuppressFinalize(this); + + } + + + /// + /// Dispose(bool disposing) executes in two distinct scenarios. + /// If disposing equals true, the method has been called directly + /// or indirectly by a user's code. Managed and unmanaged resources + /// can be disposed. + /// If disposing equals false, the method has been called by the + /// runtime from inside the finalizer and you should not reference + /// other objects. Only unmanaged resources can be disposed. + /// + /// If true dispose all resources, else dispose only release unmanaged resources. + protected virtual void Dispose(bool disposing) + { + // Check to see if Dispose has already been called. + if (!this.disposed) + { + //no managed resources anymore + } + disposed = true; + } + + + #endregion + } + + + /// + /// This class holds all of the header properties of a Targa image. + /// This includes the TGA File Header section the ImageID and the Color Map. + /// + public class TargaHeader + { + private byte bImageIDLength = 0; + private ColorMapType eColorMapType = ColorMapType.NO_COLOR_MAP; + private ImageType eImageType = ImageType.NO_IMAGE_DATA; + private short sColorMapFirstEntryIndex = 0; + private short sColorMapLength = 0; + private byte bColorMapEntrySize = 0; + private short sXOrigin = 0; + private short sYOrigin = 0; + private short sWidth = 0; + private short sHeight = 0; + private byte bPixelDepth = 0; + private byte bImageDescriptor = 0; + private VerticalTransferOrder eVerticalTransferOrder = VerticalTransferOrder.UNKNOWN; + private HorizontalTransferOrder eHorizontalTransferOrder = HorizontalTransferOrder.UNKNOWN; + private byte bAttributeBits = 0; + private string strImageIDValue = string.Empty; + private System.Collections.Generic.List cColorMap = new List(); + + /// + /// Gets the number of bytes contained the ImageIDValue property. The maximum + /// number of characters is 255. A value of zero indicates that no ImageIDValue is included with the + /// image. + /// + public byte ImageIDLength + { + get { return this.bImageIDLength; } + } + + /// + /// Sets the ImageIDLength property, available only to objects in the same assembly as TargaHeader. + /// + /// The Image ID Length value read from the file. + internal protected void SetImageIDLength(byte bImageIDLength) + { + this.bImageIDLength = bImageIDLength; + } + + /// + /// Gets the type of color map (if any) included with the image. There are currently 2 + /// defined values for this field: + /// NO_COLOR_MAP - indicates that no color-map data is included with this image. + /// COLOR_MAP_INCLUDED - indicates that a color-map is included with this image. + /// + public ColorMapType ColorMapType + { + get { return this.eColorMapType; } + } + + /// + /// Sets the ColorMapType property, available only to objects in the same assembly as TargaHeader. + /// + /// One of the ColorMapType enumeration values. + internal protected void SetColorMapType(ColorMapType eColorMapType) + { + this.eColorMapType = eColorMapType; + } + + /// + /// Gets one of the ImageType enumeration values indicating the type of Targa image read from the file. + /// + public ImageType ImageType + { + get { return this.eImageType; } + } + + /// + /// Sets the ImageType property, available only to objects in the same assembly as TargaHeader. + /// + /// One of the ImageType enumeration values. + internal protected void SetImageType(ImageType eImageType) + { + this.eImageType = eImageType; + } + + /// + /// Gets the index of the first color map entry. ColorMapFirstEntryIndex refers to the starting entry in loading the color map. + /// + public short ColorMapFirstEntryIndex + { + get { return this.sColorMapFirstEntryIndex; } + } + + /// + /// Sets the ColorMapFirstEntryIndex property, available only to objects in the same assembly as TargaHeader. + /// + /// The First Entry Index value read from the file. + internal protected void SetColorMapFirstEntryIndex(short sColorMapFirstEntryIndex) + { + this.sColorMapFirstEntryIndex = sColorMapFirstEntryIndex; + } + + /// + /// Gets total number of color map entries included. + /// + public short ColorMapLength + { + get { return this.sColorMapLength; } + } + + /// + /// Sets the ColorMapLength property, available only to objects in the same assembly as TargaHeader. + /// + /// The Color Map Length value read from the file. + internal protected void SetColorMapLength(short sColorMapLength) + { + this.sColorMapLength = sColorMapLength; + } + + /// + /// Gets the number of bits per entry in the Color Map. Typically 15, 16, 24 or 32-bit values are used. + /// + public byte ColorMapEntrySize + { + get { return this.bColorMapEntrySize; } + } + + /// + /// Sets the ColorMapEntrySize property, available only to objects in the same assembly as TargaHeader. + /// + /// The Color Map Entry Size value read from the file. + internal protected void SetColorMapEntrySize(byte bColorMapEntrySize) + { + this.bColorMapEntrySize = bColorMapEntrySize; + } + + /// + /// Gets the absolute horizontal coordinate for the lower + /// left corner of the image as it is positioned on a display device having + /// an origin at the lower left of the screen (e.g., the TARGA series). + /// + public short XOrigin + { + get { return this.sXOrigin; } + } + + /// + /// Sets the XOrigin property, available only to objects in the same assembly as TargaHeader. + /// + /// The X Origin value read from the file. + internal protected void SetXOrigin(short sXOrigin) + { + this.sXOrigin = sXOrigin; + } + + /// + /// These bytes specify the absolute vertical coordinate for the lower left + /// corner of the image as it is positioned on a display device having an + /// origin at the lower left of the screen (e.g., the TARGA series). + /// + public short YOrigin + { + get { return this.sYOrigin; } + } + + /// + /// Sets the YOrigin property, available only to objects in the same assembly as TargaHeader. + /// + /// The Y Origin value read from the file. + internal protected void SetYOrigin(short sYOrigin) + { + this.sYOrigin = sYOrigin; + } + + /// + /// Gets the width of the image in pixels. + /// + public short Width + { + get { return this.sWidth; } + } + + /// + /// Sets the Width property, available only to objects in the same assembly as TargaHeader. + /// + /// The Width value read from the file. + internal protected void SetWidth(short sWidth) + { + this.sWidth = sWidth; + } + + /// + /// Gets the height of the image in pixels. + /// + public short Height + { + get { return this.sHeight; } + } + + /// + /// Sets the Height property, available only to objects in the same assembly as TargaHeader. + /// + /// The Height value read from the file. + internal protected void SetHeight(short sHeight) + { + this.sHeight = sHeight; + } + + /// + /// Gets the number of bits per pixel. This number includes + /// the Attribute or Alpha channel bits. Common values are 8, 16, 24 and 32. + /// + public byte PixelDepth + { + get { return this.bPixelDepth; } + } + + /// + /// Sets the PixelDepth property, available only to objects in the same assembly as TargaHeader. + /// + /// The Pixel Depth value read from the file. + internal protected void SetPixelDepth(byte bPixelDepth) + { + this.bPixelDepth = bPixelDepth; + } + + /// + /// Gets or Sets the ImageDescriptor property. The ImageDescriptor is the byte that holds the + /// Image Origin and Attribute Bits values. + /// Available only to objects in the same assembly as TargaHeader. + /// + internal protected byte ImageDescriptor + { + get { return this.bImageDescriptor; } + set { this.bImageDescriptor = value; } + } + + /// + /// Gets one of the FirstPixelDestination enumeration values specifying the screen destination of first pixel based on VerticalTransferOrder and HorizontalTransferOrder + /// + public FirstPixelDestination FirstPixelDestination + { + get + { + + if (this.eVerticalTransferOrder == VerticalTransferOrder.UNKNOWN || this.eHorizontalTransferOrder == HorizontalTransferOrder.UNKNOWN) + return FirstPixelDestination.UNKNOWN; + else if (this.eVerticalTransferOrder == VerticalTransferOrder.BOTTOM && this.eHorizontalTransferOrder == HorizontalTransferOrder.LEFT) + return FirstPixelDestination.BOTTOM_LEFT; + else if (this.eVerticalTransferOrder == VerticalTransferOrder.BOTTOM && this.eHorizontalTransferOrder == HorizontalTransferOrder.RIGHT) + return FirstPixelDestination.BOTTOM_RIGHT; + else if (this.eVerticalTransferOrder == VerticalTransferOrder.TOP && this.eHorizontalTransferOrder == HorizontalTransferOrder.LEFT) + return FirstPixelDestination.TOP_LEFT; + else + return FirstPixelDestination.TOP_RIGHT; + + } + } + + + /// + /// Gets one of the VerticalTransferOrder enumeration values specifying the top-to-bottom ordering in which pixel data is transferred from the file to the screen. + /// + public VerticalTransferOrder VerticalTransferOrder + { + get { return this.eVerticalTransferOrder; } + } + + /// + /// Sets the VerticalTransferOrder property, available only to objects in the same assembly as TargaHeader. + /// + /// One of the VerticalTransferOrder enumeration values. + internal protected void SetVerticalTransferOrder(VerticalTransferOrder eVerticalTransferOrder) + { + this.eVerticalTransferOrder = eVerticalTransferOrder; + } + + /// + /// Gets one of the HorizontalTransferOrder enumeration values specifying the left-to-right ordering in which pixel data is transferred from the file to the screen. + /// + public HorizontalTransferOrder HorizontalTransferOrder + { + get { return this.eHorizontalTransferOrder; } + } + + /// + /// Sets the HorizontalTransferOrder property, available only to objects in the same assembly as TargaHeader. + /// + /// One of the HorizontalTransferOrder enumeration values. + internal protected void SetHorizontalTransferOrder(HorizontalTransferOrder eHorizontalTransferOrder) + { + this.eHorizontalTransferOrder = eHorizontalTransferOrder; + } + + /// + /// Gets the number of attribute bits per pixel. + /// + public byte AttributeBits + { + get { return this.bAttributeBits; } + } + + /// + /// Sets the AttributeBits property, available only to objects in the same assembly as TargaHeader. + /// + /// The Attribute Bits value read from the file. + internal protected void SetAttributeBits(byte bAttributeBits) + { + this.bAttributeBits = bAttributeBits; + } + + /// + /// Gets identifying information about the image. + /// A value of zero in ImageIDLength indicates that no ImageIDValue is included with the image. + /// + public string ImageIDValue + { + get { return this.strImageIDValue; } + } + + /// + /// Sets the ImageIDValue property, available only to objects in the same assembly as TargaHeader. + /// + /// The Image ID value read from the file. + internal protected void SetImageIDValue(string strImageIDValue) + { + this.strImageIDValue = strImageIDValue; + } + + /// + /// Gets the Color Map of the image, if any. The Color Map is represented by a list of System.Drawing.Color objects. + /// + public System.Collections.Generic.List ColorMap + { + get { return this.cColorMap; } + } + + /// + /// Gets the offset from the beginning of the file to the Image Data. + /// + public int ImageDataOffset + { + get + { + // calculate the image data offset + + // start off with the number of bytes holding the header info. + int intImageDataOffset = TargaConstants.HeaderByteLength; + + // add the Image ID length (could be variable) + intImageDataOffset += this.bImageIDLength; + + // determine the number of bytes for each Color Map entry + int Bytes = 0; + switch (this.bColorMapEntrySize) + { + case 15: + Bytes = 2; + break; + case 16: + Bytes = 2; + break; + case 24: + Bytes = 3; + break; + case 32: + Bytes = 4; + break; + } + + // add the length of the color map + intImageDataOffset += ((int)this.sColorMapLength * (int)Bytes); + + // return result + return intImageDataOffset; + } + } + + /// + /// Gets the number of bytes per pixel. + /// + public int BytesPerPixel + { + get + { + return (int)this.bPixelDepth / 8; + } + } + } + + + /// + /// Holds Footer infomation read from the image file. + /// + public class TargaFooter + { + private int intExtensionAreaOffset = 0; + private int intDeveloperDirectoryOffset = 0; + private string strSignature = string.Empty; + private string strReservedCharacter = string.Empty; + + /// + /// Gets the offset from the beginning of the file to the start of the Extension Area. + /// If the ExtensionAreaOffset is zero, no Extension Area exists in the file. + /// + public int ExtensionAreaOffset + { + get { return this.intExtensionAreaOffset; } + } + + /// + /// Sets the ExtensionAreaOffset property, available only to objects in the same assembly as TargaFooter. + /// + /// The Extension Area Offset value read from the file. + internal protected void SetExtensionAreaOffset(int intExtensionAreaOffset) + { + this.intExtensionAreaOffset = intExtensionAreaOffset; + } + + /// + /// Gets the offset from the beginning of the file to the start of the Developer Area. + /// If the DeveloperDirectoryOffset is zero, then the Developer Area does not exist + /// + public int DeveloperDirectoryOffset + { + get { return this.intDeveloperDirectoryOffset; } + } + + /// + /// Sets the DeveloperDirectoryOffset property, available only to objects in the same assembly as TargaFooter. + /// + /// The Developer Directory Offset value read from the file. + internal protected void SetDeveloperDirectoryOffset(int intDeveloperDirectoryOffset) + { + this.intDeveloperDirectoryOffset = intDeveloperDirectoryOffset; + } + + /// + /// This string is formatted exactly as "TRUEVISION-XFILE" (no quotes). If the + /// signature is detected, the file is assumed to be a New TGA format and MAY, + /// therefore, contain the Developer Area and/or the Extension Areas. If the + /// signature is not found, then the file is assumed to be an Original TGA format. + /// + public string Signature + { + get { return this.strSignature; } + } + + /// + /// Sets the Signature property, available only to objects in the same assembly as TargaFooter. + /// + /// The Signature value read from the file. + internal protected void SetSignature(string strSignature) + { + this.strSignature = strSignature; + } + + /// + /// A New Targa format reserved character "." (period) + /// + public string ReservedCharacter + { + get { return this.strReservedCharacter; } + } + + /// + /// Sets the ReservedCharacter property, available only to objects in the same assembly as TargaFooter. + /// + /// The ReservedCharacter value read from the file. + internal protected void SetReservedCharacter(string strReservedCharacter) + { + this.strReservedCharacter = strReservedCharacter; + } + + /// + /// Creates a new instance of the TargaFooter class. + /// + public TargaFooter() + { } + + + } + + + /// + /// This class holds all of the Extension Area properties of the Targa image. If an Extension Area exists in the file. + /// + public class TargaExtensionArea + { + int intExtensionSize = 0; + string strAuthorName = string.Empty; + string strAuthorComments = string.Empty; + DateTime dtDateTimeStamp = DateTime.Now; + string strJobName = string.Empty; + TimeSpan dtJobTime = TimeSpan.Zero; + string strSoftwareID = string.Empty; + string strSoftwareVersion = string.Empty; + Color cKeyColor = Color.Empty; + int intPixelAspectRatioNumerator = 0; + int intPixelAspectRatioDenominator = 0; + int intGammaNumerator = 0; + int intGammaDenominator = 0; + int intColorCorrectionOffset = 0; + int intPostageStampOffset = 0; + int intScanLineOffset = 0; + int intAttributesType = 0; + private System.Collections.Generic.List intScanLineTable = new List(); + private System.Collections.Generic.List cColorCorrectionTable = new List(); + + /// + /// Gets the number of Bytes in the fixed-length portion of the ExtensionArea. + /// For Version 2.0 of the TGA File Format, this number should be set to 495 + /// + public int ExtensionSize + { + get { return this.intExtensionSize; } + } + + /// + /// Sets the ExtensionSize property, available only to objects in the same assembly as TargaExtensionArea. + /// + /// The Extension Size value read from the file. + internal protected void SetExtensionSize(int intExtensionSize) + { + this.intExtensionSize = intExtensionSize; + } + + /// + /// Gets the name of the person who created the image. + /// + public string AuthorName + { + get { return this.strAuthorName; } + } + + /// + /// Sets the AuthorName property, available only to objects in the same assembly as TargaExtensionArea. + /// + /// The Author Name value read from the file. + internal protected void SetAuthorName(string strAuthorName) + { + this.strAuthorName = strAuthorName; + } + + /// + /// Gets the comments from the author who created the image. + /// + public string AuthorComments + { + get { return this.strAuthorComments; } + } + + /// + /// Sets the AuthorComments property, available only to objects in the same assembly as TargaExtensionArea. + /// + /// The Author Comments value read from the file. + internal protected void SetAuthorComments(string strAuthorComments) + { + this.strAuthorComments = strAuthorComments; + } + + /// + /// Gets the date and time that the image was saved. + /// + public DateTime DateTimeStamp + { + get { return this.dtDateTimeStamp; } + } + + /// + /// Sets the DateTimeStamp property, available only to objects in the same assembly as TargaExtensionArea. + /// + /// The Date Time Stamp value read from the file. + internal protected void SetDateTimeStamp(DateTime dtDateTimeStamp) + { + this.dtDateTimeStamp = dtDateTimeStamp; + } + + /// + /// Gets the name or id tag which refers to the job with which the image was associated. + /// + public string JobName + { + get { return this.strJobName; } + } + + /// + /// Sets the JobName property, available only to objects in the same assembly as TargaExtensionArea. + /// + /// The Job Name value read from the file. + internal protected void SetJobName(string strJobName) + { + this.strJobName = strJobName; + } + + /// + /// Gets the job elapsed time when the image was saved. + /// + public TimeSpan JobTime + { + get { return this.dtJobTime; } + } + + /// + /// Sets the JobTime property, available only to objects in the same assembly as TargaExtensionArea. + /// + /// The Job Time value read from the file. + internal protected void SetJobTime(TimeSpan dtJobTime) + { + this.dtJobTime = dtJobTime; + } + + /// + /// Gets the Software ID. Usually used to determine and record with what program a particular image was created. + /// + public string SoftwareID + { + get { return this.strSoftwareID; } + } + + /// + /// Sets the SoftwareID property, available only to objects in the same assembly as TargaExtensionArea. + /// + /// The Software ID value read from the file. + internal protected void SetSoftwareID(string strSoftwareID) + { + this.strSoftwareID = strSoftwareID; + } + + /// + /// Gets the version of software defined by the SoftwareID. + /// + public string SoftwareVersion + { + get { return this.strSoftwareVersion; } + } + + /// + /// Sets the SoftwareVersion property, available only to objects in the same assembly as TargaExtensionArea. + /// + /// The Software Version value read from the file. + internal protected void SetSoftwareVersion(string strSoftwareVersion) + { + this.strSoftwareVersion = strSoftwareVersion; + } + + /// + /// Gets the key color in effect at the time the image is saved. + /// The Key Color can be thought of as the "background color" or "transparent color". + /// + public Color KeyColor + { + get { return this.cKeyColor; } + } + + /// + /// Sets the KeyColor property, available only to objects in the same assembly as TargaExtensionArea. + /// + /// The Key Color value read from the file. + internal protected void SetKeyColor(Color cKeyColor) + { + this.cKeyColor = cKeyColor; + } + + /// + /// Gets the Pixel Ratio Numerator. + /// + public int PixelAspectRatioNumerator + { + get { return this.intPixelAspectRatioNumerator; } + } + + /// + /// Sets the PixelAspectRatioNumerator property, available only to objects in the same assembly as TargaExtensionArea. + /// + /// The Pixel Aspect Ratio Numerator value read from the file. + internal protected void SetPixelAspectRatioNumerator(int intPixelAspectRatioNumerator) + { + this.intPixelAspectRatioNumerator = intPixelAspectRatioNumerator; + } + + /// + /// Gets the Pixel Ratio Denominator. + /// + public int PixelAspectRatioDenominator + { + get { return this.intPixelAspectRatioDenominator; } + } + + /// + /// Sets the PixelAspectRatioDenominator property, available only to objects in the same assembly as TargaExtensionArea. + /// + /// The Pixel Aspect Ratio Denominator value read from the file. + internal protected void SetPixelAspectRatioDenominator(int intPixelAspectRatioDenominator) + { + this.intPixelAspectRatioDenominator = intPixelAspectRatioDenominator; + } + + /// + /// Gets the Pixel Aspect Ratio. + /// + public float PixelAspectRatio + { + get + { + if (this.intPixelAspectRatioDenominator > 0) + { + return (float)this.intPixelAspectRatioNumerator / (float)this.intPixelAspectRatioDenominator; + } + else + return 0.0F; + } + } + + /// + /// Gets the Gamma Numerator. + /// + public int GammaNumerator + { + get { return this.intGammaNumerator; } + } + + /// + /// Sets the GammaNumerator property, available only to objects in the same assembly as TargaExtensionArea. + /// + /// The Gamma Numerator value read from the file. + internal protected void SetGammaNumerator(int intGammaNumerator) + { + this.intGammaNumerator = intGammaNumerator; + } + + /// + /// Gets the Gamma Denominator. + /// + public int GammaDenominator + { + get { return this.intGammaDenominator; } + } + + /// + /// Sets the GammaDenominator property, available only to objects in the same assembly as TargaExtensionArea. + /// + /// The Gamma Denominator value read from the file. + internal protected void SetGammaDenominator(int intGammaDenominator) + { + this.intGammaDenominator = intGammaDenominator; + } + + /// + /// Gets the Gamma Ratio. + /// + public float GammaRatio + { + get + { + if (this.intGammaDenominator > 0) + { + float ratio = (float)this.intGammaNumerator / (float)this.intGammaDenominator; + return (float)Math.Round(ratio, 1); + } + else + return 1.0F; + } + } + + /// + /// Gets the offset from the beginning of the file to the start of the Color Correction table. + /// + public int ColorCorrectionOffset + { + get { return this.intColorCorrectionOffset; } + } + + /// + /// Sets the ColorCorrectionOffset property, available only to objects in the same assembly as TargaExtensionArea. + /// + /// The Color Correction Offset value read from the file. + internal protected void SetColorCorrectionOffset(int intColorCorrectionOffset) + { + this.intColorCorrectionOffset = intColorCorrectionOffset; + } + + /// + /// Gets the offset from the beginning of the file to the start of the Postage Stamp image data. + /// + public int PostageStampOffset + { + get { return this.intPostageStampOffset; } + } + + /// + /// Sets the PostageStampOffset property, available only to objects in the same assembly as TargaExtensionArea. + /// + /// The Postage Stamp Offset value read from the file. + internal protected void SetPostageStampOffset(int intPostageStampOffset) + { + this.intPostageStampOffset = intPostageStampOffset; + } + + /// + /// Gets the offset from the beginning of the file to the start of the Scan Line table. + /// + public int ScanLineOffset + { + get { return this.intScanLineOffset; } + } + + /// + /// Sets the ScanLineOffset property, available only to objects in the same assembly as TargaExtensionArea. + /// + /// The Scan Line Offset value read from the file. + internal protected void SetScanLineOffset(int intScanLineOffset) + { + this.intScanLineOffset = intScanLineOffset; + } + + /// + /// Gets the type of Alpha channel data contained in the file. + /// 0: No Alpha data included. + /// 1: Undefined data in the Alpha field, can be ignored + /// 2: Undefined data in the Alpha field, but should be retained + /// 3: Useful Alpha channel data is present + /// 4: Pre-multiplied Alpha (see description below) + /// 5-127: RESERVED + /// 128-255: Un-assigned + /// + public int AttributesType + { + get { return this.intAttributesType; } + } + + /// + /// Sets the AttributesType property, available only to objects in the same assembly as TargaExtensionArea. + /// + /// The Attributes Type value read from the file. + internal protected void SetAttributesType(int intAttributesType) + { + this.intAttributesType = intAttributesType; + } + + /// + /// Gets a list of offsets from the beginning of the file that point to the start of the next scan line, + /// in the order that the image was saved + /// + public System.Collections.Generic.List ScanLineTable + { + get { return this.intScanLineTable; } + } + + /// + /// Gets a list of Colors where each Color value is the desired Color correction for that entry. + /// This allows the user to store a correction table for image remapping or LUT driving. + /// + public System.Collections.Generic.List ColorCorrectionTable + { + get { return this.cColorCorrectionTable; } + } + + } + + + /// + /// Utilities functions used by the TargaImage class. + /// + static class Utilities + { + + /// + /// Gets an int value representing the subset of bits from a single Byte. + /// + /// The Byte used to get the subset of bits from. + /// The offset of bits starting from the right. + /// The number of bits to read. + /// + /// An int value representing the subset of bits. + /// + /// + /// Given -> b = 00110101 + /// A call to GetBits(b, 2, 4) + /// GetBits looks at the following bits in the byte -> 00{1101}00 + /// Returns 1101 as an int (13) + /// + internal static int GetBits(byte b, int offset, int count) + { + return (b >> offset) & ((1 << count) - 1); + } + + /// + /// Reads ARGB values from the 16 bits of two given Bytes in a 1555 format. + /// + /// The first Byte. + /// The Second Byte. + /// A Color with a ARGB values read from the two given Bytes + /// + /// Gets the ARGB values from the 16 bits in the two bytes based on the below diagram + /// | BYTE 1 | BYTE 2 | + /// | A RRRRR GG | GGG BBBBB | + /// + internal static Color GetColorFrom2Bytes(byte one, byte two) + { + // get the 5 bits used for the RED value from the first byte + int r1 = Utilities.GetBits(one, 2, 5); + int r = r1 << 3; + + // get the two high order bits for GREEN from the from the first byte + int bit = Utilities.GetBits(one, 0, 2); + // shift bits to the high order + int g1 = bit << 6; + + // get the 3 low order bits for GREEN from the from the second byte + bit = Utilities.GetBits(two, 5, 3); + // shift the low order bits + int g2 = bit << 3; + // add the shifted values together to get the full GREEN value + int g = g1 + g2; + + // get the 5 bits used for the BLUE value from the second byte + int b1 = Utilities.GetBits(two, 0, 5); + int b = b1 << 3; + + // get the 1 bit used for the ALPHA value from the first byte + int a1 = Utilities.GetBits(one, 7, 1); + int a = a1 * 255; + + // return the resulting Color + return Color.FromArgb(a, r, g, b); + } + + /// + /// Gets a 32 character binary string of the specified Int32 value. + /// + /// The value to get a binary string for. + /// A string with the resulting binary for the supplied value. + /// + /// This method was used during debugging and is left here just for fun. + /// + internal static string GetIntBinaryString(Int32 n) + { + char[] b = new char[32]; + int pos = 31; + int i = 0; + + while (i < 32) + { + if ((n & (1 << i)) != 0) + { + b[pos] = '1'; + } + else + { + b[pos] = '0'; + } + pos--; + i++; + } + return new string(b); + } + + /// + /// Gets a 16 character binary string of the specified Int16 value. + /// + /// The value to get a binary string for. + /// A string with the resulting binary for the supplied value. + /// + /// This method was used during debugging and is left here just for fun. + /// + internal static string GetInt16BinaryString(Int16 n) + { + char[] b = new char[16]; + int pos = 15; + int i = 0; + + while (i < 16) + { + if ((n & (1 << i)) != 0) + { + b[pos] = '1'; + } + else + { + b[pos] = '0'; + } + pos--; + i++; + } + return new string(b); + } + + } +} diff --git a/server/TargaImage/TargaImagePCL.csproj b/server/TargaImage/TargaImagePCL.csproj new file mode 100644 index 0000000..ed0bc7e --- /dev/null +++ b/server/TargaImage/TargaImagePCL.csproj @@ -0,0 +1,66 @@ + + + + + 10.0 + Debug + AnyCPU + {D8232422-9D79-4200-A981-EB70ED82CCF3} + Library + Properties + TargaImagePCL + TargaImagePCL + en-US + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Profile7 + v4.5 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + true + + + bin\ServerRelease\ + TRACE + true + pdbonly + AnyCPU + prompt + MinimumRecommendedRules.ruleset + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/server/TargaImage/TgaPixelFormat.cs b/server/TargaImage/TgaPixelFormat.cs new file mode 100644 index 0000000..e8b0c5a --- /dev/null +++ b/server/TargaImage/TgaPixelFormat.cs @@ -0,0 +1,13 @@ +namespace TargaImagePCL +{ + public enum TGAPixelFormat + { + Undefined, + Grayscale_8bpp, + RGB555_16bpp, + ARGB1555_16bpp, + RGB_24bpp, + RGB_32bpp, + ARGB_32bpp + } +} diff --git a/server/fsomockapi.json b/server/fsoapimock.json similarity index 100% rename from server/fsomockapi.json rename to server/fsoapimock.json diff --git a/server/fsoapimock.restbook b/server/fsoapimock.restbook new file mode 100644 index 0000000..2e1a4e5 --- /dev/null +++ b/server/fsoapimock.restbook @@ -0,0 +1 @@ +[{"kind":1,"language":"markdown","value":"","outputs":[]},{"kind":2,"language":"rest-book","value":"GET ","outputs":[]}] \ No newline at end of file diff --git a/server/tso.common/FSO.Common.csproj b/server/tso.common/FSO.Common.csproj index 888cc32..903c13f 100755 --- a/server/tso.common/FSO.Common.csproj +++ b/server/tso.common/FSO.Common.csproj @@ -17,34 +17,8 @@ false true
- - true - true - - - true - - - bin\x86\Debug\ - true - MinimumRecommendedRules.ruleset - - - bin\x86\Release\ - MinimumRecommendedRules.ruleset - - - bin\ServerRelease\ - true - MinimumRecommendedRules.ruleset - - - bin\x86\ServerRelease\ - true - MinimumRecommendedRules.ruleset - - net45;net8.0 + netstandard2.0 false @@ -54,37 +28,12 @@ - - - Always - - - False - Microsoft .NET Framework 4 %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - false - - - False - Windows Installer 3.1 - true - - diff --git a/server/tso.files/FSO.Files.csproj b/server/tso.files/FSO.Files.csproj index 23f3152..37480f5 100755 --- a/server/tso.files/FSO.Files.csproj +++ b/server/tso.files/FSO.Files.csproj @@ -1,6 +1,6 @@  - net45 + netstandard2.0 Library publish\ true