Rev 5626 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3107 | leency | 1 | //Asper |
5598 | pavelyakov | 2 | #ifndef INCLUDE_LIBIMG_H |
3 | #define INCLUDE_LIBIMG_H |
||
5676 | pavelyakov | 4 | #print "[include |
3107 | leency | 5 | |
5598 | pavelyakov | 6 | #ifndef INCLUDE_KOLIBRI_H |
7 | #include "../lib/kolibri.h" |
||
8 | #endif |
||
9 | |||
10 | #ifndef INCLUDE_MEM_H |
||
11 | #include "../lib/mem.h" |
||
12 | #endif |
||
13 | |||
14 | #ifndef INCLUDE_DLL_H |
||
15 | #include "../lib/dll.h" |
||
16 | #endif |
||
17 | |||
18 | #ifndef INCLUDE_LIBIO_H |
||
19 | #include "../lib/obj/libio_lib.h" |
||
20 | #endif |
||
21 | |||
22 | :byte init_imglib_check; |
||
23 | |||
3107 | leency | 24 | //library |
25 | dword libimg = #alibimg; |
||
26 | char alibimg[21] = "/sys/lib/libimg.obj\0"; |
||
5626 | leency | 27 | |
3107 | leency | 28 | dword libimg_init = #alibimg_init; |
29 | dword img_is_img = #aimg_is_img; |
||
30 | dword img_to_rgb2 = #aimg_to_rgb2; |
||
31 | dword img_decode = #aimg_decode; |
||
32 | dword img_destroy = #aimg_destroy; |
||
33 | dword img_draw = #aimg_draw; |
||
34 | //dword img_flip = #aimg_flip; |
||
35 | //dword img_rotate = #aimg_rotate; |
||
3839 | Asper | 36 | $DD 2 dup 0 |
3107 | leency | 37 | |
38 | //import libimg , \ |
||
39 | char alibimg_init[9] = "lib_init\0"; |
||
40 | char aimg_is_img[11] = "img_is_img\0"; |
||
41 | char aimg_to_rgb2[12] = "img_to_rgb2\0"; |
||
42 | char aimg_decode[11] = "img_decode\0"; |
||
43 | char aimg_destroy[12] = "img_destroy\0"; |
||
44 | char aimg_draw[9] = "img_draw\0"; |
||
45 | //char aimg_flip[9] = "img_flip\0"; |
||
46 | //char aimg_rotate[11] = "img_rotate\0 "; |
||
47 | |||
48 | |||
49 | |||
50 | dword load_image(dword filename) |
||
51 | { |
||
52 | //align 4 |
||
53 | dword img_data=0; |
||
54 | dword img_data_len=0; |
||
55 | dword fh=0; |
||
56 | dword image=0; |
||
57 | |||
58 | byte tmp_buf[40]; |
||
59 | $and img_data, 0 |
||
60 | //$mov eax, filename |
||
61 | //$push eax |
||
62 | //invoke file.open, eax, O_READ |
||
63 | file_open stdcall (filename, O_READ); |
||
64 | $or eax, eax |
||
65 | $jnz loc05 |
||
66 | $stc |
||
67 | return 0; |
||
68 | @loc05: |
||
69 | $mov fh, eax |
||
70 | //invoke file.size |
||
71 | file_size stdcall (filename); |
||
72 | $mov img_data_len, ebx |
||
73 | //stdcall mem.Alloc, ebx |
||
74 | mem_Alloc(EBX); |
||
75 | |||
76 | $test eax, eax |
||
77 | $jz error_close |
||
78 | $mov img_data, eax |
||
79 | //invoke file.read, [fh], eax, [img_data_len] |
||
80 | file_read stdcall (fh, EAX, img_data_len); |
||
81 | $cmp eax, -1 |
||
82 | $jz error_close |
||
83 | $cmp eax, img_data_len |
||
84 | $jnz error_close |
||
85 | //invoke file.close, [fh] |
||
86 | file_close stdcall (fh); |
||
87 | $inc eax |
||
88 | $jz error_ |
||
89 | //; img.decode checks for img.is_img |
||
90 | //; //invoke img.is_img, [img_data], [img_data_len] |
||
91 | //; $or eax, eax |
||
92 | //; $jz exit |
||
93 | //invoke img.decode, [img_data], [img_data_len], 0 |
||
94 | EAX=img_data; |
||
95 | img_decode stdcall (EAX, img_data_len,0); |
||
96 | $or eax, eax |
||
97 | $jz error_ |
||
98 | $cmp image, 0 |
||
99 | $pushf |
||
100 | $mov image, eax |
||
101 | //call init_frame |
||
102 | $popf |
||
103 | //call update_image_sizes |
||
104 | mem_Free(img_data);//free_img_data(img_data); |
||
105 | $clc |
||
106 | return image; |
||
107 | |||
108 | @error_free: |
||
109 | //invoke img.destroy, [image] |
||
110 | img_destroy stdcall (image); |
||
111 | $jmp error_ |
||
112 | |||
113 | @error_pop: |
||
114 | $pop eax |
||
115 | $jmp error_ |
||
116 | @error_close: |
||
117 | //invoke file.close, [fh] |
||
118 | file_close stdcall (fh); |
||
119 | @error_: |
||
120 | mem_Free(img_data); |
||
121 | $stc |
||
122 | return 0; |
||
123 | } |
||
5598 | pavelyakov | 124 | |
125 | #endif |