Page 1 of 1
Help CatchSprite
Posted: Fri Mar 12, 2010 12:08 pm
by qqqnnn
Code: Select all
ReadFile(0, "c:/0.jpg")
size=Lof(0)
*buffer=AllocateMemory(size)
*target=AllocateMemory(size)
ReadData(0, *buffer, size)
CloseFile(0)
For c=0 To size-1
pos=*buffer+c
pos2=*target+c
t=PeekB(pos)
q = t + 13
If q > 255
q = q - 256
EndIf
PokeB(pos2, q)
Next c
If CreateFile (1,"c:/0.dat")
WriteData(1, *target, size)
CloseFile(1)
EndIf
ReadFile(0, "c:/0.dat")
size=Lof(0)
*buffer2=AllocateMemory(size)
*target2=AllocateMemory(size)
ReadData(0, *buffer2, size)
CloseFile(0)
Debug size
For c=0 To size-1
pos=*buffer2+c
pos2=*target2+c
t=PeekB(pos)
q = t - 13
If q < 0
q = q + 256
EndIf
PokeB(pos2, q)
Next
If OpenWindow(0, 0, 0, 320, 200, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
InitSprite()
OpenWindowedScreen(WindowID(0), 0, 0, 320, 200, #False, 0, 0)
CatchSprite(0,*buffer2)
DisplaySprite(0, 0, 0)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
EndIf
Why is there an error? Help me
Re: Help CatchSprite
Posted: Fri Mar 12, 2010 12:29 pm
by netmaestro
You'll need UseJPEGImageDecoder().
Re: Help CatchSprite
Posted: Fri Mar 12, 2010 12:50 pm
by qqqnnn
Added
Code: Select all
UseJPEGImageDecoder()
UseJPEGImageEncoder()
Not OK
Re: Help CatchSprite
Posted: Fri Mar 12, 2010 1:24 pm
by Kaeru Gaman
1st build a correct GameLoop. you left out the FlipBuffers.
Code: Select all
Repeat
Repeat
Event = WaitWindowEvent(10)
If Event = #PB_Event_CloseWindow
EXIT = 1
EndIf
Until Event = #Null Or EXIT
ClearScreen( $000000 )
DisplaySprite(0, 0, 0)
FlipBuffers()
Until EXIT
2nd devide the probings.
first test your file encoding with an own binary file and compare byte by byte, this helps improving the calculations first.
then test it with a bitmap sprite, not JPG.
a tip:
you can use .a variables and PeekA/PokeA
you'll not need some <0 or >255 test then.
and better use PNG instead of JPG, JPG looks shitty if you don't switch color-subsampling off.
Re: Help CatchSprite
Posted: Fri Mar 12, 2010 4:39 pm
by Rook Zimbabwe
As a purist I just use BMP files with RGB(0,0,0) = BLACK for transparent and rgb(0,0,1) for black...
Than gain I just use LoadSprite() as welll
Easier cause I am lazy!