2021-09-03 01:15:33 +02:00
|
|
|
(*
|
2022-01-05 21:32:53 +01:00
|
|
|
Copyright 2021, 2022 Anton Krotov
|
2021-06-15 19:33:16 +02:00
|
|
|
|
|
|
|
This file is part of CEdit.
|
|
|
|
|
|
|
|
CEdit is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
CEdit is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with CEdit. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*)
|
|
|
|
|
|
|
|
MODULE Icons;
|
|
|
|
|
|
|
|
IMPORT
|
2021-12-17 07:12:02 +01:00
|
|
|
LibImg, K := KolibriOS, Graph, SYSTEM;
|
2021-06-15 19:33:16 +02:00
|
|
|
|
|
|
|
CONST
|
2022-01-05 21:32:53 +01:00
|
|
|
fileName = "/sys/Icons16.png";
|
2021-06-15 19:33:16 +02:00
|
|
|
SIZE* = 18;
|
|
|
|
|
|
|
|
VAR
|
|
|
|
source: INTEGER;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE copy (src, dst: INTEGER);
|
|
|
|
VAR
|
|
|
|
src_sizeX, src_sizeY, dst_sizeX, dst_sizeY,
|
|
|
|
src_data, dst_data: INTEGER;
|
|
|
|
BEGIN
|
|
|
|
LibImg.GetInf(src, src_sizeX, src_sizeY, src_data);
|
|
|
|
LibImg.GetInf(dst, dst_sizeX, dst_sizeY, dst_data);
|
|
|
|
ASSERT(src_sizeX = dst_sizeX);
|
|
|
|
ASSERT(src_sizeY = dst_sizeY);
|
|
|
|
SYSTEM.MOVE(src_data, dst_data, src_sizeX*src_sizeY*3)
|
|
|
|
END copy;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE load (): INTEGER;
|
|
|
|
VAR
|
|
|
|
y: INTEGER;
|
|
|
|
BEGIN
|
|
|
|
RETURN LibImg.LoadFromFile(fileName, SIZE, y)
|
|
|
|
END load;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE draw* (icons, n, x, y: INTEGER);
|
|
|
|
VAR
|
|
|
|
sizeX, sizeY, data: INTEGER;
|
|
|
|
BEGIN
|
|
|
|
LibImg.GetInf(icons, sizeX, sizeY, data);
|
|
|
|
K.DrawImage(data + SIZE*SIZE*3*n, SIZE, SIZE, x, y)
|
|
|
|
END draw;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE gray (icons: INTEGER);
|
|
|
|
VAR
|
|
|
|
sizeX, sizeY, data, x, y: INTEGER;
|
|
|
|
b, g, r, gr: BYTE;
|
|
|
|
BEGIN
|
|
|
|
LibImg.GetInf(icons, sizeX, sizeY, data);
|
|
|
|
FOR y := 0 TO sizeY - 1 DO
|
|
|
|
FOR x := 0 TO sizeX - 1 DO
|
|
|
|
SYSTEM.GET8(data, b);
|
|
|
|
SYSTEM.GET8(data + 1, g);
|
|
|
|
SYSTEM.GET8(data + 2, r);
|
|
|
|
gr := (r + g + b) DIV 3;
|
|
|
|
SYSTEM.PUT8(data, gr);
|
|
|
|
SYSTEM.PUT8(data + 1, gr);
|
|
|
|
SYSTEM.PUT8(data + 2, gr);
|
|
|
|
INC(data, 3);
|
|
|
|
END
|
|
|
|
END
|
|
|
|
END gray;
|
|
|
|
|
|
|
|
|
2021-12-29 16:38:29 +01:00
|
|
|
PROCEDURE iconsBackColor (icons: INTEGER; BackColor: INTEGER);
|
2021-06-15 19:33:16 +02:00
|
|
|
VAR
|
|
|
|
sizeX, sizeY, data, x, y: INTEGER;
|
|
|
|
b, g, r: BYTE;
|
|
|
|
BEGIN
|
|
|
|
LibImg.GetInf(icons, sizeX, sizeY, data);
|
|
|
|
FOR y := 0 TO sizeY - 1 DO
|
|
|
|
FOR x := 0 TO sizeX - 1 DO
|
|
|
|
SYSTEM.GET8(data, b);
|
|
|
|
SYSTEM.GET8(data + 1, g);
|
|
|
|
SYSTEM.GET8(data + 2, r);
|
|
|
|
IF b + g + r = 765 THEN
|
2021-12-29 16:38:29 +01:00
|
|
|
Graph.getRGB(BackColor, r, g, b)
|
2021-06-15 19:33:16 +02:00
|
|
|
END;
|
|
|
|
SYSTEM.PUT8(data, b);
|
|
|
|
SYSTEM.PUT8(data + 1, g);
|
|
|
|
SYSTEM.PUT8(data + 2, r);
|
|
|
|
INC(data, 3);
|
|
|
|
END
|
|
|
|
END
|
|
|
|
END iconsBackColor;
|
|
|
|
|
|
|
|
|
2021-12-29 16:38:29 +01:00
|
|
|
PROCEDURE get* (VAR icons, grayIcons: INTEGER; BackColor: INTEGER);
|
2021-06-15 19:33:16 +02:00
|
|
|
BEGIN
|
|
|
|
IF source = 0 THEN
|
|
|
|
source := load();
|
|
|
|
icons := load();
|
|
|
|
grayIcons := load()
|
|
|
|
ELSE
|
|
|
|
copy(source, icons);
|
|
|
|
copy(source, grayIcons)
|
|
|
|
END;
|
|
|
|
gray(grayIcons);
|
2021-12-29 16:38:29 +01:00
|
|
|
iconsBackColor(icons, BackColor);
|
|
|
|
iconsBackColor(grayIcons, BackColor)
|
2021-06-15 19:33:16 +02:00
|
|
|
END get;
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN
|
|
|
|
source := 0
|
|
|
|
END Icons.
|