Bilder halbtransparent zeichnen(mit Blitz2D) von ???
Hier mal ein paar Möglichkeiten um ein Bild halbtransparent einzuzeichnen(einfach ein bisschen mit Timer & VWait rumspielen um Unterschiede besser zu erkennen):

[code:1:9a7e862c87]
;by Robert Hierl(BIG BUG) 25.06.2003

;Images halbtransparent zeichnen mit Blitz2D
;1. Read-/Writepixelmethode(Debugging ausschalten!)
; Pixel werden einzeln eingelesen und der Durchschnitt berechnet
; -gute Bildqualitaet
; -von Synchronisation unabhängig
; -langsam
; -kein Clipping
;2. Rastermethode
; Es wird nur jedes 2. Pixel eingezeichnet
; -schlechte Bildqualitaet
; -schnell
; -von Synchronisation unabhängig
; -relativ hohe Aufloesung benoetigt
;3. An-/Ausmethode
; Das gesamte Bild wird nur jede 2. Frame eingezeichnet
; -mittlere Bildqualitaet, aber nur bei exakter Synchronisation mit Monitor(V-Sync)
; Hier besser "VWait" mit "Flip 0" verwenden um V-Sync zu erzwingen
; -schnell
; -relativ hohe Framerate benoetigt
; -kein Waittimer moeglich
;4. Kombimethode
; Raster- mit An-/Ausmethode kombiniert
; -mittlere Bildqualitaet, V-Sync zwar empfehlenswert, aber nicht so anfaellig gegen
; ungenaue Synchronisation wie An-/Ausmethode, so dass auch Waittimer moeglich ist
; -schnell
; -relativ hohe Framerate benoetigt

Graphics 800, 600, 16, 1
SetBuffer BackBuffer()

img_bg = LoadImage("Back.jpg")
img_sp = LoadImage("Sprite.png")

bk_sprite = CreateImageBank(img_sp)

img_grid1 = CreateGridImage(img_sp)
img_grid2 = CreateGridImage(img_sp,1)

timer = CreateTimer(60)

Repeat

If h_switch Then
h_switch = 0
Else
h_switch = 1
EndIf

TileBlock img_bg


; 1.Echte Halbtransparenz(evtl. Auskommentieren wenn zu langsam)
DrawTranspImage(bk_sprite, 130, 60)

; 2.Fake mit Rastermethode
DrawImage(img_grid1, 210, 60)

; 3.Fake durch Zeichnen nur bei jeder 2. Frame
If h_switch Then DrawImage(img_sp, 130, 130)

; 4.Beide Fake-Methoden gemischt
If h_switch Then
DrawImage(img_grid1, 210, 130)
Else
DrawImage(img_grid2, 210, 130)
EndIf


; FPS ermitteln
fps_fpscnt% = fps_fpscnt% + 1
fps_new_sec% = MilliSecs()
If (fps_new_sec% => fps_old_sec% + 1000)
fps_fps% = fps_fpscnt%
fps_fpscnt% = 0
fps_old_sec% = fps_new_sec%
EndIf
Text 0,0, fps_fps%

Text 120, 60, "1."
Text 200, 60, "2."
Text 120, 130, "3."
Text 200, 130, "4."

WaitTimer timer

; VWait()
Flip 0

Until KeyHit(1)

;-----Ende Hauptprogramm


;Erstellt ein neues Rasterbild aus bestehendem Image
Function CreateGridImage(image, start=0, maskcolor=$000000)

Local grid
Local hx
Local hy

grid = CopyImage(image)
For hy = 0 To ImageHeight(grid) - 1
For hx = 0 To ImageWidth(grid) - 1
If (start + hx + hy) Mod 2 Then WritePixel hx, hy, maskcolor, ImageBuffer(grid)
Next
Next
Return grid

End Function



;Speichert ein Bild in einer Bank
Function CreateImageBank(image)

Local bank
Local offset
Local hx
Local hy

bank = CreateBank(ImageWidth(image) * ImageHeight(image) * 4 + 4)

; Bildinformationen
PokeShort bank, 0, ImageWidth(image)
PokeShort bank, 2, ImageHeight(image)

; Bilddaten
offset = 4
For hy = 0 To ImageHeight(image) - 1
For hx = 0 To ImageWidth(image) - 1
PokeInt bank, offset, ReadPixel(hx, hy, ImageBuffer(image)) And $FFFFFF
offset = offset + 4
Next
Next
Return bank

End Function


;Zeichnet eine Imagebank halbtransparent(ohne Clipping)
Function DrawTranspBlock(imagebank, x, y)

Local hx
Local hy
Local bx
Local by
Local offset


LockBuffer

by = y
offset = 4
For hy = 0 To PeekShort(imagebank, 2) - 1
bx = x
For hx = 0 To PeekShort(imagebank, 0) - 1
pixel = PeekInt(imagebank, offset)
pixel = (pixel And $FEFEFE) Shr 1 + (ReadPixelFast(bx, by) And $FEFEFE) Shr 1
WritePixelFast bx, by, pixel
bx = bx + 1
offset = offset + 4
Next
by = by + 1
Next

UnlockBuffer

End Function


;Zeichnet eine Imagebank halbtransparent(ohne Clipping mit Maskcolor)
Function DrawTranspImage(imagebank, x, y, maskcolor=$000000)

Local hx
Local hy
Local bx
Local by
Local offset


LockBuffer

by = y
offset = 4
For hy = 0 To PeekShort(imagebank, 2) - 1
bx = x
For hx = 0 To PeekShort(imagebank, 0) - 1
pixel = PeekInt(imagebank, offset)
If pixel <> maskcolor Then
pixel = (pixel And $FEFEFE) Shr 1 + (ReadPixelFast(bx, by) And $FEFEFE) Shr 1
WritePixelFast bx, by, pixel
EndIf
bx = bx + 1
offset = offset + 4
Next
by = by + 1
Next

UnlockBuffer

End Function

[/code:1:9a7e862c87]

hier noch Beispielbilder
[url]http://www.mein-murks.de/grafik/back.jpg[/url]
[url]http://www.mein-murks.de/grafik/sprite.png[/url]



Suche:
(unterstützt mySQL Wildcards ala %)
Titel:
Text:
Autor: