Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1951 mario79 1
;*****************************************************************************
2
; PNG to RAW convert plugin - for zSea image viewer
3
; Copyright (c) 2008, 2009, Marat Zakiyanov aka Mario79, aka Mario
4
; All rights reserved.
5
;
6
; Redistribution and use in source and binary forms, with or without
7
; modification, are permitted provided that the following conditions are met:
8
;	 * Redistributions of source code must retain the above copyright
9
;	   notice, this list of conditions and the following disclaimer.
10
;	 * Redistributions in binary form must reproduce the above copyright
11
;	   notice, this list of conditions and the following disclaimer in the
12
;	   documentation and/or other materials provided with the distribution.
13
;	 * Neither the name of the  nor the
14
;	   names of its contributors may be used to endorse or promote products
15
;	   derived from this software without specific prior written permission.
16
;
17
; THIS SOFTWARE IS PROVIDED BY Marat Zakiyanov ''AS IS'' AND ANY
18
; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19
; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20
; DISCLAIMED. IN NO EVENT SHALL  BE LIABLE FOR ANY
21
; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22
; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23
; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24
; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26
; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
;---------------------------------------------------------------------
28
filtering_RGB_Interlaced:
29
	mov edx,dword filtering_RGB
30
	mov ebp,dword move_Interlaced_RGB
31
	jmp  filtering_All
32
;---------------------------------------------------------------------
33
filtering_RGB_16_Interlaced:
34
	mov edx,dword filtering_RGB_16
35
	mov ebp,dword move_Interlaced_RGB
36
	jmp  filtering_All
37
;---------------------------------------------------------------------
38
filtering_grayscale_Interlaced:
39
	mov edx,dword filtering_grayscale
40
	mov ebp,dword move_Interlaced_grayscale
41
	jmp  filtering_All
42
;---------------------------------------------------------------------
43
filtering_grayscale_16_Interlaced:
44
	mov edx,dword filtering_grayscale_16
45
	mov ebp,dword move_Interlaced_grayscale
46
	jmp  filtering_All
47
;---------------------------------------------------------------------
48
pass dd 0
49
filtering_All:
50
	push edi
51
 
52
	mov ecx,[resolution]
53
	imul ecx,[IHDR_data.Width]
54
	mov  eax,ecx
55
	shr  ecx,3
56
	test eax,7
57
	jz  @f
58
	inc  ecx
59
@@:
60
	mov  eax,[IHDR_data.Height]
61
	shr  eax,1
62
	inc  eax
63
	imul ecx,eax
64
	mcall 68, 12
65
	mov [Interlaced_area],eax
66
;	jmp .3
67
	mov  eax,dword calculate_Interlaced_counters
68
	mov  ecx,7
69
@@:
70
	mov  [pass],ecx
71
	mov [Interlaced_step],eax
72
	push ecx
73
	push eax edx edi ebp eax
74
	call dword [eax] ;calculate_Interlaced_1
75
;	cmp  [pass],1
76
;	jbe   .2
77
	call edx
78
;.2:
79
	pop  eax ebp edi
80
	push ebp
81
;	cmp  [pass],1
82
;	jbe   .1
83
	call ebp
84
;.1:
85
	pop  ebp edx eax
86
	add  eax,4
87
	pop  ecx
88
	dec  ecx
89
	jnz  @r
90
;.3:
91
	mov ecx,[Interlaced_area]
92
	mcall 68, 13
93
 
94
	pop edi
95
	ret
96
;---------------------------------------------------------------------
97
move_Interlaced_RGB:
98
	push edi esi
99
	mov  esi,[Interlaced_area]
100
 
101
	mov  ecx,[IHDR_data.Height]
102
	test ecx,ecx
103
	jz	 .end
104
 
105
	mov edx,[IHDR_data.Width]
106
	test edx,edx
107
	jz	 .end
108
 
109
	mov  ebx,[Image_Width]
110
	imul ebx,[resolution]
111
	shr  ebx,3
112
 
113
	mov  eax,[Starting_Col]
114
	imul eax,[resolution]
115
	shr  eax,3
116
	add  edi,eax
117
 
118
	mov  eax,[Starting_Row]
119
	imul eax,ebx
120
	add  edi,eax
121
 
122
	imul ebx,[Row_Increment]
123
 
124
	mov  ebp,[resolution]
125
	imul ebp,[Col_Increment]
126
	shr  ebp,3
127
 
128
.filter:
129
	mov edx,[IHDR_data.Width]
130
	push edi
131
 
132
.filter_x:
133
    cmp   [IHDR_data.Bit_depth],byte 8
134
	jne   @f
135
	call .Interlaced_RGB_8
136
	jmp   .1
137
@@:
138
	call .Interlaced_RGB_16
139
.1:
140
	dec edx
141
	jnz .filter_x
142
 
143
	pop edi
144
 
145
	add edi,ebx
146
	dec ecx
147
	jnz .filter
148
.end:
149
	pop  esi edi
150
	ret
151
;-------------------------------------------
152
.Interlaced_RGB_8:
153
	cld
154
	lodsw
155
	mov [edi],ax
156
	lodsb
157
	mov [edi+2],al
158
	cmp [IHDR_data.Color_type],byte 6
159
	jne @f
160
	lodsb
161
	mov [edi+3],al
162
@@:
163
	add edi,ebp
164
	ret
165
;-------------------------------------------
166
.Interlaced_RGB_16:
167
	cld
168
	lodsd
169
	mov [edi],eax
170
	lodsw
171
	mov [edi+4],ax
172
	cmp [IHDR_data.Color_type],byte 6
173
	jne @f
174
	lodsw
175
	mov [edi+6],al
176
@@:
177
	add edi,ebp
178
	ret
179
;---------------------------------------------------------------------
180
move_Interlaced_grayscale:
181
;	cmp  [eax],dword calculate_Interlaced_1
182
;	jne   @f
183
;	ret
184
;@@:
185
;	cmp  [eax],dword calculate_Interlaced_2
186
;	jne   @f
187
;	ret
188
;@@:
189
;	cmp  [eax],dword calculate_Interlaced_3
190
;	jne   @f
191
;	ret
192
;@@:
193
;	cmp  [eax],dword calculate_Interlaced_4
194
;	jne   @f
195
;	ret
196
;@@:
197
;	cmp  [eax],dword calculate_Interlaced_5
198
;	jne   @f
199
;	ret
200
;@@:
201
;	cmp  [eax],dword calculate_Interlaced_6
202
;	jne   @f
203
;	ret
204
;@@:
205
;	cmp  [eax],dword calculate_Interlaced_7
206
;	jne   @f
207
;	ret
208
;@@:
209
 
210
	push edi esi
211
	mov  esi,[Interlaced_area]
212
 
213
	mov  ecx,[IHDR_data.Height]
214
	test ecx,ecx
215
	jz	 .end
216
 
217
	mov edx,[IHDR_data.Width]
218
	test edx,edx
219
	jz	 .end
220
 
221
	mov  ebx,[Image_Width]
222
	imul ebx,[resolution]
223
	mov eax,ebx
224
	shr  ebx,3
225
	test eax,7
226
	jz  @f
227
	inc  ebx
228
@@:
229
; ebx = Width in bytes, need correct for resolution less 4b
230
 
231
	mov  eax,[Starting_Col]
232
	imul eax,[resolution]
233
;	mov  ebp,eax
234
	shr  eax,3
235
;	test ebp,7
236
;	jz  @f
237
;	inc  eax
238
;@@:
239
; eax = Starting Colummn in bytes
240
	add  edi,eax
241
 
242
	mov  eax,[Starting_Row]
243
	imul eax,ebx
244
; eax = Starting Row in bytes, no need correct!
245
	add  edi,eax
246
 
247
	imul ebx,[Row_Increment]
248
; ebx = Row Increment in bytes, no need correct!
249
 
250
	mov  eax,[IHDR_data.Width]
251
	imul eax,[resolution]
252
	mov ebp,eax
253
	shr  eax,3
254
	test ebp,7
255
	jz  @f
256
	inc  eax
257
@@:
258
; eax = Width in bytes for Interlaced,
259
;		need correct for resolution less 4b
260
 
261
	mov  ebp,[resolution]
262
	imul ebp,[Col_Increment]
263
;	mov  eax,ebp
264
	shr  ebp,3
265
;	test eax,7
266
;	jz  @f
267
;	inc  ebp
268
;@@:
269
; ebp = Column Increment in bytes
270
 
271
.filter_grayscale:
272
	mov edx,[IHDR_data.Width]
273
	cmp [resolution],8
274
	jae .filter_grayscale_1
275
 
276
.resolution_4:
277
	cmp [resolution],4
278
	jne .resolution_2
279
	test edx,1
280
	jnz  @f
281
	inc  edx
282
@@:
283
	shr edx,1
284
	jmp .filter_grayscale_1
285
 
286
.resolution_2:
287
	cmp [resolution],2
288
	jne .resolution_1
289
	test edx,3
290
	jnz  @f
291
	add  edx,4
292
@@:
293
	shr edx,2
294
	jmp .filter_grayscale_1
295
 
296
.resolution_1:
297
	push eax
298
	mov eax,edx
299
	shr edx,3
300
	test eax,7
301
	jz  @f
302
	inc  edx
303
@@:
304
	pop eax
305
.filter_grayscale_1:
306
	push eax edi esi
307
 
308
.filter_x_grayscale:
309
    cmp   [IHDR_data.Bit_depth],byte 16
310
	jne   @f
311
	call .Interlaced_grayscale_16
312
	jmp   .1
313
@@:
314
    cmp   [IHDR_data.Bit_depth],byte 8
315
	jne   @f
316
	call .Interlaced_grayscale_8
317
	jmp   .1
318
@@:
319
    cmp   [IHDR_data.Bit_depth],byte 4
320
	jne   @f
321
	call .Interlaced_grayscale_4
322
	jmp   .1
323
@@:
324
    cmp   [IHDR_data.Bit_depth],byte 2
325
	jne   @f
326
	call .Interlaced_grayscale_2
327
	jmp   .1
328
@@:
329
	call .Interlaced_grayscale_1
330
	jmp   .1
331
.1:
332
 
333
	dec edx
334
	jnz .filter_x_grayscale
335
	pop  esi edi eax
336
	add esi,eax
337
 
338
	add edi,ebx
339
	dec ecx
340
	jnz .filter_grayscale
341
.end:
342
	pop  esi edi
343
	ret
344
;-----------------------------------
345
.Interlaced_grayscale_1:
346
	mov  eax,[Interlaced_step]
347
	cmp eax,calculate_Interlaced_counters.1
348
	je  .step_1
349
	cmp eax,calculate_Interlaced_counters.2
350
	je  .step_2
351
	cmp eax,calculate_Interlaced_counters.3
352
	je  .step_3
353
	cmp eax,calculate_Interlaced_counters.4
354
	je  .step_4
355
	cmp eax,calculate_Interlaced_counters.5
356
	je  .step_5
357
	cmp eax,calculate_Interlaced_counters.6
358
	je  .step_6
359
	cld
360
	movsb
361
	ret
362
;--------------------
363
.step_6:
364
	push ebx
365
	cld
366
	lodsb
367
	mov ah,al
368
 
369
	call @f
370
 
371
	shl ah,4
372
	mov al,ah
373
 
374
	call @f
375
 
376
	pop ebx
377
	ret
378
;--------------------
379
@@:
380
	shr al,1
381
	and al,64
382
 
383
	mov bl,ah
384
	shr bl,2
385
	and bl,16
386
	add al,bl
387
 
388
	mov bl,ah
389
	shr bl,3
390
	and bl,4
391
	add al,bl
392
 
393
	mov bl,ah
394
	shr bl,4
395
	and bl,1
396
	add al,bl
397
 
398
	add al,[edi]
399
	stosb
400
	ret
401
;--------------------
402
.step_5:
403
	push ebx
404
	cld
405
	lodsb
406
 
407
	mov ah,al
408
 
409
	call @f
410
 
411
	shl ah,4
412
	mov al,ah
413
 
414
	call @f
415
 
416
	pop ebx
417
	ret
418
;--------------------
419
@@:
420
	and al,128
421
 
422
	mov bl,ah
423
	shr bl,1
424
	and bl,32
425
	add al,bl
426
 
427
	mov bl,ah
428
	shr bl,2
429
	and bl,8
430
	add al,bl
431
 
432
	mov bl,ah
433
	shr bl,3
434
	and bl,2
435
	add al,bl
436
 
437
	add al,[edi]
438
	stosb
439
	ret
440
;--------------------
441
.step_4:
442
	push ebx
443
	cld
444
	lodsb
445
 
446
	mov ah,al
447
	shr al,2
448
	and al,32
449
	mov bl,ah
450
	shr bl,5
451
	call @f
452
 
453
	mov al,ah
454
	and al,32
455
	mov bl,ah
456
	shr bl,3
457
	call @f
458
 
459
	mov al,ah
460
	shl al,2
461
	and al,32
462
	mov bl,ah
463
	shr bl,1
464
	call @f
465
 
466
	mov al,ah
467
	shl al,4
468
	and al,32
469
	mov bl,ah
470
	shl bl,1
471
	call @f
472
	pop ebx
473
	ret
474
;--------------------
475
@@:
476
	and bl,2
477
	add al,bl
478
	add al,[edi]
479
	stosb
480
	ret
481
;--------------------
482
.step_3:
483
	push ebx
484
	cld
485
	lodsb
486
 
487
	mov ah,al
488
	and al,128
489
	mov bl,ah
490
	shr bl,3
491
	call @f
492
 
493
	mov al,ah
494
	shl al,2
495
	and al,128
496
	mov bl,ah
497
	shr bl,1
498
	call @f
499
 
500
	mov al,ah
501
	shl al,4
502
	and al,128
503
	mov bl,ah
504
	shl bl,1
505
	call @f
506
 
507
	mov al,ah
508
	shl al,6
509
	and al,128
510
	mov bl,ah
511
	shl bl,3
512
	call @f
513
	pop ebx
514
	ret
515
;--------------------
516
@@:
517
	and bl,8
518
	add al,bl
519
	add al,[edi]
520
	stosb
521
	ret
522
;--------------------
523
.step_2:
524
	cld
525
	lodsb
526
 
527
	mov ah,al
528
	shr al,4
529
	and al,8
530
	add al,[edi]
531
	stosb
532
 
533
	mov al,ah
534
	shr al,3
535
	and al,8
536
	add al,[edi]
537
	stosb
538
 
539
	mov al,ah
540
	shr al,2
541
	and al,8
542
	add al,[edi]
543
	stosb
544
 
545
	mov al,ah
546
	shr al,1
547
	and al,8
548
	add al,[edi]
549
	stosb
550
 
551
	mov al,ah
552
	and al,8
553
	add al,[edi]
554
	stosb
555
 
556
	mov al,ah
557
	shl al,1
558
	and al,8
559
	add al,[edi]
560
	stosb
561
 
562
	mov al,ah
563
	shl al,2
564
	and al,8
565
	add al,[edi]
566
	stosb
567
 
568
	mov al,ah
569
	shl al,3
570
	and al,8
571
	add al,[edi]
572
	stosb
573
 
574
	ret
575
;--------------------
576
.step_1:
577
	cld
578
	lodsb
579
	mov ah,al
580
	and al,128
581
	stosb
582
	mov al,ah
583
	shl al,1
584
	and al,128
585
	stosb
586
	mov al,ah
587
	shl al,2
588
	and al,128
589
	stosb
590
	mov al,ah
591
	shl al,3
592
	and al,128
593
	stosb
594
	mov al,ah
595
	shl al,4
596
	and al,128
597
	stosb
598
	mov al,ah
599
	shl al,5
600
	and al,128
601
	stosb
602
	mov al,ah
603
	shl al,6
604
	and al,128
605
	stosb
606
	mov al,ah
607
	shl al,7
608
	and al,128
609
	stosb
610
	ret
611
;-----------------------------------
612
.Interlaced_grayscale_2:
613
	mov  eax,[Interlaced_step]
614
	cmp eax,calculate_Interlaced_counters.1
615
	je  .step_1_1
616
	cmp eax,calculate_Interlaced_counters.2
617
	je  .step_2_1
618
	cmp eax,calculate_Interlaced_counters.3
619
	je  .step_3_1
620
	cmp eax,calculate_Interlaced_counters.4
621
	je  .step_4_1
622
	cmp eax,calculate_Interlaced_counters.5
623
	je  .step_5_1
624
	cmp eax,calculate_Interlaced_counters.6
625
	je  .step_6_1
626
	cld
627
	movsb
628
	ret
629
 
630
.step_6_1:
631
	push ebx
632
	cld
633
	lodsb
634
	mov ah,al
635
 
636
	shr al,2
637
	and al,48
638
	mov bl,ah
639
	shr bl,4
640
	and bl,3
641
	add al,bl
642
	add al,[edi]
643
	stosb
644
 
645
	mov al,ah
646
	shl al,2
647
	and al,48
648
	mov bl,ah
649
	and bl,3
650
	add al,bl
651
	add al,[edi]
652
	stosb
653
	pop ebx
654
	ret
655
 
656
.step_5_1:
657
	push ebx
658
	cld
659
	lodsb
660
	mov ah,al
661
 
662
	and al,192
663
	mov bl,ah
664
	shr bl,2
665
	and bl,12
666
	add al,bl
667
	add al,[edi]
668
	stosb
669
 
670
	mov al,ah
671
	shl al,4
672
	and al,192
673
	mov bl,ah
674
	shl bl,2
675
	and bl,12
676
	add al,bl
677
	add al,[edi]
678
	stosb
679
	pop ebx
680
	ret
681
 
682
.step_4_1:
683
	cld
684
	lodsb
685
	mov ah,al
686
 
687
	shr al,4
688
	and al,12
689
	add al,[edi]
690
	stosb
691
 
692
	mov al,ah
693
	shr al,2
694
	and al,12
695
	add al,[edi]
696
	stosb
697
 
698
	mov al,ah
699
	and al,12
700
	add al,[edi]
701
	stosb
702
 
703
	mov al,ah
704
	shl al,2
705
	and al,12
706
	add al,[edi]
707
	stosb
708
 
709
	ret
710
 
711
.step_3_1:
712
	cld
713
	lodsb
714
	mov ah,al
715
 
716
	and al,192
717
	stosb
718
 
719
	mov al,ah
720
	shl al,2
721
	and al,192
722
	stosb
723
 
724
	mov al,ah
725
	shl al,4
726
	and al,192
727
	stosb
728
 
729
	mov al,ah
730
	shl al,6
731
	and al,192
732
	stosb
733
 
734
	ret
735
 
736
.step_2_1:
737
	cld
738
	lodsb
739
	mov ah,al
740
 
741
	and al,192
742
	stosb
743
	inc edi
744
 
745
	mov al,ah
746
	shl al,2
747
	and al,192
748
	stosb
749
	inc edi
750
 
751
	mov al,ah
752
	shl al,4
753
	and al,192
754
	stosb
755
	inc edi
756
 
757
	mov al,ah
758
	shl al,6
759
	and al,192
760
	stosb
761
	inc edi
762
 
763
	ret
764
 
765
.step_1_1:
766
	cld
767
	lodsb
768
 
769
	mov ah,al
770
	and al,192
771
	stosb
772
	inc edi
773
 
774
	mov al,ah
775
	shl al,2
776
	and al,192
777
	stosb
778
	inc edi
779
 
780
	mov al,ah
781
	shl al,4
782
	and al,192
783
	stosb
784
	inc edi
785
 
786
	mov al,ah
787
	shl al,6
788
	and al,192
789
	stosb
790
	inc edi
791
 
792
	ret
793
;-----------------------------------
794
.Interlaced_grayscale_4:
795
	mov al,[esi]
796
	mov ah,[edi]
797
	test ebp,ebp
798
	jnz  @f
799
	call .even_2
800
	jmp  .2
801
@@:
802
	test [Starting_Col],byte 1
803
	jz  @f
804
	call .even_1
805
	jmp  .2
806
@@:
807
	call .odd_1
808
.2:
809
	add al,ah
810
	mov [edi],al
811
	add edi,ebp
812
 
813
	mov al,[esi]
814
	mov ah,[edi]
815
	test ebp,ebp
816
	jnz  @f
817
	call .odd_1
818
	jmp  .3
819
@@:
820
	test [Starting_Col],byte 1
821
	jz  @f
822
	call .even_2
823
	jmp  .3
824
@@:
825
	call .odd_2
826
.3:
827
	add al,ah
828
	mov [edi],al
829
	add edi,ebp
830
 
831
	inc  esi
832
	test ebp,ebp
833
	jnz  @f
834
	inc edi
835
@@:
836
	ret
837
;---------------------
838
.even_1:
839
	shr al,4
840
	and ah,11110000b
841
	ret
842
;---------------------
843
.even_2:
844
	and al,1111b
845
	and ah,11110000b
846
	ret
847
;---------------------
848
.odd_1:
849
	and al,11110000b
850
	and ah,1111b
851
	ret
852
;---------------------
853
.odd_2:
854
	shl al,4
855
	and ah,1111b
856
	ret
857
;-----------------------------------
858
.Interlaced_grayscale_8:
859
	cld
860
	lodsb
861
	mov [edi],al
862
	cmp [IHDR_data.Color_type],byte 4
863
	jne @f
864
	cld
865
	lodsb
866
	mov [edi+1],al
867
@@:
868
	add edi,ebp
869
	ret
870
;-----------------------------------
871
.Interlaced_grayscale_16:
872
	cld
873
	lodsw
874
	mov [edi],ax
875
	cmp [IHDR_data.Color_type],byte 4
876
	jne @f
877
	cld
878
	lodsw
879
	mov [edi+2],ax
880
@@:
881
	add edi,ebp
882
	ret
883
;---------------------------------------------------------------------
884
calculatte_Interlaced_data_1:
885
	mov [first_line],byte 1
886
	mov edi,[Interlaced_area]
887
	mov eax,[Image_Width]
888
	mov ebx,dword Starting_Row
889
	ret
890
;---------------------------------------------------------------------
891
calculate_Interlaced_1:
892
	call calculatte_Interlaced_data_1
893
	mov [ebx+0],dword 0 ;Starting_Row
894
	mov [ebx+4],dword 0 ;Starting_Col
895
	mov [ebx+8],dword 8 ;Row_Increment
896
	mov [ebx+12],dword 8 ;Col_Increment
897
	mov ebx,eax
898
	shr eax,3
899
	test ebx,7
900
	jz @f
901
	inc  eax
902
@@:
903
	mov [IHDR_data.Width],eax
904
 
905
	mov eax,[Image_Height]
906
	mov ebx,eax
907
	shr eax,3
908
	test ebx,7
909
	jz @f
910
	inc  eax
911
@@:
912
	mov [IHDR_data.Height],eax
913
	ret
914
;---------------------------------------------------------------------
915
calculate_Interlaced_2:
916
	call calculatte_Interlaced_data_1
917
	mov [ebx+0],dword 0 ;Starting_Row
918
	mov [ebx+4],dword 4 ;Starting_Col
919
	mov [ebx+8],dword 8 ;Row_Increment
920
	mov [ebx+12],dword 8 ;Col_Increment
921
	cmp eax,4
922
	ja  @f
923
	mov eax,4
924
@@:
925
	sub eax,4
926
	mov ebx,eax
927
	shr eax,3
928
	test ebx,7
929
	jz @f
930
	inc  eax
931
@@:
932
	mov [IHDR_data.Width],eax
933
 
934
	mov eax,[Image_Height]
935
	mov ebx,eax
936
	shr eax,3
937
	test ebx,7
938
	jz @f
939
	inc  eax
940
@@:
941
	mov [IHDR_data.Height],eax
942
	ret
943
;---------------------------------------------------------------------
944
calculate_Interlaced_3:
945
	call calculatte_Interlaced_data_1
946
	mov [ebx+0],dword 4 ;Starting_Row
947
	mov [ebx+4],dword 0 ;Starting_Col
948
	mov [ebx+8],dword 8 ;Row_Increment
949
	mov [ebx+12],dword 4 ;Col_Increment
950
	mov ebx,eax
951
	shr eax,2
952
	test ebx,3
953
	jz @f
954
	inc  eax
955
@@:
956
	mov [IHDR_data.Width],eax
957
 
958
	mov eax,[Image_Height]
959
	cmp eax,4
960
	ja  @f
961
	mov eax,4
962
@@:
963
	sub eax,4
964
	mov ebx,eax
965
	shr eax,3
966
	test ebx,7
967
	jz @f
968
	inc  eax
969
@@:
970
	mov [IHDR_data.Height],eax
971
	ret
972
;---------------------------------------------------------------------
973
calculate_Interlaced_4:
974
	call calculatte_Interlaced_data_1
975
	mov [ebx+0],dword 0 ;Starting_Row
976
	mov [ebx+4],dword 2 ;Starting_Col
977
	mov [ebx+8],dword 4 ;Row_Increment
978
	mov [ebx+12],dword 4 ;Col_Increment
979
	cmp eax,2
980
	ja  @f
981
	mov eax,2
982
@@:
983
	sub eax,2
984
	mov ebx,eax
985
	shr eax,2
986
	test ebx,3
987
	jz @f
988
	inc  eax
989
@@:
990
	mov [IHDR_data.Width],eax
991
 
992
	mov eax,[Image_Height]
993
	mov ebx,eax
994
	shr eax,2
995
	test ebx,3
996
	jz @f
997
	inc  eax
998
@@:
999
	mov [IHDR_data.Height],eax
1000
	ret
1001
;---------------------------------------------------------------------
1002
calculate_Interlaced_5:
1003
	call calculatte_Interlaced_data_1
1004
	mov [ebx+0],dword 2 ;Starting_Row
1005
	mov [ebx+4],dword 0 ;Starting_Col
1006
	mov [ebx+8],dword 4 ;Row_Increment
1007
	mov [ebx+12],dword 2 ;Col_Increment
1008
	mov ebx,eax
1009
	shr eax,1
1010
	test ebx,1
1011
	jz @f
1012
	inc  eax
1013
@@:
1014
	mov [IHDR_data.Width],eax
1015
 
1016
	mov eax,[Image_Height]
1017
	cmp eax,2
1018
	ja  @f
1019
	mov eax,2
1020
@@:
1021
	sub eax,2
1022
	mov ebx,eax
1023
	shr eax,2
1024
	test ebx,3
1025
	jz @f
1026
	inc  eax
1027
@@:
1028
	mov [IHDR_data.Height],eax
1029
	ret
1030
;---------------------------------------------------------------------
1031
calculate_Interlaced_6:
1032
	call calculatte_Interlaced_data_1
1033
	mov [ebx+0],dword 0 ;Starting_Row
1034
	mov [ebx+4],dword 1 ;Starting_Col
1035
	mov [ebx+8],dword 2 ;Row_Increment
1036
	mov [ebx+12],dword 2 ;Col_Increment
1037
	cmp eax,1
1038
	ja  @f
1039
	mov eax,1
1040
@@:
1041
	dec eax
1042
	mov ebx,eax
1043
	shr eax,1
1044
	test ebx,1
1045
	jz @f
1046
	inc  eax
1047
@@:
1048
	mov [IHDR_data.Width],eax
1049
 
1050
	mov eax,[Image_Height]
1051
	mov ebx,eax
1052
	shr eax,1
1053
	test ebx,1
1054
	jz @f
1055
	inc  eax
1056
@@:
1057
	mov [IHDR_data.Height],eax
1058
	ret
1059
;---------------------------------------------------------------------
1060
calculate_Interlaced_7:
1061
	call calculatte_Interlaced_data_1
1062
	mov [ebx+0],dword 1 ;Starting_Row
1063
	mov [ebx+4],dword 0 ;Starting_Col
1064
	mov [ebx+8],dword 2 ;Row_Increment
1065
	mov [ebx+12],dword 1 ;Col_Increment
1066
 
1067
	mov [IHDR_data.Width],eax
1068
;	mov ebx,[raw_area]
1069
;	mov [ebx+4],eax
1070
 
1071
	mov eax,[Image_Height]
1072
	cmp eax,1
1073
	ja  @f
1074
	mov eax,1
1075
@@:
1076
	dec eax
1077
	mov ebx,eax
1078
	shr eax,1
1079
	test ebx,1
1080
	jz @f
1081
	inc  eax
1082
@@:
1083
	mov [IHDR_data.Height],eax
1084
 
1085
;	mov ebx,[raw_area]
1086
;	mov eax,[Image_Height]
1087
;	mov [ebx+8],eax
1088
	ret
1089
;---------------------------------------------------------------------