forked from KolibriOS/kolibrios
ImgEdit: first release version with the basic funcionality
Appearance: fixes git-svn-id: svn://kolibrios.org@9643 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
ee607a0840
commit
dbd52c5074
@ -427,9 +427,17 @@ void EventApply()
|
||||
void EventOpenFile()
|
||||
{
|
||||
switch (tabs.active_tab) {
|
||||
case TAB_SKINS: RunProgram("/sys/skincfg", list.get(select_list.cur_y)); break;
|
||||
case TAB_WALLPAPERS: RunProgram("/sys/media/kiv", list.get(select_list.cur_y)); break;
|
||||
case TAB_SCREENSAVERS: if(select_list.cur_y) RunProgram(list.get(select_list.cur_y), "@ss");
|
||||
case TAB_SKINS:
|
||||
RunProgram("/sys/skincfg", list.get(select_list.cur_y));
|
||||
break;
|
||||
case TAB_WALLPAPERS:
|
||||
RunProgram("/sys/media/kiv", list.get(select_list.cur_y));
|
||||
break;
|
||||
case TAB_SCREENSAVERS:
|
||||
if(select_list.cur_y) {
|
||||
KillProcessByName("@ss", MULTIPLE);
|
||||
RunProgram(list.get(select_list.cur_y), "@ss");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ void DrawUiElementsPreview(dword x,y,h)
|
||||
spinbox1.draw(x, y2.set(y+30));
|
||||
WriteText(x, y2.inc(30), 0x90, sc.work_text, "C-- Edit");
|
||||
DrawEditBoxPos(x, y2.inc(20), #edit_cmm);
|
||||
WriteText(x, y2.inc(35), 0x90, sc.work_text, "Standart Edit");
|
||||
WriteText(x, y2.inc(35), 0x90, sc.work_text, "Standard Edit");
|
||||
DrawStEditBoxPos(x, y2.inc(20), #edit_st);
|
||||
DrawStandartCaptButton(x, y+h-40, GetFreeButtonId(), "Button1");
|
||||
DrawStandartCaptButton(x+100, y+h-40, GetFreeButtonId(), "Button2");
|
||||
|
54
programs/cmm/imgedit/data.h
Normal file
54
programs/cmm/imgedit/data.h
Normal file
@ -0,0 +1,54 @@
|
||||
//Sizes
|
||||
#define PAD 13
|
||||
#define TOOLBAR_ITEM_H PAD + PAD
|
||||
#define TOOLBAR_W 136
|
||||
#define STATUSBAR_H 20
|
||||
#define HEADERH TOOLBAR_ITEM_H + 14
|
||||
#define HEADER_TEXTY HEADERH - 14 / 2
|
||||
#define CANVASX TOOLBAR_W + PAD + PAD
|
||||
#define CANVASY HEADERH + 2
|
||||
|
||||
// Colors
|
||||
#define COL_WORK 0x242424
|
||||
#define COL_WORK_TEXT 0xBEBEBE
|
||||
#define COL_LIGHT 0x424242
|
||||
#define COL_DARK 0x1D1D1D
|
||||
#define COL_LINE 0x010101
|
||||
#define COL_BUTTON 0x181818
|
||||
#define COL_BUTTON_TEXT 0x18A2CC
|
||||
|
||||
block canvas = { CANVASX, CANVASY, NULL, NULL };
|
||||
|
||||
EVENTS button;
|
||||
EVENTS key;
|
||||
|
||||
proc_info Form;
|
||||
int pressed_button_id;
|
||||
|
||||
char default_dir[4096] = "/sys";
|
||||
od_filter filter2 = { 69, "BMP\0GIF\0ICO\0CUR\0JPEG\0JPG\0PNG\0PNM\0TGA\0TIFF\0TIF\0WBMP\0XBM\0XCF\Z80\0\0" };
|
||||
|
||||
libimg_image icons18;
|
||||
libimg_image icons18a;
|
||||
libimg_image pixie_skin;
|
||||
libimg_image main_image;
|
||||
|
||||
scroll_bar scroll_v = { 15,NULL,NULL,HEADERH+1,15,2,NULL,0,0,COL_DARK,COL_LIGHT,COL_LINE};
|
||||
scroll_bar scroll_h = { NULL,TOOLBAR_W+PAD+PAD,15,NULL,15,2,NULL,0,0,COL_DARK,COL_LIGHT,COL_LINE};
|
||||
|
||||
enum { SAVE_AS_PNG=1, SAVE_AS_BMP=2, SAVE_AS_RAW=4, SAVE_AS_PNM=8 };
|
||||
int saving_type = NULL;
|
||||
|
||||
char* libimg_bpp[] = { "-", "8pal", "24", "32", "15", "16",
|
||||
"mono", "8gray", "2pal", "4pal", "8gr/a" };
|
||||
int color_depth_btnid_1;
|
||||
|
||||
enum {
|
||||
TOOL_EXPORT=1,
|
||||
TOOL_CROP=2,
|
||||
TOOL_RESIZE=4,
|
||||
TOOL_COLOR_DEPTH=8,
|
||||
TOOL_FLIP_ROTATE=16
|
||||
};
|
||||
int active_tool = NULL;
|
||||
|
@ -1,5 +1,11 @@
|
||||
#define MEMSIZE 1024*100
|
||||
|
||||
/*=====================================================
|
||||
| |
|
||||
| LIB |
|
||||
| |
|
||||
=====================================================*/
|
||||
|
||||
#include "../lib/gui.h"
|
||||
#include "../lib/random.h"
|
||||
#include "../lib/mem.h"
|
||||
@ -15,96 +21,48 @@
|
||||
#include "../lib/patterns/toolbar_button.h"
|
||||
#include "../lib/patterns/simple_open_dialog.h"
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
// DATA //
|
||||
// //
|
||||
//===================================================//
|
||||
/*=====================================================
|
||||
| |
|
||||
| DATA |
|
||||
| |
|
||||
=====================================================*/
|
||||
|
||||
//Sizes
|
||||
#define PAD 13
|
||||
#define TOOLBAR_ITEM_H PAD + PAD
|
||||
#define TOOLBAR_W 132
|
||||
#define STATUSBAR_H 20
|
||||
#define HEADERH TOOLBAR_ITEM_H + 14
|
||||
#define HEADER_TEXTY HEADERH - 14 / 2
|
||||
#define CANVASX TOOLBAR_W + PAD + PAD
|
||||
#define CANVASY HEADERH + 2
|
||||
#include "data.h"
|
||||
|
||||
// Colors
|
||||
#define COL_WORK 0x242424
|
||||
#define COL_WORK_TEXT 0xBEBEBE
|
||||
#define COL_LIGHT 0x424242
|
||||
#define COL_DARK 0x1D1D1D
|
||||
#define COL_LINE 0x010101
|
||||
#define COL_BUTTON 0x181818
|
||||
#define COL_BUTTON_TEXT 0x18A2CC
|
||||
|
||||
block canvas = { CANVASX, CANVASY, NULL, NULL };
|
||||
|
||||
EVENTS button;
|
||||
EVENTS key;
|
||||
|
||||
proc_info Form;
|
||||
int pressed_button_id;
|
||||
|
||||
char default_dir[4096] = "/sys";
|
||||
od_filter filter2 = { 69, "BMP\0GIF\0ICO\0CUR\0JPEG\0JPG\0PNG\0PNM\0TGA\0TIFF\0TIF\0WBMP\0XBM\0XCF\Z80\0\0" };
|
||||
|
||||
libimg_image icons18;
|
||||
libimg_image icons18a;
|
||||
libimg_image pixie_skin;
|
||||
libimg_image main_image;
|
||||
|
||||
scroll_bar scroll_v = { 15,NULL,NULL,HEADERH+1,15,2,NULL,0,0,COL_DARK,COL_LIGHT,COL_LINE};
|
||||
scroll_bar scroll_h = { NULL,TOOLBAR_W+PAD+PAD,15,NULL,15,2,NULL,0,0,COL_DARK,COL_LIGHT,COL_LINE};
|
||||
|
||||
enum { SAVE_AS_PNG=1, SAVE_AS_BMP=2, SAVE_AS_RAW=4 };
|
||||
int saving_type=SAVE_AS_PNG;
|
||||
|
||||
char* libimg_bpp[] = { "-", "8pal", "24", "32", "15", "16",
|
||||
"mono", "8gray", "2pal", "4pal", "8gr/a" };
|
||||
|
||||
enum {
|
||||
TOOL_CROP=1,
|
||||
TOOL_RESIZE=2,
|
||||
TOOL_COLOR_DEPTH=4,
|
||||
TOOL_FLIP_ROTATE=8
|
||||
};
|
||||
int active_tool = NULL;
|
||||
|
||||
//===================================================//
|
||||
// //
|
||||
// CODE //
|
||||
// //
|
||||
//===================================================//
|
||||
|
||||
void init_ui()
|
||||
{
|
||||
icons18.load("/sys/icons16.png");
|
||||
icons18.replace_2colors(0xffFFFfff, COL_LIGHT, 0xffCACBD6, COL_LIGHT-0x080808);
|
||||
icons18a.load("/sys/icons16.png");
|
||||
icons18a.replace_2colors(0xffFFFfff, COL_BUTTON, 0xffCACBD6, 0);
|
||||
|
||||
pixie_skin.load("/sys/media/pixieskn.png");
|
||||
}
|
||||
/*=====================================================
|
||||
| |
|
||||
| CODE |
|
||||
| |
|
||||
=====================================================*/
|
||||
|
||||
void main()
|
||||
{
|
||||
/* Init external libraries */
|
||||
load_dll(libimg, #libimg_init, 1);
|
||||
load_dll(boxlib, #box_lib_init,0);
|
||||
load_dll(Proc_lib, #OpenDialog_init,0);
|
||||
OpenDialog_init stdcall (#o_dialog);
|
||||
|
||||
open_image("/sys/home.png");
|
||||
/* Init UI */
|
||||
icons18.load("/sys/icons16.png");
|
||||
icons18.replace_2colors(0xffFFFfff, COL_LIGHT, 0xffCACBD6, COL_LIGHT-0x080808);
|
||||
icons18a.load("/sys/icons16.png");
|
||||
icons18a.replace_2colors(0xffFFFfff, COL_BUTTON, 0xffCACBD6, 0);
|
||||
pixie_skin.load("/sys/media/pixieskn.png");
|
||||
Form.width = screen.w/6*5;
|
||||
Form.height = screen.h/6*5;
|
||||
|
||||
/* Handle application parameters */
|
||||
//if (!param) open_image("/sys/home.png");
|
||||
|
||||
/* Set event mask and go to main loop */
|
||||
SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
|
||||
loop() switch(WaitEvent())
|
||||
{
|
||||
case evMouse:
|
||||
mouse.get();
|
||||
scrollbar_v_mouse stdcall(#scroll_v);
|
||||
scrollbar_h_mouse stdcall(#scroll_h);
|
||||
if (main_image.h > canvas.h) scrollbar_v_mouse stdcall(#scroll_v);
|
||||
if (main_image.w > canvas.w) scrollbar_h_mouse stdcall(#scroll_h);
|
||||
if (scroll_v.delta) || (scroll_h.delta) draw_canvas();
|
||||
if (EAX = mouse.vert) {
|
||||
if (EAX<10) event_scroll_canvas(SCAN_CODE_DOWN);
|
||||
@ -138,11 +96,18 @@ void main()
|
||||
|
||||
void draw_window()
|
||||
{
|
||||
Form.width = screen.w/6*5;
|
||||
Form.height = screen.h/6*5;
|
||||
DefineAndDrawWindow(screen.w-Form.width/2, screen.h-Form.height/2, Form.width, Form.height, 0x42, NULL, NULL, 0);
|
||||
GetProcessInfo(#Form, SelfInfo);
|
||||
if (Form.status_window&ROLLED_UP) return;
|
||||
/* Draw window borders */
|
||||
DrawRectangle(0,0,Form.width,Form.height,COL_LINE);
|
||||
DrawRectangle(1,1,Form.width-2,Form.height-2,COL_LIGHT);
|
||||
/* Check if the window is collapsed into header */
|
||||
if (Form.status_window&ROLLED_UP) {
|
||||
DrawBar(2, 2, Form.width-3, skin_h-4, COL_WORK);
|
||||
WriteText(5, skin_h-11/2, 0x90, COL_WORK_TEXT, "ImageEditor Pro [Collapsed]");
|
||||
draw_window_manipulation_buttons(skin_h-17/2);
|
||||
return;
|
||||
}
|
||||
if (Form.width < 560) { MoveSize(OLD,OLD,560,OLD); return; }
|
||||
if (Form.height < 430) { MoveSize(OLD,OLD,OLD,430); return; }
|
||||
scroll_v.all_redraw = scroll_h.all_redraw = 1;
|
||||
@ -155,15 +120,12 @@ void draw_content()
|
||||
button.init(40);
|
||||
key.init(40);
|
||||
|
||||
init_ui();
|
||||
canvas.w = Form.cwidth - CANVASX - 1;
|
||||
canvas.h = Form.cheight - STATUSBAR_H - CANVASY - 1;
|
||||
if (main_image.h > canvas.h) canvas.w -= scroll_v.size_x + 1;
|
||||
if (main_image.w > canvas.w) canvas.h -= scroll_h.size_y + 1;
|
||||
|
||||
//window border and panel border
|
||||
DrawRectangle(0,0,Form.width,Form.height,COL_LINE);
|
||||
DrawRectangle(1,1,Form.width-2,Form.height-2,COL_LIGHT);
|
||||
//draw panel border
|
||||
DrawBar(CANVASX, 0, 1, Form.cheight, COL_LINE);
|
||||
|
||||
//draw title
|
||||
@ -171,12 +133,9 @@ void draw_content()
|
||||
WriteText(PAD+5, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "ImageEditor Pro");
|
||||
|
||||
//draw header
|
||||
DrawBar(CANVASX+1, 2, Form.width-CANVASX-2, HEADERH-1, COL_WORK);
|
||||
DrawBar(CANVASX+1, CANVASY-1, Form.width-CANVASX-2, 1, COL_LINE);
|
||||
img_draw stdcall(pixie_skin.image, Form.width-63, 7, 57, 18, 265, 0);
|
||||
DefineHiddenButton(Form.width-63, 7, 28, 17, button.add(#MinimizeWindow));
|
||||
DefineHiddenButton(Form.width-35, 7, 28, 17, 1);
|
||||
draw_acive_panel();
|
||||
draw_window_manipulation_buttons(7);
|
||||
|
||||
//left panel bg
|
||||
DrawBar(2, 1+HEADERH, CANVASX-2, Form.cheight-2-HEADERH, COL_WORK);
|
||||
@ -189,28 +148,26 @@ void draw_content()
|
||||
#define GAP_B TOOLBAR_ITEM_H+23
|
||||
tx.set(PAD-GAP_S+HEADERH);
|
||||
//draw_tool_btn(10, ECTRL + SCAN_CODE_KEY_N, PAD, tx.inc(GAP_S), 02, "Create image", false);
|
||||
draw_tool_btn(#event_open, ECTRL + SCAN_CODE_KEY_O, PAD, tx.inc(GAP_S), 00, "Open image", false);
|
||||
//draw_tool_btn(13, ECTRL + SCAN_CODE_LEFT, PAD, tx.inc(GAP_B), 30, false);
|
||||
//draw_tool_btn(14, ECTRL + SCAN_CODE_RIGHT, PAD, tx.inc(GAP_S), 31, false);
|
||||
//draw_tool_btn(15, ECTRL + SCAN_CODE_UP, PAD, tx.inc(GAP_S), 32, false);
|
||||
//draw_tool_btn(16, ECTRL + SCAN_CODE_DOWN, PAD, tx.inc(GAP_S), 33, false);
|
||||
if (!main_image.image) goto _NO_IMAGE;
|
||||
|
||||
draw_tool_btn(#event_save, ECTRL + SCAN_CODE_KEY_S, PAD, tx.inc(GAP_B), 05, "Save as", false);
|
||||
draw_tool_btn(#event_save_png, 0, PAD, tx.inc(GAP_S), -1, "PNG", saving_type & SAVE_AS_PNG);
|
||||
draw_tool_btn(#event_save_bmp, 0, PAD*2+34, tx.n, -1, "BMP", saving_type & SAVE_AS_BMP);
|
||||
draw_tool_btn(#event_save_raw, 0, PAD*3+68, tx.n, -1, "RAW", saving_type & SAVE_AS_RAW);
|
||||
|
||||
draw_tool_btn(#event_activate_crop, 0, PAD, tx.inc(GAP_B), 46, "Crop", active_tool & TOOL_CROP);
|
||||
draw_tool_btn(#event_activate_resize,0, PAD, tx.inc(GAP_S), 06, "Resize", active_tool & TOOL_RESIZE);
|
||||
draw_tool_btn(#event_activate_depth, 0, PAD, tx.inc(GAP_S), 52, "Color depth", active_tool & TOOL_COLOR_DEPTH);
|
||||
draw_tool_btn(#event_activate_flprot,0, PAD, tx.inc(GAP_S), 36, "Flip/Rotate", active_tool & TOOL_FLIP_ROTATE);
|
||||
_NO_IMAGE:
|
||||
|
||||
draw_tool_btn(#event_open, ECTRL + SCAN_CODE_KEY_O, PAD, tx.inc(GAP_S), 00, "Open image ", false);
|
||||
if (main_image.image) {
|
||||
draw_tool_btn(#event_activate_export, ECTRL + SCAN_CODE_KEY_S, PAD, tx.inc(GAP_S), 05, "Export image", active_tool & TOOL_EXPORT);
|
||||
//draw_tool_btn(#event_activate_crop, 0, PAD, tx.inc(GAP_B), 46, "Crop", active_tool & TOOL_CROP);
|
||||
//draw_tool_btn(#event_activate_resize,0, PAD, tx.inc(GAP_B), 06, "Resize ", active_tool & TOOL_RESIZE);
|
||||
draw_tool_btn(#event_activate_depth, 0, PAD, tx.inc(GAP_B), 52, "Color depth ", active_tool & TOOL_COLOR_DEPTH);
|
||||
draw_tool_btn(#event_activate_flprot,0, PAD, tx.inc(GAP_S), 36, "Flip/Rotate ", active_tool & TOOL_FLIP_ROTATE);
|
||||
}
|
||||
draw_status_bar();
|
||||
draw_canvas();
|
||||
}
|
||||
|
||||
void draw_window_manipulation_buttons(int y)
|
||||
{
|
||||
DrawBar(Form.width-65, 2, 63, HEADERH-1, COL_WORK);
|
||||
img_draw stdcall(pixie_skin.image, Form.width-63, y, 57, 18, 265, 0);
|
||||
DefineHiddenButton(Form.width-63, y, 28, 17, button.add(#MinimizeWindow));
|
||||
DefineHiddenButton(Form.width-35, y, 28, 17, 1);
|
||||
}
|
||||
|
||||
void draw_status_bar()
|
||||
{
|
||||
char img_info[24];
|
||||
@ -228,10 +185,14 @@ void draw_status_bar()
|
||||
|
||||
int draw_tool_btn(dword _event, _hotkey, _x, _y, _icon_n, _text, _active)
|
||||
{
|
||||
int w = TOOLBAR_W;
|
||||
dword img_ptr = icons18.image;
|
||||
if (!_text) w = PAD + PAD + 6;
|
||||
if (_icon_n==-1) w = strlen(_text) * 8 + 14;
|
||||
|
||||
int w = 32; //default width: icon only
|
||||
if (_text) {
|
||||
w = strlen(_text) * 8 + 15;
|
||||
if (_icon_n!=-1) w += 26;
|
||||
}
|
||||
|
||||
if (_active==-1) {
|
||||
$push COL_LIGHT
|
||||
EDX = COL_LINE;
|
||||
@ -302,11 +263,10 @@ void open_image(char* _path)
|
||||
scroll_h.position = 0;
|
||||
}
|
||||
|
||||
int color_depth_id;
|
||||
void event_set_color_depth() {
|
||||
img_convert stdcall(main_image.image, 0, pressed_button_id-color_depth_id, 0, 0);
|
||||
img_convert stdcall(main_image.image, 0, pressed_button_id-color_depth_btnid_1, 0, 0);
|
||||
if (!EAX) {
|
||||
notify("'ImageEdit Pro\nConvertation error' -Et");
|
||||
notify("'ImageEdit Pro\nNot possible to convert into specified color depth' -Et");
|
||||
} else {
|
||||
$push eax
|
||||
img_destroy stdcall(main_image.image);
|
||||
@ -319,30 +279,43 @@ void event_set_color_depth() {
|
||||
}
|
||||
}
|
||||
|
||||
void WritePanelText(int _x, _text) { WriteTextWithBg(_x, HEADER_TEXTY, 0xD0, COL_WORK_TEXT, _text, COL_WORK); }
|
||||
void draw_acive_panel()
|
||||
{
|
||||
char edit_width_text[8];
|
||||
edit_box edit_width;
|
||||
int i, x = CANVASX + PAD;
|
||||
bool a;
|
||||
DrawBar(CANVASX+1, 2, Form.width-CANVASX-64, HEADERH-1, COL_WORK);
|
||||
switch(active_tool) {
|
||||
case TOOL_EXPORT:
|
||||
WritePanelText(CANVASX+PAD, "Format");
|
||||
x += 6*8 + PAD;
|
||||
x += draw_tool_btn(#event_save_png, 0, x, 7, -1, "PNG", saving_type & SAVE_AS_PNG) + PAD;
|
||||
x += draw_tool_btn(#event_save_pnm, 0, x, 7, -1, "PNM", saving_type & SAVE_AS_PNM) + PAD;
|
||||
x += draw_tool_btn(#event_save_bmp, 0, x, 7, -1, "BMP", saving_type & SAVE_AS_BMP) + PAD + PAD;
|
||||
if (saving_type) draw_tool_btn(#event_save, 0, x, 7, 53, "Export", false);
|
||||
break;
|
||||
case TOOL_CROP:
|
||||
WriteText(CANVASX+PAD, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "Crop tool");
|
||||
WritePanelText(CANVASX+PAD, "Crop tool");
|
||||
break;
|
||||
case TOOL_RESIZE:
|
||||
WriteText(CANVASX+PAD, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "New width");
|
||||
WriteText(CANVASX+PAD+150, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "New height");
|
||||
WritePanelText(CANVASX+PAD, "New width");
|
||||
WritePanelText(CANVASX+PAD+150, "New height");
|
||||
draw_tool_btn(#event_rotate_left, SCAN_CODE_ENTER, CANVASX + PAD + 300, 7, -1, "Apply", false);
|
||||
EditBox_Create(#edit_width, 9*8+CANVASX+PAD+PAD, HEADER_TEXTY-3, 50, sizeof(edit_width_text), #edit_width_text, 0b);
|
||||
edit_box_draw stdcall (#edit_width);
|
||||
break;
|
||||
case TOOL_COLOR_DEPTH:
|
||||
WriteText(CANVASX+PAD, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "Color depth");
|
||||
WritePanelText(CANVASX+PAD, "Color depth");
|
||||
x += 11*8 + PAD;
|
||||
color_depth_id = button.new_id;
|
||||
color_depth_btnid_1 = button.new_id;
|
||||
for (i=1; i<11; i++) {
|
||||
DeleteButton(color_depth_btnid_1+i);
|
||||
if (main_image.type == i) {
|
||||
//this is current image depth
|
||||
a = true;
|
||||
a = true; //this is current image depth
|
||||
} else {
|
||||
//this is image ve san set
|
||||
a = false;
|
||||
a = false; //this is image depth we can set
|
||||
//probe does libimg support converting current image gepth to i-one
|
||||
img_create stdcall(1, 1, main_image.type);
|
||||
img_convert stdcall(EAX, 0, i, 0, 0);
|
||||
@ -350,26 +323,30 @@ void draw_acive_panel()
|
||||
img_destroy stdcall(EAX);
|
||||
} else {
|
||||
a = -1;
|
||||
if (Form.width-CANVASX-64 < 652) {
|
||||
button.add(1);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
x += draw_tool_btn(#event_set_color_depth, SCAN_CODE_ENTER, x, 7, -1, libimg_bpp[i], a) + PAD;
|
||||
}
|
||||
break;
|
||||
case TOOL_FLIP_ROTATE:
|
||||
WriteText(CANVASX+PAD, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "Flip");
|
||||
WritePanelText(CANVASX+PAD, "Flip");
|
||||
draw_tool_btn(#event_flip_hor, ECTRL + SCAN_CODE_KEY_H, CANVASX + PAD + 040, 7, 34, NULL, false);
|
||||
draw_tool_btn(#event_flip_ver, ECTRL + SCAN_CODE_KEY_V, CANVASX + PAD + 080, 7, 35, NULL, false);
|
||||
WriteText(CANVASX+PAD + 142, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "Rotate");
|
||||
WritePanelText(CANVASX+PAD + 142, "Rotate");
|
||||
draw_tool_btn(#event_rotate_left, ECTRL + SCAN_CODE_KEY_L, CANVASX + PAD + 200, 7, 37, NULL, false);
|
||||
draw_tool_btn(#event_rotate_right, ECTRL + SCAN_CODE_KEY_R, CANVASX + PAD + 240, 7, 36, NULL, false);
|
||||
// WriteText(CANVASX+PAD + 142, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "Move");
|
||||
// DrawTopPanelButton1(#EventMoveLeft, ECTRL + SCAN_CODE_LEFT, tx.inc(GAP_B), 30);
|
||||
// DrawTopPanelButton1(#EventMoveRight, ECTRL + SCAN_CODE_RIGHT, tx.inc(GAP_S), 31);
|
||||
// DrawTopPanelButton1(#EventMoveUp, ECTRL + SCAN_CODE_UP, tx.inc(GAP_S), 32);
|
||||
// DrawTopPanelButton1(#EventMoveDown, ECTRL + SCAN_CODE_DOWN, tx.inc(GAP_S), 33);
|
||||
// WritePanelText(CANVASX+PAD + 142, "Move");
|
||||
//draw_tool_btn(#event_move_left, ECTRL + SCAN_CODE_LEFT, PAD, tx.inc(GAP_B), 30, false);
|
||||
//draw_tool_btn(#event_move_right, ECTRL + SCAN_CODE_RIGHT, PAD, tx.inc(GAP_S), 31, false);
|
||||
//draw_tool_btn(#event_move_up, ECTRL + SCAN_CODE_UP, PAD, tx.inc(GAP_S), 32, false);
|
||||
//draw_tool_btn(#event_move_down, ECTRL + SCAN_CODE_DOWN, PAD, tx.inc(GAP_S), 33, false);
|
||||
break;
|
||||
default:
|
||||
WriteText(CANVASX+PAD, HEADER_TEXTY, 0x90, COL_WORK_TEXT, "Welcome to ImageEditor Pro! Try to open a file.");
|
||||
if (!param) WritePanelText(CANVASX+PAD, "Welcome to ImageEditor Pro! Try to open a file.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -379,6 +356,16 @@ void draw_acive_panel()
|
||||
// //
|
||||
//===================================================//
|
||||
|
||||
void event_save_png() { saving_type = SAVE_AS_PNG; draw_acive_panel(); }
|
||||
void event_save_bmp() { saving_type = SAVE_AS_BMP; draw_acive_panel(); }
|
||||
void event_save_raw() { saving_type = SAVE_AS_RAW; draw_acive_panel(); }
|
||||
void event_save_pnm() { saving_type = SAVE_AS_PNM; draw_acive_panel(); }
|
||||
void event_activate_export() { active_tool = TOOL_EXPORT; draw_content(); }
|
||||
void event_activate_crop() { active_tool = TOOL_CROP; draw_content(); }
|
||||
void event_activate_resize() { active_tool = TOOL_RESIZE; draw_content(); }
|
||||
void event_activate_depth() { active_tool = TOOL_COLOR_DEPTH; draw_content(); }
|
||||
void event_activate_flprot() { active_tool = TOOL_FLIP_ROTATE; draw_content(); }
|
||||
|
||||
void event_open()
|
||||
{
|
||||
o_dialog.type = 0; //open file
|
||||
@ -415,34 +402,48 @@ void event_rotate_right()
|
||||
draw_content();
|
||||
}
|
||||
|
||||
void event_save_png() { saving_type = SAVE_AS_PNG; draw_content(); }
|
||||
void event_save_bmp() { saving_type = SAVE_AS_BMP; draw_content(); }
|
||||
void event_save_raw() { saving_type = SAVE_AS_RAW; draw_content(); }
|
||||
|
||||
void event_activate_crop() { active_tool = TOOL_CROP; draw_content(); }
|
||||
void event_activate_resize() { active_tool = TOOL_RESIZE; draw_content(); }
|
||||
void event_activate_depth() { active_tool = TOOL_COLOR_DEPTH; draw_content(); }
|
||||
void event_activate_flprot() { active_tool = TOOL_FLIP_ROTATE; draw_content(); }
|
||||
|
||||
void event_save()
|
||||
{
|
||||
o_dialog.type = 1; //save file
|
||||
dword _image_format, _image_depth;
|
||||
strcpy(#filename_area, #param + strrchr(#param, '/'));
|
||||
if (EAX = strrchr(#filename_area, '.')) filename_area[EAX-1] = '\0';
|
||||
switch (saving_type) {
|
||||
case SAVE_AS_PNG:
|
||||
strcpy(#filename_area, "image.png");
|
||||
OpenDialog_start stdcall (#o_dialog);
|
||||
if (o_dialog.status) {
|
||||
set_file_path(#openfile_path);
|
||||
img_to_rgb stdcall (main_image.image);
|
||||
save_image(main_image.imgsrc, main_image.w, main_image.h, #openfile_path);
|
||||
}
|
||||
strcat(#filename_area, "_IEP.png");
|
||||
_image_format = LIBIMG_FORMAT_PNG;
|
||||
_image_depth = IMAGE_BPP24;
|
||||
break;
|
||||
case SAVE_AS_BMP:
|
||||
notify("Not implemented yet.");
|
||||
strcat(#filename_area, "_IEP.bmp");
|
||||
_image_format = LIBIMG_FORMAT_BMP;
|
||||
_image_depth = IMAGE_BPP24;
|
||||
break;
|
||||
case SAVE_AS_PNM:
|
||||
strcat(#filename_area, "_IEP.pnm");
|
||||
_image_format = LIBIMG_FORMAT_PNM;
|
||||
_image_depth = IMAGE_BPP24;
|
||||
break;
|
||||
case SAVE_AS_RAW:
|
||||
notify("Not implemented yet.");
|
||||
break;
|
||||
return;
|
||||
}
|
||||
o_dialog.type = 1; //save file
|
||||
OpenDialog_start stdcall (#o_dialog);
|
||||
if (o_dialog.status) {
|
||||
set_file_path(#openfile_path);
|
||||
img_convert stdcall(main_image.image, 0, _image_depth, 0, 0);
|
||||
if (!EAX) {
|
||||
notify("'ImageEdit Pro\nCan not convert image into specified color depth' -Et");
|
||||
} else {
|
||||
$push eax //converted data
|
||||
img_encode stdcall(EAX, _image_format, 0); //<=EAX data, ECX size
|
||||
$push eax //encoded data
|
||||
CreateFile(ECX, EAX, #openfile_path);
|
||||
$pop ecx
|
||||
free(ECX);
|
||||
$pop eax
|
||||
img_destroy stdcall(EAX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,11 +136,8 @@ dword width,
|
||||
ESI.edit_box.size = strlen(ed_text);
|
||||
}
|
||||
|
||||
:dword EditBox_Create(dword left, top, width, maxlen, text, flags)
|
||||
:dword EditBox_Create(dword eb, left, top, width, maxlen, text, flags)
|
||||
{
|
||||
dword eb, i;
|
||||
eb = malloc(sizeof(edit_box));
|
||||
for (i = 0; i < sizeof(edit_box); i++) ESBYTE[eb + i] = 0;
|
||||
ESDWORD[eb] = width;
|
||||
ESDWORD[eb + 4] = left;
|
||||
ESDWORD[eb + 8] = top;
|
||||
@ -155,7 +152,6 @@ dword width,
|
||||
ESDWORD[eb + 44] = flags;
|
||||
ESDWORD[eb + 48] = 0;
|
||||
ESDWORD[eb + 52] = 0;
|
||||
return eb;
|
||||
}
|
||||
|
||||
struct scroll_bar
|
||||
|
@ -186,14 +186,6 @@ struct libimg_image
|
||||
}
|
||||
}
|
||||
|
||||
// size - output parameter, error code / the size of encoded data
|
||||
:dword encode_image(dword image_ptr, dword options, dword specific_options, dword* size) {
|
||||
img_encode stdcall(image_ptr, options, specific_options);
|
||||
ESDWORD[size] = ECX;
|
||||
|
||||
return EAX;
|
||||
}
|
||||
|
||||
:dword save_image(dword _image_pointer, _w, _h, _path)
|
||||
{
|
||||
dword encoded_data=0;
|
||||
@ -210,7 +202,9 @@ struct libimg_image
|
||||
EDI = image_ptr;
|
||||
memmov(EDI.libimg_image.imgsrc, _image_pointer, _w * _h * 3);
|
||||
|
||||
encoded_data = encode_image(image_ptr, LIBIMG_FORMAT_PNG, 0, #encoded_size);
|
||||
img_encode stdcall(image_ptr, LIBIMG_FORMAT_PNG, 0);
|
||||
encoded_data = EAX;
|
||||
encoded_size = ECX;
|
||||
|
||||
img_destroy stdcall(image_ptr);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user