GLBasic forum

Main forum => GLBasic - en => Topic started by: msx on 2010-Dec-31

Title: Problems with transparency
Post by: msx on 2010-Dec-31
When I add a background image with LOADBMP Command the black area of the Sprites are displayed transparents (I use the DRAWSPRITE Command). Does anyone know what happens?.  :doubt:
Title: Re: Problems with transparency
Post by: Ian Price on 2010-Dec-31
Check that your bitmap is in 24 Bit format or created in an image editor that doesn't use the proper image foramt standard. There were issues a long while back with 32Bit colour (I thought this was sorted, but it might still be a problem).

If in doubt, post a single image here and we'll have a look at it.
Title: Re: Problems with transparency
Post by: msx on 2010-Dec-31
sprites and background are 24-bit BMP format . This problem occurs only in IPhone, it works correctly in windows.
Title: Re: Problems with transparency
Post by: Ian Price on 2011-Jan-01
Post the image (or something made in the same art package that does the same) so that we can see the problem directly - without seeing for ourselves it's just guesswork.
Title: Re: Problems with transparency
Post by: msx on 2011-Jan-01
It will be difficult  because as I said  only happens in the  iPhone, and capture an image showing clearly the fault is complicated.
Title: Re: Problems with transparency
Post by: Ian Price on 2011-Jan-01
I meant post the actual image (or a derivitive) so that we can test on OUR iPhones.

If you post the image we can see if it is an image fault, a GLBasic bug or a problem with your code.


Help us to help you.
Title: Re: Problems with transparency
Post by: msx on 2011-Jan-01
You can to check this code on an iPhone. I attached examples BMP files.

Code (glbasic) Select
   
LOADSPRITE "sprite.bmp",0
DRAWRECT 0,0,32,32, RGB(255,0,128)
DRAWSPRITE 0,0,0
GRABSPRITE 1,0,0,32,32

LOADBMP "background.bmp"
DRAWSPRITE 1,100,100


[attachment deleted by admin]
Title: Re: Problems with transparency
Post by: Kitty Hello on 2011-Jan-01
oh. Try DRAWRECT 0,0,1000,1000,0 before you draw the background image.

instead of grabsprite I'd do that with createscreen and drawsprite on that screen then.
Title: Re: Problems with transparency
Post by: msx on 2011-Jan-01
There is a sample game with the CREATESCREEN Command? I need to see some code.

Thank you.
Title: Re: Problems with transparency
Post by: msx on 2011-Jan-01
Quote from: Kitty Hello on 2011-Jan-01
oh. Try DRAWRECT 0,0,1000,1000,0 before you draw the background image.

Not work  :'(
Title: Re: Problems with transparency
Post by: msx on 2011-Jan-02
I add an  example, only you have to  compile for iphone. Note that the sprite containing  the black.

[attachment deleted by admin]
Title: Re: Problems with transparency
Post by: Kitty Hello on 2011-Jan-05
I have no idea why it doesn't work. But that might work:

Code (glbasic) Select


SETCURRENTDIR("Media") // seperate media and binaries?

LOADSPRITE "sprite.bmp",0

CREATESCREEN 7, 1, 32, 32
USESCREEN 7
// DRAWRECT 0,0,32,32, RGB(255,0,128)
DRAWSPRITE 0, 0,0
USESCREEN -1


//DRAWRECT 0,0,32,32, RGB(255,0,128)
//DRAWSPRITE 0,0,0
//GRABSPRITE 1,0,0,32,32

LOADBMP "background.bmp"
DRAWSPRITE 1,100,100
SHOWSCREEN
MOUSEWAIT

Title: Re: Problems with transparency
Post by: ampos on 2011-Jan-05
Quote from: Ocean on 2011-Jan-02
Show us your code that doesn't work - you might get help faster that way.

Instead of BMPs, use PNGs. And if the "pink" background still do not work, cut the image in PSD as a layer, remove background and save as PNG. THEY WORK, I can promise it to you.
Title: Re: Problems with transparency
Post by: msx on 2011-Jan-05
Thanks, I've finally replaced the  RGB (0,0,0) for RGB  (1,1,1) in the sprites, so  it already works well.

The problem is that I do not know how to use CREATESCREEN to generate motion with several sprites.

As always, I hope you excuse my English
Title: Re: Problems with transparency
Post by: msx on 2011-Jan-05
Quote from: ampos on 2011-Jan-05
Quote from: Ocean on 2011-Jan-02
Show us your code that doesn't work - you might get help faster that way.

Instead of BMPs, use PNGs. And if the "pink" background still do not work, cut the image in PSD as a layer, remove background and save as PNG. THEY WORK, I can promise it to you.

ampos el problema es que el negro me lo convierte en trasparente, ya he probado con PNG y BMP de varios formatos y nada. El rosa funciona como debiera.
Title: Re: Problems with transparency
Post by: ampos on 2011-Jan-05
Pos no me lo explico, en mi juego tengo negros a mogollón y no son transparentes.

Yo uso siempre PNGs, grabados como "fondo" si no necesitan transparencias y como "capa" si la necesitan, y te puedo asegurar que se ven bien en el iphone.

Añade un alphamode 0 o un alphamode -1 delante del drawsprite a ver si es algo que se te está colando...

Te adjunto un png que me funciona perfectamente. Si siques con problemas, hazmelo saber.
Title: Re: Problems with transparency
Post by: msx on 2011-Jan-05
¿Pero has probado GRABSPRITE con ese ejemplo? Me da que el problema lo tiene ese comando. Es que con CREATESCREEN no se como generar movimiento intercambiando Sprites, ¿tienes por casualidad algún ejemplo? es que no encuentro ná por ningún lao.

P.D.: Espero que no se ofendan por escribir en Español en un foro inglés pero es que me cuesta menos expresarme.  :glare:
Title: Re: Problems with transparency
Post by: Ian Price on 2011-Jan-05
Is there a reason you have to create the images at runtime and not use pre-rendered sprites?
Title: Re: Problems with transparency
Post by: msx on 2011-Jan-05
Yes, I have not had time to study all the  commands still.  :-[
Title: Re: Problems with transparency
Post by: ampos on 2011-Jan-05
La verdad es que no sé cual es tu problema...

¿Qué es lo que quieres hacer EXACTAMENTE, y porqué es necesario usar GRABSPRITE?

Para hacer animaciones se usa DRAWANIM. Se me ocurren muy pocas (por no decir ninguna) situaciones donde sea necesario usar el grabsprite...
Title: Re: Problems with transparency
Post by: msx on 2011-Jan-06
El problema es que muchos comandos (entre ellos DRAWANIM) en el manual online están incompletos, faltan los archivos BMP y entonces no puedo conocer el comportamiento de dichos comandos. Ví un ejemplo de un juego realizado con GRABSPRITE y así lo estoy haciendo yo, pero ya te digo que más bien es por desconocimiento.  :S
Title: Re: Problems with transparency
Post by: ampos on 2011-Jan-06
Drawankm es muy fácil. Un sprite de 32x32. Si quieres que tenga 10 frames de animación haz un lienzo de 320x32 en Photoshop. Dibuja cada frame en un cada pedazo de 32x32.

Luego carga como loadanim "nombre",id,32,32

Para dibujarlo usa Drawanim id,frame,x,y

Es muy sencillo.

Si no lo pillas te subo luego un png kestoy con el móvil.
Title: Re: Problems with transparency
Post by: msx on 2011-Jan-06
Quote from: Ocean on 2011-Jan-06
Quote from: msx on 2011-Jan-05
Yes, I have not had time to study all the  commands still.  :-[

in that case, perhaps a thread title like 'Questions about...' would have been more appropriate than 'Problems with...'  ?     =D

in fact, is a behavior problem of the iPhone  that uses black as transparent. I think it  ;/

QuoteDrawankm es muy fácil. Un sprite de 32x32. Si quieres que tenga 10 frames de animación haz un lienzo de 320x32 en Photoshop. Dibuja cada frame en un cada pedazo de 32x32.

Luego carga como loadanim "nombre",id,32,32

Para dibujarlo usa Drawanim id,frame,x,y

Es muy sencillo.

Vaya, demasiado tarde, eso mismo lo hago yo con GRABSPRITE que es mucho más complicado, es lo que tiene la ignorancia.

Gracias ampos, lo he entendido a la perfección, es que no acababa de entenderlo antes porque no sabía como montar el BMP. En fín, supongo que ya para el próximo proyecto, a éste le queda poco
Title: Re: Problems with transparency
Post by: ampos on 2011-Jan-06
Pos te recomendaría ke lo cambiases.
Title: Re: Problems with transparency
Post by: msx on 2011-Jan-06
¿Por algo en especial?
Title: Re: Problems with transparency
Post by: ampos on 2011-Jan-07
Performance. Y ganas de complicarse la vida...