Subversion Repositories Kolibri OS

Rev

Rev 2397 | Rev 2992 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2397 Rev 2733
Line 16... Line 16...
16
;; If not, see .                                                    ;;
16
;; If not, see .                                                    ;;
17
;;                                                                                                ;;
17
;;                                                                                                ;;
18
;;================================================================================================;;
18
;;================================================================================================;;
Line 19... Line 19...
19
 
19
 
20
include 'tiff.inc'
-
 
Line 21... Line 20...
21
;include '../../../../../system/board/trunk/debug.inc'
20
include 'tiff.inc'
22
 
21
 
23
;;================================================================================================;;
22
;;================================================================================================;;
24
proc img.is.tiff _data, _length ;/////////////////////////////////////////////////////////////////;;
23
proc img.is.tiff _data, _length ;/////////////////////////////////////////////////////////////////;;
Line 183... Line 182...
183
 
182
 
Line 184... Line 183...
184
	push	esi		; fixme!!
183
	push	esi		; fixme!!
185
 
184
 
186
	mov	ecx, [edx + Image.Type]
185
	mov	ecx, [edx + Image.Type]
187
	dec	ecx
186
	dec	ecx
188
	jz	.bpp8
187
	jz	.bpp8i
189
	dec	ecx
188
	dec	ecx
190
	jz	.bpp24
189
	jz	.bpp24
191
	dec	ecx
190
	dec	ecx
192
	jz	.bpp32
191
	jz	.bpp32
193
	dec	ecx
192
	dec	ecx
194
	dec	ecx		; tiff doesn't handle 15bpp images
193
	dec	ecx		; tiff doesn't handle 15bpp images
195
	jz	.bpp16
194
	jz	.bpp16
196
	dec	ecx
195
	dec	ecx
197
	jz	.bpp1
196
	jz	.bpp1
-
 
197
	dec	ecx
-
 
198
	jz	.bpp8g
198
	dec	ecx
199
	dec	ecx
Line 199... Line 200...
199
	jz	.bpp4
200
	jz	.bpp8a
200
;error report!!
201
;error report!!
201
 
202
 
Line 214... Line 215...
214
	jmp	.common
215
	jmp	.common
Line 215... Line 216...
215
 
216
 
216
  .bpp4:
217
  .bpp4:
Line 217... Line 218...
217
	jmp	.common
218
	jmp	.common
218
 
-
 
219
  .bpp8:
-
 
220
	cmp	[ebx + tiff_extra.palette], 0
-
 
221
	je	.bpp8.grayscale
219
 
222
 
220
  .bpp8i:
223
	mov	esi, [ebx + tiff_extra.palette]
221
	mov	esi, [ebx + tiff_extra.palette]
224
	mov	ah, 2
222
	mov	ah, 2
225
  .bpp8.channel:
223
  .bpp8.channel:
Line 236... Line 234...
236
	dec	ecx
234
	dec	ecx
237
	jnz	@b
235
	jnz	@b
238
	dec	ah
236
	dec	ah
239
	jns	.bpp8.channel
237
	jns	.bpp8.channel
240
	jmp	.common
238
	jmp	.common
241
  .bpp8.grayscale:
239
  .bpp8g:
242
	mov	edi, [edx + Image.Palette]
-
 
243
	mov	eax, 0xff000000
240
	jmp	.common
244
    @@:
-
 
245
	stosd
241
 
246
	add	eax, 0x00010101
-
 
247
	jnc	@b
242
  .bpp8a:
248
	jmp	.common
243
	jmp	.common
Line 249... Line 244...
249
 
244
 
250
  .bpp16:
245
  .bpp16:
Line 344... Line 339...
344
	jnz	.l_l
339
	jnz	.l_l
345
	jmp	.decoded
340
	jmp	.decoded
Line 346... Line 341...
346
 
341
 
-
 
342
 
347
 
343
  .decoded:
348
  .decoded:
344
  .check1:
349
	cmp	[ebx + tiff_extra.samples_per_pixel], 3
345
	cmp	[ebx + tiff_extra.samples_per_pixel], 3
350
	jne	.pop_quit
346
	jne	.check2
351
	mov	eax, [retvalue]
347
	mov	eax, [retvalue]
352
	mov	esi, [eax + Image.Data]
348
	mov	esi, [eax + Image.Data]
353
	mov	edi, [eax + Image.Data]
349
	mov	edi, [eax + Image.Data]
Line 358... Line 354...
358
	movsb
354
	movsb
359
	mov	byte[esi - 1], al
355
	mov	byte[esi - 1], al
360
	add	edi, 2
356
	add	edi, 2
361
	dec	ecx
357
	dec	ecx
362
	jnz	@b
358
	jnz	@b
-
 
359
	jmp	.pop_quit
-
 
360
  .check2:
-
 
361
	mov	ebx, [retvalue]
-
 
362
	cmp	[ebx + Image.Type], Image.bpp8a
-
 
363
	jne	.pop_quit
-
 
364
	stdcall	tiff._.pack_8a, ebx
-
 
365
	mov	[ebx + Image.Type], Image.bpp8g
-
 
366
;	mov	eax, [ebx + Image.Width]
-
 
367
;	imul	eax, [ebx + Image.Height]
-
 
368
;	mov	ecx, eax
-
 
369
;	add	ecx, [ebx + Image.Data]
-
 
370
;	mov	[ebx + Image.Palette], ecx
-
 
371
;	add	eax, 256*4
-
 
372
;	stdcall	[mem.realloc], [ebx + Image.Data], eax
-
 
373
;	mov	edi, [ebx + Image.Palette]
-
 
374
;	mov	eax, 0xff000000
-
 
375
;    @@:
363
 
376
;	stosd
-
 
377
;	add	eax, 0x00010101
-
 
378
;	jnc	@b
Line 364... Line 379...
364
 
379
 
365
  .pop_quit:
380
  .pop_quit:
366
	pop	esi
381
	pop	esi
367
  .quit:
382
  .quit:
Line 390... Line 405...
390
	lodsw
405
	lodsw
391
	lodsd
406
	lodsd
392
	lodsd
407
	lodsd
393
	jmp	.quit			; just skip it
408
	jmp	.quit					; just skip it
Line 394... Line 409...
394
 
409
 
395
  .tag_100:
410
  .tag_100:						; ImageWidth
396
	cmp	ax, TIFF.IFDE_TYPE.SHORT
411
	cmp	ax, TIFF.IFDE_TYPE.SHORT
397
	jne	@f
412
	jne	@f
398
	lodsd
413
	lodsd
399
	xor	eax, eax
414
	xor	eax, eax
Line 409... Line 424...
409
	mov	[ebx + tiff_extra.image_width], eax
424
	mov	[ebx + tiff_extra.image_width], eax
410
	jmp	.quit
425
	jmp	.quit
411
    @@:
426
    @@:
412
	jmp	.quit
427
	jmp	.quit
Line 413... Line 428...
413
 
428
 
414
  .tag_101:
429
  .tag_101:						; ImageHeight
415
	cmp	ax, TIFF.IFDE_TYPE.SHORT
430
	cmp	ax, TIFF.IFDE_TYPE.SHORT
416
	jne	@f
431
	jne	@f
417
	lodsd
432
	lodsd
418
	xor	eax, eax
433
	xor	eax, eax
Line 428... Line 443...
428
	mov	[ebx + tiff_extra.image_height], eax
443
	mov	[ebx + tiff_extra.image_height], eax
429
	jmp	.quit
444
	jmp	.quit
430
    @@:
445
    @@:
431
	jmp	.quit
446
	jmp	.quit
Line 432... Line 447...
432
 
447
 
433
  .tag_102:
448
  .tag_102:						; BitsPerSample
434
	lodsd_
449
	lodsd_
435
	imul	eax, TIFF.IFDE_TYPE_LENGTH.SHORT
450
	imul	eax, TIFF.IFDE_TYPE_LENGTH.SHORT
436
	cmp	eax, 4
451
	cmp	eax, 4
437
	ja	@f
452
	ja	@f
Line 449... Line 464...
449
	lodsw_
464
	lodsw_
450
	pop	esi
465
	pop	esi
451
	mov	[ebx + tiff_extra.bits_per_sample], eax
466
	mov	[ebx + tiff_extra.bits_per_sample], eax
452
	jmp	.quit
467
	jmp	.quit
Line 453... Line 468...
453
 
468
 
454
  .tag_103:
469
  .tag_103:						; Compression
455
	cmp	ax, TIFF.IFDE_TYPE.SHORT
470
	cmp	ax, TIFF.IFDE_TYPE.SHORT
456
	jne	@f
471
	jne	@f
457
	lodsd
472
	lodsd
458
	xor	eax, eax
473
	xor	eax, eax
Line 461... Line 476...
461
	lodsw
476
	lodsw
462
	jmp	.quit
477
	jmp	.quit
463
    @@:
478
    @@:
464
	jmp	.quit
479
	jmp	.quit
Line 465... Line 480...
465
 
480
 
466
  .tag_106:
481
  .tag_106:						; PhotometricInterpretation
467
	cmp	ax, TIFF.IFDE_TYPE.SHORT
482
	cmp	ax, TIFF.IFDE_TYPE.SHORT
468
	jne	@f
483
	jne	@f
469
	lodsd
484
	lodsd
470
	xor	eax, eax
485
	xor	eax, eax
Line 474... Line 489...
474
	jmp	.quit
489
	jmp	.quit
475
    @@:
490
    @@:
Line 476... Line 491...
476
 
491
 
Line 477... Line 492...
477
	jmp	.quit
492
	jmp	.quit
478
 
493
 
479
  .tag_111:
494
  .tag_111:						; StripOffsets
480
	cmp	ax, TIFF.IFDE_TYPE.SHORT
495
	cmp	ax, TIFF.IFDE_TYPE.SHORT
481
	jne	@f
496
	jne	@f
482
	mov	[ebx + tiff_extra.strip_offsets_length], TIFF.IFDE_TYPE_LENGTH.SHORT
497
	mov	[ebx + tiff_extra.strip_offsets_length], TIFF.IFDE_TYPE_LENGTH.SHORT
Line 496... Line 511...
496
	lodsd_
511
	lodsd_
497
	add	eax, [_data]
512
	add	eax, [_data]
498
	mov	[ebx + tiff_extra.strip_offsets], eax
513
	mov	[ebx + tiff_extra.strip_offsets], eax
499
	jmp	.quit
514
	jmp	.quit
Line 500... Line 515...
500
 
515
 
501
  .tag_115:
516
  .tag_115:						; SamplesPerPixel
502
	lodsd_
517
	lodsd_
503
	imul	eax, TIFF.IFDE_TYPE_LENGTH.SHORT
518
	imul	eax, TIFF.IFDE_TYPE_LENGTH.SHORT
504
	cmp	eax, 4
519
	cmp	eax, 4
505
	ja	@f
520
	ja	@f
Line 512... Line 527...
512
	lodsd_
527
	lodsd_
513
	add	eax, [_data]
528
	add	eax, [_data]
514
	movzx	eax, word[eax]
529
	movzx	eax, word[eax]
515
	jmp	.quit
530
	jmp	.quit
Line 516... Line 531...
516
 
531
 
517
  .tag_116:
532
  .tag_116:						; RowsPerStrip
518
	cmp	ax, TIFF.IFDE_TYPE.SHORT
533
	cmp	ax, TIFF.IFDE_TYPE.SHORT
519
	jne	@f
534
	jne	@f
520
	lodsd
535
	lodsd
521
	xor	eax, eax
536
	xor	eax, eax
Line 527... Line 542...
527
	lodsd
542
	lodsd
528
	lodsd_
543
	lodsd_
529
	mov	[ebx + tiff_extra.rows_per_strip], eax
544
	mov	[ebx + tiff_extra.rows_per_strip], eax
530
	jmp	.quit
545
	jmp	.quit
Line 531... Line 546...
531
 
546
 
532
  .tag_117:
547
  .tag_117:						; StripByteCounts
533
	cmp	ax, TIFF.IFDE_TYPE.SHORT
548
	cmp	ax, TIFF.IFDE_TYPE.SHORT
534
	jne	@f
549
	jne	@f
535
	mov	[ebx + tiff_extra.strip_byte_counts_length], TIFF.IFDE_TYPE_LENGTH.SHORT
550
	mov	[ebx + tiff_extra.strip_byte_counts_length], TIFF.IFDE_TYPE_LENGTH.SHORT
536
	jmp	.tag_117.common
551
	jmp	.tag_117.common
Line 548... Line 563...
548
	lodsd_
563
	lodsd_
549
	add	eax, [_data]
564
	add	eax, [_data]
550
	mov	[ebx + tiff_extra.strip_byte_counts], eax
565
	mov	[ebx + tiff_extra.strip_byte_counts], eax
551
	jmp	.quit
566
	jmp	.quit
Line 552... Line 567...
552
 
567
 
553
  .tag_140:
568
  .tag_140:						; ColorMap
554
	lodsd
569
	lodsd
555
	lodsd_
570
	lodsd_
556
	add	eax, [_data]
571
	add	eax, [_data]
557
	mov	[ebx + tiff_extra.palette], eax
572
	mov	[ebx + tiff_extra.palette], eax
-
 
573
	jmp	.quit
-
 
574
  .tag_152:						; ExtraSamples
-
 
575
	mov	[ebx + tiff_extra.extra_samples], esi
-
 
576
	mov	ecx, [ebx + tiff_extra.extra_samples_number]
-
 
577
	rep	lodsw	; ignored
Line 558... Line 578...
558
	jmp	.quit
578
	jmp	.quit
559
 
579
 
560
  .quit:
580
  .quit:
561
	pop	edi edx ebx
581
	pop	edi edx ebx
Line 565... Line 585...
565
 
585
 
Line 566... Line 586...
566
proc tiff._.define_image_type
586
proc tiff._.define_image_type
Line -... Line 587...
-
 
587
 
-
 
588
	xor	eax, eax
-
 
589
 
-
 
590
	cmp	[ebx + tiff_extra.photometric], TIFF.PHOTOMETRIC.RGB
-
 
591
	jne	.not_full_color
-
 
592
	mov	eax, -3
-
 
593
	add	eax, [ebx + tiff_extra.samples_per_pixel]
-
 
594
	mov	[ebx + tiff_extra.extra_samples_number], eax
-
 
595
	dec	eax
-
 
596
	jns	@f
-
 
597
	mov	eax, Image.bpp24
-
 
598
	jmp	.quit
-
 
599
    @@:
-
 
600
	dec	eax
-
 
601
	jns	@f
-
 
602
	mov	eax, Image.bpp32
-
 
603
;	mov	[ebx + tiff_extra.extra_samples_number], 0
567
 
604
	jmp	.quit
568
	xor	eax, eax
605
    @@:
569
 
606
  .not_full_color:	; grayscale, indexed, bilevel
570
	cmp	[ebx + tiff_extra.bits_per_sample], 1
607
	cmp	[ebx + tiff_extra.bits_per_sample], 1
571
	jg	.not_bilevel
608
	jg	.not_bilevel
572
	mov	eax, Image.bpp1
609
	mov	eax, Image.bpp1
573
	jmp	.quit
610
	jmp	.quit
574
  .not_bilevel:
611
  .not_bilevel:		; grayscale, indexed
575
	cmp	[ebx + tiff_extra.palette], 0
612
	cmp	[ebx + tiff_extra.palette], 0
576
	je	.without_palette
613
	je	.without_palette
577
	cmp	[ebx + tiff_extra.bits_per_sample], 4
614
	cmp	[ebx + tiff_extra.bits_per_sample], 4
578
	jne	@f
615
	jne	@f
579
	mov	eax, Image.bpp4
616
;	mov	eax, Image.bpp4
580
	jmp	.quit
617
	jmp	.quit
581
    @@:
618
    @@:
582
	cmp	[ebx + tiff_extra.bits_per_sample], 8
619
	cmp	[ebx + tiff_extra.bits_per_sample], 8
583
	jne	@f
620
	jne	@f
584
	mov	eax, Image.bpp8
621
	mov	eax, Image.bpp8i
585
	jmp	.quit
622
	jmp	.quit
586
    @@: 
-
 
587
	jmp	.quit
623
    @@: 
588
  .without_palette:
624
	jmp	.quit
589
	cmp	[ebx + tiff_extra.samples_per_pixel], 1
-
 
590
	jg	.not_grayscale
-
 
591
	cmp	[ebx + tiff_extra.bits_per_sample], 4
-
 
592
	jne	@f
-
 
593
	mov	eax, Image.bpp4
625
  .without_palette:	; grayscale
594
	jmp	.quit
626
	mov	eax, -1
595
    @@:
-
 
596
	cmp	[ebx + tiff_extra.bits_per_sample], 8
-
 
597
	jne	@f
-
 
598
	mov	eax, Image.bpp8
-
 
599
	jmp	.quit
627
	add	eax, [ebx + tiff_extra.samples_per_pixel]
600
  .not_grayscale:
628
	mov	[ebx + tiff_extra.extra_samples_number], eax
601
	cmp	[ebx + tiff_extra.samples_per_pixel], 3
629
	dec	eax
602
	jne	@f
630
	jns	@f
-
 
631
	mov	eax, Image.bpp8g
603
	mov	eax, Image.bpp24
632
	jmp	.quit
604
	jmp	.quit
633
    @@:
605
    @@:
634
	mov	eax, Image.bpp8a
606
	jmp	.quit
635
	jmp	.quit
Line 828... Line 857...
828
 
857
 
829
	ret
858
	ret
Line -... Line 859...
-
 
859
endp
-
 
860
 
-
 
861
 
-
 
862
proc	tiff._.pack_8a _img
-
 
863
	mov	ebx, [_img]
-
 
864
	mov	esi, [ebx + Image.Data]
-
 
865
	mov	edi, esi
-
 
866
	mov	ecx, [ebx + Image.Width]
-
 
867
	imul	ecx, [ebx + Image.Height]
-
 
868
    @@:
-
 
869
	lodsw
-
 
870
	stosb
-
 
871
	dec	ecx
-
 
872
	jnz	@b
830
endp
873
	ret
831
 
874
endp
832
 
875
 
833
;;================================================================================================;;
876
;;================================================================================================;;
834
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
877
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
Line 846... Line 889...
846
  .tag_111:		dd	0x0111,	tiff._.parse_IFDE.tag_111		; strip offsets
889
  .tag_111:		dd	0x0111,	tiff._.parse_IFDE.tag_111		; strip offsets
847
  .tag_115:		dd	0x0115,	tiff._.parse_IFDE.tag_115		; samples per pixel
890
  .tag_115:		dd	0x0115,	tiff._.parse_IFDE.tag_115		; samples per pixel
848
  .tag_116:		dd	0x0116,	tiff._.parse_IFDE.tag_116		; rows per strip
891
  .tag_116:		dd	0x0116,	tiff._.parse_IFDE.tag_116		; rows per strip
849
  .tag_117:		dd	0x0117,	tiff._.parse_IFDE.tag_117		; strip byte counts
892
  .tag_117:		dd	0x0117,	tiff._.parse_IFDE.tag_117		; strip byte counts
850
  .tag_140:		dd	0x0140,	tiff._.parse_IFDE.tag_140		; color map
893
  .tag_140:		dd	0x0140,	tiff._.parse_IFDE.tag_140		; color map
-
 
894
  .tag_152:		dd	0x0152,	tiff._.parse_IFDE.tag_152		; extra samples
851
tiff.IFDE_tag_table.end:
895
tiff.IFDE_tag_table.end:
Line 852... Line 896...
852
 
896