人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統(tǒng)下載站 > 技術開發(fā)教程 > 詳細頁面

如何產生一個BMP文件

如何產生一個BMP文件

更新時間:2022-10-16 文章作者:未知 信息來源:網絡 閱讀次數(shù):

BMP 文件是一種常用的圖像文件格式,本文的例子程序產生一個簡單的 640x480 24 bit 顏色的 BMP 文件。BMP 文件的格式分兩部分,第一部分為文件頭,具體定義見源程序,第二部分為數(shù)據(jù)區(qū),緊接著文件頭存放。

源程序:

code segment
assume cs:code,ds:code
org 100h
start:
jmp install

;BMP 文件頭定義
;---------------------------------------------------------------
BMP_HEAD DB 'BM' ;固定為 'BM'
D_FILE_LENGTH DD 640*480*3+36h ;文件總長度,包括文件頭
D_RESERVED DD ? ;reserved
D_OFFSET DD 36h ;數(shù)據(jù)區(qū)開始位置
D_BISIZE DD 28h ;bit map info' head length
D_WIDTH DD 640 ;圖形的寬度(單位象素)
D_HEIGHT DD 480 ;圖形的高度(單位象素)
D_PLANES DW 1 ;圖形的平面數(shù)
D_BIT DW 24 ;顏色位數(shù)
D_COMPRESS DD 0 ;壓縮方式(0為不壓縮)
D_SIZE DD 640*480*3 ;數(shù)據(jù)長度
D_XPPM DD 0c00h ;pixels per meter (x)
D_YPPM DD 0c00h ;pixels per meter (y)
D_CLRUSED DD 0 ;color used
D_CLRIMP DD 0 ;important color index
BMP_HEAD_END EQU THIS BYTE
;----------------------------------------------------------------
HANDLE DW ?
FILE_NAME DB 'test.bmp',0
LINE_BUF DB 640*3 dup (0)
D_RED DB 0ffh
D_GREEN DB 0
D_BLUE DB 0
install:
mov ah,3ch ;建立文件
xor cx,cx
mov dx,offset file_name
int 21h
jnb cre_ok
int 20h
cre_ok:
mov handle,ax

mov ah,40h ;寫入文件頭
mov bx,handle
mov cx,offset bmp_head_end-offset bmp_head
mov dx,offset bmp_head
int 21h

mov cx,480 ;寫入 480 行數(shù)據(jù)
xor bp,bp
b_lop:
push cx

mov ax,bp
inc bp
cmp ax,160
jb b1
cmp ax,320
jb b2
b3:
sub ax,320
mov si,offset d_blue
mov di,offset d_red
jmp short b4
b2:
sub ax,160
mov si,offset d_green
mov di,offset d_blue
jmp short b4
b1:
mov si,offset d_red
mov di,offset d_green
b4:
mov cx,0ffh
mul cx
mov cx,160 ;160
div cx

mov byte ptr ds:[si],0ffh
sub byte ptr ds:[si],al
mov byte ptr ds:[di],al

mov cx,640
mov di,offset line_buf
cld
b_lop1:
mov al,d_red
stosb
mov al,d_green
stosb
mov al,d_blue
stosb
loop b_lop1

mov ah,40h
mov bx,handle
mov cx,640*3
mov dx,offset line_buf
int 21h
pop cx
loop b_lop

mov ah,3eh ;關閉文件
int 21h
int 20h
CODE ENDS
END START

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統(tǒng)下載排行

網站地圖xml | 網站地圖html
主站蜘蛛池模板: 星座| 封开县| 临城县| 两当县| 烟台市| 江门市| 大新县| 临武县| 温州市| 海伦市| 张家川| 兴义市| 商丘市| 庐江县| 乐亭县| 太湖县| 那坡县| 永修县| 都兰县| 如皋市| 阳新县| 丰都县| 文成县| 大田县| 郸城县| 龙泉市| 河池市| 安丘市| 阿坝县| 丘北县| 石河子市| 拉萨市| 金阳县| 凌云县| 海南省| 林甸县| 射洪县| 阜新市| 谢通门县| 南江县| 寿光市|