Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6733 | IgorA | 1 | |
2 | |||
3 | |||
4 | ; Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson |
||
5 | ; (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) |
||
6 | ; (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) |
||
7 | |||
8 | |||
9 | ; For conditions of distribution and use, see the disclaimer |
||
10 | ; and license in png.inc |
||
11 | |||
12 | |||
13 | ; special handling are expected to write functions that have the same |
||
14 | ; arguments as these and perform similar functions, but that possibly |
||
15 | ; use different output methods. Note that you shouldn't change these |
||
16 | ; functions, but rather write replacement functions and then change |
||
17 | ; them at run time with png_set_write_fn(...). |
||
18 | |||
19 | |||
20 | |||
21 | ; writes to a file pointer. Note that this routine sometimes gets called |
||
22 | ; with very small lengths, so you should implement some kind of simple |
||
23 | ; buffering if you are using unbuffered writes. This should never be asked |
||
24 | ; to write more than 64K on a 16-bit machine. |
||
25 | |||
26 | |||
27 | align 4 |
||
28 | proc png_write_data uses edi, png_ptr:dword, p2data:dword, length:dword |
||
29 | ; NOTE: write_data_fn must not change the buffer! |
||
30 | mov edi,[png_ptr] |
||
31 | cmp dword[edi+png_struct.write_data_fn],0 |
||
32 | je @f ;if (..!=0) |
||
33 | stdcall dword[edi+png_struct.write_data_fn], edi, [p2data], [length] |
||
34 | jmp .end_f |
||
35 | @@: ;else |
||
36 | png_error edi, 'Call to NULL write function' |
||
37 | .end_f: |
||
38 | ret |
||
39 | endp |
||
40 | |||
41 | |||
42 | ; not writing to a standard C stream, you should create a replacement |
||
43 | ; write_data function and use it at run time with png_set_write_fn(), rather |
||
44 | ; than changing the library. |
||
45 | |||
46 | |||
47 | align 4 |
||
48 | proc png_default_write_data uses eax edi, png_ptr:dword, p2data:dword, length:dword |
||
49 | ; png_size_t check; |
||
50 | |||
51 | |||
52 | cmp edi,0 |
||
53 | je .end_f ;if (..==0) return |
||
54 | |||
55 | |||
56 | |||
57 | |||
58 | ; png_error(png_ptr, "Write Error"); |
||
59 | .end_f: |
||
60 | ret |
||
61 | endp |
||
62 | |||
63 | |||
64 | ; to disk). After png_flush is called, there should be no data pending |
||
65 | ; writing in any buffers. |
||
66 | |||
67 | |||
68 | align 4 |
||
69 | proc png_flush uses edi, png_ptr:dword |
||
70 | mov edi,[png_ptr] |
||
71 | cmp dword[edi+png_struct.output_flush_fn],0 |
||
72 | je @f ;if (..!=..) |
||
73 | stdcall dword[edi+png_struct.output_flush_fn],edi |
||
74 | @@: |
||
75 | ret |
||
76 | endp |
||
77 | |||
78 | |||
79 | align 4 |
||
80 | proc png_default_flush uses eax edi, png_ptr:dword |
||
81 | mov edi,[png_ptr] |
||
82 | cmp edi,0 |
||
83 | je @f ;if (..==0) return |
||
84 | ;;; stdcall fflush, [edi+png_struct.io_ptr] |
||
85 | @@: |
||
86 | ret |
||
87 | endp |
||
88 | |||
89 | |||
90 | ; libpng if standard C streams aren't being used. |
||
91 | |||
92 | |||
93 | ; png_ptr - pointer to a png output data structure |
||
94 | ; io_ptr - pointer to user supplied structure containing info about |
||
95 | ; the output functions. May be NULL. |
||
96 | ; write_data_fn - pointer to a new output function that takes as its |
||
97 | ; arguments a pointer to a png_struct, a pointer to |
||
98 | ; data to be written, and a 32-bit unsigned int that is |
||
99 | ; the number of bytes to be written. The new write |
||
100 | ; function should call png_error(png_ptr, "Error msg") |
||
101 | ; to exit and output any fatal error messages. May be |
||
102 | ; NULL, in which case libpng's default function will |
||
103 | ; be used. |
||
104 | ; flush_data_fn - pointer to a new flush function that takes as its |
||
105 | ; arguments a pointer to a png_struct. After a call to |
||
106 | ; the flush function, there should be no data in any buffers |
||
107 | ; or pending transmission. If the output method doesn't do |
||
108 | ; any buffering of output, a function prototype must still be |
||
109 | ; supplied although it doesn't have to do anything. If |
||
110 | ; PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile |
||
111 | ; time, output_flush_fn will be ignored, although it must be |
||
112 | ; supplied for compatibility. May be NULL, in which case |
||
113 | ; libpng's default function will be used, if |
||
114 | ; PNG_WRITE_FLUSH_SUPPORTED is defined. This is not |
||
115 | ; a good idea if io_ptr does not point to a standard |
||
116 | ; *FILE structure. |
||
117 | |||
118 | |||
119 | ; png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) |
||
120 | align 4 |
||
121 | proc png_set_write_fn uses eax edi, png_ptr:dword, io_ptr:dword, write_data_fn:dword, output_flush_fn:dword |
||
122 | mov edi,[png_ptr] |
||
123 | cmp edi,0 |
||
124 | je .end_f ;if (..==0) return |
||
125 | |||
126 | |||
127 | mov [edi+png_struct.io_ptr],eax |
||
128 | |||
129 | |||
130 | mov eax,png_default_write_data ;else |
||
131 | cmp dword[write_data_fn],0 |
||
132 | je @f ;if (..!=0) |
||
133 | mov eax,[write_data_fn] |
||
134 | @@: |
||
135 | else |
||
136 | mov eax,[write_data_fn] |
||
137 | end if |
||
138 | mov [edi+png_struct.write_data_fn],eax |
||
139 | |||
140 | |||
141 | if PNG_STDIO_SUPPORTED eq 1 |
||
142 | mov eax,[png_default_flush] ;else |
||
143 | cmp dword[output_flush_fn],0 |
||
144 | je @f ;if (..!=0) |
||
145 | mov eax,[output_flush_fn] |
||
146 | @@: |
||
147 | else |
||
148 | mov eax,[output_flush_fn] |
||
149 | end if |
||
150 | mov [edi+png_struct.output_flush_fn],eax |
||
151 | end if ;WRITE_FLUSH |
||
152 | |||
153 | |||
154 | ; It is an error to read while writing a png file |
||
155 | cmp dword[edi+png_struct.read_data_fn],0 |
||
156 | je @f ;if (..!=0) |
||
157 | mov dword[edi+png_struct.read_data_fn], 0 |
||
158 | |||
159 | |||
160 | @@: |
||
161 | end if |
||
162 | .end_f: |
||
163 | ret |
||
164 | endp'Can',39,'t> |
||
165 |