Subversion Repositories Kolibri OS

Rev

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