You are not logged in or registered. Please login or register to use the full functionality of this board...
The QB64 Edition
Basic Dithering/Convert to BW - Printable Version

+- The QB64 Edition (http://www.thejoyfulprogrammer.com/qb64/forum)
+ Thread: Basic Dithering/Convert to BW (/showthread.php?tid=513)



Basic Dithering/Convert to BW - Aureal - 10-04-2016 04:50 PM

This is my simple method to convert an Image to B/W. Can someone help me doing Bayer Dithering?

_FULLSCREEN: _MOUSEHIDE: IF COMMAND$ = "" THEN Parameter$ = "earth.jpg" ELSE Parameter$ = COMMAND$
DIM SHARED VideoWidth: VideoWidth = 800
DIM SHARED VideoHeight: VideoHeight = 600
DIM SHARED PointReturn AS _UNSIGNED LONG
SCREEN _NEWIMAGE(VideoWidth, VideoHeight, 32)
Image = _LOADIMAGE(Parameter$, 32)
_PUTIMAGE (0, 0), Image: SLEEP: RenderDithering

SUB RenderDithering 'Actual Rendering!
DO
DO
x = x + 1
PointReturn = POINT(x, y)
IF PointReturn < 4289243304 THEN PSET (x, y), _RGB32(0, 0, 0) ELSE PSET (x, y), _RGB32(255, 255, 255)
IF x = VideoWidth THEN EXIT DO
LOOP
IF y = VideoHeight THEN EXIT DO
y = y + 1
x = 0
LOOP
END SUB