. See Other Thread
The Really fast way to GreyScale Images (DirectX)
BlitzMax Forums/BlitzMax Beginners Area/The Really fast way to GreyScale Images (DirectX) 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:
* BTW, the Render2Texture demo runs (max app window appears) then closes down promptly.
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
' indiepaths fast greyscale function Graphics 640,480,0 i:timage=LoadImage("testimage.png") MidHandleImage i Local b@[8] , fac% , dr%=1 , tog%=True Repeat Cls If KeyDown(KEY_LSHIFT) dr=-1 Else dr=1 b[0] = (b[0]+(dr*KeyHit(KEY_1))) Mod 16 b[1] = (b[1]+(dr*KeyHit(KEY_2))) Mod 16 b[2] = (b[2]+(dr*KeyHit(KEY_3))) Mod 16 b[3] = (b[3]+(dr*KeyHit(KEY_4))) Mod 16 b[4] = (b[4]+(dr*KeyHit(KEY_5))) Mod 16 b[5] = (b[5]+(dr*KeyHit(KEY_6))) Mod 16 b[6] = (b[6]+(dr*KeyHit(KEY_7))) Mod 16 b[7] = (b[7]+(dr*KeyHit(KEY_8))) Mod 16 fac = (b[7]*$10000000) + (b[6]*$1000000) + (b[5]*$100000) + (b[4]*$10000) +( b[3]*$1000) + (b[2]*$100) + (b[1]*$10) + b[0] If MouseHit(1) tog=Not tog SetImageMono tog, fac DrawImage i,MouseX(),MouseY() 'SetImageMono False DebugLog "dwFactor = $"+Hex(fac) Flip Until KeyHit(KEY_ESCAPE) End Function SetImageMono(state%,dwFactor%=$FFF00000) If state PrimaryDevice.device.SetRenderState(D3DRS_TEXTUREFACTOR, dwFactor) PrimaryDevice.device.SetTextureStageState(0, D3DTSS_COLOROP,D3DTOP_DOTPRODUCT3) PrimaryDevice.device.SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE) PrimaryDevice.device.SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR) Else PrimaryDevice.device.SetRenderState(D3DRS_TEXTUREFACTOR, $FFFFFFFF ) PrimaryDevice.device.SetTextureStageState(0, D3DTSS_COLOROP,D3DTOP_MODULATE) PrimaryDevice.device.SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE) PrimaryDevice.device.SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_DIFFUSE) EndIf End Function
* BTW, the Render2Texture demo runs (max app window appears) then closes down promptly.
Hmmn, Perhaps you could try the example again, this time you will get a console window that should display the error.
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.
But I can't get the proper results with it.
BlackSp1der has posted some source code related to pixmaps which is quite fast.
Same again Tim. No console appears though.
@Jim, Sure you did not download the old cached file?
The new file is a debug build with a console.
The new file is a debug build with a console.
Works now. I re-downloaded as Example3.rar
It works?!?!? I did not change anything apart from the debug build.
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.
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.
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?
I've been playing with the parameters, but don't see any way to prevent that from happening?
Does a factor of $50FEFF help?
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.
Can people post some screen shots, it looks like some may be getting negative images, whereas I am not.
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.


(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.