forked from KolibriOS/kolibrios
libimg:
1. tiff (baseline) support 2. pnm (portable anymap) bilevel, grayscale (8bpp), pixmap (24bpp) support 3. xcf: optional layer merging/blending with sse (default is mmx) 4'. new formatting for my old code. more readable for now git-svn-id: svn://kolibrios.org@2388 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
117
programs/develop/libraries/libs-dev/libimg/pnm/ppm.asm
Normal file
117
programs/develop/libraries/libs-dev/libimg/pnm/ppm.asm
Normal file
@@ -0,0 +1,117 @@
|
||||
.ppm:
|
||||
stdcall img.create, [width], [height], Image.bpp24
|
||||
test eax, eax
|
||||
jz .quit
|
||||
mov [retvalue], eax
|
||||
mov ebx, eax
|
||||
|
||||
mov edi, [ebx + Image.Data]
|
||||
mov ecx, [ebx + Image.Width]
|
||||
imul ecx, [ebx + Image.Height]
|
||||
|
||||
cmp [data_type], PNM_ASCII
|
||||
je .ppm.ascii
|
||||
|
||||
.ppm.raw:
|
||||
cmp [maxval], 0xff
|
||||
jne .ppm.raw.scale
|
||||
@@:
|
||||
lodsw
|
||||
xchg al, ah
|
||||
movsb
|
||||
stosw
|
||||
dec ecx
|
||||
jnz @b
|
||||
jmp .quit
|
||||
.ppm.raw.scale:
|
||||
mov edx, [maxval]
|
||||
xor eax, eax
|
||||
@@:
|
||||
lodsb
|
||||
mov ebx, eax
|
||||
shl eax, 8
|
||||
sub eax, ebx
|
||||
div dl
|
||||
stosb
|
||||
lodsb
|
||||
mov ebx, eax
|
||||
shl eax, 8
|
||||
sub eax, ebx
|
||||
div dl
|
||||
stosb
|
||||
lodsb
|
||||
mov ebx, eax
|
||||
shl eax, 8
|
||||
sub eax, ebx
|
||||
div dl
|
||||
stosb
|
||||
dec ecx
|
||||
jnz @b
|
||||
jmp .quit
|
||||
|
||||
.ppm.ascii:
|
||||
xor eax, eax
|
||||
cmp [maxval], 0xff
|
||||
jne .ppm.ascii.scale
|
||||
.ppm.ascii.next_char:
|
||||
@@:
|
||||
lodsb
|
||||
cmp al, ' '
|
||||
jna @b
|
||||
call pnm._.get_number
|
||||
mov [edi + 2], bl
|
||||
@@:
|
||||
lodsb
|
||||
cmp al, ' '
|
||||
jna @b
|
||||
call pnm._.get_number
|
||||
mov [edi + 1], bl
|
||||
@@:
|
||||
lodsb
|
||||
cmp al, ' '
|
||||
jna @b
|
||||
call pnm._.get_number
|
||||
mov [edi + 0], bl
|
||||
add edi, 3
|
||||
dec ecx
|
||||
jnz .ppm.ascii.next_char
|
||||
jmp .quit
|
||||
|
||||
.ppm.ascii.scale:
|
||||
mov edx, [maxval]
|
||||
.ppm.ascii.scale.next_char:
|
||||
@@:
|
||||
lodsb
|
||||
cmp al, ' '
|
||||
jna @b
|
||||
call pnm._.get_number
|
||||
mov eax, ebx
|
||||
shl eax, 8
|
||||
sub eax, ebx
|
||||
div dl
|
||||
mov [edi + 2], al
|
||||
@@:
|
||||
lodsb
|
||||
cmp al, ' '
|
||||
jna @b
|
||||
call pnm._.get_number
|
||||
mov eax, ebx
|
||||
shl eax, 8
|
||||
sub eax, ebx
|
||||
div dl
|
||||
mov [edi + 1], al
|
||||
@@:
|
||||
lodsb
|
||||
cmp al, ' '
|
||||
jna @b
|
||||
call pnm._.get_number
|
||||
mov eax, ebx
|
||||
shl eax, 8
|
||||
sub eax, ebx
|
||||
div dl
|
||||
mov [edi + 0], al
|
||||
add edi, 3
|
||||
dec ecx
|
||||
jnz .ppm.ascii.next_char
|
||||
jmp .quit
|
||||
|
Reference in New Issue
Block a user