my WritePixel has no effect?

BlitzMax Forums/BlitzMax Programming/my WritePixel has no effect?

Drakim(Posted 2008) [#1]
After using impixi's Pixmap Blur for a while, I decide to create my own bloom code based on his code, seeing it would be about half the same.

A short note for those who doesn't know how to bloom. You take a picture, remove all non-bright areas, blur those remaining bright areas, and reapply that on top of the old picture.
Here is a good explanation with good pictures!

Long story short, I'm stuck on something simple. I've written a code that is supposed to detect all non bright pixels and delete them, leaving only the bright area which I am to blur later.

However, when I use WritePixel to make a pixel diffrent, there is simply no effect. I have no idea what I wrong.

Function bloomPixmap(pm:TPixmap)
	pm = ConvertPixmap(pm, PF_RGBA8888)

	For Local x:Int = 0 To (pm.Width-1)
    	For Local z:Int = 0 To (pm.Height-1)
            If ReadPixel(pm, x, z) <> -1 Then
              WritePixel(pm,x,z,-16777216)
            End If
    	Next
    Next
End Function


it's pretty simple. Loop though all the pixels in the pixmap, and if they are anything other than -1 in color value, then write their value to -16777216.

I've tested printing ReadPixel(pm, x, z) before and after the WritePixel line, and it DOES work, the value is changed.

But, when I'm drawing the pixmap, expecting only pure white to be left in it, there is no change. My picture is exactly like it was before.

Am I missing something with how pixmaps works here? I got the blur (first link) which works almost the exact same way, to work without problems. If I erase my "bloomPixmap(pixmap)" function call and replace it with a "blurPixmap(pixmap)" then the picture is blurred, so I'm sure no other part of my code is wrong, such as a typo (I'm using superstrict anyway)


amonite(Posted 2008) [#2]
Hello,

If you are using superstrict you must provide the type the function should
return .

I ran your function and if you put -1 instead of -16777216 as the argb value then it gives the result your are expecting (white color).


Drakim(Posted 2008) [#3]
thanks, I'll test it tomorrow again. I have no idea why it doesn't work for me, but it might be that "-16777216" isn't a valid value? I'll try -1 when I can.


Jesse(Posted 2008) [#4]
-16777216 = $ff000000 = this leave the alpha channel set to 255 only everything else is set to 0 in other words black.
-1 = $ffffffff = alpha 255,red 255, green 255 and blue 255 = white
$ff = 255


Drakim(Posted 2008) [#5]
Ah, I see. I thought having the alpha channel set to 255 would mean the color is completely invisible. But, now I figure that it's the opposite. Silly me.

And I found what was wrong for reference. This line:
[code]
pm = ConvertPixmap(pm, PF_RGBA8888)
[code]
This seems to mess up my code if done inside the function, making a new pixmap that I modify, while I'm rendering the only one, thus seeing no effect.