Grey Scale Bitmaps

From QB64 Wiki
Revision as of 00:22, 6 September 2010 by imported>Clippy
Jump to navigation Jump to search

SUB TrueCOLOR12 'Screen 12 greyscale 24 bit 'code by Bob Seguin IF BMP.PWidth * 3) MOD 4) <> 0 THEN ZeroPAD$ = SPACE$((4 - ((BMP.PWidth * 3) MOD 4))) END IF n = 3 FOR Colr = 0 TO 15 OUT &H3C8, Colr OUT &H3C9, n OUT &H3C9, n OUT &H3C9, n n = n + 4 NEXT Colr y = PictureDEPTH& - 1: o$ = " " GET #1, BMP.Offset, o$ R$ = " ": G$ = " ": B$ = " " DO x = 0 DO GET #1, , a$ GET #1, , B$ GET #1, , c$ b = ASC(a$) 'intensities from 0 to 255 g = ASC(B$) r = ASC(c$) average = (r + g + b) \ 48 'divide by 16 colors and divide by 3 for average PSET (x, y), average x = x + 1 LOOP WHILE x < PictureWIDTH& GET #1, , ZeroPAD$ y = y - 1 LOOP UNTIL y = -1 END SUB


SUB TrueCOLOR13 'Screen 13 greyscale of 24 bit 'code by Bob Seguin IF ((BMP.PWidth * 3) MOD 4) <> 0 THEN ZeroPAD$ = SPACE$((4 - ((BMP.PWidth * 3) MOD 4))) END IF SCREEN 13 FOR Colr = 0 TO 255 STEP 4 FOR Reps = 0 TO 3 OUT &H3C8, Colr + Reps OUT &H3C9, n OUT &H3C9, n OUT &H3C9, n NEXT Reps n = n + 1 NEXT Colr y = BMP.PDepth - 1: o$ = " " GET #1, BMP.Offset, o$ 'offset + 1 immediately after header R$ = " ": G$ = " ": B$ = " " DO x = 0 'set image to left side of screen DO GET #1, , B$ GET #1, , G$ GET #1, , R$ red = ASC(R$) grn = ASC(G$) blu = ASC(B$) average = (red + grn + blu) \ 3 PSET (x, y), average x = x + 1 LOOP WHILE x < BMP.PWidth GET #1, , ZeroPAD$ 'skip padder if used y = y - 1 'move up one row from bottom LOOP UNTIL y = -1 END SUB


See also:




Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page