【发布时间】:2011-01-22 12:19:34
【问题描述】:
您好,我已经开发了水平镜像/翻转 8 bpp .BMP 图像的代码。正确处理任何宽度,不仅是 4 的倍数。现在我必须将此代码转换为相同但为 1 bpp 。使用 x86 的 bmp 图像(灰度)。困难的部分是我不知道如何超越个别位也许有人可以编辑这段代码..
section .text
global mirrorbmp8
mirrorbmp8:
push ebp
mov ebp, esp
push ebx
push esi
push edi
mov ebx, [ebp+12] ;width - without padding
and ebx, 11b
je init ;checking if there is a padding
mov edi, 4
sub edi, ebx
add [ebp+12], edi ;width - with padding
init:
mov ebx, [ebp+16]
;calculating the distance between top&bottom pixel
dec ebx
mov eax, [ebp+12]
mul ebx
mov esi, eax
mov edi, [ebp+8] ;the first bottom pixel
mov edx, edi ;the first top pixel
mov eax, edi
add eax, esi
mov ecx, [ebp+12]
;register responsible for calc left columns
loop0:
push esi
mov esi, [ebp+12]
loop1:
mov bl, [edi] ;changing pixels
xchg bl, [eax]
mov [edi], bl
add edi, esi ;next pixel in this column
sub eax, esi
cmp edi, eax
jl loop1
inc edx ;next bottom pixel
mov edi, edx
mov eax, edi ;next top pixel
pop esi
add eax, esi
dec ecx ;decrement number of columns left
jnz loop0 ;was that the last column?
end:
pop edi
pop esi
pop ebx
mov esp, ebp
pop ebp
ret
任何帮助将不胜感激。 在此先感谢:)
p.s 如果我能做这个版本,那么我也必须将整个代码转换为 x86-64 版本,这方面的任何提示也会有所帮助..
【问题讨论】:
-
在我看来,代码是垂直翻转图像,而不是水平翻转。我错过了什么吗?
-
这是用于水平翻转而不是垂直:)
标签: assembly image-processing bitmap x86 x86-64