Deutsch
Quelltexte/ Codesnippets

Bmp Datei Farbtiefe Laden

 

Andreas
Gaida
Hi!
Hier ein kleines Beispiel wie man eine BMP Datei mit 24Bit und 8Bit Farbtiefe(unkomprimiert)
selber Ladet und Anzeigt ohne die Profan eigenen BMP Routinen.
KompilierenMarkierenSeparieren
Declare datei_load$,bits_per_pixel&,pixels_width&,pixels_height&,compresion_image&,offset_image&,pixels_width_rest&
Declare Temp1&,Temp2&,color_bmp&[257,4],temp_R&,temp_G&,temp_B&
cls
datei_load$ = LoadFile$(ÖFFNE,BMP|*.bmp;*.bmp|Batch|*.bmp)
sleep 50
cls
Assign #1, datei_load$
OpenRW #1
print @GetChar$(#1,2)               2   BM ID
print @GetLong(#1)                  6   Länge
print @GetWord(#1)                  8   0
print @GetWord(#1)                  10  0
offset_image& = @GetLong(#1)        14  Offset off Data
print offset_image&
print @GetLong(#1)                  18    Grösse des Headers
pixels_width&  = @GetLong(#1)       22  bitmap width in pixels
print pixels_width&
pixels_height& = @GetLong(#1)       26  bitmap height in pixels
print pixels_height&
print @GetWord(#1)                  28  number of color planes being used
bits_per_pixel& = @GetWord(#1)      30  number of bits per pixel
print Bit p Pixel : ;bits_per_pixel&
compresion_image& = @GetLong(#1)    34  compression method being used
print compresion_image&                 0 BI_RGB none Most common
print @GetLong(#1)                  38  This is the size of the raw bitmap data
print @GetLong(#1)                  42  horizontal resolution of the image. (pixel per meter)
print @GetLong(#1)                  46  vertical resolution of the image. (pixel per meter)
print @GetLong(#1)                  50  number of colors used
print @GetLong(#1)                  54  number of important colors used

if (@Int((pixels_width&/4))-(pixels_width&/4)) <> 0

    pixels_width_rest& = ((@Int(pixels_width&/4)+1)*4) - pixels_width&

endif

if      (bits_per_pixel& = 24) and (compresion_image& = 0) and (offset_image& = 54)

    WhileLoop pixels_height&

        Temp1& = &loop

        WhileLoop pixels_width&

            temp_R& = @GetByte(#1)
            temp_G& = @GetByte(#1)
            temp_B& = @GetByte(#1)
            SetPixel &loop,((pixels_height&+1) - Temp1&),@RGB(temp_B&,temp_G&,temp_R&)
            SetPixel &loop,((pixels_height&+1) - Temp1&),@RGB(@GetByte(#1),@GetByte(#1),@GetByte(#1))

        EndWhile

        if       pixels_width_rest& = 1

            @GetByte(#1)
            @GetByte(#1)
            @GetByte(#1)

        elseif   pixels_width_rest& = 2

            @GetByte(#1)
            @GetByte(#1)

        elseif   pixels_width_rest& = 3

            @GetByte(#1)

        Endif

    EndWhile

elseif (bits_per_pixel& = 8) and (compresion_image& = 0) and (offset_image& = 54)

    WhileLoop 256

        color_bmp&[&loop,3] = @GetByte(#1)@Ord(GetChar$(#1,1))
        color_bmp&[&loop,2] = @GetByte(#1)@Ord(GetChar$(#1,1))
        color_bmp&[&loop,1] = @GetByte(#1)@Ord(GetChar$(#1,1))
        color_bmp&[&loop,4] = @GetByte(#1)@Ord(GetChar$(#1,1))

    EndWhile

    WhileLoop pixels_height&

        Temp1& = &loop

        WhileLoop pixels_width&

            Temp2& = (@GetByte(#1)+1)(@Ord(GetChar$(#1,1)) +1)
            SetPixel &loop,(pixels_height&+1) - Temp1&,@RGB(color_bmp&[Temp2&,1],color_bmp&[Temp2&,2],color_bmp&[Temp2&,3])

        EndWhile

        if       pixels_width_rest& = 1

            @GetByte(#1)

        elseif   pixels_width_rest& = 2

            @GetByte(#1)
            @GetByte(#1)

        elseif   pixels_width_rest& = 3

            @GetByte(#1)
            @GetByte(#1)
            @GetByte(#1)

        Endif

    EndWhile

else

    Print Das Bild ist in einen nicht unterstützten Format

Endif

Close #1
waitinput
 
Athlon X2 4800 , 2GB Ram , GeForce 7800GT
Windows XP Pro , XProfan 10 und 11 , Profan2Cpp 1.6b
14.08.2007  
 



Der Code ist sehr optimier- und beschleunigbar, aber er scheint funktionieren und zeigt sehr schön wie einfach BMP aufgebaut sein kann. Bist am OGL-Rumprobieren für BUMP- und AlphaChannel was? Magst etwa mein .tex-Format nicht?
 
14.08.2007  
 




Andreas
Gaida
Um ehrlich zu sein kamm ich noch nicht dazu Deine Quellcodes mir richtig anzusehen. Da sie auch etwas umfamgreicher sind und ich mich mommentan schon seit mehreren Tagen auf Nachschicht rumtreibe habe ich mir erstmal etwas leichtere Kost vorgenommen . Dein .tex Format ist schon o.k , für Spiele Programmierung sowieso damit nicht jeder einen ohne probleme die
Texturen verändern kann .

MfG
Andreas
 
Athlon X2 4800 , 2GB Ram , GeForce 7800GT
Windows XP Pro , XProfan 10 und 11 , Profan2Cpp 1.6b
15.08.2007  
 



Zum Quelltext


Thementitel, max. 100 Zeichen.
 

Systemprofile:

Kein Systemprofil angelegt. [anlegen]

XProfan:

 Beitrag  Schrift  Smilies  ▼ 

Bitte anmelden um einen Beitrag zu verfassen.
 

Themenoptionen

4.150 Betrachtungen

Unbenanntvor 0 min.
Sven Bader23.10.2021
Uwe ''Pascal'' Niemeier01.04.2014

Themeninformationen

Dieses Thema hat 2 Teilnehmer:

Andreas Gaida (2x)
iF (1x)


Admins  |  AGB  |  Anwendungen  |  Autoren  |  Chat  |  Datenschutz  |  Download  |  Eingangshalle  |  Hilfe  |  Händlerportal  |  Impressum  |  Mart  |  Schnittstellen  |  SDK  |  Services  |  Spiele  |  Suche  |  Support

Ein Projekt aller XProfaner, die es gibt!


Mein XProfan
Private Nachrichten
Eigenes Ablageforum
Themen-Merkliste
Eigene Beiträge
Eigene Themen
Zwischenablage
Abmelden
 Deutsch English Français Español Italia
Übersetzungen

Datenschutz


Wir verwenden Cookies nur als Session-Cookies wegen der technischen Notwendigkeit und bei uns gibt es keine Cookies von Drittanbietern.

Wenn du hier auf unsere Webseite klickst oder navigierst, stimmst du unserer Erfassung von Informationen in unseren Cookies auf XProfan.Net zu.

Weitere Informationen zu unseren Cookies und dazu, wie du die Kontrolle darüber behältst, findest du in unserer nachfolgenden Datenschutzerklärung.


einverstandenDatenschutzerklärung
Ich möchte keinen Cookie