Subversion Repositories Kolibri OS

Rev

Rev 6733 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6733 IgorA 1
 
2
3
 
4
; Copyright (c) 1998-2002,2004,2006-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
 
14
align 4
15
proc png_get_valid, png_ptr:dword, info_ptr:dword, flag:dword
16
	mov eax,[png_ptr]
17
	cmp eax,0
18
	je @f
19
	mov eax,[info_ptr]
20
	cmp eax,0
21
	je @f ;if (..!=0 || ..!=0)
22
		mov eax,[eax+png_info_def.valid]
23
		and eax,[flag]
24
	@@:
25
	ret
26
endp
27
28
 
29
align 4
30
proc png_get_rowbytes, png_ptr:dword, info_ptr:dword
31
	mov eax,[png_ptr]
32
	cmp eax,0
33
	je @f
34
	mov eax,[info_ptr]
35
	cmp eax,0
36
	je @f ;if (..!=0 || ..!=0)
37
		mov eax,[eax+png_info_def.rowbytes]
38
	@@:
39
	ret
40
endp
41
42
 
43
align 4
44
proc png_get_rows, png_ptr:dword, info_ptr:dword
45
	mov eax,[png_ptr]
46
	cmp eax,0
47
	je @f
48
	mov eax,[info_ptr]
49
	cmp eax,0
50
	je @f ;if (..!=0 || ..!=0)
51
		mov eax,[eax+png_info_def.row_pointers]
52
	@@:
53
	ret
54
endp
55
56
 
57
;uint_32 (png_structrp png_ptr, png_inforp info_ptr)
58
align 4
59
proc png_get_image_width, png_ptr:dword, info_ptr:dword
60
	mov eax,[png_ptr]
61
	cmp eax,0
62
	je @f
63
	mov eax,[info_ptr]
64
	cmp eax,0
65
	je @f ;if (..!=0 || ..!=0)
66
		mov eax,[eax+png_info_def.width]
67
	@@:
68
	ret
69
endp
70
71
 
72
align 4
73
proc png_get_image_height, png_ptr:dword, info_ptr:dword
74
	mov eax,[png_ptr]
75
	cmp eax,0
76
	je @f
77
	mov eax,[info_ptr]
78
	cmp eax,0
79
	je @f ;if (..!=0 || ..!=0)
80
		mov eax,[eax+png_info_def.height]
81
	@@:
82
	ret
83
endp
84
85
 
86
align 4
87
proc png_get_bit_depth, png_ptr:dword, info_ptr:dword
88
	mov eax,[png_ptr]
89
	cmp eax,0
90
	je @f
91
	mov eax,[info_ptr]
92
	cmp eax,0
93
	je @f ;if (..!=0 || ..!=0)
94
		movzx eax,byte[eax+png_info_def.bit_depth]
95
	@@:
96
	ret
97
endp
98
99
 
100
align 4
101
proc png_get_color_type, png_ptr:dword, info_ptr:dword
102
	mov eax,[png_ptr]
103
	cmp eax,0
104
	je @f
105
	mov eax,[info_ptr]
106
	cmp eax,0
107
	je @f ;if (..!=0 || ..!=0)
108
		movzx eax,byte[eax+png_info_def.color_type]
109
	@@:
110
	ret
111
endp
112
113
 
114
align 4
115
proc png_get_filter_type, png_ptr:dword, info_ptr:dword
116
	mov eax,[png_ptr]
117
	cmp eax,0
118
	je @f
119
	mov eax,[info_ptr]
120
	cmp eax,0
121
	je @f ;if (..!=0 || ..!=0)
122
		movzx eax,byte[eax+png_info_def.filter_type]
123
	@@:
124
	ret
125
endp
126
127
 
128
align 4
129
proc png_get_interlace_type, png_ptr:dword, info_ptr:dword
130
	mov eax,[png_ptr]
131
	cmp eax,0
132
	je @f
133
	mov eax,[info_ptr]
134
	cmp eax,0
135
	je @f ;if (..!=0 || ..!=0)
136
		movzx eax,byte[eax+png_info_def.interlace_type]
137
	@@:
138
	ret
139
endp
140
141
 
142
align 4
143
proc png_get_compression_type, png_ptr:dword, info_ptr:dword
144
	mov eax,[png_ptr]
145
	cmp eax,0
146
	je @f
147
	mov eax,[info_ptr]
148
	cmp eax,0
149
	je @f ;if (..!=0 || ..!=0)
150
		mov eax,[eax+png_info_def.compression_type]
151
	@@:
152
	ret
153
endp
154
155
 
156
align 4
157
proc png_get_x_pixels_per_meter, png_ptr:dword, info_ptr:dword
158
if PNG_pHYs_SUPPORTED eq 1
159
	mov eax,[png_ptr]
160
	cmp eax,0
161
	je @f
162
	mov esi,[info_ptr]
163
	cmp esi,0
164
	je @f
165
	mov eax,[esi+png_info_def.valid]
166
	and eax,PNG_INFO_pHYs
167
	cmp eax,0
168
	je @f ;if (..!=0 && ..!=0 && ..!=0)
169
		png_debug1 1, 'in %s retrieval function', 'png_get_x_pixels_per_meter'
170
171
 
172
		jne @f ;if (..==..)
173
			mov eax,[esi+png_info_def.x_pixels_per_unit]
174
			jmp .end_f
175
	@@:
176
end if
177
	xor eax,eax
178
.end_f:
179
	ret
180
endp
181
182
 
183
align 4
184
proc png_get_y_pixels_per_meter, png_ptr:dword, info_ptr:dword
185
if PNG_pHYs_SUPPORTED eq 1
186
	mov eax,[png_ptr]
187
	cmp eax,0
188
	je @f
189
	mov esi,[info_ptr]
190
	cmp esi,0
191
	je @f
192
	mov eax,[esi+png_info_def.valid]
193
	and eax,PNG_INFO_pHYs
194
	cmp eax,0
195
	je @f ;if (..!=0 && ..!=0 && ..!=0)
196
		png_debug1 1, 'in %s retrieval function', 'png_get_y_pixels_per_meter'
197
198
 
199
		jne @f ;if (..==..)
200
			mov eax,[esi+png_info_def.y_pixels_per_unit]
201
			jmp .end_f
202
	@@:
203
end if
204
	xor eax,eax
205
.end_f:
206
	ret
207
endp
208
209
 
210
align 4
211
proc png_get_pixels_per_meter uses esi, png_ptr:dword, info_ptr:dword
212
if PNG_pHYs_SUPPORTED eq 1
213
	mov eax,[png_ptr]
214
	cmp eax,0
215
	je @f
216
	mov esi,[info_ptr]
217
	cmp esi,0
218
	je @f
219
	mov eax,[esi+png_info_def.valid]
220
	and eax,PNG_INFO_pHYs
221
	cmp eax,0
222
	je @f ;if (..!=0 && ..!=0 && ..!=0)
223
		png_debug1 1, 'in %s retrieval function', 'png_get_pixels_per_meter'
224
225
 
226
		jne @f
227
		mov eax,[esi+png_info_def.x_pixels_per_unit]
228
		cmp eax,[esi+png_info_def.y_pixels_per_unit]
229
		jne @f ;if (..==.. && ..==..)
230
			jmp .end_f
231
	@@:
232
end if
233
	xor eax,eax
234
.end_f:
235
	ret
236
endp
237
238
 
239
align 4
240
proc png_get_pixel_aspect_ratio, png_ptr:dword, info_ptr:dword
241
if PNG_READ_pHYs_SUPPORTED eq 1
242
;   if (png_ptr != NULL && info_ptr != NULL &&
243
;       (info_ptr->valid & PNG_INFO_pHYs) != 0)
244
;   {
245
		png_debug1 1, 'in %s retrieval function', 'png_get_aspect_ratio'
246
247
 
248
;         return ((float)((float)info_ptr->y_pixels_per_unit
249
;             /(float)info_ptr->x_pixels_per_unit));
250
;   }
251
end if
252
253
 
254
	ret
255
endp
256
257
 
258
align 4
259
proc png_get_pixel_aspect_ratio_fixed, png_ptr:dword, info_ptr:dword
260
if PNG_READ_pHYs_SUPPORTED eq 1
261
;   if (png_ptr != NULL && info_ptr != NULL &&
262
;       (info_ptr->valid & PNG_INFO_pHYs) != 0 &&
263
;       info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 &&
264
;       info_ptr->x_pixels_per_unit <= PNG_UINT_31_MAX &&
265
;       info_ptr->y_pixels_per_unit <= PNG_UINT_31_MAX)
266
;   {
267
;      png_fixed_point res;
268
269
 
270
271
 
272
	; range of 0..2^31-1; otherwise the cast might overflow.
273
274
 
275
;          (int_32)info_ptr->x_pixels_per_unit) != 0)
276
;         return res;
277
;   }
278
end if
279
280
 
281
	ret
282
endp
283
284
 
285
align 4
286
proc png_get_x_offset_microns, png_ptr:dword, info_ptr:dword
287
if PNG_oFFs_SUPPORTED eq 1
288
;   if (png_ptr != NULL && info_ptr != NULL &&
289
;       (info_ptr->valid & PNG_INFO_oFFs) != 0)
290
;   {
291
		png_debug1 1, 'in %s retrieval function', 'png_get_x_offset_microns'
292
293
 
294
;         return (info_ptr->x_offset);
295
;   }
296
end if
297
298
 
299
	ret
300
endp
301
302
 
303
align 4
304
proc png_get_y_offset_microns, png_ptr:dword, info_ptr:dword
305
if PNG_oFFs_SUPPORTED eq 1
306
;   if (png_ptr != NULL && info_ptr != NULL &&
307
;       (info_ptr->valid & PNG_INFO_oFFs) != 0)
308
;   {
309
		png_debug1 1, 'in %s retrieval function', 'png_get_y_offset_microns'
310
311
 
312
;         return (info_ptr->y_offset);
313
;   }
314
end if
315
316
 
317
	ret
318
endp
319
320
 
321
align 4
322
proc png_get_x_offset_pixels, png_ptr:dword, info_ptr:dword
323
if PNG_oFFs_SUPPORTED eq 1
324
;   if (png_ptr != NULL && info_ptr != NULL &&
325
;       (info_ptr->valid & PNG_INFO_oFFs) != 0)
326
;   {
327
		png_debug1 1, 'in %s retrieval function', 'png_get_x_offset_pixels'
328
329
 
330
;         return (info_ptr->x_offset);
331
;   }
332
end if
333
334
 
335
	ret
336
endp
337
338
 
339
align 4
340
proc png_get_y_offset_pixels, png_ptr:dword, info_ptr:dword
341
if PNG_oFFs_SUPPORTED eq 1
342
;   if (png_ptr != NULL && info_ptr != NULL &&
343
;       (info_ptr->valid & PNG_INFO_oFFs) != 0)
344
;   {
345
		png_debug1 1, 'in %s retrieval function', 'png_get_y_offset_pixels'
346
347
 
348
;         return (info_ptr->y_offset);
349
;   }
350
end if
351
352
 
353
	ret
354
endp
355
356
 
357
align 4
358
proc ppi_from_ppm, ppm:dword
359
;#if 0
360
	; The conversion is *(2.54/100), in binary (32 digits):
361
	; .00000110100000001001110101001001
362
363
 
364
;   ppm >>= 1;                  /* .1 */
365
;   t1001 = ppm + (ppm >> 3);   /* .1001 */
366
;   t1101 = t1001 + (ppm >> 1); /* .1101 */
367
;   ppm >>= 20;                 /* .000000000000000000001 */
368
;   t1101 += t1101 >> 15;       /* .1101000000000001101 */
369
;   t1001 >>= 11;               /* .000000000001001 */
370
;   t1001 += t1001 >> 12;       /* .000000000001001000000001001 */
371
;   ppm += t1001;               /* .000000000001001000001001001 */
372
;   ppm += t1101;               /* .110100000001001110101001001 */
373
;   return (ppm + 16) >> 5;/* .00000110100000001001110101001001 */
374
;#else
375
	; The argument is a PNG unsigned integer, so it is not permitted
376
	; to be bigger than 2^31.
377
378
 
379
;   if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (int_32)ppm, 127,
380
;       5000) != 0)
381
;      return result;
382
383
 
384
;   return 0;
385
;end if
386
	ret
387
endp
388
389
 
390
align 4
391
proc png_get_pixels_per_inch, png_ptr:dword, info_ptr:dword
392
	stdcall png_get_pixels_per_meter, [png_ptr], [info_ptr]
393
	stdcall ppi_from_ppm, eax
394
	ret
395
endp
396
397
 
398
align 4
399
proc png_get_x_pixels_per_inch, png_ptr:dword, info_ptr:dword
400
	stdcall png_get_x_pixels_per_meter, [png_ptr], [info_ptr]
401
	stdcall ppi_from_ppm, eax
402
	ret
403
endp
404
405
 
406
align 4
407
proc png_get_y_pixels_per_inch, png_ptr:dword, info_ptr:dword
408
	stdcall png_get_y_pixels_per_meter, [png_ptr], [info_ptr]
409
	stdcall ppi_from_ppm, eax
410
	ret
411
endp
412
413
 
414
align 4
415
proc png_fixed_inches_from_microns, png_ptr:dword, microns:dword
416
	; Convert from metres * 1,000,000 to inches * 100,000, meters to
417
	; inches is simply *(100/2.54), so we want *(10/2.54) == 500/127.
418
	; Notice that this can overflow - a warning is output and 0 is
419
	; returned.
420
421
 
422
	ret
423
endp
424
425
 
426
align 4
427
proc png_get_x_offset_inches_fixed, png_ptr:dword, info_ptr:dword
428
	stdcall png_get_x_offset_microns, [png_ptr], [info_ptr]
429
	stdcall png_fixed_inches_from_microns, [png_ptr], eax
430
	ret
431
endp
432
433
 
434
align 4
435
proc png_get_y_offset_inches_fixed, png_ptr:dword, info_ptr:dword
436
	stdcall png_get_y_offset_microns, [png_ptr], [info_ptr]
437
	stdcall png_fixed_inches_from_microns, [png_ptr], eax
438
	ret
439
endp
440
441
 
442
align 4
443
proc png_get_x_offset_inches, png_ptr:dword, info_ptr:dword
444
	; To avoid the overflow do the conversion directly in floating
445
	; point.
446
447
 
448
	ret
449
endp
450
451
 
452
align 4
453
proc png_get_y_offset_inches, png_ptr:dword, info_ptr:dword
454
	; To avoid the overflow do the conversion directly in floating
455
	; point.
456
457
 
458
	ret
459
endp
460
461
 
462
;    uint_32 *res_x, uint_32 *res_y, int *unit_type)
463
align 4
464
proc png_get_pHYs_dpi, png_ptr:dword, info_ptr:dword, res_x:dword, res_y:dword, unit_type:dword
465
;   uint_32 retval = 0;
466
467
 
468
;       (info_ptr->valid & PNG_INFO_pHYs) != 0)
469
;   {
470
		png_debug1 1, 'in %s retrieval function', 'pHYs'
471
472
 
473
;      {
474
;         *res_x = info_ptr->x_pixels_per_unit;
475
;         retval |= PNG_INFO_pHYs;
476
;      }
477
478
 
479
;      {
480
;         *res_y = info_ptr->y_pixels_per_unit;
481
;         retval |= PNG_INFO_pHYs;
482
;      }
483
484
 
485
;      {
486
;         *unit_type = (int)info_ptr->phys_unit_type;
487
;         retval |= PNG_INFO_pHYs;
488
489
 
490
;         {
491
;            if (res_x != NULL) *res_x = (uint_32)(*res_x * .0254 + .50);
492
;            if (res_y != NULL) *res_y = (uint_32)(*res_y * .0254 + .50);
493
;         }
494
;      }
495
;   }
496
497
 
498
	ret
499
endp
500
501
 
502
503
 
504
align 4
505
proc png_get_channels, png_ptr:dword, info_ptr:dword
506
	mov eax,[png_ptr]
507
	cmp eax,0
508
	je @f
509
	mov eax,[info_ptr]
510
	cmp eax,0
511
	je @f ;if (..!=0 || ..!=0)
512
		movzx eax,byte[eax+png_info_def.channels]
513
	@@:
514
	ret
515
endp
516
517
 
518
align 4
519
proc png_get_signature, png_ptr:dword, info_ptr:dword
520
	mov eax,[png_ptr]
521
	cmp eax,0
522
	je @f
523
	mov eax,[info_ptr]
524
	cmp eax,0
525
	je @f ;if (..!=0 || ..!=0)
526
		movzx eax,byte[eax+png_info_def.signature]
527
	@@:
528
	ret
529
endp
530
531
 
532
;    png_color_16p *background)
533
align 4
534
proc png_get_bKGD, png_ptr:dword, info_ptr:dword, background:dword
535
;   if (png_ptr != NULL && info_ptr != NULL &&
536
;       (info_ptr->valid & PNG_INFO_bKGD) != 0 &&
537
;       background != NULL)
538
;   {
539
		png_debug1 1, 'in %s retrieval function', 'bKGD'
540
541
 
542
;      return (PNG_INFO_bKGD);
543
;   }
544
545
 
546
	ret
547
endp
548
549
 
550
; The XYZ APIs were added in 1.5.5 to take advantage of the code added at the
551
; same time to correct the rgb grayscale coefficient defaults obtained from the
552
; cHRM chunk in 1.5.4
553
554
 
555
;    double *white_x, double *white_y, double *red_x, double *red_y,
556
;    double *green_x, double *green_y, double *blue_x, double *blue_y)
557
align 4
558
proc png_get_cHRM, png_ptr:dword, info_ptr:dword, white_x:dword, white_y:dword, red_x:dword, red_y:dword, green_x:dword, green_y:dword, blue_x:dword, blue_y:dword
559
	; Quiet API change: this code used to only return the end points if a cHRM
560
	; chunk was present, but the end points can also come from iCCP or sRGB
561
	; chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and
562
	; the png_set_ APIs merely check that set end points are mutually
563
	; consistent.
564
565
 
566
;      (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
567
;   {
568
		png_debug1 1, 'in %s retrieval function', 'cHRM'
569
570
 
571
;         *white_x = png_float(png_ptr,
572
;             info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
573
;      if (white_y != NULL)
574
;         *white_y = png_float(png_ptr,
575
;             info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
576
;      if (red_x != NULL)
577
;         *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx,
578
;             "cHRM red X");
579
;      if (red_y != NULL)
580
;         *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy,
581
;             "cHRM red Y");
582
;      if (green_x != NULL)
583
;         *green_x = png_float(png_ptr,
584
;             info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
585
;      if (green_y != NULL)
586
;         *green_y = png_float(png_ptr,
587
;             info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
588
;      if (blue_x != NULL)
589
;         *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex,
590
;             "cHRM blue X");
591
;      if (blue_y != NULL)
592
;         *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
593
;             "cHRM blue Y");
594
;      return (PNG_INFO_cHRM);
595
;   }
596
597
 
598
	ret
599
endp
600
601
 
602
;    double *red_X, double *red_Y, double *red_Z, double *green_X,
603
;    double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
604
;    double *blue_Z)
605
align 4
606
proc png_get_cHRM_XYZ, png_ptr:dword, info_ptr:dword, red_X:dword, red_Y:dword, red_Z:dword, green_X:dword, green_Y:dword, green_Z:dword, blue_X:dword, blue_Y:dword, blue_Z:dword
607
;   if (png_ptr != NULL && info_ptr != NULL &&
608
;       (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
609
;   {
610
		png_debug1 1, 'in %s retrieval function', 'cHRM_XYZ(float)'
611
612
 
613
;         *red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,
614
;             "cHRM red X");
615
;      if (red_Y != NULL)
616
;         *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y,
617
;             "cHRM red Y");
618
;      if (red_Z != NULL)
619
;         *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z,
620
;             "cHRM red Z");
621
;      if (green_X != NULL)
622
;         *green_X = png_float(png_ptr,
623
;             info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X");
624
;      if (green_Y != NULL)
625
;         *green_Y = png_float(png_ptr,
626
;             info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y");
627
;      if (green_Z != NULL)
628
;         *green_Z = png_float(png_ptr,
629
;             info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
630
;      if (blue_X != NULL)
631
;         *blue_X = png_float(png_ptr,
632
;             info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
633
;      if (blue_Y != NULL)
634
;         *blue_Y = png_float(png_ptr,
635
;             info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
636
;      if (blue_Z != NULL)
637
;         *blue_Z = png_float(png_ptr,
638
;             info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
639
;      return (PNG_INFO_cHRM);
640
;   }
641
642
 
643
	ret
644
endp
645
646
 
647
;    png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
648
;    png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
649
;    png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
650
;    png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
651
;    png_fixed_point *int_blue_Z)
652
align 4
653
proc png_get_cHRM_XYZ_fixed, png_ptr:dword, info_ptr:dword, int_red_X:dword, int_red_Y:dword, int_red_Z:dword, int_green_X:dword, int_green_Y:dword, int_green_Z:dword, int_blue_X:dword, int_blue_Y:dword, int_blue_Z:dword
654
;   if (png_ptr != NULL && info_ptr != NULL &&
655
;      (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
656
;   {
657
	png_debug1 1, 'in %s retrieval function', 'cHRM_XYZ'
658
659
 
660
;         *int_red_X = info_ptr->colorspace.end_points_XYZ.red_X;
661
;      if (int_red_Y != NULL)
662
;         *int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y;
663
;      if (int_red_Z != NULL)
664
;         *int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z;
665
;      if (int_green_X != NULL)
666
;         *int_green_X = info_ptr->colorspace.end_points_XYZ.green_X;
667
;      if (int_green_Y != NULL)
668
;         *int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y;
669
;      if (int_green_Z != NULL)
670
;         *int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z;
671
;      if (int_blue_X != NULL)
672
;         *int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X;
673
;      if (int_blue_Y != NULL)
674
;         *int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y;
675
;      if (int_blue_Z != NULL)
676
;         *int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z;
677
;      return (PNG_INFO_cHRM);
678
;   }
679
680
 
681
.end_f:
682
	ret
683
endp
684
685
 
686
;    png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
687
;    png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
688
;    png_fixed_point *blue_x, png_fixed_point *blue_y)
689
align 4
690
proc png_get_cHRM_fixed, png_ptr:dword, info_ptr:dword, white_x:dword, white_y:dword, red_x:dword, red_y:dword, green_x:dword, green_y:dword, blue_x:dword, blue_y:dword
691
	png_debug1 1, 'in %s retrieval function', 'cHRM'
692
693
 
694
;      (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
695
;   {
696
;      if (white_x != NULL)
697
;         *white_x = info_ptr->colorspace.end_points_xy.whitex;
698
;      if (white_y != NULL)
699
;         *white_y = info_ptr->colorspace.end_points_xy.whitey;
700
;      if (red_x != NULL)
701
;         *red_x = info_ptr->colorspace.end_points_xy.redx;
702
;      if (red_y != NULL)
703
;         *red_y = info_ptr->colorspace.end_points_xy.redy;
704
;      if (green_x != NULL)
705
;         *green_x = info_ptr->colorspace.end_points_xy.greenx;
706
;      if (green_y != NULL)
707
;         *green_y = info_ptr->colorspace.end_points_xy.greeny;
708
;      if (blue_x != NULL)
709
;         *blue_x = info_ptr->colorspace.end_points_xy.bluex;
710
;      if (blue_y != NULL)
711
;         *blue_y = info_ptr->colorspace.end_points_xy.bluey;
712
;      return (PNG_INFO_cHRM);
713
;   }
714
715
 
716
	ret
717
endp
718
;end if
719
720
 
721
;    png_fixed_point *file_gamma)
722
align 4
723
proc png_get_gAMA_fixed, png_ptr:dword, info_ptr:dword, file_gamma:dword
724
	png_debug1 1, 'in %s retrieval function', 'gAMA'
725
726
 
727
;       (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
728
;       file_gamma != NULL)
729
;   {
730
;      *file_gamma = info_ptr->colorspace.gamma;
731
;      return (PNG_INFO_gAMA);
732
;   }
733
734
 
735
	ret
736
endp
737
738
 
739
align 4
740
proc png_get_gAMA, png_ptr:dword, info_ptr:dword, file_gamma:dword
741
	png_debug1 1, 'in %s retrieval function', 'gAMA(float)'
742
743
 
744
;      (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
745
;      file_gamma != NULL)
746
;   {
747
;      *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
748
;          "png_get_gAMA");
749
;      return (PNG_INFO_gAMA);
750
;   }
751
752
 
753
	ret
754
endp
755
756
 
757
align 4
758
proc png_get_sRGB, png_ptr:dword, info_ptr:dword, file_srgb_intent:dword
759
	png_debug1 1, 'in %s retrieval function', 'sRGB'
760
761
 
762
;      (info_ptr->valid & PNG_INFO_sRGB) != 0 && file_srgb_intent != NULL)
763
;   {
764
;      *file_srgb_intent = info_ptr->colorspace.rendering_intent;
765
;      return (PNG_INFO_sRGB);
766
;   }
767
768
 
769
	ret
770
endp
771
772
 
773
;    png_charpp name, int *compression_type, bytepp profile, uint_32 *proflen)
774
align 4
775
proc png_get_iCCP, png_ptr:dword, info_ptr:dword, name:dword, compression_type:dword, profile:dword, proflen:dword
776
	png_debug1 1, 'in %s retrieval function', 'iCCP'
777
778
 
779
;       (info_ptr->valid & PNG_INFO_iCCP) != 0 &&
780
;       name != NULL && compression_type != NULL && profile != NULL &&
781
;           proflen != NULL)
782
;   {
783
;      *name = info_ptr->iccp_name;
784
;      *profile = info_ptr->iccp_profile;
785
;      *proflen = png_get_uint_32(info_ptr->iccp_profile);
786
	; This is somewhat irrelevant since the profile data returned has
787
	; actually been uncompressed.
788
789
 
790
;      return (PNG_INFO_iCCP);
791
;   }
792
793
 
794
	ret
795
endp
796
797
 
798
;    png_sPLT_tpp spalettes)
799
align 4
800
proc png_get_sPLT, png_ptr:dword, info_ptr:dword, spalettes:dword
801
;   if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
802
;   {
803
;      *spalettes = info_ptr->splt_palettes;
804
;      return info_ptr->splt_palettes_num;
805
;   }
806
807
 
808
	ret
809
endp
810
811
 
812
;    uint_16p hist)
813
align 4
814
proc png_get_hIST, png_ptr:dword, info_ptr:dword, hist:dword
815
	png_debug1 1, 'in %s retrieval function', 'hIST'
816
817
 
818
;       (info_ptr->valid & PNG_INFO_hIST) != 0 && hist != NULL)
819
;   {
820
;      *hist = info_ptr->hist;
821
;      return (PNG_INFO_hIST);
822
;   }
823
824
 
825
	ret
826
endp
827
828
 
829
;    uint_32 *width, uint_32 *height, int *bit_depth,
830
;    int *color_type, int *interlace_type, int *compression_type,
831
;    int *filter_type)
832
align 4
833
proc png_get_IHDR, png_ptr:dword, info_ptr:dword,\
834
	width:dword, height:dword, bit_depth:dword, color_type:dword,\
835
	interlace_type:dword, compression_type:dword, filter_type:dword
836
	png_debug1 1, 'in %s retrieval function', 'IHDR'
837
838
 
839
;      return (0);
840
841
 
842
;       *width = info_ptr->width;
843
844
 
845
;       *height = info_ptr->height;
846
847
 
848
;       *bit_depth = info_ptr->bit_depth;
849
850
 
851
;       *color_type = info_ptr->color_type;
852
853
 
854
;      *compression_type = info_ptr->compression_type;
855
856
 
857
;      *filter_type = info_ptr->filter_type;
858
859
 
860
;      *interlace_type = info_ptr->interlace_type;
861
862
 
863
	; assigned in png_set_IHDR().  We do the check anyhow in case an
864
	; application has ignored our advice not to mess with the members
865
	; of info_ptr directly.
866
867
 
868
;       info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
869
;       info_ptr->compression_type, info_ptr->filter_type);
870
871
 
872
	inc eax
873
	ret
874
endp
875
876
 
877
;    int_32 *offset_x, int_32 *offset_y, int *unit_type)
878
align 4
879
proc png_get_oFFs, png_ptr:dword, info_ptr:dword, offset_x:dword, offset_y:dword, unit_type:dword
880
	png_debug1 1, 'in %s retrieval function', 'oFFs'
881
882
 
883
;       (info_ptr->valid & PNG_INFO_oFFs) != 0 &&
884
;       offset_x != NULL && offset_y != NULL && unit_type != NULL)
885
;   {
886
;      *offset_x = info_ptr->x_offset;
887
;      *offset_y = info_ptr->y_offset;
888
;      *unit_type = (int)info_ptr->offset_unit_type;
889
;      return (PNG_INFO_oFFs);
890
;   }
891
892
 
893
	ret
894
endp
895
896
 
897
;    charp *purpose, int_32 *X0, int_32 *X1, int *type, int *nparams,
898
;    charp *units, charpp *params)
899
align 4
900
proc png_get_pCAL, png_ptr:dword, info_ptr:dword, purpose:dword, X0:dword, X1:dword, type:dword, nparams:dword, units:dword, params:dword
901
	png_debug1 1, 'in %s retrieval function', 'pCAL'
902
903
 
904
;       (info_ptr->valid & PNG_INFO_pCAL) != 0 &&
905
;       purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
906
;       nparams != NULL && units != NULL && params != NULL)
907
;   {
908
;      *purpose = info_ptr->pcal_purpose;
909
;      *X0 = info_ptr->pcal_X0;
910
;      *X1 = info_ptr->pcal_X1;
911
;      *type = (int)info_ptr->pcal_type;
912
;      *nparams = (int)info_ptr->pcal_nparams;
913
;      *units = info_ptr->pcal_units;
914
;      *params = info_ptr->pcal_params;
915
;      return (PNG_INFO_pCAL);
916
;   }
917
918
 
919
	ret
920
endp
921
922
 
923
;    int *unit, png_fixed_point *width, png_fixed_point *height)
924
align 4
925
proc png_get_sCAL_fixed, png_ptr:dword, info_ptr:dword, unit:dword, width:dword, height:dword
926
;   if (png_ptr != NULL && info_ptr != NULL &&
927
;       (info_ptr->valid & PNG_INFO_sCAL) != 0)
928
;   {
929
;      *unit = info_ptr->scal_unit;
930
	;TODO: make this work without FP support; the API is currently eliminated
931
	; if neither floating point APIs nor internal floating point arithmetic
932
	; are enabled.
933
934
 
935
;      *height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
936
;          "sCAL height");
937
;      return (PNG_INFO_sCAL);
938
;   }
939
940
 
941
	ret
942
endp
943
944
 
945
;    int *unit, double *width, double *height)
946
align 4
947
proc png_get_sCAL, png_ptr:dword, info_ptr:dword, unit:dword, width:dword, height:dword
948
;   if (png_ptr != NULL && info_ptr != NULL &&
949
;       (info_ptr->valid & PNG_INFO_sCAL) != 0)
950
;   {
951
;      *unit = info_ptr->scal_unit;
952
;      *width = atof(info_ptr->scal_s_width);
953
;      *height = atof(info_ptr->scal_s_height);
954
;      return (PNG_INFO_sCAL);
955
;   }
956
957
 
958
	ret
959
endp
960
961
 
962
;    int *unit, charpp width, charpp height)
963
align 4
964
proc png_get_sCAL_s, png_ptr:dword, info_ptr:dword, unit:dword, width:dword, height:dword
965
;   if (png_ptr != NULL && info_ptr != NULL &&
966
;       (info_ptr->valid & PNG_INFO_sCAL) != 0)
967
;   {
968
;      *unit = info_ptr->scal_unit;
969
;      *width = info_ptr->scal_s_width;
970
;      *height = info_ptr->scal_s_height;
971
;      return (PNG_INFO_sCAL);
972
;   }
973
974
 
975
.end_f:
976
	ret
977
endp
978
979
 
980
;    uint_32 *res_x, uint_32 *res_y, int *unit_type)
981
align 4
982
proc png_get_pHYs, png_ptr:dword, info_ptr:dword, res_x:dword, res_y:dword, unit_type:dword
983
;   uint_32 retval = 0;
984
985
 
986
987
 
988
;       (info_ptr->valid & PNG_INFO_pHYs) != 0)
989
;   {
990
;      if (res_x != NULL)
991
;      {
992
;         *res_x = info_ptr->x_pixels_per_unit;
993
;         retval |= PNG_INFO_pHYs;
994
;      }
995
996
 
997
;      {
998
;         *res_y = info_ptr->y_pixels_per_unit;
999
;         retval |= PNG_INFO_pHYs;
1000
;      }
1001
1002
 
1003
;      {
1004
;         *unit_type = (int)info_ptr->phys_unit_type;
1005
;         retval |= PNG_INFO_pHYs;
1006
;      }
1007
;   }
1008
1009
 
1010
	ret
1011
endp
1012
1013
 
1014
;    png_colorp *palette, int *num_palette)
1015
align 4
1016
proc png_get_PLTE, png_ptr:dword, info_ptr:dword, palette:dword, num_palette:dword
1017
	png_debug1 1, 'in %s retrieval function', 'PLTE'
1018
1019
 
1020
;       (info_ptr->valid & PNG_INFO_PLTE) != 0 && palette != NULL)
1021
;   {
1022
;      *palette = info_ptr->palette;
1023
;      *num_palette = info_ptr->num_palette;
1024
;      png_debug1(3, "num_palette = %d", *num_palette);
1025
;      return (PNG_INFO_PLTE);
1026
;   }
1027
1028
 
1029
	ret
1030
endp
1031
1032
 
1033
align 4
1034
proc png_get_sBIT, png_ptr:dword, info_ptr:dword, sig_bit:dword
1035
	png_debug1 1, 'in %s retrieval function', 'sBIT'
1036
1037
 
1038
;       (info_ptr->valid & PNG_INFO_sBIT) != 0 && sig_bit != NULL)
1039
;   {
1040
;      *sig_bit = &(info_ptr->sig_bit);
1041
;      return (PNG_INFO_sBIT);
1042
;   }
1043
1044
 
1045
	ret
1046
endp
1047
1048
 
1049
align 4
1050
proc png_get_text, png_ptr:dword, info_ptr:dword, text_ptr:dword, num_text:dword
1051
;   if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
1052
;   {
1053
;      png_debug1(1, "in 0x%lx retrieval function",
1054
;         (unsigned long)png_ptr->chunk_name);
1055
1056
 
1057
;         *text_ptr = info_ptr->text;
1058
1059
 
1060
;         *num_text = info_ptr->num_text;
1061
1062
 
1063
;   }
1064
1065
 
1066
;      *num_text = 0;
1067
1068
 
1069
	ret
1070
endp
1071
1072
 
1073
;    png_timep *mod_time)
1074
align 4
1075
proc png_get_tIME, png_ptr:dword, info_ptr:dword, mod_time:dword
1076
	png_debug1 1, 'in %s retrieval function', 'tIME'
1077
1078
 
1079
;       (info_ptr->valid & PNG_INFO_tIME) != 0 && mod_time != NULL)
1080
;   {
1081
;      *mod_time = &(info_ptr->mod_time);
1082
;      return (PNG_INFO_tIME);
1083
;   }
1084
1085
 
1086
	ret
1087
endp
1088
1089
 
1090
;    bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
1091
align 4
1092
proc png_get_tRNS, png_ptr:dword, info_ptr:dword, trans_alpha:dword, num_trans:dword, trans_color:dword
1093
;   uint_32 retval = 0;
1094
;   if (png_ptr != NULL && info_ptr != NULL &&
1095
;       (info_ptr->valid & PNG_INFO_tRNS) != 0)
1096
;   {
1097
		png_debug1 1, 'in %s retrieval function', 'tRNS'
1098
1099
 
1100
;      {
1101
;         if (trans_alpha != NULL)
1102
;         {
1103
;            *trans_alpha = info_ptr->trans_alpha;
1104
;            retval |= PNG_INFO_tRNS;
1105
;         }
1106
1107
 
1108
;            *trans_color = &(info_ptr->trans_color);
1109
;      }
1110
1111
 
1112
;      {
1113
;         if (trans_color != NULL)
1114
;         {
1115
;            *trans_color = &(info_ptr->trans_color);
1116
;            retval |= PNG_INFO_tRNS;
1117
;         }
1118
1119
 
1120
;            *trans_alpha = NULL;
1121
;      }
1122
1123
 
1124
;      {
1125
;         *num_trans = info_ptr->num_trans;
1126
;         retval |= PNG_INFO_tRNS;
1127
;      }
1128
;   }
1129
1130
 
1131
	ret
1132
endp
1133
1134
 
1135
;    png_unknown_chunkpp unknowns)
1136
align 4
1137
proc png_get_unknown_chunks, png_ptr:dword, info_ptr:dword, unknowns:dword
1138
;   if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
1139
;   {
1140
;      *unknowns = info_ptr->unknown_chunks;
1141
;      return info_ptr->unknown_chunks_num;
1142
;   }
1143
1144
 
1145
	ret
1146
endp
1147
1148
 
1149
align 4
1150
proc png_get_rgb_to_gray_status, png_ptr:dword
1151
	mov eax,[png_ptr]
1152
	cmp eax,0
1153
	je @f
1154
		mov eax,[eax+png_struct.rgb_to_gray_status]
1155
	@@:
1156
	ret
1157
endp
1158
1159
 
1160
align 4
1161
proc png_get_user_chunk_ptr, png_ptr:dword
1162
	mov eax,[png_ptr]
1163
	cmp eax,0
1164
	je @f
1165
		mov eax,[eax+png_struct.user_chunk_ptr]
1166
	@@:
1167
	ret
1168
endp
1169
1170
 
1171
align 4
1172
proc png_get_compression_buffer_size uses ebx, png_ptr:dword
1173
	mov eax,[png_ptr]
1174
	cmp eax,0
1175
	je .end_f ;if (..==0) return 0
1176
1177
 
1178
	mov ebx,[eax+png_struct.mode]
1179
	and ebx,PNG_IS_READ_STRUCT
1180
	cmp ebx,0
1181
;   if (..!=0)
1182
end if
1183
;   {
1184
if PNG_SEQUENTIAL_READ_SUPPORTED eq 1
1185
		mov eax,[eax+png_struct.IDAT_read_size]
6881 IgorA 1186
else
6733 IgorA 1187
		mov eax,PNG_IDAT_READ_SIZE
1188
end if
1189
;   }
1190
1191
 
1192
		jmp .end_f
6881 IgorA 1193
;   else
6733 IgorA 1194
		mov eax,[eax+png_struct.zbuffer_size]
6881 IgorA 1195
end if
6733 IgorA 1196
.end_f:
1197
	ret
1198
endp
1199
1200
 
1201
; by default in libpng-1.4.0
1202
;uint_32 (png_structrp png_ptr)
1203
align 4
1204
proc png_get_user_width_max, png_ptr:dword
1205
	mov eax,[png_ptr]
1206
	cmp eax,0
1207
	je @f
1208
		mov eax,[eax+png_struct.user_width_max]
1209
	@@:
1210
	ret
1211
endp
1212
1213
 
1214
align 4
1215
proc png_get_user_height_max, png_ptr:dword
1216
	mov eax,[png_ptr]
1217
	cmp eax,0
1218
	je @f
1219
		mov eax,[eax+png_struct.user_height_max]
1220
	@@:
1221
	ret
1222
endp
1223
1224
 
1225
;uint_32 (png_structrp png_ptr)
1226
align 4
1227
proc png_get_chunk_cache_max, png_ptr:dword
1228
	mov eax,[png_ptr]
1229
	cmp eax,0
1230
	je @f
1231
		mov eax,[eax+png_struct.user_chunk_cache_max]
1232
	@@:
1233
	ret
1234
endp
1235
1236
 
1237
;png_alloc_size_t (png_structrp png_ptr)
1238
align 4
1239
proc png_get_chunk_malloc_max, png_ptr:dword
1240
	mov eax,[png_ptr]
1241
	cmp eax,0
1242
	je @f
1243
		mov eax,[eax+png_struct.user_chunk_malloc_max]
1244
	@@:
1245
	ret
1246
endp
1247
1248
 
1249
;uint_32 (png_structrp png_ptr)
1250
align 4
1251
proc png_get_io_state, png_ptr:dword
1252
	mov eax,[png_ptr]
1253
	mov eax,[eax+png_struct.io_state]
1254
	ret
1255
endp
1256
1257
 
1258
align 4
1259
proc png_get_io_chunk_type, png_ptr:dword
1260
	mov eax,[png_ptr]
1261
	mov eax,[eax+png_struct.chunk_name]
1262
	ret
1263
endp
1264
1265
 
1266
align 4
1267
proc png_get_palette_max, png_ptr:dword, info_ptr:dword
1268
	mov eax,[png_ptr]
1269
	cmp eax,0
1270
	je @f
1271
	cmp dword[info_ptr],0
1272
	je @f ;if (..!=0 && ..!=0)
1273
		mov eax,[eax+png_struct.num_palette_max]
1274
		jmp .end_f
1275
	@@:
1276
	xor eax,eax
1277
	dec eax
1278
.end_f:
1279
	ret
1280
endp
1281