Subversion Repositories Kolibri OS

Rev

Rev 7928 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. #ifndef INCLUDE_LIBIMG_LOAD_SKIN_H
  2. #define INCLUDE_LIBIMG_LOAD_SKIN_H
  3.  
  4. #ifndef INCLUDE_LIBIMG_H
  5. #include "../lib/obj/libimg.h"
  6. #endif
  7.  
  8. :struct libimg_image {
  9.         dword image, w, h, imgsrc;
  10.         void load_as24b();
  11.         void load();
  12.         void replace_color();
  13.         void fill_transparent();
  14. } skin;
  15.  
  16. :void libimg_image::load_as24b(dword file_path)
  17. {
  18.         dword image_pointer = load_image(file_path);
  19.         if (!image_pointer) notify("'Error: Image not loaded' -E");
  20.  
  21.         img_convert stdcall(image_pointer, 0, Image_bpp24, 0, 0);
  22.         if (!EAX) {
  23.                 notify("'Error: Image can not be converted to 24b' -E");
  24.         } else {
  25.                 image = image_pointer = EAX;
  26.                 w = DSWORD[image_pointer+4];
  27.                 h = DSWORD[image_pointer+8];
  28.                 imgsrc = ESDWORD[image_pointer+24];            
  29.         }
  30. }
  31.  
  32. :void libimg_image::load(dword file_path)
  33. {
  34.         dword image_pointer = load_image(file_path);
  35.         if (!EAX) {
  36.                 notify("'Error: Image not loaded' -E");
  37.         } else {
  38.                 image = image_pointer = EAX;
  39.                 w = DSWORD[image_pointer+4];
  40.                 h = DSWORD[image_pointer+8];
  41.                 imgsrc = ESDWORD[image_pointer+24];            
  42.         }
  43.  
  44. }
  45.  
  46. :void libimg_image::replace_color(dword old_color, new_color)
  47. {
  48.         dword i, max_i;
  49.         max_i =  w * h * 4 + imgsrc;
  50.         for (i = imgsrc; i < max_i; i += 4)     if (DSDWORD[i]==old_color) DSDWORD[i] = new_color;
  51. }
  52.  
  53. :void libimg_image::fill_transparent(new_color)
  54. {
  55.         if (new_color) replace_color(0, new_color);
  56. }
  57.  
  58. :libimg_image icons32draw;
  59. :void DrawIcon32(dword x,y, bg, icon_n) {
  60.         //load_dll(libimg, #libimg_init,1);
  61.         if (!icons32draw.image) {
  62.                 icons32draw.load("/sys/icons32.png");
  63.                 icons32draw.fill_transparent(bg);
  64.         }
  65.         if (icon_n>=0) img_draw stdcall(icons32draw.image, x, y, 32, 32, 0, icon_n*32);
  66. }
  67.  
  68. :libimg_image icons16draw;
  69. :void DrawIcon16(dword x,y, bg, icon_n) {
  70.         //load_dll(libimg, #libimg_init,1);
  71.         if (!icons16draw.image) {
  72.                 icons16draw.load("/sys/icons16.png");
  73.                 icons16draw.replace_color(0xffFFFfff, bg);
  74.                 icons16draw.replace_color(0xffCACBD6, MixColors(bg, 0, 220));
  75.         }
  76.         if (icon_n>=0) img_draw stdcall(icons16draw.image, x, y, 16, 16, 0, icon_n*16);
  77. }
  78.  
  79. #endif