Level of Transparancy
BlitzMax Forums/BlitzMax Beginners Area/Level of Transparancy
| ||
.jpg has no transparancy .png has only 1-bit 9 (on / off) transparancy, right? but TARGA .tga has 255 levels of opacity / transparancy how can you control the level of tranparancy in an image? I mean can you import a .tga that has 127 as transparancy, since when saved as .png in paint shop pro and the like, its either on or off. nothing in the middle for shades etc? |
| ||
Wrong. PNG as TGA have both full 8 Bit Alpha. Main difference is that PNG has a working standard, TGA has too much optional stuff that tends to create problems. To control the Alpha of a given pixel, you will need an app that allows this. In GIMP / Photoshop etc you normaly can not draw alpha like a normal color. But you can set the alpha on the layer blending. The only thing needed to have alpha in the end picture is that the background layer had alpha as background color and not some other. But there are many tutorials on that for the different apps, how to use alpha on layers, alpha masks and the like :) But to get alpha in BM you need to set blend to AlphaBlend before. On / OFF alpha btw is called masking. This is controled through the masking color and MaskBlend. |
| ||
Erm... I think you're confusing alpha and masking. Try SetBlend ALPHABLEND, then SetAlpha 0.5 (any float between 0 and 1) before drawing images. In GIMP / Photoshop etc you normaly can not draw alpha like a normal color. You can edit the alpha layer directly in Photoshop. |
| ||
setblend maskblend and setalpha 1.0 are the "default" values, yes? (I mean for un-changed stuff) |
| ||
SetAlpha only works in ALPHABLEND mode. And yes, if you're using a MASKBLEND then obviously you won't be able to get soft transitions. |
| ||
but that wasn't my question ;-) Maskblend is the default unless you change that setting, right? and alpha of 1.0 is default too unless changed; that was all I needed clarified :-) |
| ||
I think in maskblend the default alpha is 0.5, not 1. ??? |
| ||
its 1.0 accoding to the tests I made ... |
| ||
Default maskblend is 1.0. Wheras with alphablend you can go like SetAlpha(0.25), and the image will be drawn at 0.25 opacity. |
| ||
This may help:images = LoadPixmapPNG("images.png") xsize = PixmapWidth(images) ysize = PixmapHeight(images) images_alpha = LoadPixmapPNG("images_alpha.png") new_images = CreatePixmap(xsize, ysize, PF_RGBA8888) For y = 0 Until ysize For x = 0 Until xsize WritePixel new_images, x, y, (ReadPixel(images, x, y) & $FFFFFF) | ((ReadPixel(images_alpha, x, y) & $FF) Shl 24) Next Next SavePixmapPNG new_images, "new_images.png", 9 DebugLog "Done!" |
| ||
Here is a program I wrote up demonstrating the various blend modes and alpha settings. It draws three overlapping circles, with the alpha channel decreasing from the center of the circle to the edge. |