Page 1 of 1
Add GrabSprite /SaveSprite Alpha Chanel Support
Posted: Wed Jul 29, 2009 4:56 pm
by thyphoon
Can you add Alpha Chanel support to GrabSprite and SaveSprite.
today If I load a Sprite with Alpha Chanel (with #PB_Sprite_AlphaBlending) and i use GrabSprite or SaveSprite, a lose the Alpha Chanel

Best regards
Posted: Thu Jul 30, 2009 1:21 pm
by Kaeru Gaman
it is not possible to support an Alpha-Channel with GabSprite, because the Background has none.
does re-saving of an RGBA-Sprite work?
Posted: Thu Jul 30, 2009 1:50 pm
by thyphoon
Kaeru Gaman wrote:it is not possible to support an Alpha-Channel with GabSprite, because the Background has none.
does re-saving of an RGBA-Sprite work?
No you lose the Alpha Channel !
I want to load a big PNG image with Alpha Channel and split it in many tiles (32x32) and save all tiles. But it's not possible with PB

Posted: Thu Jul 30, 2009 3:47 pm
by Kaeru Gaman
did you check just resaving it?
... and did you try using Images to split it into Tiles?
Posted: Thu Jul 30, 2009 5:09 pm
by thyphoon
Kaeru Gaman wrote:did you check just resaving it?
... and did you try using Images to split it into Tiles?
yes !!!
The image
The code to try
Code: Select all
If InitSprite() = 0
MessageRequester("Erreur", "Impossible d'ouvrir l'écran & l'environnement nécessaire aux sprites !", 0)
End
EndIf
If OpenWindow(0, 0, 0, 220, 160, "Un écran dans une fenêtre...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(0, 170, 135, 45, 20, "Quitter")
If OpenWindowedScreen(WindowID(0), 0, 0, 160, 160, 0, 0, 0)=0
MessageRequester("Erreur", "Impossible d'ouvrir un écran dans la fenêtre!", 0)
End
EndIf
EndIf
Global Nbsprite=0
UsePNGImageDecoder()
UsePNGImageEncoder()
Procedure LoadSpriteAlphaAuto(IdSprite.l,Filename.s,Option.l=0)
;Merci a Cpl.Bator,Case et Ollivier sans qui cette fonction n'existerait pas !
;http://www.purebasic.fr/french/viewtopic.php?t=9324
;On verifie si le sprite est un PNG si il y a une couche alpha
If LCase(GetExtensionPart(Filename.s))="png" And ReadFile(0,Filename.s)
FileSeek(0,25)
If ReadByte(0)=6
Option.l=Option | #PB_Sprite_AlphaBlending;Si c'est le cas alors on rajoute l'option qui va bien
EndIf
CloseFile(0)
EndIf
If LoadSprite(IdSprite,Filename,Option)
ProcedureReturn #True
Else
NbSprite-1
Debug "ERROR:"+Filename
ProcedureReturn #False
EndIf
EndProcedure
Debug LoadSpriteAlphaAuto(10,"house.png")
;Coordonée du sprite (on verra plus tard pour la boucle )
x=4
y=4
Debug GrabSprite(11,32*x,32*y,32,32)
de changer le numero de sprite dans savesprite
SaveSprite(10,"hometest.png",#PB_ImagePlugin_PNG)
SaveSprite(11,"home_"+Str(x)+"x"+Str(y)+".png",#PB_ImagePlugin_PNG)
Posted: Tue Aug 04, 2009 7:24 pm
by zxtunes.com
+1
Posted: Tue Aug 04, 2009 7:24 pm
by zxtunes.com
+1