Subversion Repositories Kolibri OS

Rev

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

  1. #define MEMSIZE 0xFFFFF
  2. #include "../lib/kolibri.h"
  3. #include "../lib/strings.h"
  4. #include "../lib/mem.h"
  5. #include "../lib/gui.h"
  6.  
  7. #ifndef AUTOBUILD
  8.         #include "lang.h--"
  9. #endif
  10.  
  11. /* === DATA === */
  12.  
  13. system_colors sc;
  14. proc_info Form;
  15.  
  16.  
  17. dword b_screen,
  18.       s_screen;
  19.  
  20. int b_screen_width,
  21.     b_screen_height,
  22.     b_screen_length,
  23.     s_screen_width,
  24.     s_screen_height,
  25.     s_screen_length;
  26.  
  27.  
  28. /* === CODE === */
  29.  
  30.  
  31. void main()
  32. {      
  33.         char id;
  34.         mem_Init();
  35.         b_screen_width  = GetScreenWidth()+1;
  36.         b_screen_height = GetScreenHeight()+1;
  37.         b_screen_length = b_screen_width*b_screen_height*3;
  38.         s_screen_width  = b_screen_width / 2;
  39.         s_screen_height = b_screen_height / 2;
  40.         s_screen_length = b_screen_length / 2; 
  41.  
  42.         b_screen  = malloc(b_screen_length);
  43.         s_screen = malloc(b_screen_length/2);
  44.  
  45.         loop()
  46.         {
  47.                 switch(WaitEvent())
  48.                 {
  49.                 case evButton:
  50.                         id = GetButtonID();
  51.                         if (id==1) ExitProcess();
  52.                         if (id==10) TakeScreenshot();
  53.                         break;
  54.          
  55.                 case evReDraw:
  56.                         sc.get();
  57.                         DefineAndDrawWindow(b_screen_width/4, b_screen_height/4, s_screen_width + 9, s_screen_height + skin_height + 45,0x74, 0, "EasyShot v0.2",0);
  58.                         GetProcessInfo(#Form, SelfInfo);
  59.                         if (Form.status_window>2) break;
  60.                         DrawBar(0, 0, Form.cwidth, 41, sc.work);
  61.                         DrawCaptButton(10, 10, 140, 20, 10, sc.work_button, sc.work_button_text, "Make screenshot");
  62.                         _PutImage(0, Form.cheight - s_screen_height,  s_screen_width, s_screen_height, s_screen);
  63.                         if (ESDWORD[s_screen]==0)
  64.                                 WriteTextB(Form.cwidth/2 - 60, Form.cheight/2+10, 0x90, 0xFFFfff, "There will be preview");
  65.                         else
  66.                         DrawCaptButton(160, 10, 80, 20, 11, sc.work_button, sc.work_button_text, "Save");
  67.       }
  68.    }
  69. }
  70.  
  71. void TakeScreenshot() {
  72.         MinimizeWindow();
  73.         pause(20);
  74.         CopyScreen(b_screen, 0, 0, b_screen_width, b_screen_height);
  75.         ZoomImageTo50percent();
  76.         ActivateWindow(GetProcessSlot(Form.ID));
  77.         //_PutImage(0, Form.cheight - s_screen_height,  s_screen_width, s_screen_height, s_screen);
  78. }
  79.  
  80. void ZoomImageTo50percent() {
  81.         dword point_x,
  82.               item_h= b_screen_width * 3,
  83.               s_off = s_screen + 3,
  84.               b_off = b_screen + 6,
  85.               b_off_r,
  86.               b_off_g,
  87.               b_off_b,
  88.               rez_r,
  89.               rez_g,
  90.               rez_b;
  91.  
  92.         while( (s_off < s_screen + s_screen_length) && (b_off < b_screen + b_screen_length ) ) {
  93.                
  94.                 if (b_off < b_screen + item_h) || (b_off > b_screen + b_screen_length - item_h)
  95.                 {
  96.                         ESBYTE[s_off]   = ESBYTE[b_off];
  97.                         ESBYTE[s_off+1] = ESBYTE[b_off+1];
  98.                         ESBYTE[s_off+2] = ESBYTE[b_off+2];
  99.                 }
  100.                 else
  101.                 {
  102.                         // line[x].R = (line[x+1].R + line[x].R + line[x-1].R + line1[x].R + line2[x].R) / 5;
  103.                         // line[x].G = (line[x+1].G + line[x].G + line[x-1].G + line1[x].G + line2[x].G) / 5;
  104.                         // line[x].B = (line[x+1].B + line[x].B + line[x-1].B + line1[x].B + line2[x].B) / 5
  105.                         b_off_r = b_off;
  106.                         b_off_g = b_off + 1;
  107.                         b_off_b = b_off + 2;
  108.                         rez_r = ESBYTE[b_off_r+3] + ESBYTE[b_off_r] + ESBYTE[b_off_r-3] + ESBYTE[b_off_r-item_h] + ESBYTE[b_off_r+item_h] / 5;
  109.                         rez_g = ESBYTE[b_off_g+3] + ESBYTE[b_off_g] + ESBYTE[b_off_g-3] + ESBYTE[b_off_g-item_h] + ESBYTE[b_off_g+item_h] / 5;
  110.                         rez_b = ESBYTE[b_off_b+3] + ESBYTE[b_off_b] + ESBYTE[b_off_b-3] + ESBYTE[b_off_b-item_h] + ESBYTE[b_off_b+item_h] / 5;
  111.                         ESBYTE[s_off] = rez_r;
  112.                         ESBYTE[s_off+1] = rez_g;
  113.                         ESBYTE[s_off+2] = rez_b;
  114.  
  115.                 }
  116.        
  117.                 s_off+=3;
  118.                 b_off+=6;
  119.  
  120.                 point_x+=2;
  121.                 if (point_x >= b_screen_width)
  122.                 {
  123.                         b_off += item_h;
  124.                         point_x = 0;
  125.                 }
  126.         }
  127. }
  128.  
  129.  
  130. stop:
  131.