kolibrios/programs/develop/libraries/libs-dev/libimg/pnm/pgm.asm
Ivan Baravy 0808796ed5 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
2012-02-23 22:09:09 +00:00

73 lines
1.0 KiB
NASM

.pgm:
stdcall img.create, [width], [height], Image.bpp8
test eax, eax
jz .quit
mov [retvalue], eax
mov ebx, eax
mov edi, [ebx+Image.Palette]
mov eax, 0xff000000
@@:
stosd
add eax, 0x00010101
jnc @b
mov edi, [ebx+Image.Data]
mov ecx, [ebx+Image.Width]
imul ecx, [ebx+Image.Height]
cmp [data_type], PNM_ASCII
je .pgm.ascii
.pgm.raw:
cmp [maxval], 0xff
jne .pgm.raw.scale
rep movsb
jmp .quit
.pgm.raw.scale:
mov edx, [maxval]
mov eax, 0
@@:
lodsb
mov ebx, eax
shl eax, 8
sub eax, ebx
div dl
stosb
dec ecx
jnz @b
jmp .quit
.pgm.ascii:
xor eax, eax
cmp [maxval], 0xff
jne .pgm.ascii.scale
.pgm.ascii.next_char:
lodsb
cmp al, ' '
jna .pgm.ascii.next_char
call pnm._.get_number
mov eax, ebx
stosb
dec ecx
jnz .pgm.ascii.next_char
jmp .quit
.pgm.ascii.scale:
mov edx, [maxval]
.pgm.ascii.scale.next_char:
lodsb
cmp al, ' '
jna .pgm.ascii.scale.next_char
call pnm._.get_number
mov eax, ebx
shl eax, 8
sub eax, ebx
div dl
stosb
dec ecx
jnz .pgm.ascii.scale.next_char
jmp .quit