Rev 6807 | Rev 7735 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6807 | Rev 7105 | ||
---|---|---|---|
Line 24... | Line 24... | ||
24 | 24 | ||
25 | include '../../../../struct.inc' |
25 | include '../../../../struct.inc' |
26 | include '../../../../proc32.inc' |
26 | include '../../../../proc32.inc' |
27 | include '../../../../macros.inc' |
27 | include '../../../../macros.inc' |
28 | include '../../../../config.inc' |
28 | include '../../../../config.inc' |
- | 29 | include '../../../../debug-fdo.inc' |
|
- | 30 | __DEBUG__ = 0 |
|
- | 31 | __DEBUG_LEVEL__ = 1 |
|
29 | ;include '../../../../debug.inc' |
32 | include '../../../../develop/libraries/libs-dev/libio/libio.inc' |
Line 30... | Line 33... | ||
30 | purge section,mov,add,sub |
33 | purge section,mov,add,sub |
Line 31... | Line 34... | ||
31 | 34 | ||
Line 122... | Line 125... | ||
122 | endp |
125 | endp |
Line 123... | Line 126... | ||
123 | 126 | ||
124 | ;;================================================================================================;; |
127 | ;;================================================================================================;; |
125 | proc img.from_file _filename ;////////////////////////////////////////////////////////////////////;; |
128 | proc img.from_file _filename ;////////////////////////////////////////////////////////////////////;; |
126 | ;;------------------------------------------------------------------------------------------------;; |
129 | ;;------------------------------------------------------------------------------------------------;; |
127 | ;? --- TBD --- ;; |
130 | ;? load file from disk and decode it ;; |
128 | ;;------------------------------------------------------------------------------------------------;; |
131 | ;;------------------------------------------------------------------------------------------------;; |
129 | ;> --- TBD --- ;; |
132 | ;> [_filename] = file name as passed to libio ;; |
130 | ;;------------------------------------------------------------------------------------------------;; |
133 | ;;------------------------------------------------------------------------------------------------;; |
131 | ;< eax = 0 / pointer to image ;; |
134 | ;< eax = 0 / pointer to image ;; |
- | 135 | ;;================================================================================================;; |
|
- | 136 | locals |
|
- | 137 | fd dd ? |
|
- | 138 | img_data_len dd ? |
|
- | 139 | img_data dd ? ; raw bytes |
|
- | 140 | img dd ? ; Image pointer |
|
- | 141 | endl |
|
- | 142 | DEBUGF 2, 'img.from_file: %s\n', [_filename] |
|
- | 143 | push ebx |
|
- | 144 | mov [img], 0 |
|
- | 145 | invoke file.open, [_filename], O_READ |
|
- | 146 | mov [fd], eax |
|
- | 147 | test eax, eax |
|
- | 148 | jz .exit |
|
132 | ;;================================================================================================;; |
149 | invoke file.size, [_filename] |
- | 150 | test eax, eax |
|
- | 151 | jnz .exit_close |
|
- | 152 | mov [img_data_len], ebx |
|
- | 153 | invoke mem.alloc, ebx |
|
- | 154 | test eax, eax |
|
- | 155 | jz .exit_close |
|
- | 156 | mov [img_data], eax |
|
- | 157 | invoke file.read, [fd], eax, [img_data_len] |
|
- | 158 | cmp eax, -1 |
|
- | 159 | jz .exit_free_close |
|
- | 160 | cmp eax, [img_data_len] |
|
- | 161 | jnz .exit_free_close |
|
- | 162 | stdcall img.decode, [img_data], [img_data_len], 0 |
|
- | 163 | test eax, eax |
|
- | 164 | jz .exit_free_close |
|
- | 165 | mov [img], eax |
|
- | 166 | .exit_free_close: |
|
- | 167 | invoke mem.free, [img_data] |
|
- | 168 | .exit_close: |
|
- | 169 | invoke file.close, [fd] |
|
- | 170 | mov eax, [img] |
|
- | 171 | .exit: |
|
133 | xor eax, eax |
172 | pop ebx |
134 | ret |
173 | ret |
Line 135... | Line 174... | ||
135 | endp |
174 | endp |
136 | 175 | ||
Line 2437... | Line 2476... | ||
2437 | .wbmp dd LIBIMG_FORMAT_WBMP, img.is.wbmp, img.decode.wbmp, img.encode.wbmp,0 |
2476 | .wbmp dd LIBIMG_FORMAT_WBMP, img.is.wbmp, img.decode.wbmp, img.encode.wbmp,0 |
2438 | .xbm dd LIBIMG_FORMAT_XBM, img.is.xbm, img.decode.xbm, img.encode.xbm, 0 |
2477 | .xbm dd LIBIMG_FORMAT_XBM, img.is.xbm, img.decode.xbm, img.encode.xbm, 0 |
2439 | .z80 dd LIBIMG_FORMAT_Z80, img.is.z80, img.decode.z80, img.encode.z80, 0 ;this must be the last entry as there are no signatures in z80 screens at all |
2478 | .z80 dd LIBIMG_FORMAT_Z80, img.is.z80, img.decode.z80, img.encode.z80, 0 ;this must be the last entry as there are no signatures in z80 screens at all |
2440 | dd 0 |
2479 | dd 0 |
Line 2441... | Line -... | ||
2441 | - | ||
2442 | align 4 |
- | |
2443 | img.types_table: ; entries order must correspond to type defnitions in libimg.inc |
- | |
2444 | dd 0 ; there is no Image.bpp* = 0 |
- | |
2445 | .bpp8i dd (1 SHL Image.bpp24) |
- | |
2446 | .bpp24 dd (1 SHL Image.bpp24) OR (1 SHL Image.bpp8g) |
- | |
2447 | .bpp32 dd (1 SHL Image.bpp24) |
- | |
2448 | .bpp15 dd (1 SHL Image.bpp24) |
- | |
2449 | .bpp16 dd (1 SHL Image.bpp24) |
- | |
2450 | .bpp1 dd (1 SHL Image.bpp24) |
- | |
2451 | .bpp8g dd (1 SHL Image.bpp24) OR (1 SHL Image.bpp1 ) OR (1 SHL Image.bpp8g) |
- | |
2452 | .bpp8a dd (1 SHL Image.bpp24) |
- | |
2453 | 2480 | ||
2454 | ;;================================================================================================;; |
2481 | ;;================================================================================================;; |
2455 | ;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
2482 | ;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
2456 | ;;================================================================================================;; |
2483 | ;;================================================================================================;; |
2457 | ;! Below are private procs you should never call directly from your code ;; |
2484 | ;! Below are private procs you should never call directly from your code ;; |
Line 2715... | Line 2742... | ||
2715 | ;! Below is private data you should never use directly from your code ;; |
2742 | ;! Below is private data you should never use directly from your code ;; |
2716 | ;;================================================================================================;; |
2743 | ;;================================================================================================;; |
2717 | ;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
2744 | ;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
2718 | ;;================================================================================================;; |
2745 | ;;================================================================================================;; |
Line -... | Line 2746... | ||
- | 2746 | ||
- | 2747 | include_debug_strings |
|
2719 | 2748 | ||
2720 | align 4 |
2749 | align 4 |
2721 | type2bpp dd 8, 24, 32, 15, 16, 1, 9, 2, 4 |
2750 | type2bpp dd 8, 24, 32, 15, 16, 1, 9, 2, 4 |
2722 | img._.do_rgb.handlers: |
2751 | img._.do_rgb.handlers: |
2723 | dd img._.do_rgb.bpp8i |
2752 | dd img._.do_rgb.bpp8i |
Line 2784... | Line 2813... | ||
2784 | ; import from deflate unpacker |
2813 | ; import from deflate unpacker |
2785 | ; is initialized only when PNG loading is requested |
2814 | ; is initialized only when PNG loading is requested |
2786 | align 16 |
2815 | align 16 |
2787 | @IMPORT: |
2816 | @IMPORT: |
Line -... | Line 2817... | ||
- | 2817 | ||
2788 | 2818 | library \ |
|
- | 2819 | archiver, 'archiver.obj', \ |
|
- | 2820 | libio , 'libio.obj' |
|
2789 | library archiver, 'archiver.obj' |
2821 | |
2790 | import archiver, \ |
2822 | import archiver, \ |
2791 | deflate_unpack2, 'deflate_unpack2',\ |
2823 | deflate_unpack2, 'deflate_unpack2',\ |
2792 | deflateInit2, 'deflateInit2',\ |
2824 | deflateInit2, 'deflateInit2',\ |
2793 | deflateReset, 'deflateReset',\ |
2825 | deflateReset, 'deflateReset',\ |
2794 | deflate, 'deflate',\ |
2826 | deflate, 'deflate',\ |
2795 | deflateEnd, 'deflateEnd',\ |
2827 | deflateEnd, 'deflateEnd',\ |
Line -... | Line 2828... | ||
- | 2828 | calc_crc32, 'calc_crc32' |
|
- | 2829 | ||
- | 2830 | import libio , \ |
|
- | 2831 | file.size , 'file_size' , \ |
|
- | 2832 | file.open , 'file_open' , \ |
|
- | 2833 | file.read , 'file_read' , \ |
|
2796 | calc_crc32, 'calc_crc32' |
2834 | file.close, 'file_close' |
2797 | 2835 | ||
2798 | align 4 |
2836 | align 4 |
Line 2799... | Line 2837... | ||
2799 | ; mutex for unpacker loading |
2837 | ; mutex for unpacker loading |