Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. (*
  2.     Copyright 2021, 2022 Anton Krotov
  3.  
  4.     This file is part of fb2read.
  5.  
  6.     fb2read is free software: you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation, either version 3 of the License, or
  9.     (at your option) any later version.
  10.  
  11.     fb2read is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with fb2read. If not, see <http://www.gnu.org/licenses/>.
  18. *)
  19.  
  20. MODULE Icons;
  21.  
  22. IMPORT
  23.     LibImg, K := SysUtils, Graph, File, KOSAPI, SYSTEM;
  24.  
  25. CONST
  26.         fileName = "/sys/Icons16.png";
  27.         SIZE* = 18;
  28.  
  29. VAR
  30.         source: INTEGER;
  31.  
  32. (*
  33. PROCEDURE copy (src, dst: INTEGER);
  34. VAR
  35.         src_width, src_height,
  36.         dst_width, dst_height,
  37.         src_data, dst_data: INTEGER;
  38. BEGIN
  39.         LibImg.GetInf(src, src_width, src_height, src_data);
  40.         LibImg.GetInf(dst, dst_width, dst_height, dst_data);
  41.         ASSERT(src_width = dst_width);
  42.         ASSERT(src_height = dst_height);
  43.         SYSTEM.MOVE(src_data, dst_data, src_width*src_height*4)
  44. END copy;
  45. *)
  46.  
  47.  
  48. PROCEDURE load (): INTEGER;
  49. VAR
  50.         height: INTEGER;
  51. BEGIN
  52.         RETURN LibImg.LoadFromFile(fileName, SIZE, height)
  53. END load;
  54.  
  55.  
  56. PROCEDURE draw* (icons, n, x, y: INTEGER);
  57. VAR
  58.         width, height, data: INTEGER;
  59. BEGIN
  60.         LibImg.GetInf(icons, width, height, data);
  61.         KOSAPI.sysfunc7(65, data + SIZE*SIZE*4*n, SIZE*65536 + SIZE, x*65536 + y, 32, 0, 0)
  62. END draw;
  63.  
  64.  
  65. PROCEDURE iconsBackColor (icons: INTEGER; BackColor: INTEGER);
  66. VAR
  67.         width, height, data, x, y, pix: INTEGER;
  68.         b, g, r, gr: BYTE;
  69. BEGIN
  70.         LibImg.GetInf(icons, width, height, data);
  71.         FOR y := 0 TO height - 1 DO
  72.                 FOR x := 0 TO width - 1 DO
  73.                         SYSTEM.GET32(data, pix);
  74.                         Graph.getRGB(pix, r, g, b);
  75.                         gr := (r + g + b) DIV 3;
  76.                         IF BackColor = -1 THEN
  77.                                 pix := gr + 256*gr + 65536*gr
  78.                         ELSIF gr = 255 THEN
  79.                                 pix := BackColor
  80.                         END;
  81.                         SYSTEM.PUT32(data, pix);
  82.                         INC(data, 4)
  83.                 END
  84.         END
  85. END iconsBackColor;
  86.  
  87.  
  88. PROCEDURE get* (VAR icons, grayIcons: INTEGER; BackColor: INTEGER);
  89. BEGIN
  90.         IF source = 0 THEN
  91.                 source := load();
  92.                 icons := load();
  93.                 grayIcons := load();
  94.                 iconsBackColor(grayIcons, -1);
  95.                 iconsBackColor(grayIcons, BackColor);
  96.                 iconsBackColor(icons, BackColor)
  97.         (*ELSE
  98.                 copy(source, icons);
  99.                 copy(source, grayIcons)*)
  100.         END;
  101. END get;
  102.  
  103.  
  104. BEGIN
  105.         source := 0
  106. END Icons.