semi transparent Image
Blitz3D Forums/Blitz3D Beginners Area/semi transparent Image
| ||
simple question: Is there a way in B3D to make an image semi transparent? It's for a Menu... Thanks, Floppyracer |
| ||
You cannot do that with images, but you could use 3D sprites instead. They allow for setting Alpha:Graphics3D 640, 480, 0, 2 sprite = LoadSprite("image.png") EntityAlpha sprite, 0.5 cam = CreateCamera() MoveEntity cam, 0, 0, -5 RenderWorld Flip WaitKey End If you want to combine 2D drawings and 3D rendering, use CameraClsMode to prevent RenderWorld from clearing the screen. |
| ||
Use Draw3D. It's really not that hard to integrate (and even if you don't speak German, this works pretty well for documentation once you run it through Google Translate). It offers replacements for all of the 2D commands - I recomend using all of them wherever you need 2D drawing and text, as 3D-accelerated drawing is much faster. |
| ||
You cannot do that with images, Actually, you can do that with images.(At least to an extent) Warners idea to use 2D sprites is probably the best option, but if you speckle an image with black(Pure black with RGB of 0,0,0) it will appear to be semi transparent. It won't give nearly as neat an effect as with just using entity alpha, but its always an option. WERDNA |
| ||
That is a nice idea, Werdna. Thinking about it, I also remembered a routine called DrawImageAlpha. A quick search gave me this: http://www.blitzbasic.com/codearcs/codearcs.php?code=343 I believe there are more functions like that, like one that loads that alpha channel from a separate image. Because the routines use WritePixel, depending on your hardware, they could be slow though. |
| ||
awesome, this helped a bunch! Thanks, Floppyracer :) |
| ||
I remember using the checkered image trick. It looks quite bad if you have two for these overlapping each other, but otherwise, looks decent :D |
| ||
lol, yeah. checkered images should be used, 'sparingly'. Alpha is probably the way to go instead. |
| ||
hey, I got another question, does anybody know what the argb value of readpixel/writepixel is based on? like what would red50,green100,blue200 with 50% transparency look like and why? thanks, floppyracer :) |
| ||
You can substract the pixels like this:col = ReadPixel(x, y) alpha = (col And $ff000000) red = (col And $ff0000) Shr 16 green = (col And $ff00) Shr 8 blue = (col And $ff) or this: blue = col mod 256 green = (col / 256) mod 256 red = (col / 65536) mod 256 The other way around would be something like this: col = alpha shl 24 + red shl 16 + green shl 8 + blue Or this: col = blue + green*256 + red*65536 |
| ||
coolieo, that helps a bunch, thanks for all your help guys, Floppyracer :) |
| ||
hey, new question, I'm making my own 3D imaging thingy for learning, and I was just wondering if there was a faster way to get the width and height of an image without using loadimage and imagewidth/imageheight. |
| ||
there probably is but reading all the different file headers isn't going to be fun... |
| ||
yea... looked into it myself, and figured that it'd just be plain easier with loadimage. For what I'm using it for it doesn't make much of a difference. |