Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3067 leency 1
//Asper
2
 
3
//library
4
dword libimg = #alibimg;
5
char alibimg[21] = "/sys/lib/libimg.obj\0";
6
 
7
dword libimg_init = #alibimg_init;
8
dword img_is_img  = #aimg_is_img;
9
dword img_to_rgb2 = #aimg_to_rgb2;
10
dword img_decode  = #aimg_decode;
11
dword img_destroy = #aimg_destroy;
12
dword img_draw    = #aimg_draw;
13
//dword img_flip    = #aimg_flip;
14
//dword img_rotate  = #aimg_rotate;
15
 
16
dword  am1__ = 0x0;
17
dword  bm1__ = 0x0;
18
 
19
//import  libimg                     , \
20
char alibimg_init[9] = "lib_init\0";
21
char aimg_is_img[11]  = "img_is_img\0";
22
char aimg_to_rgb2[12] = "img_to_rgb2\0";
23
char aimg_decode[11]  = "img_decode\0";
24
char aimg_destroy[12] = "img_destroy\0";
25
char aimg_draw[9]    = "img_draw\0";
26
//char aimg_flip[9]    = "img_flip\0";
27
//char aimg_rotate[11]  = "img_rotate\0 ";
28
 
29
 
30
 
31
dword load_image(dword filename)
32
{
33
        //align 4
34
        dword img_data=0;
35
        dword img_data_len=0;
36
        dword fh=0;
37
        dword image=0;
38
 
39
        byte tmp_buf[40];
40
        $and     img_data, 0
41
        //$mov     eax, filename
42
        //$push    eax
43
        //invoke  file.open, eax, O_READ
44
        file_open stdcall (filename, O_READ);
45
        $or      eax, eax
46
        $jnz      loc05
47
        $stc
48
        return 0;
49
    @loc05:
50
        $mov     fh, eax
51
        //invoke  file.size
52
        file_size stdcall (filename);
53
        $mov     img_data_len, ebx
54
        //stdcall mem.Alloc, ebx
55
        mem_Alloc(EBX);
56
 
57
        $test    eax, eax
58
        $jz      error_close
59
        $mov     img_data, eax
60
        //invoke  file.read, [fh], eax, [img_data_len]
61
        file_read stdcall (fh, EAX, img_data_len);
62
        $cmp     eax, -1
63
        $jz      error_close
64
        $cmp     eax, img_data_len
65
        $jnz     error_close
66
        //invoke  file.close, [fh]
67
        file_close stdcall (fh);
68
        $inc     eax
69
        $jz      error_
70
//; img.decode checks for img.is_img
71
//;       //invoke  img.is_img, [img_data], [img_data_len]
72
//;       $or      eax, eax
73
//;       $jz      exit
74
        //invoke  img.decode, [img_data], [img_data_len], 0
75
        EAX=img_data;
76
        img_decode stdcall (EAX, img_data_len,0);
77
        $or      eax, eax
78
        $jz      error_
79
        $cmp     image, 0
80
        $pushf
81
        $mov     image, eax
82
        //call    init_frame
83
        $popf
84
        //call    update_image_sizes
85
        mem_Free(img_data);//free_img_data(img_data);
86
        $clc
87
        return image;
88
 
89
@error_free:
90
        //invoke  img.destroy, [image]
91
        img_destroy stdcall (image);
92
        $jmp     error_
93
 
94
@error_pop:
95
        $pop     eax
96
        $jmp     error_
97
@error_close:
98
        //invoke  file.close, [fh]
99
        file_close stdcall (fh);
100
@error_:
101
        mem_Free(img_data);
102
        $stc
103
        return 0;
104
}