From e9998d7f130c654fd6838285b265a9cb044368b6 Mon Sep 17 00:00:00 2001 From: Ivan Baravy Date: Sun, 18 Nov 2012 16:10:28 +0000 Subject: [PATCH] libimg: introduce img.convert + example update tga decoder img.to_rgb and img.to_rgb2 are deprecated git-svn-id: svn://kolibrios.org@3055 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../libraries/libs-dev/.test/003/test003.asm | 4 +- .../libs-dev/.test/005/kolibri_logo.jpg | Bin 0 -> 17376 bytes .../libraries/libs-dev/.test/005/test005.asm | 184 ++++++++++ .../libraries/libs-dev/libimg/libimg.asm | 15 +- .../libraries/libs-dev/libimg/libimg.inc | 2 +- .../libraries/libs-dev/libimg/tga/tga.asm | 326 ++++++++++-------- .../libraries/libs-dev/libimg/tga/tga.inc | 39 ++- 7 files changed, 407 insertions(+), 163 deletions(-) create mode 100644 programs/develop/libraries/libs-dev/.test/005/kolibri_logo.jpg create mode 100644 programs/develop/libraries/libs-dev/.test/005/test005.asm diff --git a/programs/develop/libraries/libs-dev/.test/003/test003.asm b/programs/develop/libraries/libs-dev/.test/003/test003.asm index 13af263b48..62c0016b0f 100644 --- a/programs/develop/libraries/libs-dev/.test/003/test003.asm +++ b/programs/develop/libraries/libs-dev/.test/003/test003.asm @@ -75,8 +75,8 @@ START: dec ecx jnz @b - stdcall [img.encode], [image_to_rgb2], (LIBIMG_FORMAT_ID_PNM), 0 -; stdcall [img.encode], [image_initial], (LIBIMG_FORMAT_ID_PNM), 0 + stdcall [img.encode], [image_to_rgb2], (LIBIMG_FORMAT_PNM), 0 +; stdcall [img.encode], [image_initial], (LIBIMG_FORMAT_PNM), 0 test eax, eax jz exit mov [encoded_file], eax diff --git a/programs/develop/libraries/libs-dev/.test/005/kolibri_logo.jpg b/programs/develop/libraries/libs-dev/.test/005/kolibri_logo.jpg new file mode 100644 index 0000000000000000000000000000000000000000..733b65db05eaba4ab6381df4f782fdd6860ee790 GIT binary patch literal 17376 zcmb5Vb97`uw?5plZBA_4>Dab4F(%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4z%vb<4D+UJmIr5<9jW{;q?C|QevapSipj8=cq_GeNWH1PWJDi>t4Hbl=Z2%L- zG$VikRX_!B8GQ08NQn!%bUsu;&@xJB{{SnV2KTVUC9Z(Bxo+%)jH3FmRG>JA#@49< z8i+ZHxx@Rn;*$iX0?`~@AxJE9iXkmPqt}+HG;0D7q~|sIh#D;X(t?qADW;o2Unv_3 zFr_wY6Cz5uodJC{&scGh=G-8#-y`s_427`3Sd^;8R<|3(3j!`96sqws9v+yTUo1o* zq2x5cvT%whffB;mB|d^HR;Ak_(3zLB3QZ!QCW3feirm?WVV3Ju=)@?s%aG786b*+f zdhOV$PEY_s3u(h4cogW10FeOVWLojE4z2m;N+UNg941N|AqEnYAOp50AGnPNO|@iD z8icsv6e{SrjoxMTNc83e+{187aMN}sCyJt|dl5ML7s~egV}%suK2^poP`qpDhMT4)FPE7|Yo(h5PV_2tP0y67h@kW((OX0aw~3Ne Nw`tcRT>^#I|JmCL84&;g literal 0 HcmV?d00001 diff --git a/programs/develop/libraries/libs-dev/.test/005/test005.asm b/programs/develop/libraries/libs-dev/.test/005/test005.asm new file mode 100644 index 0000000000..f40c00d68b --- /dev/null +++ b/programs/develop/libraries/libs-dev/.test/005/test005.asm @@ -0,0 +1,184 @@ +use32 +org 0x0 + db 'MENUET01' + dd 0x01, START, I_END, E_END, E_END, 0, 0 + +;----------------------------------------------------------------------------- + +include '../../../../../proc32.inc' +include '../../../../../macros.inc' +include '../../../../../dll.inc' +;include '../../../../../debug.inc' + +include '../../libio/libio.inc' +include '../../libimg/libimg.inc' + +;----------------------------------------------------------------------------- + +START: + mcall 68, 11 + + stdcall dll.Load, @IMPORT + or eax, eax + jnz exit + + invoke file.open, input_file, O_READ + or eax, eax + jz exit + mov [fh], eax + + invoke file.size, input_file + mov [img_data_len], ebx + + stdcall mem.Alloc, ebx + or eax, eax + jz exit + mov [img_data], eax + + invoke file.read, [fh], eax, [img_data_len] + cmp eax, -1 + je exit + cmp eax, [img_data_len] + jne exit + + invoke file.close, [fh] + inc eax + jz exit + + invoke img.decode, [img_data], [img_data_len], 0 + or eax, eax + jz exit + mov [image_initial], eax + +;pushfd +;pushad +;mov ebx, [image_initial] +;debug_print_dec dword[ebx + Image.Type] +;newline +;popad +;popfd + stdcall mem.Free, [img_data] + test eax, eax + jz exit + + invoke img.convert, [image_initial], 0, Image.bpp8g, 0, 0 + test eax, eax + jz exit + mov [image_converted], eax + + invoke img.destroy, [image_initial] + + mov ebx, [image_converted] + mov eax, [ebx + Image.Width] + add eax, 200*0x10000 + 5*2 - 1 ; window x position + 10 pixels width for skin borders + mov [window_width], eax + + mcall 48, 4 ; get skin height + mov ebx, [image_converted] + add eax, [ebx + Image.Height] + add eax, 100*0x10000 + 5 - 1 ; window y position + 5 pixels height for skin bottom border + mov [window_height], eax +;----------------------------------------------------------------------------- + +still: + mcall 10 + cmp eax, 1 + je .draw_window + cmp eax, 2 + je .key + cmp eax, 3 + je .button + jmp still + + + .draw_window: + mcall 12, 1 + mcall 0, [window_width], [window_height], 0x74FFFFFF, 0x00000000, window_title + call draw_image + mcall 12, 2 + jmp still + + .key: + mcall 2 + jmp still + + .button: + mcall 17 + shr eax, 8 + cmp eax, 1 + jne still + +exit: + invoke img.destroy, [image_converted] + mcall -1 + + +proc draw_image + + mov ebx, [image_converted] + invoke img.draw, ebx, 0, 0, [ebx + Image.Width], [ebx + Image.Height], 0, 0 + + ret +endp + +;----------------------------------------------------------------------------- + +window_title db 'img.convert example',0 +input_file: + db '/hd0/1/kolibri_logo.jpg',0 +; db '/hd0/1/tga/CTC16.TGA',0 +; db '/hd0/1/indexed_packbits_le_test_00.tiff',0 +; db '/hd0/1/graya_123x123.tiff',0 +; db '/hd0/1/bilevel_00.wbmp',0 +; db '/hd0/1/rgb_af.jpg',0 +; db '/hd0/1/gray_5x7.tiff',0 +; db '/hd0/1/rgb_lzw_le_2x2.tiff',0 +; db '/hd0/1/grayscale_123x123.tiff',0 +; db '/hd0/1/grayscale_357x357.tiff',0 +; db '/hd0/1/grayscale_620x620.tiff',0 +; db '/hd0/1/rgb_220.jpg',0 +; db '/hd0/1/rgba_217.tiff',0 +; db '/hd0/1/rgb_7x9.tiff',0 +; db '/hd0/1/rgba_7x9.tiff',0 +; db '/hd0/1/gray_7x9.tiff',0 +; db '/hd0/1/rgb_70x90.png',0 +;----------------------------------------------------------------------------- + +align 4 +@IMPORT: + +library \ + libio , 'libio.obj' , \ + libimg , 'libimg.obj' + +import libio , \ + libio.init , 'lib_init' , \ + file.size , 'file_size' , \ + file.open , 'file_open' , \ + file.read , 'file_read' , \ + file.close , 'file_close' + +import libimg , \ + libimg.init , 'lib_init' , \ + img.decode , 'img_decode' , \ + img.destroy , 'img_destroy' , \ + img.draw , 'img_draw' , \ + img.convert , 'img_convert' , \ + img.types_table , 'img_types_table' + +;----------------------------------------------------------------------------- + +I_END: + +fh dd ? +img_data_len dd ? +img_data dd ? + +image_initial dd ? +image_converted dd ? + +window_width dd ? +window_height dd ? + +rd 0x1000 ; stack +E_END: diff --git a/programs/develop/libraries/libs-dev/libimg/libimg.asm b/programs/develop/libraries/libs-dev/libimg/libimg.asm index b010b8fee4..97108dc0b5 100644 --- a/programs/develop/libraries/libs-dev/libimg/libimg.asm +++ b/programs/develop/libraries/libs-dev/libimg/libimg.asm @@ -47,7 +47,7 @@ include 'pnm/pnm.asm' include 'wbmp/wbmp.asm' include 'scale.asm' -;include 'convert.asm' +include 'convert.asm' ;include 'transform.asm' ;;================================================================================================;; @@ -1929,6 +1929,18 @@ img.formats_table: .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) + ;;================================================================================================;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;================================================================================================;; @@ -2206,6 +2218,7 @@ export \ 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 diff --git a/programs/develop/libraries/libs-dev/libimg/libimg.inc b/programs/develop/libraries/libs-dev/libimg/libimg.inc index 997cb24737..f98c940cd8 100644 --- a/programs/develop/libraries/libs-dev/libimg/libimg.inc +++ b/programs/develop/libraries/libs-dev/libimg/libimg.inc @@ -67,7 +67,7 @@ LIBIMG_ENCODE_DELETE_ALPHA = 0x08 LIBIMG_ENCODE_FLUSH_ALPHA = 0x10 ; convert flags -LIBIMG_CONVERT_IN_PLACE = 0x01 ; do not create new image, store result in _src +; TBD struct FormatsTableEntry Format_id dd ? diff --git a/programs/develop/libraries/libs-dev/libimg/tga/tga.asm b/programs/develop/libraries/libs-dev/libimg/tga/tga.asm index c1ad9d0b5b..fa39547971 100644 --- a/programs/develop/libraries/libs-dev/libimg/tga/tga.asm +++ b/programs/develop/libraries/libs-dev/libimg/tga/tga.asm @@ -1,5 +1,5 @@ ;;================================================================================================;; -;;//// tga.asm //// (c) Nable, 2007-2008 /////////////////////////////////////////////////////////;; +;;//// tga.asm //// (c) Nable, 2007-2008, (c) dunkaist, 2012 /////////////////////////////////////;; ;;================================================================================================;; ;; ;; ;; This file is part of Common development libraries (Libs-Dev). ;; @@ -19,6 +19,8 @@ ;; ;; ;; 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 ;; ;; ;; ;;================================================================================================;; @@ -34,46 +36,49 @@ proc img.is.tga _data, _length ;//////////////////////////////////////////////// ;;------------------------------------------------------------------------------------------------;; ;< eax = false / true ;; ;;================================================================================================;; - push ebx + push ebx cmp [_length], 18 jbe .nope - mov eax, [_data] - mov ebx,[eax+1] ;bl=cmatype,bh=subtype - cmp bl,1 ;cmatype is in [0..1] + mov ebx, [_data] + mov eax, dword[ebx + tga_header.colormap_type] + cmp al, 1 ja .nope - cmp bh,11 ;subtype is in [1..3] (non-rle) or in [9..11] (rle) + cmp ah, 11 ja .nope - cmp bh,9 + cmp ah, 9 jae .cont1 - cmp bh,3 + cmp ah, 3 ja .nope -.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 + .cont1: + mov eax, dword[ebx + tga_header.image_spec.depth] + test eax, 111b ; bpp must be 8, 15, 16, 24 or 32 jnz .maybe15 - shr bl,3 - cmp bl,4 + shr al, 3 + cmp al, 4 ja .nope jmp .cont2 -.maybe15: - cmp bl,15 + .maybe15: + cmp al, 15 jne .nope -.cont2: ;continue testing - 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 + .cont2: ; continue testing + movzx eax, byte[ebx + tga_header.colormap_spec.entry_size] ; palette bpp + cmp eax, 0 je .yep - cmp byte[eax+7],32 ;test palette bpp - only 24 and 32 are supported + cmp eax, 16 je .yep -.nope: + cmp eax, 24 + je .yep + cmp eax, 32 + je .yep + .nope: xor eax, eax - pop ebx + pop ebx ret -.yep: + .yep: xor eax, eax inc eax - pop ebx + pop ebx ret endp @@ -88,131 +93,167 @@ proc img.decode.tga _data, _length, _options ;////////////////////////////////// ;< eax = 0 (error) or pointer to image ;; ;;================================================================================================;; locals - IMGwidth dd ? - IMGheight dd ? - IMGbpp dd ? - DupPixelCount dd ? - TgaBlockCount dd ? + width dd ? + height dd ? + bytes_per_pixel dd ? + retvalue dd ? endl - 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 -@@: - 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 .locret ;then exit - cmp edx,8 + 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 + @@: + 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 + test eax, eax ; failed to allocate? + jz .done ; then exit + mov ebx, eax + cmp dword[ebx + Image.Type], Image.bpp8i jne .palette_parsed - mov edi,[eax+Image.Palette] - mov ecx,[_data] - cmp byte[ecx+2],3 ;we also have grayscale subtype - jz .write_grayscale_palette ;that don't hold palette in file - cmp byte[ecx+2],11 + mov edi, [ebx + Image.Palette] + mov ecx, [_data] + cmp byte[ecx + tga_header.image_type], 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 jz .write_grayscale_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 + 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 + rep movsd ; else they are 32 bpp jmp .palette_parsed -.write_grayscale_palette: - push eax - mov ecx,0x100 - xor eax,eax -@@: + .write_grayscale_palette: + mov ecx, 0x100 + xor eax, eax + @@: stosd - add eax,0x010101 - loop @b - pop eax + add eax, 0x010101 + loop @b jmp .palette_parsed -.skip_24bpp_palette: - push eax -@@: + .16bpp_palette: ; FIXME: code copypasted from img.do_rgb, should use img.convert + push ebx edx ebp + @@: + 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 -; bswap eax -; shr eax,8 + dec esi + and eax, 0xffffff stosd - loop @b - pop eax -.palette_parsed: - 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] - 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 - 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 -@@: - shl eax,8 - lodsb - dec dl - jnz @b - 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 ;just copy the image -.locret: - popad + loop @b + .palette_parsed: + mov edi, [ebx + Image.Data] + mov ebx, [width] + imul ebx, [height] + mov edx, [bytes_per_pixel] + mov eax, [_data] + test byte[eax + tga_header.image_type], 0x08 + jz .uncompressed + .next_rle_packet: + xor eax, eax + lodsb + btr ax, 7 ; Run-length packet? + jnc .raw_packet + add eax, 1 + sub ebx, eax + @@: + mov ecx, edx + rep movsb + sub esi, edx + sub eax, 1 + 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: + 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] ret endp @@ -230,7 +271,6 @@ proc img.encode.tga _img, _p_length, _options ;///////////////////////////////// ret endp - ;;================================================================================================;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;================================================================================================;; @@ -246,5 +286,3 @@ endp ;;================================================================================================;; ;;////////////////////////////////////////////////////////////////////////////////////////////////;; ;;================================================================================================;; - -; \ No newline at end of file diff --git a/programs/develop/libraries/libs-dev/libimg/tga/tga.inc b/programs/develop/libraries/libs-dev/libimg/tga/tga.inc index d277ac322c..a7615831db 100644 --- a/programs/develop/libraries/libs-dev/libimg/tga/tga.inc +++ b/programs/develop/libraries/libs-dev/libimg/tga/tga.inc @@ -1,5 +1,5 @@ ;;================================================================================================;; -;;//// tga.inc //// (c) Nable, 2007-2008 /////////////////////////////////////////////////////////;; +;;//// tga.inc //// (c) Nable, 2007-2008, (c) dunkaist, 2012 /////////////////////////////////////;; ;;================================================================================================;; ;; ;; ;; This file is part of Common development libraries (Libs-Dev). ;; @@ -17,19 +17,28 @@ ;; ;; ;;================================================================================================;; -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 ? +struct tga_colormap_spec + first_entry_index dw ? + colormap_length dw ? + entry_size db ? ends -tga.flags.top_down_row_order equ 32 ;bit5 -tga.flags.interlace_type equ 192;bits6/7 +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