Dark graphics.

BlitzMax Forums/BlitzMax Beginners Area/Dark graphics.

NickFalk(Posted 2007) [#1]
Things are generaly proceeding very nicely, although I'd prefer a more detailed documentation I seem to be able to progress nicely thus far. I do however have on odd problem. All the graphics I use becomes a lot darker when used in Blitzmax.

I've nicked a Gradius sprite and cleaned it up in Photoshop. When I run the program in either windowed or fullscreen mode the graphics are a lot duller than in Photoshop, or any other appllication for that matter. (I've looked at the graphics in both Preview and QT next to a windowed version of the Blitz-program).


NickFalk(Posted 2007) [#2]
This is what I'm talking about:



(If this works that is)


GfK(Posted 2007) [#3]
Looks like you're using alphablending and SetAlpha 0.2 or something.

I wouldn't use JPG format for sprites which need to be drawn with transparency. Compression artifacts will cause you all sorts of problems both with appearance, and collisions. Use PNG instead.


NickFalk(Posted 2007) [#4]
Thanks but I am using png24 actually - SetAlpha =1 but I believe you might be on to something. Anything above 0.5 gives the same result and anything from 0.5 and below returns a black screen.


JazzieB(Posted 2007) [#5]
SetColor could also have a similar affect - especially if you have something like SetColor 20,20,20 somwehere. SetColor tints any drawn images with the specified colour. Can be quite useful at times.

At the start of any rendering make sure you have SetAlpha 1 and SetColor 255,255,255.


ziggy(Posted 2007) [#6]
You need to set the blend mode to alphablend: if the PNGs have transparency. If not, I would recomend you to use maslbelnd.
To use alphablend:
SetBlend ALPHABLEND 


To use maskblend:
SetBlend MASKBLEND 



NickFalk(Posted 2007) [#7]
Thanks guys (and/or gals) setcolor was the ticket. I'm using setcolor to set colours for the stars in my paralax starfield, that's simply created through a "startype" that plots points in given colours.

Is there perhaps a more pratical way to do this in order to avoid having to call the setcolor for every sprite?


kronholm(Posted 2007) [#8]
"Anything above 0.5 gives the same result and anything from 0.5 and below returns a black screen."

You gotta feed setalpha a float variable if you haven't already, like

local myfloat# = 0.2
setalpha myfloat



NickFalk(Posted 2007) [#9]
Thanks but that seems to make excactly no difference (which kind of matches my limited understanding of the whole concept).

Also: I'm slightly confused about this ALPHABLEND ordeal, as the IDE doesn't seem to highlight the word, indicating that it's not a command but is treated like an empty variabel?

The code does actually work without both setalpha and setblend though, at least on my machine...?


JazzieB(Posted 2007) [#10]

Is there perhaps a more pratical way to do this in order to avoid having to call the setcolor for every sprite?


It's just a question of organising the order that you draw your sprites in so you don't need to call it for every sprite. For example, draw your starfield, then SetColor 255,255,255, then you can draw all other sprites with no worries (unless you actually want to tint some of them).

Also ALPHABLEND isn't highlighted because it's a pre-defined Constant. There's a lot of them, including ones for each key on your keyboard.


ImaginaryHuman(Posted 2007) [#11]
You only have to do 1 setcolor before you draw all sprites.


NickFalk(Posted 2007) [#12]
Thanks again, things are shaping up all thanks to you lot. :)


GfK(Posted 2007) [#13]
You only have to do 1 setcolor before you draw all sprites.
...unless you want to draw stuff in different colours...


ziggy(Posted 2007) [#14]
Alphablend and Maskbeldn are not commands, are consts defined in the Max2D modules. And they are not hilighted on the IDE becouse they're not commands, they're exactly like if they were fixed values. The real command is SetBlend, that tells BlitzMax how to 'draw' things (alphablend for bitmaps with transparency, and maskblend to treat the black color (or any other color defined) as the transparent color)