Image reduce colors
Posted: Sun Dec 25, 2011 5:26 pm
Hi all.
There must be a easier way than this.
This is what I am trying to achieve:
* Take a image from webcam
* Reduce image to 2 or 4 bitplanes
(next step is to take out everything within a span to find a specific marker, like a red circle or something like that)
Right now I have to save as PNG with 4 bitplanes and then load the image again... that is slooooow..
There must be a easier way than this.
This is what I am trying to achieve:
* Take a image from webcam
* Reduce image to 2 or 4 bitplanes
(next step is to take out everything within a span to find a specific marker, like a red circle or something like that)
Right now I have to save as PNG with 4 bitplanes and then load the image again... that is slooooow..
Code: Select all
OpenWindow(0,0,0,640,480,"",#PB_Window_ScreenCentered|#PB_Window_SystemMenu)
AddWindowTimer(0,0, 50)
UsePNGImageDecoder()
UsePNGImageEncoder()
Repeat
Event = WindowEvent()
If Event = #PB_Event_Timer
MX_Release(Image)
image = MXSnapshot_TakeSnapshot(640)
tempimage=CreateImage(#PB_Any,640,480)
StartDrawing(ImageOutput(tempimage))
DrawImage(image,0,0,320,240)
StopDrawing()
SaveImage(tempimage,GetTemporaryDirectory()+"temp.png",#PB_ImagePlugin_PNG,0,2)
FreeImage(tempimage)
StartDrawing(WindowOutput(0))
DrawAlphaImage(ImageID(LoadImage(#PB_Any,GetTemporaryDirectory()+"temp.png")),0,0)
StopDrawing()
EndIf
Until Event=#PB_Event_CloseWindow
MXSnapshot_StopSession()