;Programm zum Darstellen von BMP´s mit einer Breite von max 320 Pixeln und einer Höhe von max.
;200 Pixeln u. max. 256 Farben. Syntax: show4 dateiname.ext. (c) Marcus Roming.
.MODEL SMALL
.486
.STACK 100h
PalLen EQU 1024 ;Länge Palette
Headerlaenge EQU PalLen + 54 ;Länge Header
Seg2BildAnf EQU 2
Seg2BreiteFar EQU 0
include macro.inc
extrn CalcDi: NEAR ;Nur zur Demonstration...
.DATA
Header STRUC
Typ DW ? ;In BMP´s muß hier BM stehen
Size1 DD ?
Res1 DW ?
Res2 DW ?
OffBits DD ? ;Bei Adr. hier fängt das Bild an (normal: 1078) Off: 10
Size2 DD ?
Breite DW ? ;Breite des Bildes in Pixel
Breite2 DW ? ;hab ich aufgeteilt, die Hoehe auch
Hoehe DW ? ;Hoehe des Bildes in Pixel
Hoehe2 DW ?
Planes DW ?
BiBitCount DW ? ;Farbtiefe 8 bit=256
Compression DD ?
SizeImage DD ? ;Off: 34
XPelsPerMtr DD ?
YPelsPerMtr DD ?
ColorsUsed DD ?
CImportant DD ?
Palette DB PalLen DUP (?) ;Die Farbpalette
Header ENDS
Head Header <>
Filename DB 126 DUP (0) ;Kommandozeile
FehlerMsg DB "Fehler!$"
FehlerMsg2 DB "Kein oder Falscher Parameter!$"
PaletteNeu DB PalLen DUP (?)
Segment2 DW ?
;**********************************ANFANG CODE **************************************************
.CODE
CutMem
Gettail Filename,NoTail
call InitData1
mov al,00h
mov ah,3Dh
mov dx,OFFSET Filename
int 21h ;Datei oeffnen
jc Fehler
mov bx,ax
mov ah,3Fh
mov cx,Headerlaenge
mov dx,OFFSET Head
int 21h ;Header einlesen
jc Fehler
AllocMem 0FFFh
mov [Segment2],ax ;Speicher res.
cmp Head.Typ,"MB" ;Bitmap?
jne Fehler
cmp Head.BiBitCount,08h ;8-Bit Farben?
jne Fehler
mov cx,word ptr [Head.SizeImage]
call InitFardata
mov ah,3Fh
mov dx,Seg2BildAnf
int 21h ;Bild rein!!
jc Fehler
mov ah,3Eh
int 21h ;Closefile
call InitData1
mov ah,00h
mov al,13h
int 10h ;VGA-Modus
call MakePalette ;Palette umwandeln
mov ax,0A000h
mov es,ax ;es auf Videospeicher
xor ax,ax ;x-Pos: 0
mov dx,[Head.Hoehe]
call CalcDi
mov si,Seg2BildAnf ;Zeigt auf Bildanfang. Pointer fuer Buffer!
mov cx,[Head.Hoehe]
mov ax,[Head.Breite]
push ax ;Anfang: Nullbyte(!) Korrektur
mov bl,4
div bl
xor bx,bx
cmp ah,00h ;Breite durch 4 teilbar?
je Weiter ;Ja: Nichts machen Nein: bx mit Korrekturwert für si laden
mov al,ah
xor ah,ah
mov bx,04h ;4 minus Rest=Nullbyte(s)
sub bx,ax ;bx=Korrekturwert
Weiter: pop ax
;Ende Nullbyte Korrektur
call InitFardata
mov [ds:Seg2BreiteFar],ax
Loopy: push cx ;Bild zeichnen am Bsp. Vollbild: bei x=0 und y=200 anfangen,
mov cx,word ptr [ds:Seg2BreiteFar] ;bis x=320 dann y=199 x=0 bis x=320, y=198 etc.
Loopx: mov al,byte ptr [si]
inc si
stosb
Loop Loopx
add si,bx ;+ Korrekturwert (d.h. entweder 0 oder 1)
mov ax,0
dec dx
call CalcDi
pop cx
Loop Loopy
jmp Ende
Fehler: mov ah,09h
call InitData1
lea dx,FehlerMsg
int 21h
jmp Ende
NoTail: call InitData1
mov ah,09h
lea dx,FehlerMsg2
int 21h
Ende: mov ah,07h ;Warten auf Tastendruck
int 21h
StVidMod 3h
mov es,[Segment2]
mov ah,49h
int 21h ;Speicher wieder freigeben
mov ah,4Ch
int 21h
;**********************************ANFANG PROZEDUREN ********************************************
MakePalette PROC NEAR ;Palette von WIN mach DOS
push bx
cld
push ds
pop es ;ES=DS
mov si,OFFSET Head.Palette
mov di,OFFSET PaletteNeu
mov cx,1024
DivLoop:
lodsb ;r
shr al,2 ;von 255-0 (WIN) nach 63-0 (DOS)
stosb
Loop DivLoop
mov si,OFFSET PaletteNeu
mov di,si
mov cx,256
BswapLoop:
lodsd
shl eax,8
bswap eax ;Umstellen
stosd
dec di ;nur 3 Bytes der 4 benötigt!
Loop BswapLoop
mov ah,10h
mov al,12h
mov bx,0
mov cx,256
mov dx,OFFSET PaletteNeu
int 10h ;Neue Palette nach DOS
pop bx
ret
MakePalette ENDP
InitData1 PROC NEAR
push ax
mov ax,@data
mov ds,ax
ASSUME DS:@data
pop ax
ret
InitData1 ENDP
InitFardata PROC NEAR
push ax
mov ax,[Segment2] ;DS auf Segment 2
mov ds,ax
pop ax
ret
InitFardata ENDP
END
¤ Dauer der Verarbeitung: 0.44 Sekunden
(vorverarbeitet)
¤
|
Haftungshinweis
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.
|