Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 3499 → Rev 3498

/programs/develop/libraries/libs-dev/libimg/xbm/xbm.asm
File deleted
/programs/develop/libraries/libs-dev/libimg/libimg.asm
45,7 → 45,6
include 'tiff/tiff.asm'
include 'pnm/pnm.asm'
include 'wbmp/wbmp.asm'
include 'xbm/xbm.asm'
 
include 'scale.asm'
include 'convert.asm'
1927,7 → 1926,6
.tiff dd LIBIMG_FORMAT_TIFF, img.is.tiff, img.decode.tiff, img.encode.tiff,0
.pnm dd LIBIMG_FORMAT_PNM, img.is.pnm, img.decode.pnm, img.encode.pnm, 1 + (1 SHL Image.bpp1) + (1 SHL Image.bpp8g) + (1 SHL Image.bpp24)
.wbmp dd LIBIMG_FORMAT_WBMP, img.is.wbmp, img.decode.wbmp, img.encode.wbmp,0
.xbm dd LIBIMG_FORMAT_XBM, img.is.xbm, img.decode.xbm, img.encode.xbm, 0
.z80 dd LIBIMG_FORMAT_Z80, img.is.z80, img.decode.z80, img.encode.z80, 0 ;this must be the last entry as there are no signatures in z80 screens at all
dd 0
 
2163,7 → 2161,7
;;================================================================================================;;
 
align 4
type2bpp dd 8, 24, 32, 15, 16, 1, 9;, 2, 4
type2bpp dd 8, 24, 32, 15, 16, 1, 9 ;,16
img._.do_rgb.handlers:
dd img._.do_rgb.bpp8i
dd img._.do_rgb.bpp24
/programs/develop/libraries/libs-dev/libimg/libimg.inc
30,8 → 30,7
LIBIMG_FORMAT_TIFF = 10
LIBIMG_FORMAT_PNM = 11
LIBIMG_FORMAT_WBMP = 12
LIBIMG_FORMAT_XBM = 13
LIBIMG_FORMAT_Z80 = 14
LIBIMG_FORMAT_Z80 = 13
 
; scale type ; corresponding img.scale params
LIBIMG_SCALE_INTEGER = 1 ; scale factor ; reserved 0
79,7 → 78,7
ends
 
struct Image
Checksum dd ? ; ((Width ROL 16) OR Height) XOR Data[0] ; ignored so far
Checksum dd ? ; ((Width ROL 16) OR Height) XOR Data[0]
Width dd ?
Height dd ?
Next dd ?
86,7 → 85,7
Previous dd ?
Type dd ? ; one of Image.bppN
Data dd ?
Palette dd ? ; used iff Type eq Image.bpp1, Image.bpp2, Image.bpp4 or Image.bpp8i
Palette dd ? ; used iff Type eq Image.bpp8 or Image.bpp1
Extended dd ?
Flags dd ? ; bitfield
Delay dd ? ; used iff Image.IsAnimated is set in Flags
102,8 → 101,8
Image.bpp1 = 6
Image.bpp8g = 7 ; grayscale
Image.bpp8a = 8 ; grayscale with alpha channel; application layer only!!! kernel doesn't handle this image type, libimg can only create and destroy such images
;Image.bpp2 = 9
;Image.bpp4 = 10
;Image.bpp4 = 9
;Image.bpp2 = 10
 
; bits in Image.Flags
Image.IsAnimated = 1
/programs/develop/libraries/libs-dev/libimg/tiff/tiff.asm
193,25 → 193,21
push esi ; fixme!!
 
mov ecx, [edx + Image.Type]
cmp ecx, Image.bpp8i
je .bpp8i
cmp ecx, Image.bpp24
je .bpp24
cmp ecx, Image.bpp32
je .bpp32
cmp ecx, Image.bpp16
je .bpp16
cmp ecx, Image.bpp1
je .bpp1
cmp ecx, Image.bpp8g
je .bpp8g
cmp ecx, Image.bpp8a
je .bpp8a
; cmp ecx, Image.bpp2
; je .bpp2
; cmp ecx, Image.bpp4
; je .bpp4
jmp .quit
dec ecx
jz .bpp8i
dec ecx
jz .bpp24
dec ecx
jz .bpp32
dec ecx
dec ecx ; tiff doesn't handle 15bpp images
jz .bpp16
dec ecx
jz .bpp1
dec ecx
jz .bpp8g
dec ecx
jz .bpp8a
;error report!!
 
.bpp1:
228,9 → 224,6
mov [edi + 4], dword 0x00000000
jmp .common
 
.bpp2:
jmp .common
 
.bpp4:
jmp .common
 
358,9 → 351,6
 
 
.decoded:
cmp [ebx + tiff_extra.planar_configuration], TIFF.PLANAR.PLANAR
jne .post.rgb_bgr
stdcall tiff._.planar_to_separate, [retvalue]
.post.rgb_bgr:
cmp [ebx + tiff_extra.samples_per_pixel], 3
jne .post.rgba_bgra
627,21 → 617,6
mov [ebx + tiff_extra.strip_byte_counts], eax
jmp .quit
 
.tag_11c: ; Planar configuration
cmp ax, TIFF.IFDE_TYPE.SHORT
jne @f
lodsd
xor eax, eax
lodsw_
mov [ebx + tiff_extra.planar_configuration], eax
;debug_print 'planar_configuration: '
;debug_print_dec eax
;newline
lodsw
@@:
jmp .quit
 
 
.tag_13d: ; Predictor
cmp ax, TIFF.IFDE_TYPE.SHORT
jne @f
735,7 → 710,7
 
proc tiff._.decompress.packbits _image
 
push edx
push ebx ecx edx esi
 
mov edx, ecx
 
742,9 → 717,10
.decode:
lodsb
dec edx
cmp al, 0x7f
jbe .different
cmp al, 0x80
jb .different
jg .identical
jne .identical
test edx, edx
jz .quit
jmp .decode
769,7 → 745,7
jnz .decode
 
.quit:
pop edx
pop esi edx ecx ebx
ret
endp
 
1191,75 → 1167,6
ret
endp
 
 
proc tiff._.planar_to_separate _img
locals
pixels rd 1
tmp_image rd 1
channels rd 1
channel_padding rd 1
endl
pushad
mov ebx, [_img]
mov ecx, [ebx + Image.Width]
imul ecx, [ebx + Image.Height]
mov [pixels], ecx
cmp [ebx + Image.Type], Image.bpp24
je .bpp24
cmp [ebx + Image.Type], Image.bpp32
je .bpp32
; cmp [ebx + Image.Type], Image.bpp4
; je .bpp4
jmp .quit
.bpp24:
mov [channels], 3
mov [channel_padding], 2
lea eax, [ecx*3]
jmp .proceed
.bpp32:
mov [channels], 4
mov [channel_padding], 3
shl eax, 2
jmp .proceed
.bpp4:
mov [channels], 3
mov [channel_padding], 2
shr eax, 1
jmp .proceed
.proceed:
invoke mem.alloc, eax
test eax, eax
jz .quit
mov [tmp_image], eax
.channel:
mov esi, [ebx + Image.Data]
mov edi, [tmp_image]
mov ecx, [pixels]
mov eax, [channel_padding]
inc eax
sub eax, [channels]
add edi, eax
mov eax, [channels]
dec eax
imul eax, [pixels]
add esi, eax
@@:
lodsb
stosb
add edi, [channel_padding]
dec ecx
jnz @b
dec [channels]
jnz .channel
 
.quit:
mov eax, [tmp_image]
xchg [ebx + Image.Data], eax
invoke mem.free, eax
popad
ret
endp
 
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
1277,7 → 1184,6
.tag_115: dd 0x0115, tiff._.parse_IFDE.tag_115 ; samples per pixel
.tag_116: dd 0x0116, tiff._.parse_IFDE.tag_116 ; rows per strip
.tag_117: dd 0x0117, tiff._.parse_IFDE.tag_117 ; strip byte counts
.tag_11c: dd 0x011c, tiff._.parse_IFDE.tag_11c ; planar configuration
.tag_13d: dd 0x013d, tiff._.parse_IFDE.tag_13d ; predictor
.tag_140: dd 0x0140, tiff._.parse_IFDE.tag_140 ; color map
.tag_152: dd 0x0152, tiff._.parse_IFDE.tag_152 ; extra samples
/programs/develop/libraries/libs-dev/libimg/tiff/tiff.inc
23,7 → 23,6
first_IFD rd 1
ends
 
 
struct tiff_extra
image_width rd 1 ; SHORT or LONG
image_height rd 1 ; SHORT or LONG
39,7 → 38,6
strip_byte_counts_length rd 1
palette rd 1 ; SHORT
palette_size rd 1 ; in colors, not samples
planar_configuration rd 1 ; SHORT
extra_samples rd 1 ; pointer to array of SHORTs
extra_samples_number rd 1
predictor rd 1 ; SHORT
89,10 → 87,7
TIFF.PHOTOMETRIC.YCbCr = 6
TIFF.PHOTOMETRIC.CIELAB = 8
 
TIFF.PLANAR.CHUNKY = 1
TIFF.PLANAR.PLANAR = 2
 
 
macro lodsw_
{
stdcall tiff._.get_word, [_endianness]
/programs/develop/libraries/libs-dev/libimg/pcx/pcx.asm
1,5 → 1,5
;;================================================================================================;;
;;//// pcx.asm //// (c) dunkaist, 2010,2012-2013 /////////////////////////////////////////////////;;
;;//// pcx.asm //// (c) dunkaist, 2010,2012 //////////////////////////////////////////////////////;;
;;================================================================================================;;
;; ;;
;; This file is part of Common development libraries (Libs-Dev). ;;
30,27 → 30,33
;< eax = false / true ;;
;;================================================================================================;;
 
push edi
push ecx edi
xor eax, eax
 
mov edi, [_data]
 
mov ecx, [edi]
shl ecx, 8
cmp ecx, 0x01050a00
cmp byte[edi + pcx_header.magic_number], 0x0A
jne .is_not_pcx
cmp byte[edi + pcx_header.version], 5
jne .is_not_pcx
cmp byte[edi + pcx_header.encoding], 1
jne .is_not_pcx
cmp byte[edi + pcx_header.reserved], 0
jne .is_not_pcx
 
add edi, pcx_header.filler
mov ecx, 58/2
repe scasw
jne .is_not_pcx
xor al, al
mov ecx, 58
cld
repe scasb
test ecx, ecx
jnz .is_not_pcx
 
.is_pcx:
inc eax
 
.is_not_pcx:
pop edi
pop edi ecx
ret
endp
 
66,13 → 72,12
;< eax = 0 (error) or pointer to image ;;
;;================================================================================================;;
locals
num_planes rd 1
width rd 1
height rd 1
bp_plane rd 1
bp_scanline rd 1
nplanes rd 1
xsize rd 1
ysize rd 1
bpl rd 1
total_bpl rd 1
line_begin rd 1
cur_scanline rd 1
retvalue rd 1 ; 0 (error) or pointer to image
endl
 
80,21 → 85,21
 
mov esi, [_data]
movzx eax, byte[esi + pcx_header.nplanes]
mov [num_planes], eax
mov [nplanes], eax
movzx ebx, word[esi + pcx_header.bpl]
mov [bp_plane], ebx
mov [bpl], ebx
imul eax, ebx
mov [bp_scanline], eax
mov [total_bpl], eax
 
movzx eax, word[esi + pcx_header.xmax]
sub ax, word[esi + pcx_header.xmin]
inc eax
mov [width], eax
mov [xsize], eax
 
movzx ebx, word[esi + pcx_header.ymax]
sub bx, word[esi + pcx_header.ymin]
inc ebx
mov [height], ebx
mov [ysize], ebx
 
cmp [esi + pcx_header.bpp], 1
jz .monochrome
103,36 → 108,56
 
 
.24bit:
stdcall img.create, [bp_plane], 1, Image.bpp24
mov [cur_scanline], eax
test eax, eax
jz .quit
 
stdcall img.create, [width], [height], Image.bpp24
stdcall img.create, eax, ebx, Image.bpp24
mov [retvalue], eax
test eax, eax
jz .quit
 
mov esi, [_data]
add esi, sizeof.pcx_header
mov edx, [eax + Image.Data]
add esi, 128 ; skip header
mov edi, [eax + Image.Data]
add edi, 2
mov [line_begin], edi
 
.24bit.scanline:
mov edi, [cur_scanline]
mov ebx, [bp_scanline]
mov ebx, [total_bpl]
.24bit.color_line:
mov edx, [bpl]
.24bit.next_byte:
call pcx._.get_byte
sub edx, ecx
@@:
call pcx._.get_byte
rep stosb
test ebx, ebx
mov [edi], al
add edi, [nplanes]
dec ecx
jnz @b
stdcall pcx._.scanline_unpack, [width], [cur_scanline], [num_planes]
dec [height]
jnz .24bit.scanline
jmp .quit
 
test edx, edx
jnz .24bit.next_byte
 
.24bit.end_color_line:
test ebx, ebx
jz .24bit.end_full_line
dec [line_begin]
mov edi, [line_begin]
jmp .24bit.color_line
 
.24bit.end_full_line:
dec [ysize]
jz .quit
add edi, 2
bt [xsize], 0
jnc @f
sub edi, 3
@@:
mov [line_begin], edi
jmp .24bit.scanline
 
 
.indexed:
stdcall img.create, [width], [height], Image.bpp8i
 
stdcall img.create, eax, ebx, Image.bpp8i
mov [retvalue], eax
test eax, eax
jz .quit
140,40 → 165,42
mov ebx, eax
mov esi, [_data]
add esi, [_length]
sub esi, 256*3 ; rgb triplets
sub esi, 768
mov edi, [eax + Image.Palette]
mov ecx, 256
mov eax, 0x0000ff00
xor eax, eax
@@:
mov al, [esi + 0]
mov [edi + 2], ax
mov al, [esi + 1]
mov [edi + 1], al
mov al, [esi + 2]
mov [edi + 0], al
add esi, 3
add edi, 4
lodsw
xchg al, ah
shl eax, 8
lodsb
stosd
dec ecx
jnz @b
 
mov esi, [_data]
add esi, sizeof.pcx_header
add esi, 128
mov edi, [ebx + Image.Data]
 
.indexed.scanline:
mov ebx, [bp_scanline]
.indexed.line:
mov ebx, [total_bpl]
.indexed.next_byte:
call pcx._.get_byte
@@:
call pcx._.get_byte
rep stosb
stosb
dec ecx
jnz @b
test ebx, ebx
jnz @b
dec [height]
jnz .indexed.scanline
jnz .indexed.next_byte
 
dec [ysize]
jnz .indexed.line
jmp .quit
 
 
.monochrome:
stdcall img.create, [width], [height], Image.bpp1
 
stdcall img.create, eax, ebx, Image.bpp1
mov [retvalue], eax
test eax, eax
jz .quit
183,20 → 210,25
mov [edi + 4], dword 0xffffffff
 
mov esi, [_data]
add esi, sizeof.pcx_header
add esi, 128
mov edi, [eax + Image.Data]
 
.monochrome.scanline:
mov ebx, [bp_scanline]
 
.monochrome.line:
mov ebx, [total_bpl]
.monochrome.next_byte:
call pcx._.get_byte
@@:
call pcx._.get_byte
rep stosb
stosb
dec ecx
jnz @b
test ebx, ebx
jnz @b
dec [height]
jnz .monochrome.scanline
jnz .monochrome.next_byte
dec [ysize]
jnz .monochrome.line
; jmp .quit
 
 
.quit:
popa
mov eax, [retvalue]
230,47 → 262,20
;;================================================================================================;;
proc pcx._.get_byte
 
mov ecx, 1
xor eax, eax
xor ecx, ecx
lodsb
cmp eax, 0xc0
jb @f
and eax, 0x3f
mov ecx, eax
cmp al, 0xC0
setb cl
jb .done
and al, 0x3F
mov cl, al
lodsb
@@:
.done:
sub ebx, ecx
ret
endp
 
 
proc pcx._.scanline_unpack _width, _scanline, _num_planes
push esi
 
mov esi, [_scanline]
mov ebx, [_num_planes]
dec ebx
 
.plane:
mov ecx, [_width]
mov edi, edx
add edi, ebx
@@:
mov al, [esi]
mov [edi], al
add esi, 1
add edi, [_num_planes]
dec ecx
jnz @b
bt dword[_width], 0
adc esi, 0
dec ebx
jns .plane
 
mov edx, edi
pop esi
ret
endp
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;