ImgEdit: add scale feature

git-svn-id: svn://kolibrios.org@9644 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Kirill Lipatov (Leency) 2022-01-15 20:30:04 +00:00
parent dbd52c5074
commit 361657b326
8 changed files with 175 additions and 66 deletions

View File

@ -27,7 +27,7 @@ void DrawUiElementsPreview(dword x,y,h)
ESI = edit_box_pointer; ESI = edit_box_pointer;
ESI.edit_box.left = x; ESI.edit_box.left = x;
ESI.edit_box.top = y; ESI.edit_box.top = y;
ESI.edit_box.blur_border_color = c_inactive; ESI.edit_box.border_color = c_inactive;
ESI.edit_box.focus_border_color = c_active; ESI.edit_box.focus_border_color = c_active;
edit_box_draw stdcall (edit_box_pointer); edit_box_draw stdcall (edit_box_pointer);
} }

View File

@ -904,8 +904,8 @@ void DrawOmnibox()
DrawOvalBorder(omnibox_edit.left-2, omnibox_edit.top-3, omnibox_edit.width+18, 24, sc.line, DrawOvalBorder(omnibox_edit.left-2, omnibox_edit.top-3, omnibox_edit.width+18, 24, sc.line,
sc.line, sc.line, sc.dark); sc.line, sc.line, sc.dark);
DrawBar(omnibox_edit.left-1, omnibox_edit.top-2, omnibox_edit.width+18, 1, 0xD8DCD8); DrawBar(omnibox_edit.left-1, omnibox_edit.top-2, omnibox_edit.width+18, 1, 0xD8DCD8);
DrawBar(omnibox_edit.left-1, omnibox_edit.top-1, omnibox_edit.width+18, 1, omnibox_edit.color); DrawBar(omnibox_edit.left-1, omnibox_edit.top-1, omnibox_edit.width+18, 1, omnibox_edit.bg_color);
DrawBar(omnibox_edit.left-1, omnibox_edit.top, 1, 22, omnibox_edit.color); DrawBar(omnibox_edit.left-1, omnibox_edit.top, 1, 22, omnibox_edit.bg_color);
if (omnibox_edit.flags & ed_focus) omnibox_edit.flags = ed_focus; else omnibox_edit.flags = 0; if (omnibox_edit.flags & ed_focus) omnibox_edit.flags = ed_focus; else omnibox_edit.flags = 0;
EditBox_UpdateText(#omnibox_edit, omnibox_edit.flags); EditBox_UpdateText(#omnibox_edit, omnibox_edit.flags);

View File

@ -132,7 +132,7 @@ void StartDownloading()
strcpy(#get_url, #uEdit); strcpy(#get_url, #uEdit);
} }
if (http.get(#get_url)) { if (http.get(#get_url)) {
ed.blur_border_color = 0xCACACA; ed.border_color = 0xCACACA;
EditBox_UpdateText(#ed, ed_disabled); EditBox_UpdateText(#ed, ed_disabled);
pb.value = 0; pb.value = 0;
DrawWindow(); DrawWindow();
@ -166,7 +166,7 @@ void StopDownloading()
if (http.content_pointer) http.content_pointer = free(http.content_pointer); if (http.content_pointer) http.content_pointer = free(http.content_pointer);
http.content_received = http.content_length = 0; http.content_received = http.content_length = 0;
ed.blur_border_color = 0xFFFfff; ed.border_color = 0xFFFfff;
EditBox_UpdateText(#ed, ed_focus); EditBox_UpdateText(#ed, ed_focus);
DrawWindow(); DrawWindow();
} }

View File

@ -43,14 +43,14 @@ void SettingsDialog()
{ {
if (automatic.checked) { if (automatic.checked) {
UpdateEditboxFlags(ed_disabled); UpdateEditboxFlags(ed_disabled);
POP_server_box.blur_border_color = POP_server_port_box.blur_border_color = POP_server_box.border_color = POP_server_port_box.border_color =
SMTP_server_box.blur_border_color = SMTP_server_port_box.blur_border_color = 0xCACACA; SMTP_server_box.border_color = SMTP_server_port_box.border_color = 0xCACACA;
} }
else { else {
UpdateEditboxFlags(0); UpdateEditboxFlags(0);
POP_server_box.flags = 0b10; POP_server_box.flags = 0b10;
POP_server_box.blur_border_color = POP_server_port_box.blur_border_color = POP_server_box.border_color = POP_server_port_box.border_color =
SMTP_server_box.blur_border_color = SMTP_server_port_box.blur_border_color = 0xFFFfff; SMTP_server_box.border_color = SMTP_server_port_box.border_color = 0xFFFfff;
} }
DrawOptionsWindow(); DrawOptionsWindow();
} }

View File

@ -36,6 +36,13 @@ 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_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}; scroll_bar scroll_h = { NULL,TOOLBAR_W+PAD+PAD,15,NULL,15,2,NULL,0,0,COL_DARK,COL_LIGHT,COL_LINE};
#define DIMTS 6 //dimenshion text size
char text_w[DIMTS+10], text_h[DIMTS+10];
edit_box edit_w = {DIMTS+1*8,08*8+CANVASX+PAD+PAD,HEADER_TEXTY-3,0xEEEeee,0x94AECE,
0xEEEeee,0xEEEeee,0x10000000,4,#text_w,0,ed_focus+ed_figure_only};
edit_box edit_h = {DIMTS+1*8,17*8+CANVASX+PAD+PAD+PAD-1,HEADER_TEXTY-3,0xEEEeee,
0x94AECE,0xEEEeee,0xEEEeee,0x10000000,4,#text_h,0,ed_figure_only};
enum { SAVE_AS_PNG=1, SAVE_AS_BMP=2, SAVE_AS_RAW=4, SAVE_AS_PNM=8 }; enum { SAVE_AS_PNG=1, SAVE_AS_BMP=2, SAVE_AS_RAW=4, SAVE_AS_PNM=8 };
int saving_type = NULL; int saving_type = NULL;
@ -46,9 +53,10 @@ int color_depth_btnid_1;
enum { enum {
TOOL_EXPORT=1, TOOL_EXPORT=1,
TOOL_CROP=2, TOOL_CROP=2,
TOOL_RESIZE=4, TOOL_COLOR_DEPTH=4,
TOOL_COLOR_DEPTH=8, TOOL_FLIP_ROTATE=8,
TOOL_FLIP_ROTATE=16 TOOL_SCALE=16,
}; };
int active_tool = NULL; int active_tool = NULL;
:checkbox keep_ratio = { "Keep ratio", true };

View File

@ -51,6 +51,13 @@ void main()
pixie_skin.load("/sys/media/pixieskn.png"); pixie_skin.load("/sys/media/pixieskn.png");
Form.width = screen.w/6*5; Form.width = screen.w/6*5;
Form.height = screen.h/6*5; Form.height = screen.h/6*5;
sc.work = COL_WORK;
sc.work_text = COL_WORK_TEXT;
sc.light = COL_LIGHT;
sc.dark = COL_DARK;
sc.line = COL_LINE;
sc.button = COL_BUTTON;
sc.button_text = COL_BUTTON_TEXT;
/* Handle application parameters */ /* Handle application parameters */
//if (!param) open_image("/sys/home.png"); //if (!param) open_image("/sys/home.png");
@ -63,6 +70,10 @@ void main()
mouse.get(); mouse.get();
if (main_image.h > canvas.h) scrollbar_v_mouse stdcall(#scroll_v); 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 (main_image.w > canvas.w) scrollbar_h_mouse stdcall(#scroll_h);
if (active_tool == TOOL_SCALE) {
edit_box_mouse stdcall (#edit_w);
edit_box_mouse stdcall (#edit_h);
}
if (scroll_v.delta) || (scroll_h.delta) draw_canvas(); if (scroll_v.delta) || (scroll_h.delta) draw_canvas();
if (EAX = mouse.vert) { if (EAX = mouse.vert) {
if (EAX<10) event_scroll_canvas(SCAN_CODE_DOWN); if (EAX<10) event_scroll_canvas(SCAN_CODE_DOWN);
@ -76,11 +87,36 @@ void main()
case evButton: case evButton:
pressed_button_id = GetButtonID(); pressed_button_id = GetButtonID();
if (pressed_button_id==1) ExitProcess(); if (pressed_button_id==1) ExitProcess();
keep_ratio.click(pressed_button_id);
button.press(pressed_button_id); button.press(pressed_button_id);
break; break;
case evKey: case evKey:
GetKeys(); GetKeys();
if (active_tool == TOOL_SCALE)
&& (edit_w.flags & ed_focus) || (edit_h.flags & ed_focus) {
if (key_scancode == SCAN_CODE_TAB) {
edit_w.flags >< edit_h.flags;
draw_acive_panel();
break;
}
if (edit_w.flags & ed_focus) {
edit_box_key_c stdcall (#edit_w, key_editbox);
if (keep_ratio.checked) && (text_w) && (atoi(#text_w)) {
EDI = main_image.h*100 / calc(main_image.w*100 / atoi(#text_w));
edit_box_set_text stdcall (#edit_h, itoa(EDI));
edit_box_draw stdcall (#edit_h);
}
} else {
edit_box_key_c stdcall (#edit_h, key_editbox);
if (keep_ratio.checked) && (text_h) && (atoi(#text_h)) {
EDI = main_image.h*100 / calc(main_image.w*100 / atoi(#text_h));
edit_box_set_text stdcall (#edit_w, itoa(EDI));
edit_box_draw stdcall (#edit_w);
}
}
break;
}
if (key_scancode == SCAN_CODE_DOWN) event_scroll_canvas(SCAN_CODE_DOWN); if (key_scancode == SCAN_CODE_DOWN) event_scroll_canvas(SCAN_CODE_DOWN);
if (key_scancode == SCAN_CODE_UP) event_scroll_canvas(SCAN_CODE_UP); if (key_scancode == SCAN_CODE_UP) event_scroll_canvas(SCAN_CODE_UP);
if (key_scancode == SCAN_CODE_LEFT) event_scroll_canvas(SCAN_CODE_LEFT); if (key_scancode == SCAN_CODE_LEFT) event_scroll_canvas(SCAN_CODE_LEFT);
@ -152,9 +188,9 @@ void draw_content()
if (main_image.image) { 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_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_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_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_tool_btn(#event_activate_flprot,0, PAD, tx.inc(GAP_S), 36, "Flip/Rotate ", active_tool & TOOL_FLIP_ROTATE);
draw_tool_btn(#event_activate_scale, 0, PAD, tx.inc(GAP_S), 06, "Scale ", active_tool & TOOL_SCALE);
} }
draw_status_bar(); draw_status_bar();
draw_canvas(); draw_canvas();
@ -279,11 +315,9 @@ void event_set_color_depth() {
} }
} }
void WritePanelText(int _x, _text) { WriteTextWithBg(_x, HEADER_TEXTY, 0xD0, COL_WORK_TEXT, _text, COL_WORK); } void WritePanelText(int _x, _text) { WriteText(_x, HEADER_TEXTY, 0x90, COL_WORK_TEXT, _text); }
void draw_acive_panel() void draw_acive_panel()
{ {
char edit_width_text[8];
edit_box edit_width;
int i, x = CANVASX + PAD; int i, x = CANVASX + PAD;
bool a; bool a;
DrawBar(CANVASX+1, 2, Form.width-CANVASX-64, HEADERH-1, COL_WORK); DrawBar(CANVASX+1, 2, Form.width-CANVASX-64, HEADERH-1, COL_WORK);
@ -294,17 +328,18 @@ void draw_acive_panel()
x += draw_tool_btn(#event_save_png, 0, x, 7, -1, "PNG", saving_type & SAVE_AS_PNG) + 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_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; 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); if (saving_type) draw_tool_btn(#event_save, 0, x, 7, 53, "Export", false);
break; break;
case TOOL_CROP: case TOOL_CROP:
WritePanelText(CANVASX+PAD, "Crop tool"); WritePanelText(CANVASX+PAD, "Crop tool");
break; break;
case TOOL_RESIZE: case TOOL_SCALE:
WritePanelText(CANVASX+PAD, "New width"); WritePanelText(CANVASX+PAD, "New size x");
WritePanelText(CANVASX+PAD+150, "New height"); DefineHiddenButton(edit_w.left-2, edit_w.top-2, 148, 25, 2+BT_NOFRAME);
draw_tool_btn(#event_rotate_left, SCAN_CODE_ENTER, CANVASX + PAD + 300, 7, -1, "Apply", false); DrawEditBox(#edit_w);
EditBox_Create(#edit_width, 9*8+CANVASX+PAD+PAD, HEADER_TEXTY-3, 50, sizeof(edit_width_text), #edit_width_text, 0b); DrawEditBox(#edit_h);
edit_box_draw stdcall (#edit_width); keep_ratio.draw(CANVASX + PAD + 233, HEADER_TEXTY);
draw_tool_btn(#event_scale, SCAN_CODE_ENTER, CANVASX + PAD + 370, 7, -1, "Apply", false);
break; break;
case TOOL_COLOR_DEPTH: case TOOL_COLOR_DEPTH:
WritePanelText(CANVASX+PAD, "Color depth"); WritePanelText(CANVASX+PAD, "Color depth");
@ -323,13 +358,13 @@ void draw_acive_panel()
img_destroy stdcall(EAX); img_destroy stdcall(EAX);
} else { } else {
a = -1; a = -1;
if (Form.width-CANVASX-64 < 652) { if (Form.width-CANVASX-64 < 600) {
button.add(1); button.add(1);
continue; continue;
} }
} }
} }
x += draw_tool_btn(#event_set_color_depth, SCAN_CODE_ENTER, x, 7, -1, libimg_bpp[i], a) + PAD; x += draw_tool_btn(#event_set_color_depth, SCAN_CODE_ENTER, x, 7, -1, libimg_bpp[i], a) + 6;
} }
break; break;
case TOOL_FLIP_ROTATE: case TOOL_FLIP_ROTATE:
@ -362,16 +397,68 @@ 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_save_pnm() { saving_type = SAVE_AS_PNM; draw_acive_panel(); }
void event_activate_export() { active_tool = TOOL_EXPORT; draw_content(); } void event_activate_export() { active_tool = TOOL_EXPORT; draw_content(); }
void event_activate_crop() { active_tool = TOOL_CROP; 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_scale() { active_tool = TOOL_SCALE; set_text_scale_edits(); draw_content(); }
void event_activate_depth() { active_tool = TOOL_COLOR_DEPTH; 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_activate_flprot() { active_tool = TOOL_FLIP_ROTATE; draw_content(); }
void set_text_scale_edits()
{
edit_box_set_text stdcall (#edit_w, itoa(main_image.w));
edit_box_set_text stdcall (#edit_h, itoa(main_image.h));
}
/*
;;================================================================================================;;
proc img.scale _src, _crop_x, _crop_y, _crop_width, _crop_height, _dst, _scale, _inter, _param1, _param2 ;;
;;------------------------------------------------------------------------------------------------;;
;? scale _image ;;
;;------------------------------------------------------------------------------------------------;;
;> [_src] = pointer to source image ;;
;> [_crop_x] = left coord of cropping rect ;;
;> [_crop_y] = top coord of cropping rect ;;
;> [_crop_width] = width of cropping rect ;;
;> [_crop_height] = height of cropping rect ;;
;> [_dst] = pointer to resulting image, 0 to create new one ;;
;> [_scale] = scaling method, see libimg.inc (LIBIMG_SCALE_*) ;;
;> [_inter] = interpolation algorithm, see libimg.inc (LIBIMG_INTER_*) ;;
;> [_param1] = depends on _scale, see libimg.inc ;;
;> [_param2] = depends on _scale, see libimg.inc ;;
;;------------------------------------------------------------------------------------------------;;
;< eax = 0 / pointer to scaled image ;;
;< ecx = error code / undefined ;;
;;================================================================================================;;
*/
//invoke img.scale, eax, 0, 0, [eax+Image.Width], [eax+Image.Height], 0, LIBIMG_SCALE_STRETCH, LIBIMG_INTER_DEFAULT, [view.width], [view.height]
void event_scale()
{
img_scale stdcall (main_image.image, 0, 0, main_image.w, main_image.h, 0,
LIBIMG_SCALE_STRETCH, LIBIMG_INTER_DEFAULT, atoi(#text_w), atoi(#text_h));
if (!EAX) {
if (ECX == 4) {
notify("'ImageEdit Pro\nThis color depth is not supported by Scale feature.\nPlease change color depth to 24 / 32 / 8grey.' -Et");
} else {
debugval("Error code", ECX);
notify("'ImageEdit Pro\nImage scale failed :(' -Et");
}
} else {
$push eax
img_destroy stdcall (main_image.image);
$pop eax
main_image.image = EAX;
main_image.set_vars();
draw_canvas();
}
}
void event_open() void event_open()
{ {
o_dialog.type = 0; //open file o_dialog.type = 0; //open file
OpenDialog_start stdcall (#o_dialog); OpenDialog_start stdcall (#o_dialog);
if (o_dialog.status) { if (o_dialog.status) {
open_image(#openfile_path); open_image(#openfile_path);
active_tool = NULL;
draw_window(); draw_window();
} }
} }

View File

@ -17,6 +17,7 @@ dword box_lib_init = #aboxlib_init;
dword edit_box_draw = #aEdit_box_draw; dword edit_box_draw = #aEdit_box_draw;
dword edit_box_key = #aEdit_box_key; dword edit_box_key = #aEdit_box_key;
dword edit_box_key_c = #aEdit_box_key_c;
dword edit_box_mouse = #aEdit_box_mouse; dword edit_box_mouse = #aEdit_box_mouse;
dword edit_box_set_text = #aEdit_box_set_text; dword edit_box_set_text = #aEdit_box_set_text;
@ -37,6 +38,7 @@ $DD 2 dup 0
char aEdit_box_draw [] = "edit_box"; char aEdit_box_draw [] = "edit_box";
char aEdit_box_key [] = "edit_box_key"; char aEdit_box_key [] = "edit_box_key";
char aEdit_box_key_c[] = "edit_box_key_safe";
char aEdit_box_mouse[] = "edit_box_mouse"; char aEdit_box_mouse[] = "edit_box_mouse";
char aEdit_box_set_text[] = "edit_box_set_text"; char aEdit_box_set_text[] = "edit_box_set_text";
@ -102,27 +104,16 @@ PathShow_draw stdcall(#PathShow);
#define ed_mouse_on_off 1111111011111111b #define ed_mouse_on_off 1111111011111111b
struct edit_box{ struct edit_box{
dword width, dword width, left, top,
left, bg_color, selec_color, focus_border_color, border_color, text_color,
top,
color,
shift_color,
focus_border_color,
blur_border_color,
text_color,
max, max,
text, text,
mouse_variable, mouse_variable,
flags, flags,
size, size, pos, offset,
pos, cl_curs_x, cl_curs_y,
offset, shift, shift_old,
cl_curs_x, height, char_width;
cl_curs_y,
shift,
shift_old,
height,
char_width;
}; };
:void EditBox_UpdateText(dword ed, _flags) :void EditBox_UpdateText(dword ed, _flags)
@ -165,18 +156,12 @@ struct scroll_bar
struct progress_bar struct progress_bar
{ {
dword dword value,
value, left, top,
left, width, height,
top,
width,
height,
style, style,
min, min, max,
max, back_color, progress_color, frame_color;
back_color,
progress_color,
frame_color;
}; };
struct frame struct frame

View File

@ -27,13 +27,12 @@ dword img_encode = #aimg_encode;
dword img_convert = #aimg_convert; dword img_convert = #aimg_convert;
dword img_from_file = #aimg_from_file; dword img_from_file = #aimg_from_file;
dword img_blend = #aimg_blend; dword img_blend = #aimg_blend;
//dword img_is_img = #aimg_is_img;
//dword img_to_rgb2 = #aimg_to_rgb2;
//dword img_scale = #aimg_scale;
dword img_flip = #aimg_flip; dword img_flip = #aimg_flip;
dword img_rotate = #aimg_rotate; dword img_rotate = #aimg_rotate;
dword img_to_rgb = #aimg_to_rgb; dword img_scale = #aimg_scale;
dword resize = #aresize; //dword img_is_img = #aimg_is_img;
//dword img_to_rgb = #aimg_to_rgb;
//dword img_to_rgb2 = #aimg_to_rgb2;
$DD 2 dup 0 $DD 2 dup 0
@ -47,13 +46,12 @@ char aimg_encode[] = "img_encode";
char aimg_convert[] = "img_convert"; char aimg_convert[] = "img_convert";
char aimg_from_file[] = "img_from_file"; char aimg_from_file[] = "img_from_file";
char aimg_blend[] = "img_blend"; char aimg_blend[] = "img_blend";
//char aimg_is_img[] = "img_is_img";
//char aimg_to_rgb2[] = "img_to_rgb2";
//char aimg_scale[] = "img_scale";
char aimg_flip[] = "img_flip"; char aimg_flip[] = "img_flip";
char aimg_rotate[] = "img_rotate"; char aimg_rotate[] = "img_rotate";
char aimg_to_rgb[] = "img_to_rgb"; char aimg_scale[] = "img_scale";
char aresize[] = "img_resize_data"; //char aimg_is_img[] = "img_is_img";
//char aimg_to_rgb[] = "img_to_rgb";
//char aimg_to_rgb2[] = "img_to_rgb2";
#define LIBIMG_FORMAT_BMP 1 #define LIBIMG_FORMAT_BMP 1
#define LIBIMG_FORMAT_ICO 2 #define LIBIMG_FORMAT_ICO 2
@ -85,18 +83,49 @@ char aresize[] = "img_resize_data";
// kernel doesn't handle this image type, // kernel doesn't handle this image type,
// libimg can only create and destroy such images // libimg can only create and destroy such images
//flip and rotate
#define FLIP_VERTICAL 0x01 #define FLIP_VERTICAL 0x01
#define FLIP_HORIZONTAL 0x02 #define FLIP_HORIZONTAL 0x02
#define ROTATE_90_CW 0x01 #define ROTATE_90_CW 0x01
#define ROTATE_180 0x02 #define ROTATE_180 0x02
#define ROTATE_270_CW 0x03 #define ROTATE_270_CW 0x03
#define ROTATE_90_CCW ROTATE_270_CW #define ROTATE_90_CCW ROTATE_270_CW
#define ROTATE_270_CCW ROTATE_90_CW #define ROTATE_270_CCW ROTATE_90_CW
//scale type //corresponding img.scale params
#define LIBIMG_SCALE_NONE 0 //do not scale
#define LIBIMG_SCALE_INTEGER 1 //scale factor, reserved 0
#define LIBIMG_SCALE_TILE 2 //new width, new height
#define LIBIMG_SCALE_STRETCH 3 //new width, new height
#define LIBIMG_SCALE_FIT_BOTH LIBIMG_SCALE_STRETCH
#define LIBIMG_SCALE_FIT_MIN 4 //new width, new height
#define LIBIMG_SCALE_FIT_RECT LIBIMG_SCALE_FIT_MIN
#define LIBIMG_SCALE_FIT_WIDTH 5 //new width, new height
#define LIBIMG_SCALE_FIT_HEIGHT 6 //new width, new height
#define LIBIMG_SCALE_FIT_MAX 7 //new width, new height
//interpolation algorithm
#define LIBIMG_INTER_NONE 0 //use it with LIBIMG_SCALE_INTEGER, LIBIMG_SCALE_TILE, etc
#define LIBIMG_INTER_BILINEAR 1
#define LIBIMG_INTER_DEFAULT LIBIMG_INTER_BILINEAR
/*
// error codes
LIBIMG_ERROR_OUT_OF_MEMORY = 1
LIBIMG_ERROR_FORMAT = 2
LIBIMG_ERROR_CONDITIONS = 3
LIBIMG_ERROR_BIT_DEPTH = 4
LIBIMG_ERROR_ENCODER = 5
LIBIMG_ERROR_SRC_TYPE = 6
LIBIMG_ERROR_SCALE = 7
LIBIMG_ERROR_INTER = 8
LIBIMG_ERROR_NOT_INPLEMENTED = 9
LIBIMG_ERROR_INVALID_INPUT = 10
*/
struct libimg_image struct libimg_image
{ {
dword checksum; // ((Width ROL 16) OR Height) XOR Data[0] ; ignored so far dword checksum; // ((Width ROL 16) OR Height) XOR Data[0] ; ignored so far
dword w; dword w;
dword h; dword h;
dword next; dword next;