der eine, oder andere wird vielleicht wissen, dass ich gerade an der Übersetzung des Codearchives nach PB4 arbeite.
Jetzt hab ich mit dem oben genannten Beispiel ein Problem:
Warum is DrawingBufferPitch() bei einem 8 Bit Bitmap größer als SpriteWidth() des selben??
Hier das erweiterte Beispiel:
Code: Alles auswählen
; German forum:
; Author: Danilo
; Date: 28. May 2003
; Manipulate 8-Bit (!) Sprites directly in memory
; here the color will be changed pixel by pixel
;Changes for PB4-Version (by blbltheworm):
;I put the original source by Danielo in a Procedure and wrote a little example
Procedure ChangeColor(Sprite.l, oldColor.w,newColor.w)
  StartDrawing(SpriteOutput(Sprite)) 
  *MemoryAddress.BYTE = DrawingBuffer() 
  Debug DrawingBufferPitch()
  Debug SpriteWidth(0)
  memSize.l=DrawingBufferPitch()*SpriteHeight(Sprite)-1 ;<-So tuts
  ;memSize.l=SpriteWidth(0)*SpriteHeight(Sprite)-1 ;<-Das tut nicht (wird nicht das ganze bild bearbeitet
  For i = 0 To memSize
    If *MemoryAddress\b = oldColor
      *MemoryAddress\b = newColor
    EndIf 
    *MemoryAddress + 1 
  Next i 
  LineXY(0,474,SpriteWidth(0),474,61) ;<- hier hört die Farbumwandlung mit SpriteWidth(0) auf
  StopDrawing() 
EndProcedure
InitSprite()
InitScreen()
InitPalette()
InitKeyboard()
OpenScreen(800,600,8,"Sprite change Color")
LoadSprite(0,"..\Gfx\Game.bmp",0)    ;8-Bit!!
LoadPalette(0,"..\Gfx\Game.bmp")
DisplayPalette(0)
Repeat
  StartDrawing(ScreenOutput())
    Box(0,0,800,600,61) ;61=black
    DrawText(0,0,"Press [SPACE] to change Color")
  StopDrawing()
    
  DisplaySprite(0,(800-SpriteWidth(0))/2, (600-SpriteHeight(0))/2)  
  FlipBuffers()
  
  Delay(1)
  
  ExamineKeyboard()
  If KeyboardPushed(#PB_Key_Escape) : End : EndIf
Until KeyboardPushed(#PB_Key_Space)
ChangeColor(0,63,0)
Repeat
  StartDrawing(ScreenOutput())
    Box(0,0,800,600,61)
    DrawText(0,0,"Color changed")
  StopDrawing()
  
  DisplaySprite(0,(800-SpriteWidth(0))/2, (600-SpriteHeight(0))/2)
  FlipBuffers()
  
  Delay(1)
  
  ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)



