Dessiner pixel par pixel
Publié : sam. 29/sept./2007 17:56
Bonjour,
J'ai parcouru le petit tuto "l'adresse d'un pixel" ci contre
http://www.purebasic.fr/french/viewtopi ... highlight=
J'essaye depuis cet exemple d'incorporer l'instruction PokeL() plutôt que Plot() mais il y a quelque chose que je n'ai pas compris.
DrawingBufferPitch() (=4096) qui ne vaut pas "TAILLE_ECRAN_EN_X" (=800 dans mon exemple)
J'ai laissé les codes de control volontairement
En REM les PokeL() qui ont échoués. (note qu'ils affichent quand même quelquechose, qu'une mauvaise valeur résulte en un crash)
J'ai parcouru le petit tuto "l'adresse d'un pixel" ci contre
http://www.purebasic.fr/french/viewtopi ... highlight=
J'essaye depuis cet exemple d'incorporer l'instruction PokeL() plutôt que Plot() mais il y a quelque chose que je n'ai pas compris.
DrawingBufferPitch() (=4096) qui ne vaut pas "TAILLE_ECRAN_EN_X" (=800 dans mon exemple)
J'ai laissé les codes de control volontairement

Code : Tout sélectionner
InitSprite()
InitKeyboard()
OpenScreen(800,600,32,"keftales")
Repeat
StartDrawing (ScreenOutput ())
DB = DrawingBuffer()
DBP = DrawingBufferPixelFormat()
;DBP = 7 -> PF = 4
Select DBP
Case #PB_PixelFormat_8Bits : PF=1
Case #PB_PixelFormat_15Bits : PF=2
Case #PB_PixelFormat_16Bits : PF=2
Case #PB_PixelFormat_24Bits_RGB : PF=3
Case #PB_PixelFormat_24Bits_BGR : PF=3
Case #PB_PixelFormat_32Bits_RGB : PF=4
Case #PB_PixelFormat_32Bits_BGR : PF=4
EndSelect
t = t + 1
For y = 0 To 599
For x = 0 To 799
color = 155 + 100 * Sin(t + ( x*(x+t) + y*(y+t) ) / 100)
Plot (x,y,color)
;PokeL(DB + (X * PF) +DrawingBufferPitch() * ( Y * PF ) , Color )
;PokeL(DB + (X * PF) + TAILLE_ECRAN_EN_X * ( Y * PF ) , Color )
;PokeL(DB + (X * 4) + 800 * ( Y * 4 ) , Color )
;PokeL(DB + (X * 4) + 4096 * ( Y * 4 ) , Color )
Next x
Next y
DrawText(0,0,"DrawingBuffer() = DB:" + Str(DB))
DrawText(0,16,"DBP:" + Str(DBP))
DrawText(0,32,"PF:" + Str(PF))
DrawText(0,48,"DrawingBufferPitch():" + Str(DrawingBufferPitch()))
StopDrawing ()
FlipBuffers ()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)