コード例 #1
0
ファイル: ColorMutator.cs プロジェクト: yaoya/UnityDecompiled
 public void SetColorChannelHdr(RgbaChannel channel, float value)
 {
     if (this.m_ColorHdr[(int)channel] != value)
     {
         this.m_ColorHdr[(int)channel] = value;
         this.OnRgbaHdrChannelChanged((int)channel);
     }
 }
コード例 #2
0
 public void SetColorChannelHdr(RgbaChannel channel, float value)
 {
     if (m_ColorHdr[(int)channel] == value)
     {
         return;
     }
     m_ColorHdr[(int)channel] = value;
     OnRgbaHdrChannelChanged((int)channel);
 }
コード例 #3
0
 public void SetColorChannelHdr(RgbaChannel channel, float value)
 {
     if (m_ColorHdr[(int)channel] == value)
     {
         return;
     }
     m_ColorHdr[(int)channel] = value;
     m_HDRBaseColor           = new Color(m_ColorHdr[0], m_ColorHdr[1], m_ColorHdr[2], m_ColorHdr[3]);
     OnRgbaHdrChannelChanged((int)channel);
 }
コード例 #4
0
ファイル: ColorMutator.cs プロジェクト: yaoya/UnityDecompiled
 public void SetColorChannel(RgbaChannel channel, byte value)
 {
     if (this.m_Color[(int)channel] != value)
     {
         this.m_Color[(int)channel]    = value;
         this.m_ColorHdr[(int)channel] = (float)value / 255f;
         if (channel != RgbaChannel.A)
         {
             this.m_ColorHdr[(int)channel] *= Mathf.Pow(2f, this.m_ExposureValue);
         }
         Color.RGBToHSV(this.color, out this.m_Hsv[0], out this.m_Hsv[1], out this.m_Hsv[2]);
     }
 }
コード例 #5
0
 public void SetColorChannel(RgbaChannel channel, byte value)
 {
     if (m_Color[(int)channel] == value)
     {
         return;
     }
     m_Color[(int)channel]    = value;
     m_ColorHdr[(int)channel] = (value / 255f);
     if (channel != RgbaChannel.A)
     {
         m_ColorHdr[(int)channel] *= Mathf.Pow(2f, m_ExposureValue);
     }
     Color.RGBToHSV(
         color,
         out m_Hsv[(int)HsvChannel.H],
         out m_Hsv[(int)HsvChannel.S],
         out m_Hsv[(int)HsvChannel.V]
         );
 }
コード例 #6
0
        public static Color ModifyChannelByteValue(Color color, RgbaChannel channel, byte value)
        {
            switch (channel)
            {
            case RgbaChannel.Alpha:
                return(Color.FromArgb(value, color.R, color.G, color.B));

            case RgbaChannel.Red:
                return(Color.FromArgb(color.A, value, color.G, color.B));

            case RgbaChannel.Green:
                return(Color.FromArgb(color.A, color.R, value, color.B));

            case RgbaChannel.Blue:
                return(Color.FromArgb(color.A, color.R, color.G, value));

            default:
                throw new ArgumentOutOfRangeException(nameof(channel));
            }
        }
コード例 #7
0
        public static byte GetChannelByteValue(Color color, RgbaChannel channel)
        {
            switch (channel)
            {
            case RgbaChannel.Alpha:
                return(color.A);

            case RgbaChannel.Red:
                return(color.R);

            case RgbaChannel.Green:
                return(color.G);

            case RgbaChannel.Blue:
                return(color.B);

            default:
                throw new ArgumentOutOfRangeException(nameof(channel));
            }
        }
コード例 #8
0
        public System.Drawing.Color GetColorFromChannel(System.Drawing.Color color, RgbaChannel channel)
        {
            switch (channel)
            {
            case RgbaChannel.Red:
                return(System.Drawing.Color.FromArgb(color.R, color.R, color.R));

            case RgbaChannel.Green:
                return(System.Drawing.Color.FromArgb(color.G, color.G, color.G));

            case RgbaChannel.Blue:
                return(System.Drawing.Color.FromArgb(color.B, color.B, color.B));

            case RgbaChannel.Alpha:
                return(System.Drawing.Color.FromArgb(color.A, color.A, color.A));

            default:
                return(color);
            }
        }
コード例 #9
0
        private Color GetSingleChannelColor(float value, RgbaChannel channel)
        {
            int i = (int)(value * 255.0f);

            i = Math.Max(Math.Min(i, 255), 0);

            switch (channel)
            {
            case RgbaChannel.Alpha:
                return(Color.FromArgb(i, 0, 0, 0));

            case RgbaChannel.Red:
                return(Color.FromArgb(0, i, 0, 0));

            case RgbaChannel.Green:
                return(Color.FromArgb(0, 0, i, 0));

            case RgbaChannel.Blue:
                return(Color.FromArgb(0, 0, 0, i));
            }

            return(Color.FromArgb(i, i, i, i));
        }
コード例 #10
0
 public float GetColorChannelNormalized(RgbaChannel channel)
 {
     return(m_Color[(int)channel] / 255f);
 }
コード例 #11
0
 public byte GetColorChannel(RgbaChannel channel)
 {
     return(m_Color[(int)channel]);
 }
コード例 #12
0
 public float GetColorChannelHdr(RgbaChannel channel)
 {
     return(m_ColorHdr[(int)channel]);
 }
コード例 #13
0
 public static Color ModifyChannelByteValue(this Color color, RgbaChannel channel, byte value)
 {
     return(ColorUtils.ModifyChannelByteValue(color, channel, value));
 }
コード例 #14
0
        glTFLoader.Schema.TextureInfo GetSingleChannelTexture(Rhino.DocObjects.Texture texture, RgbaChannel channel, bool invert)
        {
            string path = texture.FileReference.FullPath;

            Bitmap bmp = new Bitmap(path);

            Bitmap final = new Bitmap(bmp.Width, bmp.Height);

            for (int i = 0; i < bmp.Width; i++)
            {
                for (int j = 0; j < bmp.Height; j++)
                {
                    Color4f color = new Color4f(bmp.GetPixel(i, j));

                    float value = color.L;

                    if (invert)
                    {
                        value = 1.0f - value;
                    }

                    Color colorFinal = GetSingleChannelColor(value, channel);

                    final.SetPixel(i, j, colorFinal);
                }
            }

            int textureIndex = GetTextureFromBitmap(final);

            glTFLoader.Schema.TextureInfo textureInfo = new glTFLoader.Schema.TextureInfo()
            {
                Index    = textureIndex,
                TexCoord = 0,
            };

            return(textureInfo);
        }
コード例 #15
0
        public Rhino.Render.RenderTexture GetRenderTextureFromChannel(int textureIndex, RgbaChannel channel)
        {
            System.Drawing.Bitmap bmp = GetTextureBitmap(textureIndex, out string name);

            if (bmp == null)
            {
                return(null);
            }

            int width  = bmp.Width;
            int height = bmp.Height;

            System.Drawing.Bitmap resolvedBmp = new System.Drawing.Bitmap(width, height);

            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    System.Drawing.Color color = bmp.GetPixel(i, j);

                    System.Drawing.Color colorResolved = GetColorFromChannel(color, channel);

                    resolvedBmp.SetPixel(i, j, colorResolved);
                }
            }

            Rhino.Render.RenderTexture renderTexture = Rhino.Render.RenderTexture.NewBitmapTexture(resolvedBmp, doc);

            renderTexture.BeginChange(Rhino.Render.RenderContent.ChangeContexts.Program);

            renderTexture.Name = name;

            renderTexture.EndChange();

            return(renderTexture);
        }
コード例 #16
0
 public void SetColorChannel(RgbaChannel channel, float normalizedValue)
 {
     SetColorChannel(channel, (byte)Mathf.RoundToInt(Mathf.Clamp01(normalizedValue) * 255f));
 }
コード例 #17
0
 public static byte GetChannelByteValue(this Color color, RgbaChannel channel)
 {
     return(ColorUtils.GetChannelByteValue(color, channel));
 }