/programs/develop/libraries/libs-dev/libimg/gif/gif.asm |
---|
7,15 → 7,15 |
;; This file is part of Common development libraries (Libs-Dev). ;; |
;; ;; |
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; |
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;; |
;; of the License, or (at your option) any later version. ;; |
;; General Public License as published by the Free Software Foundation, either version 3 of the ;; |
;; License, or (at your option) any later version. ;; |
;; ;; |
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;; |
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; |
;; Lesser General Public License for more details. ;; |
;; General Public License for more details. ;; |
;; ;; |
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;; |
;; If not, see <http://www.gnu.org/licenses/>. ;; |
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;; |
;; see <http://www.gnu.org/licenses/>. ;; |
;; ;; |
;;================================================================================================;; |
;; ;; |
84,18 → 84,20 |
locals |
img dd ? |
global_color_table dd ? |
global_color_table_size dd ? |
endl |
push ebx |
; img.is.gif is called by caller (img.decode) |
; stdcall img.is.gif, [_data], [_length] |
; or eax, eax |
; jz .error |
stdcall img.is.gif, [_data], [_length] |
or eax, eax |
jz .error |
mov [global_color_table_size], 0 |
mov ebx, [_data] |
; cmp [ebx + bmp.Header.info.Compression], bmp.BI_RGB |
; je @f |
; mov eax, [ebx + bmp.Header.file.Size] |
; cmp eax, [_length] |
; jne .error |
test [ebx + gif.Header.lsd.Packed], gif.LSD.Packed.GlobalColorTableFlag |
jz @f |
104,9 → 106,9 |
mov cl, [ebx + gif.Header.lsd.Packed] |
and cl, gif.LSD.Packed.SizeOfGlobalColorTableMask |
shr cl, gif.LSD.Packed.SizeOfGlobalColorTableShift |
mov eax, 2 |
inc cl |
mov eax, 1 |
shl eax, cl |
mov [global_color_table_size], eax |
lea eax, [eax * 3] |
add ebx, eax |
@@: add ebx, sizeof.gif.Header |
128,15 → 130,11 |
jz .error |
mov edx, [img] |
mov [eax + Image.Previous], edx |
test edx, edx |
jz @f |
mov [edx + Image.Next], eax |
@@: |
mov [img], eax |
mov edx, eax |
mov [eax + Image.Type], Image.bpp8 |
invoke mem.alloc, sizeof.gif.Image |
mov ecx, sizeof.gif.Image |
invoke mem.alloc, ecx |
or eax, eax |
jz .error |
mov [edx + Image.Extended], eax |
151,35 → 149,34 |
or eax, eax |
jz .error |
mov esi, ebx |
mov edi, [edx + Image.Extended] |
mov ecx, sizeof.gif.ImageDescriptor |
rep movsb |
mov edi, [edx + Image.Palette] |
mov esi, [global_color_table] |
mov ecx, [global_color_table_size] |
xor ecx, ecx |
mov eax, [edx + Image.Extended] |
test [ebx + gif.ImageDescriptor.Packed], gif.ID.Packed.LocalColorTableFlag |
jz @f |
lea esi, [ebx + sizeof.gif.ImageDescriptor] |
mov cl, [ebx + gif.ImageDescriptor.Packed] |
and cl, gif.ID.Packed.SizeOfLocalColorTableMask |
shr cl, gif.ID.Packed.SizeOfLocalColorTableShift |
mov eax, 2 |
inc cl |
mov eax, 1 |
shl eax, cl |
mov ecx, eax |
lea eax, [eax*3] |
add ebx, eax |
@@: |
lodsd |
dec esi |
bswap eax |
shr eax, 8 |
stosd |
loop @b |
add ebx, sizeof.gif.ImageDescriptor |
stdcall ._.process_image |
lea ecx, [eax * sizeof.gif.RgbTriplet] |
lea eax, [ecx + sizeof.gif.Image] |
invoke mem.realloc, [edx + Image.Extended], eax |
or eax, eax |
jz .error |
mov [edx + Image.Extended], eax |
@@: mov esi, ebx |
lea edi, [eax + sizeof.gif.GraphicsControlExtension] |
add ecx, sizeof.gif.ImageDescriptor |
rep movsb |
mov eax, [global_color_table] |
test [ebx + gif.ImageDescriptor.Packed], gif.ID.Packed.LocalColorTableFlag |
jz @f |
lea eax, [ebx + sizeof.gif.ImageDescriptor] |
@@: mov ebx, esi |
stdcall ._.process_image, eax |
.decoded: |
or eax, eax |
jz @f |
190,11 → 187,6 |
ret |
.error: |
mov eax, [img] |
test eax, eax |
jz @f |
stdcall img.destroy, eax |
@@: |
xor eax, eax |
pop ebx |
ret |
317,7 → 309,7 |
endp |
;;================================================================================================;; |
proc img.decode.gif._.process_image ;/////////////////////////////////////////////////////////////;; |
proc img.decode.gif._.process_image _color_table ;////////////////////////////////////////////////;; |
;;------------------------------------------------------------------------------------------------;; |
;? --- TBD --- ;; |
;;------------------------------------------------------------------------------------------------;; |
350,6 → 342,8 |
mov [width], ecx |
mov eax, [edx + Image.Height] |
imul eax, ecx |
; lea eax, [eax * 3] |
shl eax, 2 |
mov [img_end], eax |
inc eax |
mov [row_end], eax |
357,6 → 351,8 |
mov eax, [edx + Image.Extended] |
test [eax + gif.Image.info.Packed], gif.ID.Packed.InterleaceFlag |
jz @f |
; lea ecx, [ecx * 3] |
shl ecx, 2 |
mov [row_end], ecx |
@@: mov esi, ebx |
506,11 → 502,21 |
.loop2: |
pop ax |
stosb |
lea esi, [eax * 3] |
add esi, [_color_table] |
mov esi, [esi] |
bswap esi |
shr esi, 8 |
mov [edi], esi |
add edi, 4 |
cmp edi, [row_end] |
jb .norowend |
mov eax, [width] |
; lea eax, [eax * 3] |
shl eax, 2 |
push eax |
sub edi, eax |
add eax, eax |
/programs/develop/libraries/libs-dev/libimg/gif/gif.inc |
---|
5,15 → 5,15 |
;; This file is part of Common development libraries (Libs-Dev). ;; |
;; ;; |
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; |
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;; |
;; of the License, or (at your option) any later version. ;; |
;; General Public License as published by the Free Software Foundation, either version 3 of the ;; |
;; License, or (at your option) any later version. ;; |
;; ;; |
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;; |
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; |
;; Lesser General Public License for more details. ;; |
;; General Public License for more details. ;; |
;; ;; |
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;; |
;; If not, see <http://www.gnu.org/licenses/>. ;; |
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;; |
;; see <http://www.gnu.org/licenses/>. ;; |
;; ;; |
;;================================================================================================;; |
/programs/develop/libraries/libs-dev/libimg/libimg.asm |
---|
1,19 → 1,19 |
;;================================================================================================;; |
;;//// libimg.asm //// (c) mike.dld, 2007-2008, (c) diamond, 2009 ////////////////////////////////;; |
;;//// libimg.asm //// (c) mike.dld, 2007-2008 ///////////////////////////////////////////////////;; |
;;================================================================================================;; |
;; ;; |
;; This file is part of Common development libraries (Libs-Dev). ;; |
;; ;; |
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; |
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;; |
;; of the License, or (at your option) any later version. ;; |
;; General Public License as published by the Free Software Foundation, either version 3 of the ;; |
;; License, or (at your option) any later version. ;; |
;; ;; |
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;; |
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; |
;; Lesser General Public License for more details. ;; |
;; General Public License for more details. ;; |
;; ;; |
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;; |
;; If not, see <http://www.gnu.org/licenses/>. ;; |
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;; |
;; see <http://www.gnu.org/licenses/>. ;; |
;; ;; |
;;================================================================================================;; |
25,7 → 25,7 |
include '../../../../struct.inc' |
include '../../../../proc32.inc' |
include '../../../../macros.inc' |
purge section,mov,add,sub |
purge section,mov;add,sub |
include 'libimg.inc' |
33,7 → 33,6 |
include 'bmp/bmp.asm' |
include 'gif/gif.asm' |
include 'jpeg/jpeg.asm' |
mem.alloc dd ? |
mem.free dd ? |
57,8 → 56,6 |
mov [mem.realloc], ecx |
mov [dll.load], edx |
call img.initialize.jpeg |
.ok: xor eax,eax |
ret |
endp |
165,14 → 162,6 |
stosd |
mov eax, [esi + Image.Height] |
stosd |
mov eax, [esi + Image.Type] |
dec eax |
jz .bpp8 |
dec eax |
jz .bpp24 |
dec eax |
jnz .error_pop |
; 32 BPP -> 24 BPP |
mov esi, [esi + Image.Data] |
@@: dec ecx |
185,37 → 174,6 |
pop edi esi |
ret |
.bpp24: |
; 24 BPP -> 24 BPP |
lea ecx, [ecx*3 + 3] |
mov esi, [esi + Image.Data] |
shr ecx, 2 |
rep movsd |
pop eax |
pop edi esi |
ret |
.bpp8: |
; 8 BPP -> 24 BPP |
push ebx |
mov ebx, [esi + Image.Palette] |
mov esi, [esi + Image.Data] |
@@: |
movzx eax, byte [esi] |
add esi, 1 |
mov eax, [ebx + eax*4] |
mov [edi], eax |
add edi, 3 |
sub ecx, 1 |
jnz @b |
pop ebx |
pop eax |
pop edi esi |
ret |
.error_pop: |
pop eax |
.error: |
xor eax, eax |
pop edi esi |
238,7 → 196,7 |
jnz @f |
add ebx, sizeof.FormatsTableEntry |
cmp dword[ebx], 0 |
jnz @b |
jnz @f |
jmp .error |
@@: stdcall [ebx + FormatsTableEntry.Decode], [_data], [_length] |
261,7 → 219,7 |
endp |
;;================================================================================================;; |
proc img.create _width, _height, _type ;//////////////////////////////////////////////////////////;; |
proc img.create _width, _height ;/////////////////////////////////////////////////////////////////;; |
;;------------------------------------------------------------------------------------------------;; |
;? --- TBD --- ;; |
;;------------------------------------------------------------------------------------------------;; |
275,9 → 233,6 |
or eax, eax |
jz .error |
mov ecx, [_type] |
mov [eax + Image.Type], ecx |
push eax |
stdcall img._.resize_data, eax, [_width], [_height] |
285,7 → 240,7 |
jz .error.2 |
pop eax |
jmp .ret |
ret |
.error.2: |
; pop eax |
293,7 → 248,6 |
xor eax, eax |
.error: |
.ret: |
pop ecx |
ret |
endp |
394,17 → 348,19 |
scanline_len dd ? |
endl |
push ebx esi edi |
mov ebx, [_img] |
stdcall img._.validate, ebx |
push esi edi |
stdcall img._.validate, [_img] |
or eax, eax |
jnz .error |
mov ecx, [ebx + Image.Height] |
mov eax, [ebx + Image.Width] |
call img._.get_scanline_len |
mov esi, [_img] |
mov ecx, [esi + Image.Height] |
mov eax, [esi + Image.Width] |
shl eax, 2 |
mov [scanline_len], eax |
push esi |
test [_flip_kind], FLIP_VERTICAL |
jz .dont_flip_vert |
411,7 → 367,7 |
imul eax, ecx |
sub eax, [scanline_len] |
shr ecx, 1 |
mov esi, [ebx + Image.Data] |
mov esi, [esi + Image.Data] |
lea edi, [esi + eax] |
.next_line_vert: |
418,27 → 374,13 |
push ecx |
mov ecx, [scanline_len] |
push ecx |
shr ecx, 2 |
@@: mov eax, [esi] |
@@: lodsd |
xchg eax, [edi] |
mov [esi], eax |
add esi, 4 |
mov [esi - 4], eax |
add edi, 4 |
sub ecx, 1 |
jnz @b |
pop ecx |
and ecx, 3 |
jz .cont_line_vert |
@@: |
mov al, [esi] |
xchg al, [edi] |
mov [esi], al |
add esi, 1 |
add edi, 1 |
dec ecx |
jnz @b |
.cont_line_vert: |
pop ecx |
mov eax, [scanline_len] |
449,22 → 391,16 |
.dont_flip_vert: |
pop esi |
test [_flip_kind], FLIP_HORIZONTAL |
jz .exit |
mov ecx, [ebx + Image.Height] |
mov eax, [ebx + Image.Type] |
mov esi, [ebx + Image.Data] |
mov edi, [scanline_len] |
add edi, esi |
mov ecx, [esi + Image.Height] |
mov esi, [esi + Image.Data] |
lea edi, [esi - 4] |
add edi, [scanline_len] |
dec eax |
jz .bpp8.2 |
dec eax |
jz .bpp24.2 |
sub edi, 4 |
.next_line_horz: |
push ecx esi edi |
475,7 → 411,7 |
mov [esi], eax |
add esi, 4 |
add edi, -4 |
sub ecx, 1 |
dec ecx |
jnz @b |
pop edi esi ecx |
483,71 → 419,16 |
add edi, [scanline_len] |
dec ecx |
jnz .next_line_horz |
jmp .exit |
.bpp8.2: |
dec edi |
.next_line_horz8: |
push ecx esi edi |
mov ecx, [scanline_len] |
shr ecx, 1 |
@@: mov al, [esi] |
mov dl, [edi] |
mov [edi], al |
mov [esi], dl |
add esi, 1 |
sub edi, 1 |
sub ecx, 1 |
jnz @b |
pop edi esi ecx |
add esi, [scanline_len] |
add edi, [scanline_len] |
dec ecx |
jnz .next_line_horz8 |
jmp .exit |
.bpp24.2: |
sub edi, 3 |
.next_line_horz32: |
push ecx esi edi |
mov ecx, [ebx + Image.Width] |
shr ecx, 1 |
@@: |
mov al, [esi] |
mov dl, [edi] |
mov [edi], al |
mov [esi], dl |
mov al, [esi+1] |
mov dl, [edi+1] |
mov [edi+1], al |
mov [esi+1], dl |
mov al, [esi+2] |
mov dl, [edi+2] |
mov [edi+2], al |
mov [esi+2], dl |
add esi, 3 |
sub edi, 3 |
sub ecx, 1 |
jnz @b |
pop edi esi ecx |
add esi, [scanline_len] |
add edi, [scanline_len] |
dec ecx |
jnz .next_line_horz32 |
.exit: |
xor eax, eax |
inc eax |
pop edi esi ebx |
pop edi esi |
ret |
.error: |
xor eax, eax |
pop edi esi ebx |
pop edi esi |
ret |
endp |
572,8 → 453,7 |
mov [line_buffer], 0 |
push ebx esi edi |
mov ebx, [_img] |
stdcall img._.validate, ebx |
stdcall img._.validate, [_img] |
or eax, eax |
jnz .error |
586,9 → 466,10 |
jmp .exit |
.rotate_ccw_low: |
mov ebx, [_img] |
mov eax, [ebx + Image.Height] |
mov [scanline_pixels_new], eax |
call img._.get_scanline_len |
shl eax, 2 |
mov [scanline_len_new], eax |
invoke mem.alloc, eax |
596,9 → 477,8 |
jz .error |
mov [line_buffer], eax |
mov eax, [ebx + Image.Width] |
mov ecx, eax |
call img._.get_scanline_len |
mov ecx, [ebx + Image.Width] |
lea eax, [ecx * 4] |
mov [scanline_len_old], eax |
mov eax, [scanline_len_new] |
606,14 → 486,9 |
add eax, [ebx + Image.Data] |
mov [pixels_ptr], eax |
cmp [ebx + Image.Type], Image.bpp8 |
jz .rotate_ccw8 |
cmp [ebx + Image.Type], Image.bpp24 |
jz .rotate_ccw24 |
.next_column_ccw_low: |
dec ecx |
js .exchange_dims |
jz .exchange_dims |
push ecx |
mov edx, [scanline_len_old] |
649,109 → 524,11 |
pop ecx |
jmp .next_column_ccw_low |
.rotate_ccw8: |
.next_column_ccw_low8: |
dec ecx |
js .exchange_dims |
push ecx |
mov edx, [scanline_len_old] |
add [scanline_len_old], -1 |
mov ecx, [scanline_pixels_new] |
mov esi, [ebx + Image.Data] |
mov edi, [line_buffer] |
@@: mov al, [esi] |
mov [edi], al |
add esi, edx |
add edi, 1 |
sub ecx, 1 |
jnz @b |
mov eax, [scanline_pixels_new] |
mov edi, [ebx + Image.Data] |
lea esi, [edi + 1] |
mov edx, [scanline_len_old] |
@@: mov ecx, edx |
shr ecx, 2 |
rep movsd |
mov ecx, edx |
and ecx, 3 |
rep movsb |
add esi, 1 |
sub eax, 1 |
jnz @b |
mov eax, [scanline_len_new] |
sub [pixels_ptr], eax |
mov ecx, [scanline_pixels_new] |
mov esi, [line_buffer] |
mov edi, [pixels_ptr] |
mov edx, ecx |
shr ecx, 2 |
rep movsd |
mov ecx, edx |
and ecx, 3 |
rep movsb |
pop ecx |
jmp .next_column_ccw_low8 |
.rotate_ccw24: |
.next_column_ccw_low24: |
dec ecx |
js .exchange_dims |
push ecx |
mov edx, [scanline_len_old] |
add [scanline_len_old], -3 |
mov ecx, [scanline_pixels_new] |
mov esi, [ebx + Image.Data] |
mov edi, [line_buffer] |
@@: mov al, [esi] |
mov [edi], al |
mov al, [esi+1] |
mov [edi+1], al |
mov al, [esi+2] |
mov [edi+2], al |
add esi, edx |
add edi, 3 |
sub ecx, 1 |
jnz @b |
mov eax, [scanline_pixels_new] |
mov edi, [ebx + Image.Data] |
lea esi, [edi + 3] |
mov edx, [scanline_len_old] |
@@: mov ecx, edx |
shr ecx, 2 |
rep movsd |
mov ecx, edx |
and ecx, 3 |
rep movsb |
add esi, 3 |
sub eax, 1 |
jnz @b |
mov eax, [scanline_len_new] |
sub [pixels_ptr], eax |
mov ecx, eax |
mov esi, [line_buffer] |
mov edi, [pixels_ptr] |
shr ecx, 2 |
rep movsd |
mov ecx, eax |
and ecx, 3 |
rep movsb |
pop ecx |
jmp .next_column_ccw_low24 |
.rotate_cw_low: |
mov ebx, [_img] |
mov eax, [ebx + Image.Height] |
mov [scanline_pixels_new], eax |
call img._.get_scanline_len |
shl eax, 2 |
mov [scanline_len_new], eax |
invoke mem.alloc, eax |
759,9 → 536,8 |
jz .error |
mov [line_buffer], eax |
mov eax, [ebx + Image.Width] |
mov ecx, eax |
call img._.get_scanline_len |
mov ecx, [ebx + Image.Width] |
lea eax, [ecx * 4] |
mov [scanline_len_old], eax |
mov eax, [scanline_len_new] |
769,11 → 545,6 |
add eax, [ebx + Image.Data] |
mov [pixels_ptr], eax |
cmp [ebx + Image.Type], Image.bpp8 |
jz .rotate_cw8 |
cmp [ebx + Image.Type], Image.bpp24 |
jz .rotate_cw24 |
.next_column_cw_low: |
dec ecx |
js .exchange_dims |
815,110 → 586,6 |
pop ecx |
jmp .next_column_cw_low |
.rotate_cw8: |
.next_column_cw_low8: |
dec ecx |
js .exchange_dims |
push ecx |
mov edx, [scanline_len_old] |
add [scanline_len_old], -1 |
mov ecx, [scanline_pixels_new] |
mov esi, [pixels_ptr] |
add esi, -1 |
mov edi, [line_buffer] |
@@: mov al, [esi] |
mov [edi], al |
sub esi, edx |
add edi, 1 |
sub ecx, 1 |
jnz @b |
mov eax, [scanline_pixels_new] |
dec eax |
mov edi, [ebx + Image.Data] |
add edi, [scanline_len_old] |
lea esi, [edi + 1] |
mov edx, [scanline_len_old] |
@@: mov ecx, edx |
shr ecx, 2 |
rep movsd |
mov ecx, edx |
and ecx, 3 |
rep movsb |
add esi, 1 |
sub eax, 1 |
jnz @b |
mov eax, [scanline_len_new] |
sub [pixels_ptr], eax |
mov ecx, eax |
mov esi, [line_buffer] |
mov edi, [pixels_ptr] |
shr ecx, 2 |
rep movsd |
mov ecx, eax |
and ecx, 3 |
rep movsb |
pop ecx |
jmp .next_column_cw_low8 |
.rotate_cw24: |
.next_column_cw_low24: |
dec ecx |
js .exchange_dims |
push ecx |
mov edx, [scanline_len_old] |
add [scanline_len_old], -3 |
mov ecx, [scanline_pixels_new] |
mov esi, [pixels_ptr] |
add esi, -3 |
mov edi, [line_buffer] |
@@: mov al, [esi] |
mov [edi], al |
mov al, [esi+1] |
mov [edi+1], al |
mov al, [esi+2] |
mov [edi+2], al |
sub esi, edx |
add edi, 3 |
sub ecx, 1 |
jnz @b |
mov eax, [scanline_pixels_new] |
dec eax |
mov edi, [ebx + Image.Data] |
add edi, [scanline_len_old] |
lea esi, [edi + 3] |
mov edx, [scanline_len_old] |
@@: mov ecx, edx |
shr ecx, 2 |
rep movsd |
mov ecx, edx |
and ecx, 3 |
rep movsb |
add esi, 3 |
sub eax, 1 |
jnz @b |
mov eax, [scanline_len_new] |
sub [pixels_ptr], eax |
mov ecx, eax |
mov esi, [line_buffer] |
mov edi, [pixels_ptr] |
shr ecx, 2 |
rep movsd |
mov ecx, eax |
and ecx, 3 |
rep movsb |
pop ecx |
jmp .next_column_cw_low24 |
.flip: |
jmp .exit |
973,17 → 640,6 |
;< eax = 0 / pointer to image ;; |
;;================================================================================================;; |
invoke mem.alloc, sizeof.Image |
test eax, eax |
jz @f |
push ecx |
xor ecx, ecx |
mov [eax + Image.Data], ecx |
mov [eax + Image.Type], ecx |
mov [eax + Image.Extended], ecx |
mov [eax + Image.Previous], ecx |
mov [eax + Image.Next], ecx |
pop ecx |
@@: |
ret |
endp |
1018,35 → 674,11 |
;;------------------------------------------------------------------------------------------------;; |
;< --- TBD --- ;; |
;;================================================================================================;; |
push ebx esi |
push ebx |
mov ebx, [_img] |
mov eax, [_height] |
; our memory is limited, [_width]*[_height] must not overflow |
; image with width or height greater than 65535 is most likely bogus |
cmp word [_width+2], 0 |
jnz .error |
cmp word [_height+2], 0 |
jnz .error |
imul eax, [_width] |
test eax, eax |
jz .error |
; do not allow images which require too many memory |
cmp eax, 4000000h |
jae .error |
cmp [ebx + Image.Type], Image.bpp8 |
jz .bpp8 |
cmp [ebx + Image.Type], Image.bpp24 |
jz .bpp24 |
.bpp32: |
shl eax, 2 |
jmp @f |
.bpp24: |
lea eax, [eax*3] |
jmp @f |
.bpp8: |
add eax, 256*4 ; for palette |
@@: |
mov esi, eax |
invoke mem.realloc, [ebx + Image.Data], eax |
or eax, eax |
jz .error |
1056,41 → 688,13 |
pop [ebx + Image.Width] |
push [_height] |
pop [ebx + Image.Height] |
cmp [ebx + Image.Type], Image.bpp8 |
jnz .ret |
lea esi, [eax + esi - 256*4] |
mov [ebx + Image.Palette], esi |
jmp .ret |
.error: |
xor eax, eax |
.ret: |
pop esi ebx |
pop ebx |
ret |
endp |
;;================================================================================================;; |
img._.get_scanline_len: ;/////////////////////////////////////////////////////////////////////////;; |
;;------------------------------------------------------------------------------------------------;; |
;? --- TBD --- ;; |
;;------------------------------------------------------------------------------------------------;; |
;> --- TBD --- ;; |
;;------------------------------------------------------------------------------------------------;; |
;< --- TBD --- ;; |
;;================================================================================================;; |
cmp [ebx + Image.Type], Image.bpp8 |
jz .bpp8.1 |
cmp [ebx + Image.Type], Image.bpp24 |
jz .bpp24.1 |
shl eax, 2 |
jmp @f |
.bpp24.1: |
lea eax, [eax*3] |
.bpp8.1: |
@@: |
ret |
;;================================================================================================;; |
;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
;;================================================================================================;; |
1106,7 → 710,7 |
; .cur dd img.is.cur, img.decode.cur, img.encode.cur |
.gif dd img.is.gif, img.decode.gif, img.encode.gif |
; .png dd img.is.png, img.decode.png, img.encode.png |
.jpg dd img.is.jpg, img.decode.jpg, img.encode.jpg |
; .jpg dd img.is.jpg, img.decode.jpg, img.encode.jpg |
dd 0 |
1119,7 → 723,7 |
;;================================================================================================;; |
align 4 |
align 16 |
@EXPORT: |
export \ |
1140,12 → 744,3 |
img.unlock_bits , 'img.unlock_bits' , \ |
img.flip , 'img.flip' , \ |
img.rotate , 'img.rotate' |
section '.data' data readable writable align 16 |
; uninitialized data - global constant tables |
; data for YCbCr -> RGB translation |
color_table_1 rd 256 |
color_table_2 rd 256 |
color_table_3 rd 256 |
color_table_4 rd 256 |
/programs/develop/libraries/libs-dev/libimg/libimg.inc |
---|
1,19 → 1,19 |
;;================================================================================================;; |
;;//// libimg.inc //// (c) mike.dld, 2007-2008, (c) diamond, 2009 ////////////////////////////////;; |
;;//// libimg.inc //// (c) mike.dld, 2007-2008 ///////////////////////////////////////////////////;; |
;;================================================================================================;; |
;; ;; |
;; This file is part of Common development libraries (Libs-Dev). ;; |
;; ;; |
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; |
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;; |
;; of the License, or (at your option) any later version. ;; |
;; General Public License as published by the Free Software Foundation, either version 3 of the ;; |
;; License, or (at your option) any later version. ;; |
;; ;; |
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;; |
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; |
;; Lesser General Public License for more details. ;; |
;; General Public License for more details. ;; |
;; ;; |
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;; |
;; If not, see <http://www.gnu.org/licenses/>. ;; |
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;; |
;; see <http://www.gnu.org/licenses/>. ;; |
;; ;; |
;;================================================================================================;; |
30,16 → 30,10 |
Height dd ? |
Next dd ? |
Previous dd ? |
Type dd ? ; one of Image.bppN |
Data dd ? |
Palette dd ? ; used iff Type eq Image.bpp8 |
Extended dd ? |
ends |
Image.bpp8 = 1 |
Image.bpp24 = 2 |
Image.bpp32 = 3 |
FLIP_VERTICAL = 0x01 |
FLIP_HORIZONTAL = 0x02 |
FLIP_BOTH = FLIP_VERTICAL or FLIP_HORIZONTAL |
/programs/develop/libraries/libs-dev/libimg/bmp/bmp.asm |
---|
1,19 → 1,19 |
;;================================================================================================;; |
;;//// bmp.asm //// (c) mike.dld, 2007-2008, (c) diamond, 2009 ///////////////////////////////////;; |
;;//// bmp.asm //// (c) mike.dld, 2007-2008 //////////////////////////////////////////////////////;; |
;;================================================================================================;; |
;; ;; |
;; This file is part of Common development libraries (Libs-Dev). ;; |
;; ;; |
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; |
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;; |
;; of the License, or (at your option) any later version. ;; |
;; General Public License as published by the Free Software Foundation, either version 3 of the ;; |
;; License, or (at your option) any later version. ;; |
;; ;; |
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;; |
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; |
;; Lesser General Public License for more details. ;; |
;; General Public License for more details. ;; |
;; ;; |
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;; |
;; If not, see <http://www.gnu.org/licenses/>. ;; |
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;; |
;; see <http://www.gnu.org/licenses/>. ;; |
;; ;; |
;;================================================================================================;; |
;; ;; |
28,8 → 28,7 |
include 'bmp.inc' |
;;================================================================================================;; |
;;proc img.is.bmp _data, _length ;////////////////////////////////////////////////////////////////;; |
img.is.bmp: |
proc img.is.bmp _data, _length ;//////////////////////////////////////////////////////////////////;; |
;;------------------------------------------------------------------------------------------------;; |
;? Determine if raw data could be decoded (is in BMP format) ;; |
;;------------------------------------------------------------------------------------------------;; |
38,23 → 37,21 |
;;------------------------------------------------------------------------------------------------;; |
;< eax = false / true ;; |
;;================================================================================================;; |
; test 1 (length of data): data must contain FileHeader and required fields from InfoHeader |
cmp dword [esp+8], sizeof.bmp.FileHeader + 12 |
cmp [_length], 2 |
jb .nope |
; test 2: signature |
mov eax, [esp+4] |
mov eax, [_data] |
cmp word [eax], 'BM' |
je .yep |
.nope: |
xor eax, eax |
ret 8 |
ret |
.yep: |
xor eax, eax |
inc eax |
ret 8 |
;endp |
ret |
endp |
;;================================================================================================;; |
proc img.decode.bmp _data, _length ;//////////////////////////////////////////////////////////////;; |
68,15 → 65,13 |
;;================================================================================================;; |
locals |
img dd ? |
bTopDown db ? |
endl |
push ebx esi edi |
push ebx |
; img.is.bmp has been already called by img.decode |
; stdcall img.is.bmp, [_data], [_length] |
; or eax, eax |
; jz .error |
stdcall img.is.bmp, [_data], [_length] |
or eax, eax |
jz .error |
mov ebx, [_data] |
; cmp [ebx + bmp.Header.info.Compression], bmp.BI_RGB |
84,60 → 79,8 |
; mov eax, [ebx + bmp.Header.file.Size] |
; cmp eax, [_length] |
; jne .error |
; @@: |
mov eax, [ebx + bmp.Header.info.Size] |
; sanity check: file length must be greater than size of headers |
add eax, sizeof.bmp.FileHeader |
cmp [_length], eax |
jbe .error |
mov [bTopDown], 0 |
cmp eax, sizeof.bmp.FileHeader + 12 |
jz .old1 |
cmp eax, sizeof.bmp.FileHeader + 40 |
jz .normal |
cmp eax, sizeof.bmp.FileHeader + 56 |
jnz .error |
; convert images with <= 8 bpp to 8bpp, other - to 32 bpp |
.normal: |
xor eax, eax |
inc eax ; Image.bpp8 |
cmp [ebx + bmp.Header.info.BitCount], 8 |
jbe @f |
mov al, Image.bpp32 |
@@: |
push eax |
mov eax, [ebx + bmp.Header.info.Height] |
test eax, eax |
jns @f |
inc [bTopDown] |
neg eax |
@@: |
pushd eax |
pushd [ebx + bmp.Header.info.Width] |
jmp .create |
.old1: |
xor eax, eax |
inc eax ; Image.bpp8 |
cmp [ebx + bmp.Header.info.OldBitCount], 8 |
jbe @f |
mov al, Image.bpp32 |
@@: |
push eax |
movsx eax, [ebx + bmp.Header.info.OldHeight] |
test eax, eax |
jns @f |
inc [bTopDown] |
neg eax |
@@: |
push eax |
movzx eax, [ebx + bmp.Header.info.OldWidth] |
push eax |
.create: |
call img.create |
@@: stdcall img.create, [ebx + bmp.Header.info.Width], [ebx + bmp.Header.info.Height] |
or eax, eax |
jz .error |
mov [img], eax |
145,38 → 88,15 |
invoke mem.alloc, sizeof.bmp.Image |
or eax, eax |
jz .error.free |
jz .error |
mov [edx + Image.Extended], eax |
push eax |
mov esi, ebx |
add esi, sizeof.bmp.FileHeader |
mov edi, eax |
mov ecx, sizeof.bmp.Image/4 |
xor eax, eax |
rep stosd |
pop edi |
lea esi, [ebx + sizeof.bmp.FileHeader] |
pushd [ebx + bmp.FileHeader.OffBits] |
mov ecx, [esi + bmp.InfoHeader.Size] |
cmp ecx, 12 |
jz .old2 |
mov ecx, sizeof.bmp.InfoHeader |
rep movsb |
jmp .decode |
.old2: |
movsd ; Size |
movzx eax, word [esi] ; OldWidth -> Width |
stosd |
movsx eax, word [esi+2] ; OldHeight -> Height |
stosd |
lodsd ; skip OldWidth+OldHeight |
movsd ; Planes+BitCount |
.decode: |
pop eax |
mov esi, [_length] |
sub esi, eax |
jbe .error.free |
mov eax, [edx + Image.Extended] |
mov eax, [eax + bmp.Image.info.Compression] |
mov eax, [ebx + bmp.Header.info.Compression] |
cmp eax, bmp.BI_RGB |
jne @f |
stdcall ._.rgb |
183,49 → 103,37 |
jmp .decoded |
@@: cmp eax, bmp.BI_RLE8 |
jne @f |
cmp [ebx + bmp.Header.info.BitCount], 8 |
jnz .error.free |
stdcall ._.rle |
jmp .decoded |
@@: cmp eax, bmp.BI_RLE4 |
jne @f |
cmp [ebx + bmp.Header.info.BitCount], 4 |
jnz .error.free |
stdcall ._.rle |
jmp .decoded |
@@: cmp eax, bmp.BI_BITFIELDS |
jne .error.free |
jne @f |
stdcall ._.bitfields |
jmp .decoded |
; BI_JPEG and BI_PNG constants are not valid values for BMP file, |
; they are intended for WinAPI |
; @@: cmp eax, bmp.BI_JPEG |
; jne @f |
; stdcall ._.jpeg |
; jmp .decoded |
; @@: cmp eax, bmp.BI_PNG |
; jne .error |
; stdcall ._.png |
@@: cmp eax, bmp.BI_JPEG |
jne @f |
stdcall ._.jpeg |
jmp .decoded |
@@: cmp eax, bmp.BI_PNG |
jne .error |
stdcall ._.png |
.decoded: |
or eax, eax |
jz @f |
.error.free: |
stdcall img.destroy, [img] |
jmp .error |
@@: |
cmp [bTopDown], 0 |
jnz @f |
stdcall img.flip, [img], FLIP_VERTICAL |
@@: |
@@: stdcall img.flip, [img], FLIP_VERTICAL |
mov eax, [img] |
pop edi esi ebx |
ret |
.error: |
xor eax, eax |
pop edi esi ebx |
pop ebx |
ret |
endp |
267,7 → 175,7 |
mov [ecx + bmp.Image.info.AlphaMask], 0 |
mov edi, [edx + Image.Data] |
movzx eax, [ecx + bmp.Image.info.BitCount] |
movzx eax, [ebx + bmp.Header.info.BitCount] |
cmp eax, 32 |
je .32bpp |
cmp eax, 24 |
294,19 → 202,13 |
;;------------------------------------------------------------------------------------------------;; |
img.decode.bmp._.rgb.24bpp: |
mov eax, [edx + Image.Width] |
lea eax, [eax*3 + 3] |
and eax, not 3 |
mov ecx, [edx + Image.Height] |
imul eax, ecx |
cmp esi, eax |
jb img.decode.bmp._.rgb.error |
mov esi, ebx |
add esi, [ebx + bmp.Header.file.OffBits] |
mov ecx, [ebx + bmp.Header.info.Height] |
.next_line: |
push ecx edx |
mov ecx, [edx + Image.Width] |
push ecx |
mov ecx, [ebx + bmp.Header.info.Width] |
xor edx, edx |
.next_line_pixel: |
318,7 → 220,7 |
and edx, 0x03 |
add esi, edx |
pop edx ecx |
pop ecx |
dec ecx |
jnz .next_line |
336,19 → 238,22 |
;;------------------------------------------------------------------------------------------------;; |
img.decode.bmp._.rgb.8bpp: |
mov eax, [edx + Image.Width] |
add eax, 3 |
call img.decode.bmp._.rgb.prepare_palette |
jc img.decode.bmp._.rgb.error |
mov esi, ebx |
add esi, [ebx + bmp.Header.file.OffBits] |
mov ecx, [ebx + bmp.Header.info.Height] |
.next_line: |
push ecx |
mov ecx, [edx + Image.Width] |
mov eax, ecx |
neg eax |
and eax, 3 |
rep movsb |
add esi, eax |
mov ecx, [ebx + bmp.Header.info.Width] |
.next_line_dword: |
lodsb |
and eax, 0x000000FF |
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette] |
stosd |
dec ecx |
jnz .next_line_dword |
pop ecx |
dec ecx |
jnz .next_line |
358,15 → 263,13 |
;;------------------------------------------------------------------------------------------------;; |
img.decode.bmp._.rgb.4bpp: |
mov eax, [edx + Image.Width] |
add eax, 7 |
shr eax, 1 |
call img.decode.bmp._.rgb.prepare_palette |
jc img.decode.bmp._.rgb.error |
mov esi, ebx |
add esi, [ebx + bmp.Header.file.OffBits] |
mov ecx, [ebx + bmp.Header.info.Height] |
.next_line: |
push ecx edx |
mov ecx, [edx + Image.Width] |
push ecx |
mov ecx, [ebx + bmp.Header.info.Width] |
.next_line_dword: |
push ecx |
378,8 → 281,9 |
.next_pixel: |
rol edx, 4 |
mov al, dl |
and al, 0x0000000F |
stosb |
and eax, 0x0000000F |
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette] |
stosd |
dec dword[esp] |
jz @f |
dec ecx |
389,7 → 293,7 |
or ecx, ecx |
jnz .next_line_dword |
pop edx ecx |
pop ecx |
dec ecx |
jnz .next_line |
398,15 → 302,13 |
;;------------------------------------------------------------------------------------------------;; |
img.decode.bmp._.rgb.1bpp: |
mov eax, [edx + Image.Width] |
add eax, 31 |
shr eax, 3 |
call img.decode.bmp._.rgb.prepare_palette |
jc img.decode.bmp._.rgb.error |
mov esi, ebx |
add esi, [ebx + bmp.Header.file.OffBits] |
mov ecx, [ebx + bmp.Header.info.Height] |
.next_line: |
push ecx edx |
mov ecx, [edx + Image.Width] |
push ecx |
mov ecx, [ebx + bmp.Header.info.Width] |
.next_line_dword: |
push ecx |
418,8 → 320,9 |
.next_pixel: |
rol edx, 1 |
mov al, dl |
and al, 0x00000001 |
stosb |
and eax, 0x00000001 |
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette] |
stosd |
dec dword[esp] |
jz @f |
dec ecx |
429,7 → 332,7 |
or ecx, ecx |
jnz .next_line_dword |
pop edx ecx |
pop ecx |
dec ecx |
jnz .next_line |
444,48 → 347,6 |
img.decode.bmp._.rgb.error: |
or eax, -1 |
ret |
img.decode.bmp._.rgb.prepare_palette: |
and eax, not 3 |
mov ecx, [edx + Image.Height] |
imul eax, ecx |
cmp esi, eax |
jb .ret |
mov esi, [ebx + bmp.Header.info.Size] |
add esi, sizeof.bmp.FileHeader |
jc .ret |
mov eax, [ebx + bmp.Header.file.OffBits] |
sub eax, esi |
jc .ret |
push edi |
mov edi, [edx + Image.Palette] |
push ecx |
mov ecx, 256 |
cmp esi, sizeof.bmp.FileHeader + 12 |
jz .old |
shr eax, 2 |
add esi, ebx |
cmp ecx, eax |
jb @f |
mov ecx, eax |
@@: |
rep movsd |
jmp .common |
.old: |
movsd |
dec esi |
sub eax, 3 |
jbe @f |
sub ecx, 1 |
jnz .old |
@@: |
.common: |
pop ecx |
pop edi |
mov esi, ebx |
add esi, [ebx + bmp.Header.file.OffBits] |
.ret: |
ret |
endp |
;;================================================================================================;; |
504,9 → 365,10 |
marker_y dd ? |
abs_mode_addr dd ? |
enc_mode_addr dd ? |
height dd ? |
endl |
mov edi, [edx + Image.Data] |
mov [abs_mode_addr], .absolute_mode.rle8 |
mov [enc_mode_addr], .encoded_mode.rle8 |
cmp [ebx + bmp.Header.info.Compression], bmp.BI_RLE4 |
513,26 → 375,17 |
jne @f |
mov [abs_mode_addr], .absolute_mode.rle4 |
mov [enc_mode_addr], .encoded_mode.rle4 |
@@: |
push esi |
xor eax, eax ; do not check file size in .prepare_palette |
call img.decode.bmp._.rgb.prepare_palette |
pop ecx ; ecx = rest bytes in file |
jc .error |
@@: mov esi, ebx |
add esi, [ebx + bmp.Header.file.OffBits] |
mov eax, [edx + Image.Width] |
shl eax, 2 |
mov [scanline_len], eax |
mov eax, [edx + Image.Height] |
mov [height], eax |
xor eax, eax |
mov [marker_x], eax |
mov [marker_y], eax |
mov edi, [edx + Image.Data] |
.next_run: |
sub ecx, 1 |
jc .eof |
xor eax, eax |
lodsb |
or al, al |
540,8 → 393,6 |
jmp [enc_mode_addr] |
.escape_mode: |
sub ecx, 1 |
jc .eof |
lodsb |
cmp al, 0 |
je .end_of_scanline |
552,30 → 403,29 |
jmp [abs_mode_addr] |
.end_of_scanline: ; 0 |
sub edi, [marker_x] |
add edi, [scanline_len] |
mov eax, [marker_x] |
shl eax, 2 |
neg eax |
add eax, [scanline_len] |
add edi, eax |
mov [marker_x], 0 |
mov eax, [marker_y] |
inc eax |
mov [marker_y], eax |
cmp eax, [height] |
jb .next_run |
jmp .exit |
inc [marker_y] |
jmp .next_run |
.offset_marker: ; 2: dx, dy |
sub ecx, 2 |
jc .eof |
lodsb |
mov edx, [marker_x] |
add edx, eax |
cmp edx, [scanline_len] |
cmp edx, [ebx + bmp.Header.info.Width] |
jae .exit |
mov [marker_x], edx |
shl eax, 2 |
add edi, eax |
lodsb |
and eax, 0x0FF |
mov edx, [marker_y] |
add edx, eax |
cmp edx, [height] |
cmp edx, [ebx + bmp.Header.info.Height] |
jae .exit |
mov [marker_y], edx |
imul eax, [scanline_len] |
583,112 → 433,90 |
jmp .next_run |
.encoded_mode.rle8: ; N: b1 * N |
call .fix_marker |
sub ecx, 1 |
jc .eof |
mov edx, eax |
lodsb |
push ecx |
mov ecx, edx |
rep stosb |
pop ecx |
jmp .check_eoi |
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette] |
@@: dec edx |
js .fix_marker |
stosd |
inc [marker_x] |
jmp @b |
.absolute_mode.rle8: ; N: b1 .. bN |
call .fix_marker |
cmp ecx, edx |
jae @f |
mov edx, ecx |
@@: |
push ecx |
mov ecx, edx |
rep movsb |
pop ecx |
sub ecx, edx |
jz .eof |
test edx, 1 |
jz .check_eoi |
sub ecx, 1 |
jc .eof |
mov edx, eax |
push eax |
@@: dec edx |
js @f |
lodsb |
and eax, 0x0FF |
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette] |
stosd |
inc [marker_x] |
jmp @b |
@@: pop eax |
test eax, 1 |
jz .fix_marker |
inc esi |
.check_eoi: |
mov eax, [marker_y] |
cmp eax, [height] |
jb .next_run |
jmp .exit |
jmp .fix_marker |
.encoded_mode.rle4: ; N: b1 * N |
call .fix_marker |
sub ecx, 1 |
jc .eof |
movzx eax, byte [esi] |
inc esi |
push ecx |
mov edx, eax |
lodsb |
mov ecx, eax |
and eax, 0xF |
shr ecx, 4 |
@@: |
dec edx |
js @f |
mov [edi], cl |
dec edx |
js @f |
mov [edi+1], al |
add edi, 2 |
mov ecx, [ebx + ecx * 4 + bmp.Header.info.Palette] |
and eax, 0x00F |
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette] |
@@: dec edx |
js .fix_marker |
test edx, 1 |
jz .odd |
mov [edi], ecx |
add edi, 4 |
inc [marker_x] |
jmp @b |
@@: |
pop ecx |
jmp .check_eoi |
.odd: |
stosd |
inc [marker_x] |
jmp @b |
.absolute_mode.rle4: ; N: b1 .. bN |
call .fix_marker |
lea eax, [edx+1] |
shr eax, 1 |
cmp ecx, eax |
jbe @f |
lea edx, [ecx*2] |
@@: |
push ecx edx |
mov edx, eax |
push eax |
@@: dec edx |
js @f |
lodsb |
mov cl, al |
shr al, 4 |
and cl, 0xF |
stosb |
and eax, 0x0FF |
mov ecx, eax |
shr eax, 4 |
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette] |
stosd |
inc [marker_x] |
dec edx |
js @f |
mov [edi], cl |
inc edi |
mov eax, ecx |
and eax, 0x00F |
mov eax, [ebx + eax * 4 + bmp.Header.info.Palette] |
stosd |
inc [marker_x] |
jmp @b |
@@: pop eax ecx |
@@: pop eax |
and eax, 0x03 |
jp .check_eoi |
sub ecx, 1 |
jc .eof |
jz .fix_marker |
cmp eax, 3 |
je .fix_marker |
inc esi |
jmp .check_eoi |
jmp .fix_marker |
.fix_marker: |
mov edx, eax |
add eax, [marker_x] |
mov eax, [marker_x] |
@@: sub eax, [ebx + bmp.Header.info.Width] |
jle .next_run |
mov [marker_x], eax |
@@: |
sub eax, [scanline_len] |
jle @f |
mov [marker_x], eax |
push eax |
mov eax, [marker_y] |
inc eax |
mov [marker_y], eax |
cmp eax, [height] |
pop eax |
jb @b |
sub edx, eax |
@@: |
retn |
inc [marker_y] |
jmp @b |
.exit: |
.eof: |
xor eax, eax |
ret |
714,24 → 542,9 |
delta dd ? |
endl |
push edi |
push esi edi |
mov esi, [edx + Image.Extended] |
mov [delta], 4 |
mov eax, [edx + Image.Extended] |
cmp [eax + bmp.Image.info.BitCount], 32 |
je @f |
cmp [eax + bmp.Image.info.BitCount], 16 |
jne .error |
mov [delta], 2 |
@@: |
mov ecx, [edx + Image.Width] |
imul ecx, [edx + Image.Height] |
imul ecx, [delta] |
cmp esi, ecx |
jb .error |
mov esi, eax |
mov ecx, [esi + bmp.Image.info.RedMask] |
call .calc_shift |
mov [shift.Red], al |
764,9 → 577,17 |
mov esi, ebx |
add esi, [ebx + bmp.Header.file.OffBits] |
mov [delta], 4 |
movzx eax, [ebx + bmp.Header.info.BitCount] |
cmp eax, 32 |
je @f |
cmp eax, 16 |
jne .error |
mov [delta], 2 |
;;------------------------------------------------------------------------------------------------;; |
mov ecx, [edx + Image.Height] |
@@: mov ecx, [edx + Image.Height] |
.next_line: |
push ecx |
821,12 → 642,12 |
.exit: |
xor eax, eax |
pop edi |
pop edi esi |
ret |
.error: |
or eax, -1 |
pop edi |
pop edi esi |
ret |
.calc_shift: |
857,7 → 678,6 |
retn |
endp |
if 0 |
;;================================================================================================;; |
proc img.decode.bmp._.jpeg ;//////////////////////////////////////////////////////////////////////;; |
;;------------------------------------------------------------------------------------------------;; |
885,8 → 705,8 |
xor eax, eax |
ret |
endp |
end if |
;;================================================================================================;; |
;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
;;================================================================================================;; |
/programs/develop/libraries/libs-dev/libimg/bmp/bmp.inc |
---|
1,19 → 1,19 |
;;================================================================================================;; |
;;//// bmp.inc //// (c) mike.dld, 2007-2008, (c) diamond, 2009 ///////////////////////////////////;; |
;;//// bmp.inc //// (c) mike.dld, 2007-2008 //////////////////////////////////////////////////////;; |
;;================================================================================================;; |
;; ;; |
;; This file is part of Common development libraries (Libs-Dev). ;; |
;; ;; |
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; |
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;; |
;; of the License, or (at your option) any later version. ;; |
;; General Public License as published by the Free Software Foundation, either version 3 of the ;; |
;; License, or (at your option) any later version. ;; |
;; ;; |
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;; |
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; |
;; Lesser General Public License for more details. ;; |
;; General Public License for more details. ;; |
;; ;; |
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;; |
;; If not, see <http://www.gnu.org/licenses/>. ;; |
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;; |
;; see <http://www.gnu.org/licenses/>. ;; |
;; ;; |
;;================================================================================================;; |
28,20 → 28,10 |
struct bmp.InfoHeader |
; v2 (Windows 2.x) |
Size dd ? ; Size of this header in bytes |
union |
struct ; new format |
Width dd ? ; Image width in pixels |
Height dd ? ; Image height in pixels |
Planes dw ? ; Number of color planes |
BitCount dw ? ; Number of bits per pixel |
ends |
struct ; old format |
OldWidth dw ? ; Image width in pixels as word |
OldHeight dw ? ; Image height in pixels as word |
OldPlanes dw ? ; Number of color planes |
OldBitCount dw ? ; Number of bits per pixel |
ends |
ends |
; v3 (Windows 3.x) |
Compression dd ? ; Compression method used |
SizeImage dd ? ; Size of bitmap in bytes |
/programs/develop/libraries/libs-dev/libimg/bmp/ico.asm |
---|
5,15 → 5,15 |
;; This file is part of Common development libraries (Libs-Dev). ;; |
;; ;; |
;; Libs-Dev is free software: you can redistribute it and/or modify it under the terms of the GNU ;; |
;; Lesser General Public License as published by the Free Software Foundation, either version 2.1 ;; |
;; of the License, or (at your option) any later version. ;; |
;; General Public License as published by the Free Software Foundation, either version 3 of the ;; |
;; License, or (at your option) any later version. ;; |
;; ;; |
;; Libs-Dev is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without ;; |
;; even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ;; |
;; Lesser General Public License for more details. ;; |
;; General Public License for more details. ;; |
;; ;; |
;; You should have received a copy of the GNU Lesser General Public License along with Libs-Dev. ;; |
;; If not, see <http://www.gnu.org/licenses/>. ;; |
;; You should have received a copy of the GNU General Public License along with Libs-Dev. If not, ;; |
;; see <http://www.gnu.org/licenses/>. ;; |
;; ;; |
;;================================================================================================;; |
;; ;; |
/programs/develop/libraries/libs-dev/libimg/jpeg/jpeg.inc |
---|
File deleted |
/programs/develop/libraries/libs-dev/libimg/jpeg/jpeg.asm |
---|
File deleted |