1,5 → 1,5 |
;;================================================================================================;; |
;;//// xcf.asm //// (c) dunkaist, 2011 ///////////////////////////////////////////////////////////;; |
;;//// xcf.asm //// (c) dunkaist, 2011-2012 //////////////////////////////////////////////////////;; |
;;================================================================================================;; |
;; ;; |
;; This file is part of Common development libraries (Libs-Dev). ;; |
27,15 → 27,14 |
;; ;; |
;;================================================================================================;; |
include 'xcf.inc' |
;include '../../../../system/board/trunk/debug.inc' |
;include '../../../../../system/board/trunk/debug.inc' |
|
COMPOSITE_MODE equ MMX |
; MMX | pretty fast and compatible |
; SSE | a bit faster, but may be unsupported by some CPUs |
|
MAX_LAYERS equ 255 |
MAX_LAYERS = 255 |
|
DEBUG_STANDARD equ TRUE |
DEBUG_FBOUNDS equ FALSE |
|
;;================================================================================================;; |
proc img.is.xcf _data, _length ;//////////////////////////////////////////////////////////////////;; |
;;------------------------------------------------------------------------------------------------;; |
75,9 → 74,9 |
.is_not_xcf: |
pop edi |
ret |
|
endp |
|
|
;;================================================================================================;; |
proc img.decode.xcf _data, _length, _options ;////////////////////////////////////////////////////;; |
;;------------------------------------------------------------------------------------------------;; |
89,8 → 88,8 |
;< eax = 0 (error) or pointer to image ;; |
;;================================================================================================;; |
locals |
count rd 1 |
retvalue rd 1 ; 0 (error) or pointer to image |
layer_count rd 1 |
retvalue rd 1 |
endl |
|
push ebx esi edi |
149,7 → 148,8 |
|
mov edi, [ebx+Image.Palette] |
mov eax, 0xff000000 |
@@: stosd |
@@: |
stosd |
add eax, 0x00010101 |
jnc @b |
|
188,48 → 188,49 |
mov [eax+xcf_ext.opacity], 0xffffffff |
mov [eax+xcf_ext.type], edx |
|
stdcall parse_properties, ebx |
stdcall xcf._.parse_properties, ebx |
|
mov edi, esi |
mov eax, 0 |
xor eax, eax |
mov ecx, MAX_LAYERS |
mov [count], MAX_LAYERS-1 |
mov [layer_count], MAX_LAYERS-1 |
repne scasd |
sub [count], ecx |
sub [layer_count], ecx |
mov esi, edi |
mov ecx, 0 |
xor ecx, ecx |
|
.still: sub esi, 8 |
.still: |
sub esi, 8 |
lodsd |
bswap eax |
|
push ecx |
stdcall decode_layer, eax, [_data] |
stdcall xcf._.decode_layer, eax, [_data] |
pop ecx |
test eax, eax |
jz @f |
push ecx |
stdcall merge_down, eax, [retvalue], ecx |
stdcall xcf._.merge_down, eax, [retvalue], ecx |
pop ecx |
add ecx, 1 |
@@: dec [count] |
@@: |
dec [layer_count] |
jnz .still |
; jmp .quit |
|
|
cmp [ebx+Image.Type], Image.bpp8 |
jne .quit |
stdcall pack_8a, ebx |
stdcall xcf._.pack_8a, ebx |
jmp .quit |
|
.error: mov [retvalue], 0 |
.quit: pop edi esi ebx |
.error: |
mov [retvalue], 0 |
.quit: |
pop edi esi ebx |
mov eax, [retvalue] |
ret |
endp |
|
|
|
;;================================================================================================;; |
proc img.encode.xcf _img, _p_length, _options ;///////////////////////////////////////////////////;; |
;;------------------------------------------------------------------------------------------------;; |
252,7 → 253,7 |
;;================================================================================================;; |
;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
;;================================================================================================;; |
proc parse_properties _img |
proc xcf._.parse_properties _img |
|
mov ebx, [_img] |
.begin: |
259,8 → 260,8 |
lodsd |
bswap eax |
|
mov ecx, (xcf_prop_table_end-xcf_prop_table_begin)/8 |
mov edi, xcf_prop_table_begin |
mov ecx, (xcf._.prop_table_end - xcf._.prop_table_begin)/8 |
mov edi, xcf._.prop_table_begin |
|
.still: |
cmp eax, [edi] |
270,16 → 271,16 |
add edi, 8 |
dec ecx |
jnz .still |
lodsd ; skip |
bswap eax ; uninteresting |
add esi, eax ; property |
lodsd |
bswap eax |
add esi, eax |
jmp .begin |
|
parse_prop_00: ; PROP_END |
.00: ; PROP_END |
lodsd |
ret |
|
parse_prop_01: ; PROP_COLORMAP |
.01: ; PROP_COLORMAP |
lodsd |
mov ecx, [ebx+Image.Extended] |
cmp [ecx+xcf_ext.type], XCF_BASETYPE_INDEXED |
286,7 → 287,7 |
je @f |
bswap eax |
add esi, eax |
jmp parse_properties.begin |
jmp xcf._.parse_properties.begin |
@@: |
lodsd |
bswap eax |
293,7 → 294,8 |
mov ecx, eax |
mov edi, [ebx+Image.Palette] |
|
@@: lodsd |
@@: |
lodsd |
sub esi, 1 |
bswap eax |
shr eax, 8 |
301,41 → 303,41 |
stosd |
dec ecx |
jnz @b |
jmp parse_properties.begin |
jmp xcf._.parse_properties.begin |
|
parse_prop_06: ; PROP_OPACITY |
.06: ; PROP_OPACITY |
lodsd |
lodsd |
bswap eax |
mov ecx, [ebx+Image.Extended] |
mov [ecx+xcf_ext.opacity], eax |
jmp parse_properties.begin |
jmp xcf._.parse_properties.begin |
|
parse_prop_07: ; PROP_MODE |
.07: ; PROP_MODE |
lodsd |
lodsd |
bswap eax |
mov ecx, [ebx+Image.Extended] |
mov [ecx+xcf_ext.layer_mode], eax |
jmp parse_properties.begin |
jmp xcf._.parse_properties.begin |
|
parse_prop_08: ; PROP_VISIBLE |
.08: ; PROP_VISIBLE |
lodsd |
lodsd |
bswap eax |
mov ecx, [ebx+Image.Extended] |
mov [ecx+xcf_ext.visible], eax |
jmp parse_properties.begin |
jmp xcf._.parse_properties.begin |
|
parse_prop_11: ; PROP_APPLY_MASK |
.11: ; PROP_APPLY_MASK |
lodsd |
lodsd |
bswap eax |
mov ecx, [ebx+Image.Extended] |
mov [ecx+xcf_ext.apply_mask], eax |
jmp parse_properties.begin |
jmp xcf._.parse_properties.begin |
|
parse_prop_15: ; PROP_OFFSETS |
.15: ; PROP_OFFSETS |
lodsd |
lodsd |
mov ecx, [ebx+Image.Extended] |
344,11 → 346,11 |
lodsd |
bswap eax |
mov [ecx+xcf_ext.offset_y], eax |
jmp parse_properties.begin |
jmp xcf._.parse_properties.begin |
endp |
|
|
proc decode_channel _channel_begin, _data |
proc xcf._.decode_channel _channel_begin, _data |
locals |
channel_width rd 1 |
channel_height rd 1 |
379,7 → 381,7 |
jz .error |
mov [ebx+Image.Extended], eax |
|
stdcall parse_properties, ebx |
stdcall xcf._.parse_properties, ebx |
|
lodsd |
bswap eax |
399,24 → 401,27 |
|
mov edi, [ebx+Image.Data] |
mov ecx, 0 |
@@: lodsd |
@@: |
lodsd |
test eax, eax |
jz .quit |
bswap eax |
add eax, [_data] |
stdcall decode_tile, eax, [channel_width], [channel_height], [total_bpl], [planes_todo], 1 |
stdcall xcf._.decode_tile, eax, [channel_width], [channel_height], [total_bpl], [planes_todo], 1 |
add ecx, 1 |
jmp @b |
|
.error: stdcall img.destroy, ebx |
.error: |
stdcall img.destroy, ebx |
mov ebx, 0 |
.quit: mov eax, ebx |
.quit: |
mov eax, ebx |
pop edi esi ebx |
ret |
endp |
|
|
proc decode_layer _layer_begin, _data |
proc xcf._.decode_layer _layer_begin, _data |
locals |
layer_width rd 1 |
layer_height rd 1 |
445,7 → 450,8 |
mov [color_step], 3 |
mov edx, Image.bpp32 |
shl [total_bpl], 1 |
@@: stdcall img.create, [layer_width], [layer_height], edx |
@@: |
stdcall img.create, [layer_width], [layer_height], edx |
mov ebx, eax |
test ebx, ebx |
jz .quit |
457,7 → 463,7 |
lodsd |
bswap eax |
add esi, eax |
stdcall parse_properties, ebx |
stdcall xcf._.parse_properties, ebx |
mov edx, [ebx+Image.Extended] |
or [edx+xcf_ext.visible], 0 |
jz .unvisible |
483,17 → 489,18 |
|
mov edi, [ebx+Image.Data] |
mov ecx, 0 |
@@: lodsd |
@@: |
lodsd |
test eax, eax |
jz @f |
bswap eax |
add eax, [_data] |
stdcall decode_tile, eax, [layer_width], [layer_height], [total_bpl], [planes_todo], 0 |
stdcall xcf._.decode_tile, eax, [layer_width], [layer_height], [total_bpl], [planes_todo], 0 |
add ecx, 1 |
jmp @b |
@@: |
|
stdcall apply_opacity, ebx, [color_step] |
stdcall xcf._.apply_opacity, ebx, [color_step] |
|
pop esi |
lodsd |
501,7 → 508,7 |
test eax, eax |
jz .quit |
|
stdcall decode_channel, eax, [_data] |
stdcall xcf._.decode_channel, eax, [_data] |
test eax, eax |
jz .error |
|
509,19 → 516,21 |
cmp [edx+xcf_ext.apply_mask], 0 |
je .quit |
|
stdcall apply_alpha_mask, ebx, eax, [color_step] |
stdcall xcf._.apply_alpha_mask, ebx, eax, [color_step] |
jmp .quit |
|
.unvisible: |
.error: stdcall img.destroy, ebx |
.error: |
stdcall img.destroy, ebx |
mov ebx, 0 |
.quit: mov eax, ebx |
.quit: |
mov eax, ebx |
pop edi esi ebx |
ret |
endp |
|
|
proc decode_tile _tile_data, _width, _height, _total_bpl, _bytes_pp, _is_channel |
proc xcf._.decode_tile _tile_data, _width, _height, _total_bpl, _bytes_pp, _is_channel |
locals |
tile_x rd 1 |
tile_y rd 1 |
595,7 → 604,7 |
|
cmp [_is_channel], 1 |
jne @f |
stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
jmp .quit |
@@: |
mov eax, [planes_todo] |
607,42 → 616,43 |
jz .p3 |
jmp .p4 |
.p1: |
stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
add edi, 1 |
stdcall fill_color, [tile_width], [tile_height], [_total_bpl], [_bytes_pp], [color_step] |
stdcall xcf._.fill_color, [tile_width], [tile_height], [_total_bpl], [_bytes_pp], [color_step] |
jmp .quit |
.p2: |
stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
add edi, 1 |
stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
jmp .quit |
.p3: |
add edi, 2 |
stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
sub edi, 1 |
stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
sub edi, 1 |
stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
add edi, 3 |
stdcall fill_color, [tile_width], [tile_height], [_total_bpl], [_bytes_pp], [color_step] |
stdcall xcf._.fill_color, [tile_width], [tile_height], [_total_bpl], [_bytes_pp], [color_step] |
jmp .quit |
.p4: |
add edi, 2 |
stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
sub edi, 1 |
stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
sub edi, 1 |
stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
add edi, 3 |
stdcall decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
stdcall xcf._.decode_color, [tile_width], [tile_height], [color_step], [_total_bpl], [_bytes_pp] |
; jmp .quit |
|
.quit: pop edi esi edx ecx ebx |
.quit: |
pop edi esi edx ecx ebx |
ret |
endp |
|
|
proc fill_color _tile_width, _tile_height, _total_bpl, _bytes_pp, _color_step |
proc xcf._.fill_color _tile_width, _tile_height, _total_bpl, _bytes_pp, _color_step |
push ebx |
mov edx, [_color_step] |
mov ebx, [_total_bpl] |
652,20 → 662,22 |
|
mov ch, byte[_tile_height] |
mov al, 0xff |
.still: mov cl, byte[_tile_width] |
@@: stosb |
.line: |
mov cl, byte[_tile_width] |
@@: |
stosb |
add edi, edx |
dec cl |
jnz @b |
add edi, ebx |
dec ch |
jnz .still |
jnz .line |
pop ebx |
ret |
endp |
|
|
proc decode_color _tile_width, _tile_height, _color_step, _total_bpl, _bytes_pp |
proc xcf._.decode_color _tile_width, _tile_height, _color_step, _total_bpl, _bytes_pp |
locals |
level_width rd 1 |
level_height rd 1 |
682,7 → 694,8 |
mov ebx, [_tile_height] |
mov edx, [_tile_width] |
|
.decode:lodsb |
.decode: |
lodsb |
cmp al, 127 |
je .long_identical |
jb .short_identical |
701,13 → 714,15 |
mov cx, ax |
xchg cl, ch |
lodsb |
.step1: cmp cx, dx |
.step1: |
cmp cx, dx |
je .step2 |
jl .step3 |
xchg cx, dx |
sub dx, cx |
sub bx, 1 |
@@: stosb |
@@: |
stosb |
add edi, [_color_step] |
loop @b |
mov cx, dx |
716,7 → 731,8 |
jmp .step1 |
|
.step2: |
@@: stosb |
@@: |
stosb |
add edi, [_color_step] |
loop @b |
mov edx, [_tile_width] |
724,8 → 740,10 |
dec bx |
jz .quit |
jmp .decode |
.step3: sub dx, cx |
@@: stosb |
.step3: |
sub dx, cx |
@@: |
stosb |
add edi, [_color_step] |
loop @b |
jmp .decode |
742,13 → 760,15 |
mov ch, al |
lodsb |
mov cl, al |
.step4: cmp cx, dx |
.step4: |
cmp cx, dx |
je .step5 |
jl .step6 |
xchg cx, dx |
sub dx, cx |
sub bx, 1 |
@@: movsb |
@@: |
movsb |
add edi, [_color_step] |
loop @b |
mov cx, dx |
757,7 → 777,8 |
jmp .step4 |
|
.step5: |
@@: movsb |
@@: |
movsb |
add edi, [_color_step] |
loop @b |
mov edx, [_tile_width] |
766,18 → 787,21 |
jz .quit |
jmp .decode |
|
.step6: sub dx, cx |
@@: movsb |
.step6: |
sub dx, cx |
@@: |
movsb |
add edi, [_color_step] |
loop @b |
jmp .decode |
|
.quit: pop edi |
.quit: |
pop edi |
ret |
endp |
|
|
proc merge_down _img, _bottom, _layer_number |
proc xcf._.merge_down _img, _bottom, _layer_number |
locals |
copy_width rd 1 |
copy_height rd 1 |
878,7 → 902,8 |
cmp [edx+Image.Width], Image.bpp16 |
je @f |
shl eax, 1 |
@@: add esi, eax |
@@: |
add esi, eax |
|
mov eax, [ebx+Image.Width] |
imul eax, [bottom_y1] |
887,7 → 912,8 |
cmp [ebx+Image.Width], Image.bpp8 |
je @f |
shl eax, 1 |
@@: add edi, eax |
@@: |
add edi, eax |
|
|
mov eax, [edx+Image.Width] |
896,7 → 922,8 |
cmp [edx+Image.Width], Image.bpp16 |
je @f |
shl eax, 1 |
@@: mov [img_total_bpl], eax |
@@: |
mov [img_total_bpl], eax |
|
mov eax, [ebx+Image.Width] |
sub eax, [copy_width] |
904,7 → 931,8 |
cmp [ebx+Image.Width], Image.bpp8 |
je @f |
shl eax, 1 |
@@: mov [bottom_total_bpl], eax |
@@: |
mov [bottom_total_bpl], eax |
|
cmp [_layer_number], 0 |
jne .not_first |
911,10 → 939,12 |
mov ecx, [copy_width] |
imul ecx, [copy_height] |
cmp [ebx+Image.Type], Image.bpp8 |
je .bpp8 |
.bpp32: rep movsd |
je .bpp8a |
.bpp32: |
rep movsd |
jmp .done |
.bpp8: rep movsw |
.bpp8a: |
rep movsw |
jmp .done |
.not_first: |
|
937,8 → 967,8 |
@@: |
mov edx, 12 |
.type_defined: |
mov ecx, (composite_table_end-composite_table_begin)/8 |
mov edi, composite_table_begin |
mov ecx, (xcf._.composite_table.end - xcf._.composite_table.begin) / 8 |
mov edi, xcf._.composite_table.begin |
|
.still: |
cmp eax, [edi] |
969,9 → 999,10 |
|
cmp [ebx+Image.Type], Image.bpp8 |
jne @f |
stdcall merge_8a, [copy_width], [copy_height], [img_total_bpl], [bottom_total_bpl] |
stdcall xcf._.merge_8a, [copy_width], [copy_height], [img_total_bpl], [bottom_total_bpl] |
jmp .done |
@@: stdcall merge_32, [copy_width], [copy_height], [img_total_bpl], [bottom_total_bpl] |
@@: |
stdcall xcf._.merge_32, [copy_width], [copy_height], [img_total_bpl], [bottom_total_bpl] |
; jmp .done |
.done: |
stdcall img.destroy, [_img] |
980,14 → 1011,14 |
endp |
|
|
proc pack_8a _img |
proc xcf._.pack_8a _img |
mov ebx, [_img] |
mov esi, [ebx+Image.Data] |
mov edi, [ebx+Image.Data] |
mov edi, esi |
mov ecx, [ebx+Image.Width] |
mov edx, [ebx+Image.Height] |
imul ecx, edx |
@@: lodsw |
imul ecx, [ebx + Image.Height] |
@@: |
lodsw |
stosb |
dec ecx |
jnz @b |
995,7 → 1026,7 |
endp |
|
|
proc apply_opacity _img, _color_step |
proc xcf._.apply_opacity _img, _color_step |
|
push ebx |
|
1010,7 → 1041,8 |
mov ebx, [_color_step] |
add esi, ebx |
mov edi, esi |
@@: lodsb |
@@: |
lodsb |
mul dl |
shr ax, 8 |
stosb |
1019,12 → 1051,13 |
dec ecx |
jnz @b |
|
.quit: pop ebx |
.quit: |
pop ebx |
ret |
endp |
|
|
proc apply_alpha_mask _img, _mask, _color_step |
proc xcf._.apply_alpha_mask _img, _mask, _color_step |
|
push ebx |
|
1051,7 → 1084,15 |
endp |
|
|
proc pixel_rgb2hsv |
;;================================================================================================;; |
proc xcf._.rgb2hsv ;///////////////////////////////////////////////////////////////////////////;; |
;;------------------------------------------------------------------------------------------------;; |
;? convert color from RGB to HSV space ;; |
;;------------------------------------------------------------------------------------------------;; |
;> eax = color (0xAARRGGBB) ;; |
;;------------------------------------------------------------------------------------------------;; |
;< eax = color (0xAAHHSSVV) ;; |
;;================================================================================================;; |
locals |
vsha rd 1 |
max rd 1 |
1074,19 → 1115,22 |
rol eax, 8 |
jmp .quit |
|
@@: cmp dl, cl |
@@: |
cmp dl, cl |
ja @f |
cmp dl, al |
ja @f |
mov byte[min], dl |
jmp .min_found |
@@: cmp cl, al |
@@: |
cmp cl, al |
ja @f |
cmp cl, dl |
ja @f |
mov byte[min], cl |
jmp .min_found |
@@: mov byte[min], al |
@@: |
mov byte[min], al |
; jmp .min_found |
.min_found: |
|
1099,7 → 1143,8 |
mov dx, cx |
mov cx, 0 |
jmp .max_found |
@@: cmp cl, al |
@@: |
cmp cl, al |
jb @f |
cmp cl, dl |
jb @f |
1108,7 → 1153,8 |
mov dx, ax |
mov cx, 85 |
jmp .max_found |
@@: mov byte[max], al |
@@: |
mov byte[max], al |
sub dx, cx |
mov cx, 171 |
; jmp .max_found |
1145,12 → 1191,21 |
@@: |
mov eax, [vsha] |
|
.quit: pop edx ecx ebx |
.quit: |
pop edx ecx ebx |
ret |
endp |
|
|
proc pixel_hsv2rgb |
;;================================================================================================;; |
proc xcf._.hsv2rgb ;///////////////////////////////////////////////////////////////////////////;; |
;;------------------------------------------------------------------------------------------------;; |
;? convert color from HSV to RGB space ;; |
;;------------------------------------------------------------------------------------------------;; |
;> eax = color (0xAAHHSSVV) ;; |
;;------------------------------------------------------------------------------------------------;; |
;< eax = color (0xAARRGGBB) ;; |
;;================================================================================================;; |
locals |
vsha rd 1 |
f rb 1 |
1178,7 → 1233,8 |
sub eax, ebx |
jmp .ok |
|
@@: cmp eax, 86 |
@@: |
cmp eax, 86 |
ja @f |
sub eax, 44 |
lea eax, [eax*3] |
1187,7 → 1243,8 |
add al, 0xff |
jmp .ok |
|
@@: cmp eax, 129 |
@@: |
cmp eax, 129 |
ja @f |
sub eax, 87 |
lea eax, [eax*3] |
1194,7 → 1251,8 |
shl eax, 1 |
jmp .ok |
|
@@: cmp eax, 171 |
@@: |
cmp eax, 171 |
ja @f |
sub eax, 130 |
lea eax, [eax*3] |
1203,7 → 1261,8 |
add al, 0xff |
jmp .ok |
|
@@: cmp eax, 214 |
@@: |
cmp eax, 214 |
ja @f |
sub eax, 172 |
lea eax, [eax*3] |
1239,7 → 1298,8 |
mov al, 0 |
jmp .done |
|
@@: cmp al, 86 |
@@: |
cmp al, 86 |
jae @f |
mov eax, [vsha] |
shr eax, 8 |
1249,7 → 1309,8 |
mov al, 0 |
jmp .done |
|
@@: cmp al, 129 |
@@: |
cmp al, 129 |
jae @f |
mov eax, [vsha] |
shr eax, 8 |
1259,7 → 1320,8 |
mov al, byte[x] |
jmp .done |
|
@@: cmp al, 171 |
@@: |
cmp al, 171 |
jae @f |
mov eax, [vsha] |
shr eax, 8 |
1269,7 → 1331,8 |
mov al, byte[c] |
jmp .done |
|
@@: cmp al, 214 |
@@: |
cmp al, 214 |
jae @f |
mov eax, [vsha] |
shr eax, 8 |
1279,7 → 1342,8 |
mov al, byte[c] |
jmp .done |
|
@@: mov eax, [vsha] |
@@: |
mov eax, [vsha] |
shr eax, 8 |
mov ah, byte[c] |
shl eax, 8 |
1296,12 → 1360,21 |
add ah, bl |
add al, bl |
|
.quit: pop edx ecx ebx |
.quit: |
pop edx ecx ebx |
ret |
endp |
|
|
proc pixel_rgb2hsl |
;;================================================================================================;; |
proc xcf._.rgb2hsl ;///////////////////////////////////////////////////////////////////////////;; |
;;------------------------------------------------------------------------------------------------;; |
;? convert color from RGB to HSL space ;; |
;;------------------------------------------------------------------------------------------------;; |
;> eax = color (0xAARRGGBB) ;; |
;;------------------------------------------------------------------------------------------------;; |
;< eax = color (0xAAHHSSLL) ;; |
;;================================================================================================;; |
; http://www.asmcommunity.net/board/index.php?topic=7425 |
; iblis: "I don't know what X-Filez is, but yes you may use it however you wish. That's why I made this post, to share." |
; so pixel_rgb2hsl procedure is based on code by Greg Hoyer (iblis). thanks! |
1339,15 → 1412,18 |
xchg esi, edi |
neg cl |
shl cl, 1 |
.cmp1: cmp edi, ebx |
.cmp1: |
cmp edi, ebx |
jb .cmp2 |
xchg edi, ebx |
neg cl |
.cmp2: cmp esi, ebx |
.cmp2: |
cmp esi, ebx |
ja .cmp3 |
xchg esi, ebx |
not cl |
.cmp3: neg ebx |
.cmp3: |
neg ebx |
add ebx, esi |
mov eax, edi |
add edi, esi |
1362,7 → 1438,8 |
jbe .csat |
neg edi |
add edi, 510 |
.csat: xor edx, edx |
.csat: |
xor edx, edx |
div edi |
pop edi |
shr edi, 1 |
1371,7 → 1448,8 |
add cl, 3 |
jnc .noneg |
neg ebx |
.noneg: shl cl, 2 |
.noneg: |
shl cl, 2 |
mov eax, 0x13135db9 |
shr eax, cl |
and eax, 7 |
1387,7 → 1465,8 |
div ebx |
shl eax, 16 |
or eax, edi |
.done: bswap eax |
.done: |
bswap eax |
shr eax, 8 |
|
mov bl, byte[bgra+3] |
1401,7 → 1480,15 |
endp |
|
|
proc pixel_hsl2rgb |
;;================================================================================================;; |
proc xcf._.hsl2rgb ;///////////////////////////////////////////////////////////////////////////;; |
;;------------------------------------------------------------------------------------------------;; |
;? convert color from HSL to RGB space ;; |
;;------------------------------------------------------------------------------------------------;; |
;> eax = color (0xAAHHSSLL) ;; |
;;------------------------------------------------------------------------------------------------;; |
;< eax = color (0xAARRGGBB) ;; |
;;================================================================================================;; |
; http://www.asmcommunity.net/board/index.php?topic=7425 |
; iblis: "I don't know what X-Filez is, but yes you may use it however you wish. That's why I made this post, to share." |
; so pixel_hsl2rgb procedure is based on code by Greg Hoyer (iblis). thanks! |
1439,7 → 1526,8 |
ja .lcase |
dec al |
xor ecx, ecx |
.lcase: add eax, edi |
.lcase: |
add eax, edi |
mul ebx |
or ecx, ecx |
jz .scase |
1450,7 → 1538,8 |
shl ecx, 8 |
sub ecx, edx |
add eax, ecx |
.scase: xor edx, edx |
.scase: |
xor edx, edx |
xor ecx, ecx |
dec cl |
mov edi, ecx |
1513,7 → 1602,8 |
jz .done |
ror eax, 8 |
xchg ah, al |
.done: and eax, 0x00ffffff |
.done: |
and eax, 0x00ffffff |
|
mov bl, byte[lsha+3] |
bswap eax |
1521,11 → 1611,15 |
ror eax, 8 |
|
pop edi esi ebx |
|
|
ret |
endp |
|
|
match =MMX,COMPOSITE_MODE{include 'composite_mmx.inc'} |
match =MMX, COMPOSITE_MODE{include 'composite_mmx.asm'} |
match =SSE, COMPOSITE_MODE{include 'composite_sse.asm'} |
|
;;================================================================================================;; |
;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
;;================================================================================================;; |
1533,41 → 1627,37 |
;;================================================================================================;; |
;;////////////////////////////////////////////////////////////////////////////////////////////////;; |
;;================================================================================================;; |
xcf_prop_table_begin: |
dd 00, parse_prop_00 |
dd 01, parse_prop_01 |
dd 06, parse_prop_06 |
dd 07, parse_prop_07 |
dd 08, parse_prop_08 |
dd 11, parse_prop_11 |
dd 15, parse_prop_15 |
xcf_prop_table_end: |
xcf._.prop_table_begin: |
dd 00, xcf._.parse_properties.00 |
dd 01, xcf._.parse_properties.01 |
dd 06, xcf._.parse_properties.06 |
dd 07, xcf._.parse_properties.07 |
dd 08, xcf._.parse_properties.08 |
dd 11, xcf._.parse_properties.11 |
dd 15, xcf._.parse_properties.15 |
xcf._.prop_table_end: |
|
composite_table_begin: |
.p00 dd 00, composite_rgb_00, composite_gray_00, composite_indexed_00 ; Normal |
.p01 dd 01, composite_rgb_01, composite_gray_01, composite_gray_01 ; Dissolve : random dithering to discrete alpha |
;.p02 dd 02, composite_rgb_02, 0, composite_indexed_02 ; Behind : not selectable in the GIMP UI. not implemented |
.p03 dd 03, composite_rgb_03, composite_rgb_03, composite_indexed_00 ; Multiply |
.p04 dd 04, composite_rgb_04, composite_rgb_04, composite_indexed_00 ; Screen |
.p05 dd 05, composite_rgb_05, composite_rgb_05, composite_indexed_00 ; Overlay |
.p06 dd 06, composite_rgb_06, composite_rgb_06, composite_indexed_00 ; Difference |
.p07 dd 07, composite_rgb_07, composite_rgb_07, composite_indexed_00 ; Addition |
.p08 dd 08, composite_rgb_08, composite_rgb_08, composite_indexed_00 ; Subtract |
.p09 dd 09, composite_rgb_09, composite_rgb_09, composite_indexed_00 ; Darken Only |
.p10 dd 10, composite_rgb_10, composite_rgb_10, composite_indexed_00 ; Lighten Only |
.p11 dd 11, composite_rgb_11, composite_gray_00, composite_indexed_00 ; Hue (H of HSV) |
.p12 dd 12, composite_rgb_12, composite_gray_00, composite_indexed_00 ; Saturation (S of HSV) |
.p13 dd 13, composite_rgb_13, composite_gray_00, composite_indexed_00 ; Color (H and S of HSL) |
.p14 dd 14, composite_rgb_14, composite_gray_00, composite_indexed_00 ; Value (V of HSV) |
.p15 dd 15, composite_rgb_15, composite_rgb_15, composite_indexed_00 ; Divide |
.p16 dd 16, composite_rgb_16, composite_rgb_16, composite_indexed_00 ; Dodge |
.p17 dd 17, composite_rgb_17, composite_rgb_17, composite_indexed_00 ; Burn |
.p18 dd 18, composite_rgb_18, composite_rgb_18, composite_indexed_00 ; Hard Light |
.p19 dd 19, composite_rgb_05, composite_rgb_05, composite_indexed_00 ; Soft Light : XCF version >= 2 only ('soft light' == 'overlay') |
.p20 dd 20, composite_rgb_20, composite_rgb_20, composite_indexed_00 ; Grain Extract : XCF version >= 2 only |
.p21 dd 21, composite_rgb_21, composite_rgb_21, composite_indexed_00 ; Grain Merge : XCF version >= 2 only |
composite_table_end: |
|
random_a dd 1103515245 |
random_b dd 777 |
random_c dd 12345 |
xcf._.composite_table.begin: |
.p00 dd 00, xcf._.composite_rgb_00, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Normal |
.p01 dd 01, xcf._.composite_rgb_01, xcf._.composite_gray_01, xcf._.composite_gray_01 ; Dissolve : random dithering to discrete alpha |
; .p02 dd 02, xcf._.composite_rgb_02, 0, xcf._.composite_indexed_02 ; Behind : not selectable in the GIMP UI. not implemented |
.p03 dd 03, xcf._.composite_rgb_03, xcf._.composite_rgb_03, xcf._.composite_indexed_00 ; Multiply |
.p04 dd 04, xcf._.composite_rgb_04, xcf._.composite_rgb_04, xcf._.composite_indexed_00 ; Screen |
.p05 dd 05, xcf._.composite_rgb_05, xcf._.composite_rgb_05, xcf._.composite_indexed_00 ; Overlay |
.p06 dd 06, xcf._.composite_rgb_06, xcf._.composite_rgb_06, xcf._.composite_indexed_00 ; Difference |
.p07 dd 07, xcf._.composite_rgb_07, xcf._.composite_rgb_07, xcf._.composite_indexed_00 ; Addition |
.p08 dd 08, xcf._.composite_rgb_08, xcf._.composite_rgb_08, xcf._.composite_indexed_00 ; Subtract |
.p09 dd 09, xcf._.composite_rgb_09, xcf._.composite_rgb_09, xcf._.composite_indexed_00 ; Darken Only |
.p10 dd 10, xcf._.composite_rgb_10, xcf._.composite_rgb_10, xcf._.composite_indexed_00 ; Lighten Only |
.p11 dd 11, xcf._.composite_rgb_11, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Hue (H of HSV) |
.p12 dd 12, xcf._.composite_rgb_12, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Saturation (S of HSV) |
.p13 dd 13, xcf._.composite_rgb_13, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Color (H and S of HSL) |
.p14 dd 14, xcf._.composite_rgb_14, xcf._.composite_gray_00, xcf._.composite_indexed_00 ; Value (V of HSV) |
.p15 dd 15, xcf._.composite_rgb_15, xcf._.composite_rgb_15, xcf._.composite_indexed_00 ; Divide |
.p16 dd 16, xcf._.composite_rgb_16, xcf._.composite_rgb_16, xcf._.composite_indexed_00 ; Dodge |
.p17 dd 17, xcf._.composite_rgb_17, xcf._.composite_rgb_17, xcf._.composite_indexed_00 ; Burn |
.p18 dd 18, xcf._.composite_rgb_18, xcf._.composite_rgb_18, xcf._.composite_indexed_00 ; Hard Light |
.p19 dd 19, xcf._.composite_rgb_05, xcf._.composite_rgb_05, xcf._.composite_indexed_00 ; Soft Light : XCF >= 2 only ('soft light' == 'overlay') |
.p20 dd 20, xcf._.composite_rgb_20, xcf._.composite_rgb_20, xcf._.composite_indexed_00 ; Grain Extract : XCF >= 2 only |
.p21 dd 21, xcf._.composite_rgb_21, xcf._.composite_rgb_21, xcf._.composite_indexed_00 ; Grain Merge : XCF >= 2 only |
xcf._.composite_table.end: |