Files
Minint/Report/lab2/newuml/dz-a1-grayscale-activity.puml
2026-04-10 02:21:47 +03:00

25 lines
694 B
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@startuml dz-a1-grayscale-activity
title ДЗ.А1 — алгоритм ApplyGrayscale (по палитре документа)
start
:Вход: **MinintDocument doc**;
:i ← 1;
while (i < doc.Palette.Count?) is (да)
:c ← doc.Palette[i];
:Y ← 0.299×c.R + 0.587×c.G + 0.114×c.B + 0.5;
:gray ← (byte) Clamp((int)Y, 0, 255);
:doc.Palette[i] ← RgbaColor(gray, gray, gray, c.A);
:i ← i + 1;
endwhile (нет)
:doc.InvalidatePaletteCache();
stop
note right
Индекс палитры **0** (прозрачный) пропускается циклом.
Коэффициенты — типичная формула **яркости** (ITU-R BT.601).
end note
@enduml