<commit_before>﻿/*  Copyright 2016 <NAME>
*
*   Licensed under the Apache License, Version 2.0 (the "License");
*   you may not use this file except in compliance with the License.
*   You may obtain a copy of the License at
*
*       http://www.apache.org/licenses/LICENSE-2.0
*
*   Unless required by applicable law or agreed to in writing, software
*   distributed under the License is distributed on an "AS IS" BASIS,
*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*   See the License for the specific language governing permissions and
*   limitations under the License.
*/
using System;

namespace FenixLib.Core
{
    public class StaticGraphic : IGraphic
    {
        public int Width { get; }
        public int Height { get; }
        public Palette Palette { get; }
        public byte[] PixelData { get; }
        public GraphicFormat GraphicFormat { get; }

        public StaticGraphic ( GraphicFormat graphicFormat, int width, int height,
            byte[] pixelData, Palette palette = null )
        {
            if ( graphicFormat == null )
            {
                throw new ArgumentNullException ( nameof ( graphicFormat ) );
            }

            if ( width <= 0 )
            {
                throw new ArgumentOutOfRangeException (
                    nameof ( width ), width, "Negative values are not accepted." );
            }

            if ( height <= 0 )
            {
                throw new ArgumentOutOfRangeException (
                    nameof ( height ), height, "Negative values are not accepted." );
            }

            if ( graphicFormat == GraphicFormat.RgbIndexedPalette && palette == null )
            {
                throw new ArgumentException ( "A palette is required if, and only if, "
                    + "graphicFormat == GraphicFormat.RgbIndexedPalette.", nameof ( palette ) );
            }

            if ( pixelData == null )
            {
                throw new ArgumentNullException ( nameof ( pixelData ) );
            }

            if ( pixelData.Length != graphicFormat.PixelsBytesForSize ( width, height ) )
            {
                throw new ArgumentException ( "The size of 'pixelData' array is not valid "
                    + "for the specified graphic format.", nameof ( pixelData ) );
            }

            Width = width;
            Height = height;
            Palette = GraphicFormat == GraphicFormat.RgbIndexedPalette ? palette : null;
            GraphicFormat = graphicFormat;
            PixelData = pixelData;
        }
    }
}<commit_msg>Fixed bug of palette not being sett on constructor.<commit_after>﻿/*  Copyright 2016 <NAME>
*
*   Licensed under the Apache License, Version 2.0 (the "License");
*   you may not use this file except in compliance with the License.
*   You may obtain a copy of the License at
*
*       http://www.apache.org/licenses/LICENSE-2.0
*
*   Unless required by applicable law or agreed to in writing, software
*   distributed under the License is distributed on an "AS IS" BASIS,
*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*   See the License for the specific language governing permissions and
*   limitations under the License.
*/
using System;

namespace FenixLib.Core
{
    public class StaticGraphic : IGraphic
    {
        public int Width { get; }
        public int Height { get; }
        public Palette Palette { get; }
        public byte[] PixelData { get; }
        public GraphicFormat GraphicFormat { get; }

        public StaticGraphic ( GraphicFormat graphicFormat, int width, int height,
            byte[] pixelData, Palette palette = null )
        {
            if ( graphicFormat == null )
            {
                throw new ArgumentNullException ( nameof ( graphicFormat ) );
            }

            if ( width <= 0 )
            {
                throw new ArgumentOutOfRangeException (
                    nameof ( width ), width, "Negative values are not accepted." );
            }

            if ( height <= 0 )
            {
                throw new ArgumentOutOfRangeException (
                    nameof ( height ), height, "Negative values are not accepted." );
            }

            if ( graphicFormat == GraphicFormat.RgbIndexedPalette && palette == null )
            {
                throw new ArgumentException ( "A palette is required if, and only if, "
                    + "graphicFormat == GraphicFormat.RgbIndexedPalette.", nameof ( palette ) );
            }

            if ( pixelData == null )
            {
                throw new ArgumentNullException ( nameof ( pixelData ) );
            }

            if ( pixelData.Length != graphicFormat.PixelsBytesForSize ( width, height ) )
            {
                throw new ArgumentException ( "The size of 'pixelData' array is not valid "
                    + "for the specified graphic format.", nameof ( pixelData ) );
            }

            Width = width;
            Height = height;
            Palette = graphicFormat == GraphicFormat.RgbIndexedPalette ? palette : null;
            GraphicFormat = graphicFormat;
            PixelData = pixelData;
        }
    }
}
{'fraction_non_alphanumeric': 0.07814900153609831, 'fraction_numerical': 0.0038402457757296467, 'mean_word_length': 1.812634989200864, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6525843', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1240, 'n_words': 454}