This repository has been archived on 2023-12-10. You can view files and clone it, but cannot push or open issues or pull requests.
2021-06-09 16:43:27 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using static Matrix_App.GifGeneratorUtils;
|
|
|
|
|
|
|
|
|
|
namespace Matrix_App.PregeneratedMods
|
|
|
|
|
{
|
|
|
|
|
public sealed class Grayscale : MatrixGifGenerator
|
|
|
|
|
{
|
2021-06-09 19:19:30 +00:00
|
|
|
|
[UiDescriptionAttribute(title: "use Luminance", description: "Use luminance as defined by ITU-R BT.709 as grayscale output")]
|
2021-06-09 16:43:27 +00:00
|
|
|
|
public bool byLuminance = false;
|
|
|
|
|
|
|
|
|
|
protected override void ColorFragment(in int x, in int y, in float u, in float v, in int frame, out float r, out float g, out float b)
|
|
|
|
|
{
|
|
|
|
|
SampleFrame(actualStore, frame, x, y, width, out float lr, out float lg, out float lb);
|
|
|
|
|
|
|
|
|
|
if (byLuminance)
|
|
|
|
|
{
|
|
|
|
|
float luminance = 0.2126f * lr + 0.7152f * lg + 0.0722f * lb;
|
|
|
|
|
|
|
|
|
|
r = luminance;
|
|
|
|
|
g = luminance;
|
|
|
|
|
b = luminance;
|
|
|
|
|
} else
|
|
|
|
|
{
|
|
|
|
|
float average = (lr + lg + lb) * 0.3333f;
|
|
|
|
|
|
|
|
|
|
r = average;
|
|
|
|
|
g = average;
|
|
|
|
|
b = average;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|