Darkness Surrounds Me

BlitzMax Forums/BlitzMax Programming/Darkness Surrounds Me

dw817(Posted 2016) [#1]
Can someone please explain to me why these pixels are darkening when copied from the screen ?

Strict

Local pic:TPixmap,r,g,b

SetGraphicsDriver GLMax2DDriver(),0 ' zero forces front buffer
Graphics 800,600
SetBlend alphablend

Repeat
  r=Rand(128,255)
  g=Rand(128,255)
  b=Rand(128,255)
  SetAlpha .5
  SetColor r,g,b
  DrawOval Rand(800),Rand(600),Rand(64,256),Rand(64,256)
  SetAlpha 1
  pic=GrabPixmap(0,0,800,600)
  Cls
  DrawImage LoadImage(Pic),0,0
  WaitKey
  Flip 0
Until KeyDown(27)


Actually, after I just posted it. I found the problem. So I guess it is now a challenge, can YOU see what's causing it ?


xlsior(Posted 2016) [#2]
SetAlpha 0.5 instead of SetAlpha 1?


dw817(Posted 2016) [#3]
Nope. That's not the right answer. You can change the code too to see it still darkens the circles.


Derron(Posted 2016) [#4]
Without testing:

You do use "setcolor" without resetting back to white...so the grabbed image is tinted with the currently set color.


Bye
Ron


TomToad(Posted 2016) [#5]
On top of that, you don't clear the screen after drawing the grabbed image, so the next random colored oval will be blended with the previous oval.


Derron(Posted 2016) [#6]
@ Tom

I believe this is desired behaviour.

Bye
Ron


dw817(Posted 2016) [#7]
Derron, you got it ! I was not resetting my color back to WHITE. Here is completed correct code:



Run without debug for best speed. ;)

I do have another question. Is it possible to plot directly to a TPIXMAP() bypassing TIMAGE ?

That is, LINE, DRAWOVAL(), DRAWRECT(), DRAWIMAGE() ?


Derron(Posted 2016) [#8]
Nope, you need to do software rendering then.

DrawImage()
https://github.com/GWRon/Dig/blob/master/base.gfx.imagehelper.bmx "DrawImageOnImage()"

DrawOval()
http://stackoverflow.com/questions/10322341/simple-algorithm-for-drawing-filled-ellipse-in-c-c

DrawRect
You should be able to do this on your own ;-)

Line
via Bresenham algorithm
http://www.blitzbasic.com/Community/posts.php?topic=51143

bye
Ron


dw817(Posted 2016) [#9]
That's too bad. But, those are some great routines you posted, Derron. *BOOKMARKING* Thanks a lot guys !

Dju ever check out my fireball routine ? It's so innovative in its design, I figured someone would say something about it. :)

http://www.blitzbasic.com/Community/posts.php?topic=107050


Derron(Posted 2016) [#10]
I am sure you are able to update your fireball now with the code posted.

PS: I did not check that out - the code is surely something nifty, but for me not that "readable" as I like them to be - so I skipped that (and surely other cool stuff posted here and there).


bye
Ron


dw817(Posted 2016) [#11]
Yep, fireball is working great. Really do appreciate your help here. Have a great Halloween too !