郁闷求助,帮我看看这个显示bmp的程序到底哪里不对吧,万分感谢!

Areslp 2004-01-01 02:46:26
data segment
;file path
pathname db 'e:\masm5\c.bmp',00
;handle
handle dw ?
;store
bmpdate1 db 256*4 dup(?)
bmpdate2 db 64000 dup(?)
len dw ?
row db 0
endcde db 0
data ends
;--------------------------------------------------------
;stack
stack segment
dw 100h dup(?)
stack ends
;-------------------------------------------------------
prognam segment
assume cs:prognam,ds:data,ss:stack
main proc far
;set stack
push ds
xor ax,ax
push ax
;set ds register to current data
mov ax,data
mov ds,ax
;main part of the program
call openf
call readf1
call dispy1
call readf2
call dispy2
mov ah,0
int 16h
mov ax,3
int 10h
mov ax,4c00h
int 21h
mov ax,4c00h
int 21h
main endp
;-------------------------------------------------------
;设置调色板
dispy1 proc near
;set the palett
mov cx,256
lea si,bmpdate1
p:
mov dx,3c8h
mov ax,cx
dec ax
out dx,al
inc dx
mov al,[si+2]
shr al,1
shr al,1
out dx,al
mov al,[si+1]
shr al,1
shr al,1
out dx,al
mov al,[si]
shr al,1
shr al,1
out dx,al
add si,4
loop p
ret
dispy1 endp
;---------------------------------------------------
;读象素的颜色信息
readf2 proc near
mov ah,42h
mov al,0
mov bx,handle
mov cx,0
mov dx,436h
int 21h
mov ah,3fh
lea dx,bmpdate2
mov cx,64000
int 21h
ret
readf2 endp
;---------------------------------------------------
;打开文件
openf proc near
lea dx,pathname
mov ah,3dh
mov al,0
int 21h
mov handle,ax
ret
openf endp
;---------------------------------------------------
;读入调色板信息
readf1 proc near
mov ah,42h
mov al,0
mov bx,handle
mov cx,0
mov dx,36h
int 21h
mov ah,3fh
lea dx,bmpdate1
mov cx,256*4
int 21h
ret
readf1 endp
;显示bmp
dispy2 proc near
mov bx,0a000h
mov es,bx
mov ax,0013h
int 10h
mov ax,0
mov di,ax
lea si,bmpdate2
mov cx,64000
dis:
mov ax,[si]
stosb
inc di
add si,2
loop dis
ret
dispy2 endp
prognam ends
end main
这个是用来显示256色bmp文件的,我为了简单一点把bmp图像改成320*200的大小,但是现在显示出来是花的,只能看到一点大概的轮廓,各位帮帮小弟吧!!
...全文
26 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
dunkel 2004-01-01
  • 打赏
  • 举报
回复
你的这个程序首先有这几个问题: 1. 应该先设置显示模式, 再设置调色板, 否则在进行模式设置时一般是会重置调色板的, 致使你前面的对调色板的设置作废(在显示模式 byte 的最高位置 1 好像可以避免这个调色板的重置); 2. 256 色的索引模式的 bmp 中的位图数据部分, 每个字节都是一个对应的像素, 但你的程序在设置显示数据时却跳过了一个字节, 不知你基于什么样的考虑, 这也是使图形变虚的原因; 3. bmp 的图象数据是从下往上排列的, 即最下面一行的数据在数据区的开头, 因此在实际显示时要有一定的处理, 否则显示出来的图形是倒置的. 但我在以上面的方法修改了你的代码后, 虽然可以显示原来的图像了, 但颜色仍有较大的失真 (我对调色板的设置用的是 int10h(AX=1012h), 这个中断调用的数据格式和 bmp 文件中的颜色表中的格式有较大的差异, 但我已经进行过处理了), 似乎是色深不够, 我也不知道是什么原因了.

21,458

社区成员

发帖
与我相关
我的任务
社区描述
汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
社区管理员
  • 汇编语言
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧