This program write a PNG image of a black square (Test.png) and load it in a transparent sprite.
The resulting sprite is displayed using the bilinear filter provided from Purebasic and the square is rotated to show the antialiasing effect.
The problem is that the filter generate grey dots detached from the black square shape (you can stop the rotation pressing the key "2" to see it better) this dots aren't in the saved PNG file.
Code: Select all
InitSprite()
InitKeyboard()
UsePNGImageDecoder()
UsePNGImageEncoder()
flag.b = #True
flag_rot.b = #True
If (OpenScreen(640, 480, 32, "Test Bug", #PB_Screen_SmartSynchronization , 60))
SetFrameRate(60)
If (CreateSprite(2001, 256, 256,#PB_Sprite_AlphaBlending))
StartDrawing(SpriteOutput(2001))
DrawingMode(#PB_2DDrawing_AlphaBlend)
Box(2,2,254,254,RGBA(1,1,1,255))
StopDrawing()
SaveSprite(2001,"Test.png", #PB_ImagePlugin_PNG)
EndIf
SpriteQuality(#PB_Sprite_BilinearFiltering)
LoadSprite(2002,"Test.png")
rotation = 0
Repeat
ClearScreen(RGBA(255,255,255,255))
If flag_rot
rotation + 1
RotateSprite(2002, rotation, #PB_Absolute)
EndIf
StartDrawing(ScreenOutput())
If (flag)
DrawText(0,20,"SpriteQuality On (Press 1 to change)",RGB(0,0,0),RGB(255,255,255))
Else
DrawText(0,20,"SpriteQuality Off (Press 1 to change)",RGB(0,0,0),RGB(255,255,255))
EndIf
If (flag_rot)
DrawText(0,40,"Sprite rotation On (Press 2 to change)",RGB(0,0,0),RGB(255,255,255))
Else
DrawText(0,40,"Sprite Rotation Off (Press 2 to change)",RGB(0,0,0),RGB(255,255,255))
EndIf
StopDrawing()
DisplayTransparentSprite(2002,640 / 2 - SpriteWidth(2002) / 2,480 / 2 - SpriteHeight(2002) / 2,255)
FlipBuffers()
ExamineKeyboard()
If KeyboardReleased(#PB_Key_1)
If flag = #False
SpriteQuality(#PB_Sprite_BilinearFiltering)
flag = #True
Else
SpriteQuality(#PB_Sprite_NoFiltering)
flag = #False
EndIf
EndIf
If KeyboardReleased(#PB_Key_2)
If flag_rot = #False
flag_rot = #True
Else
flag_rot = #False
EndIf
EndIf
If KeyboardReleased(#PB_Key_Escape)
CloseScreen()
End
EndIf
ForEver
EndIf