diff --git a/programs/cmm/easyshot/Tupfile.lua b/programs/cmm/easyshot/Tupfile.lua new file mode 100644 index 0000000000..3198450c8c --- /dev/null +++ b/programs/cmm/easyshot/Tupfile.lua @@ -0,0 +1,6 @@ +if tup.getconfig("NO_CMM") ~= "" then return end +if tup.getconfig("LANG") == "ru" +then C_LANG = "LANG_RUS" +else C_LANG = "LANG_ENG" -- this includes default case without config +end +tup.rule("easyshot.c", "c-- /D=AUTOBUILD /D=$(C_LANG) %f" .. tup.getconfig("KPACK_CMD"), "easyshot.com") diff --git a/programs/cmm/experimental/easyshot/compile_en.bat b/programs/cmm/easyshot/compile_en.bat similarity index 100% rename from programs/cmm/experimental/easyshot/compile_en.bat rename to programs/cmm/easyshot/compile_en.bat diff --git a/programs/cmm/experimental/easyshot/compile_ru.bat b/programs/cmm/easyshot/compile_ru.bat similarity index 100% rename from programs/cmm/experimental/easyshot/compile_ru.bat rename to programs/cmm/easyshot/compile_ru.bat diff --git a/programs/cmm/easyshot/easyshot.c b/programs/cmm/easyshot/easyshot.c new file mode 100644 index 0000000000..7e894f3d17 --- /dev/null +++ b/programs/cmm/easyshot/easyshot.c @@ -0,0 +1,177 @@ +#define MEMSIZE 1024 * 420 +#include "../lib/kolibri.h" +#include "../lib/strings.h" +#include "../lib/mem.h" +#include "../lib/gui.h" + +#include "../lib/obj/libimg.h" + +#ifndef AUTOBUILD + #include "lang.h--" +#endif + +/* === DATA === */ + +proc_info Form; + +dword b_screen, + preview; + +int b_screen_length, + preview_width, + preview_height, + preview_length; + +enum { + BTN_MAKE_SCREENSHOT=10, + BTN_SAVE +}; + +#define TOOLBAR_H 50; + +/* === CODE === */ + + +void main() +{ + char id; + b_screen_length = screen.width * screen.height * 3; + preview_width = screen.width / 2; + preview_height = screen.height / 2; + preview_length = b_screen_length / 2; + + b_screen = malloc(b_screen_length); + preview = malloc(b_screen_length/2); + + loop() switch(WaitEvent()) + { + case evButton: + id = GetButtonID(); + if (id == CLOSE_BTN) ExitProcess(); + if (id == BTN_MAKE_SCREENSHOT) EventTakeScreenshot(); + if (id == BTN_SAVE) EventSaveFile(); + break; + + case evKey: + GetKeys(); + if (SCAN_CODE_KEY_S == key_scancode) EventSaveFile(); + if (SCAN_CODE_ENTER == key_scancode) EventTakeScreenshot(); + break; + + case evReDraw: + system.color.get(); + DefineAndDrawWindow(screen.width/4, screen.height/4, + preview_width + 9, preview_height + skin_height + TOOLBAR_H, + 0x74, 0, "EasyShot v0.3",0); + GetProcessInfo(#Form, SelfInfo); + if (Form.status_window>2) break; + DrawBar(0, 0, Form.cwidth, TOOLBAR_H-4, system.color.work); + DrawStandartCaptButton(10, 10, BTN_MAKE_SCREENSHOT, "Take a screenshot"); + _PutImage(0, Form.cheight - preview_height, preview_width, preview_height, preview); + if (ESDWORD[preview]==0) { + WriteTextB(Form.cwidth/2 - 90, Form.cheight/2+10, 0x90, 0xFFFfff, "There will be a preview"); + } + else { + DrawStandartCaptButton(200, 10, BTN_SAVE, "Save"); + } + } +} + +void EventTakeScreenshot() { + MinimizeWindow(); + pause(100); + CopyScreen(b_screen, 0, 0, screen.width, screen.height); + ZoomImageTo50percent(); + ActivateWindow(GetProcessSlot(Form.ID)); + //_PutImage(0, Form.cheight - preview_height, preview_width, preview_height, preview); +} + +void EventSaveFile() +{ + SaveFile(b_screen, screen.width, screen.height, "/tmp0/1/screen.png"); +} + +void SaveFile(dword _image, _w, _h, _path) +{ + dword encoded_data=0; + dword encoded_size=0; + dword image_ptr = 0; + + image_ptr = create_image(Image_bpp24, _w, _h); + + if (image_ptr == 0) { + notify("'Error saving file, probably not enought memory!' -E"); + } + else { + EDI = image_ptr; + memmov(EDI._Image.Data, _image, _w * _h * 3); + + encoded_data = encode_image(image_ptr, LIBIMG_FORMAT_PNG, 0, #encoded_size); + + img_destroy stdcall(image_ptr); + + if(encoded_data == 0) { + notify("'Error saving file, incorrect data!' -E"); + } + else { + if (WriteFile(encoded_size, encoded_data, _path) == 0) { + notify("'File saved as /rd/1/saved_image.png' -O"); + } + else { + notify("'Error saving file, probably not enought space on ramdisk!' -E"); + } + } + } +} + +void ZoomImageTo50percent() { + dword point_x, + item_h= screen.width * 3, + s_off = preview + 3, + b_off = b_screen + 6, + b_off_r, + b_off_g, + b_off_b, + rez_r, + rez_g, + rez_b; + + while( (s_off <= preview + preview_length) && (b_off <= b_screen + b_screen_length ) ) { + + if (b_off <= b_screen + item_h) || (b_off >= b_screen + b_screen_length - item_h) + { + ESBYTE[s_off] = ESBYTE[b_off]; + ESBYTE[s_off+1] = ESBYTE[b_off+1]; + ESBYTE[s_off+2] = ESBYTE[b_off+2]; + } + else + { + // line[x].R = (line[x+1].R + line[x].R + line[x-1].R + line1[x].R + line2[x].R) / 5; + // line[x].G = (line[x+1].G + line[x].G + line[x-1].G + line1[x].G + line2[x].G) / 5; + // line[x].B = (line[x+1].B + line[x].B + line[x-1].B + line1[x].B + line2[x].B) / 5 + b_off_r = b_off; + b_off_g = b_off + 1; + b_off_b = b_off + 2; + 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; + 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; + 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; + ESBYTE[s_off] = rez_r; + ESBYTE[s_off+1] = rez_g; + ESBYTE[s_off+2] = rez_b; + + } + + s_off+=3; + b_off+=6; + + point_x+=2; + if (point_x >= screen.width) + { + b_off += item_h; + point_x = 0; + } + } +} + + +stop: diff --git a/programs/cmm/eolite/Eolite.c b/programs/cmm/eolite/Eolite.c index 7f366fb75c..743a7463fc 100644 --- a/programs/cmm/eolite/Eolite.c +++ b/programs/cmm/eolite/Eolite.c @@ -6,7 +6,7 @@ #endif //libraries -#define MEMSIZE 4096 * 180 +#define MEMSIZE 1024 * 720 #include "../lib/clipboard.h" #include "../lib/strings.h" #include "../lib/mem.h" diff --git a/programs/cmm/eolite/include/properties.h b/programs/cmm/eolite/include/properties.h index 4e394af72e..f9338eb20f 100644 --- a/programs/cmm/eolite/include/properties.h +++ b/programs/cmm/eolite/include/properties.h @@ -386,9 +386,9 @@ void DrawPropertiesWindow() element_size = size_dir; } WriteTextLines(10, 136, 0x90, system.color.work_text, CREATED_OPENED_MODIFIED, 20); - DrawDate(120, 136, system.color.work, #file_info_general.datecreate); - DrawDate(120, 156, system.color.work, #file_info_general.datelastaccess); - DrawDate(120, 176, system.color.work, #file_info_general.datelastedit); + DrawDate(120, 136, system.color.work_text, #file_info_general.datecreate); + DrawDate(120, 156, system.color.work_text, #file_info_general.datelastaccess); + DrawDate(120, 176, system.color.work_text, #file_info_general.datelastedit); sprintf(#element_size_label,"%s (%d %s)",ConvertSize64(element_size, NULL),element_size,SET_BYTE_LANG); WriteText(120, 99, 0x90, system.color.work_text, #element_size_label); diff --git a/programs/cmm/experimental/easyshot/easyshot.c b/programs/cmm/experimental/easyshot/easyshot.c deleted file mode 100644 index 080a25ea72..0000000000 --- a/programs/cmm/experimental/easyshot/easyshot.c +++ /dev/null @@ -1,130 +0,0 @@ -#define MEMSIZE 0xFFFFF -#include "../lib/kolibri.h" -#include "../lib/strings.h" -#include "../lib/mem.h" -#include "../lib/gui.h" - -#ifndef AUTOBUILD - #include "lang.h--" -#endif - -/* === DATA === */ - -system_colors sc; -proc_info Form; - - -dword b_screen, - s_screen; - -int b_screen_width, - b_screen_height, - b_screen_length, - s_screen_width, - s_screen_height, - s_screen_length; - - -/* === CODE === */ - - -void main() -{ - char id; - mem_Init(); - b_screen_width = GetScreenWidth()+1; - b_screen_height = GetScreenHeight()+1; - b_screen_length = b_screen_width*b_screen_height*3; - s_screen_width = b_screen_width / 2; - s_screen_height = b_screen_height / 2; - s_screen_length = b_screen_length / 2; - - b_screen = malloc(b_screen_length); - s_screen = malloc(b_screen_length/2); - - loop() - { - switch(WaitEvent()) - { - case evButton: - id = GetButtonID(); - if (id==1) ExitProcess(); - if (id==10) TakeScreenshot(); - break; - - case evReDraw: - sc.get(); - 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); - GetProcessInfo(#Form, SelfInfo); - if (Form.status_window>2) break; - DrawBar(0, 0, Form.cwidth, 41, sc.work); - DrawCaptButton(10, 10, 140, 20, 10, sc.work_button, sc.work_button_text, "Make screenshot"); - _PutImage(0, Form.cheight - s_screen_height, s_screen_width, s_screen_height, s_screen); - if (ESDWORD[s_screen]==0) - WriteTextB(Form.cwidth/2 - 60, Form.cheight/2+10, 0x90, 0xFFFfff, "There will be preview"); - else - DrawCaptButton(160, 10, 80, 20, 11, sc.work_button, sc.work_button_text, "Save"); - } - } -} - -void TakeScreenshot() { - MinimizeWindow(); - pause(20); - CopyScreen(b_screen, 0, 0, b_screen_width, b_screen_height); - ZoomImageTo50percent(); - ActivateWindow(GetProcessSlot(Form.ID)); - //_PutImage(0, Form.cheight - s_screen_height, s_screen_width, s_screen_height, s_screen); -} - -void ZoomImageTo50percent() { - dword point_x, - item_h= b_screen_width * 3, - s_off = s_screen + 3, - b_off = b_screen + 6, - b_off_r, - b_off_g, - b_off_b, - rez_r, - rez_g, - rez_b; - - while( (s_off < s_screen + s_screen_length) && (b_off < b_screen + b_screen_length ) ) { - - if (b_off < b_screen + item_h) || (b_off > b_screen + b_screen_length - item_h) - { - ESBYTE[s_off] = ESBYTE[b_off]; - ESBYTE[s_off+1] = ESBYTE[b_off+1]; - ESBYTE[s_off+2] = ESBYTE[b_off+2]; - } - else - { - // line[x].R = (line[x+1].R + line[x].R + line[x-1].R + line1[x].R + line2[x].R) / 5; - // line[x].G = (line[x+1].G + line[x].G + line[x-1].G + line1[x].G + line2[x].G) / 5; - // line[x].B = (line[x+1].B + line[x].B + line[x-1].B + line1[x].B + line2[x].B) / 5 - b_off_r = b_off; - b_off_g = b_off + 1; - b_off_b = b_off + 2; - 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; - 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; - 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; - ESBYTE[s_off] = rez_r; - ESBYTE[s_off+1] = rez_g; - ESBYTE[s_off+2] = rez_b; - - } - - s_off+=3; - b_off+=6; - - point_x+=2; - if (point_x >= b_screen_width) - { - b_off += item_h; - point_x = 0; - } - } -} - - -stop: