显示保存在缓冲区MASM 5.1中的图像文件

时间:2012-01-15 02:50:32

标签: image assembly graphics masm

我想在图形模式下显示图像。我已将图像读入缓冲区。我已经制作了这段代码但是如何在屏幕上显示像素?此代码用于显示文本文件,但如何显示像素?

readFIL PROC NEAR ; proc que escreve uma ficha
     mov ah, 3dh ;Open the file
    mov al, 0 ;Open for reading
    lea dx, FILENAM;Presume DS points at FILENAM
    int 21h ; segment.
    mov  FHAND, ax ;Save file handle
LP: mov ah,3fh ;Read data from the file
    lea dx, NAMEFLD ;Address of data NAMEFLD
    mov cx, 12 ;Read one byte
    mov bx,  FHAND ;Get file handle value
    int 21h

    cmp ax, cx ;EOF reached?
    jne EOF
    mov al, NAMEFLD ;Get character read   
    ;--------
    mov cx,0
    siga:


    ;----------------------

    mov al,NAMEFLD
    lea si , NAMEFLD
    MOV AH,09h 
    int 21h

    ;---------------------
    inc dx   ;->> move next caracter in buffer
    add cx, 1
    cmp cx,12
    jne siga

EOF: mov bx,  FHAND
     mov ah, 3eh ;Close file
     int 21h

 RET
readFIL ENDP

需要帮助学校,但老师无论如何都不帮助我们:(

1 个答案:

答案 0 :(得分:2)

使用BIOS interrupt 10h function 0设置图形模式。

我建议设置mode 13h (320x200x8bpp),因为它是最容易编程的,它应该适用于任何VGA卡或更好。

然后逐像素地在视频缓冲区中绘制图像。缓冲区从物理地址0xA0000开始,长度为320 * 200 = 64000字节。

如果您不需要支持超过“16种标准”颜色(默认情况下在文本模式下获得的颜色)或者您可以使用黑白,则可以避免重新编程VGA调色板VGA DAC,你可以避免找到最好的颜色。只需将RGB三元组转换为亮度(add together 30% of the red value, 59% of the green value, and 11% of the blue value),将值缩放到0到15(包括0和15)的范围,再添加16,这就是应该写入视频缓冲区的字节值。