The Really fast way to GreyScale Images (DirectX)

BlitzMax Forums/BlitzMax Beginners Area/The Really fast way to GreyScale Images (DirectX)

TartanTangerine (was Indiepath)(Posted 2006) [#1]
. See Other Thread


EOF(Posted 2006) [#2]
Very nice.
I'm guessing there are tons of render states such as AND, OR, XOR, BLEND, ALPHA, DIFFUSE, BUMPMAP, ..

http://www.toymaker.info/Games/html/texture_states.html

For the greyscale example I find a dwFactor of $50FEFF produces a good result.

I knocked this example up which lets you quickly change the dwFactor by using the keys 1-8 to change the digits in the hex value:
dwFactor   $ 0 0 0 0 0 0 0 0
             ^ ^ ^ ^ ^ ^ ^ ^
Key          8 7 6 5 4 3 2 1  

MOUSE1 = toggle effect on/off





* BTW, the Render2Texture demo runs (max app window appears) then closes down promptly.


TartanTangerine (was Indiepath)(Posted 2006) [#3]
Hmmn, Perhaps you could try the example again, this time you will get a console window that should display the error.


Grisu(Posted 2006) [#4]
Ouch, the coude seems interesting.
But I can't get the proper results with it.

BlackSp1der has posted some source code related to pixmaps which is quite fast.


EOF(Posted 2006) [#5]
Same again Tim. No console appears though.


TartanTangerine (was Indiepath)(Posted 2006) [#6]
@Jim, Sure you did not download the old cached file?

The new file is a debug build with a console.


EOF(Posted 2006) [#7]
Works now. I re-downloaded as Example3.rar


TartanTangerine (was Indiepath)(Posted 2006) [#8]
It works?!?!? I did not change anything apart from the debug build.


EOF(Posted 2006) [#9]
I have 2 versions here:

render2image.exe at 923Kb - Does not work (pops up and closes)
render2image.exe at 561Kb - Works (complete with DOS output)


Have you looked at other render methods such as Invert, XOR, AND, etc ..
The Amiga Blitz2 had these and it would be nice to have a play with this sort of stuff again.


xlsior(Posted 2006) [#10]
Very interesting, although the default values also seem to convert it to negative (black becomes white, and vice-versa)

I've been playing with the parameters, but don't see any way to prevent that from happening?


EOF(Posted 2006) [#11]
Does a factor of $50FEFF help?


xlsior(Posted 2006) [#12]
Does a factor of $50FEFF help?


Nope, had already tried that after seeing the posting above.
I have a mostly-orange image (clouds) with a dark line of trees at the bottom.

The trees will still turn almost completely white with the $50FEFF, or anything tlese I tried so far.


TartanTangerine (was Indiepath)(Posted 2006) [#13]
Can people post some screen shots, it looks like some may be getting negative images, whereas I am not.


xlsior(Posted 2006) [#14]
OK, here's an example:




(This is using the SetMono($FFFF0000) from your original example up above... The most obviously 'wrong' part are the trees, which should be black if all it does is convert to B&W.

Additionally, it looks like the modified version has an enormous increase in visual artifacts over the original, although that could be related to the higher contrast of the B&W version. (Although desaturating the image in a paint program does not appear to increase the visibility of artifacts)
And even though the colors are apparently reverses, it's no a true negative either, because if I invert the colors of the B&W picture shown by your code, it looks a lot darker than when I manually desaturate the color image in a paint program.