Subversion Repositories Kolibri OS

Compare Revisions

No changes between revisions

Regard whitespace Rev 3055 → Rev 3054

/programs/develop/libraries/libs-dev/.test/005/test005.asm
File deleted
/programs/develop/libraries/libs-dev/.test/005/kolibri_logo.jpg
Cannot display: file marked as a binary type.
svn:mime-type = image/jpeg
Property changes:
Deleted: svn:mime-type
-image/jpeg
\ No newline at end of property
/programs/develop/libraries/libs-dev/.test/003/test003.asm
75,8 → 75,8
dec ecx
jnz @b
 
stdcall [img.encode], [image_to_rgb2], (LIBIMG_FORMAT_PNM), 0
; stdcall [img.encode], [image_initial], (LIBIMG_FORMAT_PNM), 0
stdcall [img.encode], [image_to_rgb2], (LIBIMG_FORMAT_ID_PNM), 0
; stdcall [img.encode], [image_initial], (LIBIMG_FORMAT_ID_PNM), 0
test eax, eax
jz exit
mov [encoded_file], eax
/programs/develop/libraries/libs-dev/libimg/libimg.asm
47,7 → 47,7
include 'wbmp/wbmp.asm'
 
include 'scale.asm'
include 'convert.asm'
;include 'convert.asm'
;include 'transform.asm'
 
;;================================================================================================;;
1929,18 → 1929,6
.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
 
align 4
img.types_table: ; entries order must correspond to type defnitions in libimg.inc
dd 0 ; there is no Image.bpp* = 0
.bpp8i dd (1 SHL Image.bpp24)
.bpp24 dd (1 SHL Image.bpp24) OR (1 SHL Image.bpp8g)
.bpp32 dd (1 SHL Image.bpp24)
.bpp15 dd (1 SHL Image.bpp24)
.bpp16 dd (1 SHL Image.bpp24)
.bpp1 dd (1 SHL Image.bpp24)
.bpp8g dd (1 SHL Image.bpp24) OR (1 SHL Image.bpp1 )
.bpp8a dd (1 SHL Image.bpp24)
 
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
2218,7 → 2206,6
img.rotate.layer , 'img_rotate_layer' , \
img.draw , 'img_draw' , \
img.scale , 'img_scale' , \
img.convert , 'img_convert' , \
img.formats_table, 'img_formats_table'
 
; import from deflate unpacker
/programs/develop/libraries/libs-dev/libimg/libimg.inc
67,7 → 67,7
LIBIMG_ENCODE_FLUSH_ALPHA = 0x10
 
; convert flags
; TBD
LIBIMG_CONVERT_IN_PLACE = 0x01 ; do not create new image, store result in _src
 
struct FormatsTableEntry
Format_id dd ?
/programs/develop/libraries/libs-dev/libimg/tga/tga.asm
1,5 → 1,5
;;================================================================================================;;
;;//// tga.asm //// (c) Nable, 2007-2008, (c) dunkaist, 2012 /////////////////////////////////////;;
;;//// tga.asm //// (c) Nable, 2007-2008 /////////////////////////////////////////////////////////;;
;;================================================================================================;;
;; ;;
;; This file is part of Common development libraries (Libs-Dev). ;;
19,8 → 19,6
;; ;;
;; References: ;;
;; 1. Hiview 1.2 by Mohammad A. REZAEI ;;
;; 2. Truevision TGA FILE FORMAT SPECIFICATION Version 2.0 ;;
;; Technical Manual Version 2.2 January, 1991 ;;
;; ;;
;;================================================================================================;;
 
39,37 → 37,34
push ebx
cmp [_length], 18
jbe .nope
mov ebx, [_data]
mov eax, dword[ebx + tga_header.colormap_type]
cmp al, 1
mov eax, [_data]
mov ebx,[eax+1] ;bl=cmatype,bh=subtype
cmp bl,1 ;cmatype is in [0..1]
ja .nope
cmp ah, 11
cmp bh,11 ;subtype is in [1..3] (non-rle) or in [9..11] (rle)
ja .nope
cmp ah, 9
cmp bh,9
jae .cont1
cmp ah, 3
cmp bh,3
ja .nope
.cont1:
mov eax, dword[ebx + tga_header.image_spec.depth]
test eax, 111b ; bpp must be 8, 15, 16, 24 or 32
.cont1: ;continue testing
mov ebx,[eax+16] ;bl=bpp, bh=flags //image descriptor
test ebx,111b ;bpp must be 8, 15, 16, 24 or 32
jnz .maybe15
shr al, 3
cmp al, 4
shr bl,3
cmp bl,4
ja .nope
jmp .cont2
.maybe15:
cmp al, 15
cmp bl,15
jne .nope
.cont2: ; continue testing
movzx eax, byte[ebx + tga_header.colormap_spec.entry_size] ; palette bpp
cmp eax, 0
test bh,tga.flags.interlace_type ;deinterlacing is not supported yet
jnz .nope
cmp byte[eax+7],24 ;test palette bpp - only 24 and 32 are supported
je .yep
cmp eax, 16
cmp byte[eax+7],32 ;test palette bpp - only 24 and 32 are supported
je .yep
cmp eax, 24
je .yep
cmp eax, 32
je .yep
.nope:
xor eax, eax
pop ebx
93,74 → 88,51
;< eax = 0 (error) or pointer to image ;;
;;================================================================================================;;
locals
width dd ?
height dd ?
bytes_per_pixel dd ?
retvalue dd ?
IMGwidth dd ?
IMGheight dd ?
IMGbpp dd ?
DupPixelCount dd ?
TgaBlockCount dd ?
endl
push ebx esi edi
mov ebx, [_data]
movzx esi, byte[ebx]
lea esi, [esi + ebx + sizeof.tga_header] ; skip comment and header
mov edx, dword[ebx + tga_header.image_spec.width]
movzx ecx, dx ; ecx = width
shr edx, 16 ; edx = height
mov [width], ecx
mov [height], edx
movzx eax, byte[ebx + tga_header.image_spec.depth]
add eax, 7
shr eax, 3
mov [bytes_per_pixel], eax
movzx eax, byte[ebx + tga_header.image_spec.depth]
 
cmp eax, 8
jne @f
mov eax, Image.bpp8i
jmp .type_defined
pushad
cld ;paranoia
and [DupPixelCount],0 ;prepare variables
and [TgaBlockCount],0 ;prepare variables
mov eax,[_data]
movzx esi,byte[eax]
lea esi,[esi+eax+18] ;skip comment and header
mov ebx,[eax+12]
movzx ecx,bx ;ecx=width
shr ebx,16 ;ebx=height
mov [IMGwidth],ecx
mov [IMGheight],ebx
movzx edx,byte[eax+16]
cmp edx,16
jnz @f
dec edx ;16bpp tga images are really 15bpp ARGB
@@:
cmp eax, 15
jne @f
mov eax, Image.bpp15
jmp .type_defined
@@:
cmp eax, 16
jne @f
mov eax, Image.bpp15 ; 16bpp tga images are really 15bpp ARGB
jmp .type_defined
@@:
cmp eax, 24
jne @f
mov eax, Image.bpp24
jmp .type_defined
@@:
cmp eax, 32
jne @f
mov eax, Image.bpp32
jmp .type_defined
@@:
.type_defined:
stdcall img.create, ecx, edx, eax
mov [retvalue], eax
sub edx, 16 - Image.bpp16 ; 15 -> Image.bpp15, 16 -> Image.bpp16
mov [IMGbpp],edx
stdcall img.create,ecx,ebx,edx
mov [esp+28],eax ;save return value
test eax, eax ; failed to allocate?
jz .done ; then exit
mov ebx, eax
cmp dword[ebx + Image.Type], Image.bpp8i
jz .locret ;then exit
cmp edx,8
jne .palette_parsed
mov edi, [ebx + Image.Palette]
mov edi,[eax+Image.Palette]
mov ecx, [_data]
cmp byte[ecx + tga_header.image_type], 3 ; we also have grayscale subtype
cmp byte[ecx+2],3 ;we also have grayscale subtype
jz .write_grayscale_palette ; that don't hold palette in file
cmp byte[ecx + tga_header.image_type], 11
cmp byte[ecx+2],11
jz .write_grayscale_palette
movzx eax, byte[ecx + tga_header.colormap_spec.entry_size] ; size of colormap entries in bits
movzx ecx, word[ecx + tga_header.colormap_spec.colormap_length] ; number of colormap entries
cmp eax, 24
je .24bpp_palette
cmp eax, 16
je .16bpp_palette
mov dh,[ecx+7] ;size of colormap entries in bits
movzx ecx,word[ecx+5] ;number of colormap entries
cmp dh,24
jz .skip_24bpp_palette ;test if colormap entries are 24bpp
rep movsd ; else they are 32 bpp
jmp .palette_parsed
.write_grayscale_palette:
push eax
mov ecx, 0x100
xor eax, eax
@@:
167,93 → 139,80
stosd
add eax, 0x010101
loop @b
pop eax
jmp .palette_parsed
.16bpp_palette: ; FIXME: code copypasted from img.do_rgb, should use img.convert
push ebx edx ebp
.skip_24bpp_palette:
push eax
@@:
movzx eax, word[esi]
mov ebx, eax
add esi, 2
and eax, (0x1F) or (0x1F shl 10)
and ebx, 0x1F shl 5
lea edx, [eax + eax]
shr al, 2
mov ebp, ebx
shr ebx, 2
shr ah, 4
shl dl, 2
shr ebp, 7
add eax, edx
add ebx, ebp
mov [edi], al
mov [edi + 1], bl
mov [edi + 2], ah
add edi, 4
loop @b
pop ebp edx ebx
jmp .palette_parsed
 
.24bpp_palette:
@@:
lodsd
dec esi
and eax, 0xffffff
and eax,0xFFFFFF
; bswap eax
; shr eax,8
stosd
loop @b
pop eax
.palette_parsed:
mov edi, [ebx + Image.Data]
mov ebx, [width]
imul ebx, [height]
mov edx, [bytes_per_pixel]
mov edi,[eax+Image.Data]
imul ebx,[IMGwidth] ;ebx=width*height
 
mov edx,[IMGbpp]
add edx,7
shr edx,3 ;edx=bytes per pixel
mov dh,dl ;dh=dl=bytes per pixel
 
mov eax, [_data]
test byte[eax + tga_header.image_type], 0x08
jz .uncompressed
.next_rle_packet:
cmp byte[eax+2],9
jb .not_an_rle
.tga_read_rle_pixel:
cmp [DupPixelCount],0 ;Duplicate previously read pixel?
jg .duplicate_previously_read_pixel
dec [TgaBlockCount] ;Decrement pixels remaining in block
jns .read_non_rle_pixel
xor eax, eax
lodsb
btr ax, 7 ; Run-length packet?
jnc .raw_packet
add eax, 1
sub ebx, eax
test al,al ;Start of duplicate-pixel block?
jns .2
and al,0x7f
mov [DupPixelCount],eax ;Number of duplications after this one
and [TgaBlockCount],0 ;Then read new block header
jmp .read_non_rle_pixel
.2:
mov dword[TgaBlockCount],eax
.read_non_rle_pixel:
xor eax,eax
mov dl,dh
@@:
mov ecx, edx
rep movsb
sub esi, edx
sub eax, 1
shl eax,8
lodsb
dec dl
jnz @b
add esi, edx
test ebx, ebx
jnz .next_rle_packet
jmp .done
.raw_packet:
mov ecx, eax
add ecx, 1
sub ebx, ecx
imul ecx, edx
rep movsb
test ebx, ebx
jnz .next_rle_packet
.uncompressed:
cmp dh,3
jne .put_pixel
bswap eax
shr eax,8
jmp .put_pixel
.duplicate_previously_read_pixel:
dec [DupPixelCount]
.put_pixel:
mov dl,dh
push eax
@@:
stosb
shr eax,8
dec dl
jnz @b
pop eax
dec ebx
jnz .tga_read_rle_pixel
jmp .locret
.not_an_rle:
movzx edx,dl ;dh contains bpp too (for decoding needs)
imul edx, ebx
mov ecx, edx
rep movsb
.done:
xor ebx, ebx
mov esi, [_data]
test byte[esi + tga_header.image_spec.descriptor], TGA_START_TOP
jnz @f
or ebx, FLIP_VERTICAL
@@:
test byte[esi + tga_header.image_spec.descriptor], TGA_START_RIGHT
jz @f
or ebx, FLIP_HORIZONTAL
@@:
test ebx, ebx
jz @f
stdcall img.flip, [retvalue], ebx
@@:
pop edi esi ebx
mov eax, [retvalue]
rep movsb ;just copy the image
.locret:
popad
ret
endp
 
271,6 → 230,7
ret
endp
 
 
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
286,3 → 246,5
;;================================================================================================;;
;;////////////////////////////////////////////////////////////////////////////////////////////////;;
;;================================================================================================;;
 
;
/programs/develop/libraries/libs-dev/libimg/tga/tga.inc
1,5 → 1,5
;;================================================================================================;;
;;//// tga.inc //// (c) Nable, 2007-2008, (c) dunkaist, 2012 /////////////////////////////////////;;
;;//// tga.inc //// (c) Nable, 2007-2008 /////////////////////////////////////////////////////////;;
;;================================================================================================;;
;; ;;
;; This file is part of Common development libraries (Libs-Dev). ;;
17,28 → 17,19
;; ;;
;;================================================================================================;;
 
struct tga_colormap_spec
first_entry_index dw ?
colormap_length dw ?
entry_size db ?
struct tga.FileHeader
CommentLength db ?
ColormapType db ?
SubType db ?
DontKnow1 dw ?
ColormapSize dw ?
ColormapBpp db ?
DontKnow2 dd ?
Width dw ?
Height dw ?
BitPerPixel db ?
DontKnow3 db ?
ends
 
struct tga_image_spec
x_origin dw ?
y_origin dw ?
width dw ?
height dw ?
depth db ?
descriptor db ?
ends
 
struct tga_header
id_length db ?
colormap_type db ?
image_type db ?
colormap_spec tga_colormap_spec
image_spec tga_image_spec
ends
 
TGA_START_TOP = 0x20
TGA_START_RIGHT = 0x10
tga.flags.top_down_row_order equ 32 ;bit5
tga.flags.interlace_type equ 192;bits6/7