Plot mit Alpha-Kanal
Verfasst: 06.01.2007 16:23
Ich bin mir nicht sicher, wie sicher das ist, aber es läuft. Jemand der mehr
weiss, oder mehr Zeit hat alles nachzulesen, kann es gerne erweitern.
Wieso unterstützt Fred eigentlich DrawingBuffer() nicht auch für Images?
Bitte noch nicht in Projekten nutzen!
weiss, oder mehr Zeit hat alles nachzulesen, kann es gerne erweitern.
Wieso unterstützt Fred eigentlich DrawingBuffer() nicht auch für Images?
Code: Alles auswählen
Procedure StartBuffered(img)
Shared _buf.l, _line.l
Protected dib.DIBSECTION
getobject_(ImageID(img), SizeOf(DIBSECTION), @dib)
_buf = dib\dsBm\bmBits
_line = dib\dsBm\bmWidthBytes
ProcedureReturn _buf
EndProcedure
Procedure BPoint(x, y)
Shared _buf.l, _line.l
ProcedureReturn PeekL(_buf + y * _line + x * 4)
ProcedureReturn 0
EndProcedure
Procedure BPlot(x, y, Col.l)
Shared _buf.l, _line.l
ProcedureReturn PokeL(_buf + y * _line + x * 4, Col)
ProcedureReturn 0
EndProcedure
If OpenWindow(0, 100, 100, 500, 300, "PureBasic - Image")
CreateImage(0, 500, 300, 32)
img = CreateImage(#PB_Any, 500, 300, 32) ; ,32) ist wichtig!
StartBuffered(img)
For x = 0 To 499
For y = 0 To 299
BPlot(x, y, RGB(0, 0, 255) | (Int(x / 499.0 * $FF) << 24))
Next
Next
StartDrawing(ImageOutput(0))
Box(300, 0, 200, 100, $FF)
Box(150, 100, 100, 100, $FF00)
Box(200, 200, 120, 100, $FF0000)
DrawAlphaImage(ImageID(img), 0, 0)
StopDrawing()
CreateGadgetList(WindowID(0))
ImageGadget(0, 0, 0, 500, 300, ImageID(0))
Repeat
EventID = WaitWindowEvent()
Until EventID = #PB_Event_CloseWindow ; If the user has pressed on the close button
EndIf
End ; All the opened windows are closed automatically by PureBasic