09-19-2004, 08:08 PM
Yup...
The blender:
Blender.Map:
This is only for the windows default 8bit palette, it will only produce "good" results if you actually load a BMP with the standard palette included (pretty much any 256 color BMP saved with MS Paint)
The blender:
Code:
'Desc.: Windows Standard 256 colour BMP palette blender
'
'For: QBASIC [Any version]
'
'Author: J. Pihl (Z!re a.k.a XiberLord)
'
'Usage: NewCol = BLENDP2P(R1, G1, B1, R2, G2, B2, BlenderMap())
' NewCol = BLEND(OldCol, R, G, B, BlenderMap())
' NewCol = BLENDC2C(OldCol, BlendCol, BlenderMap())
'Where R and G is a value in the range 0-7
'And blue is a value in the range 0-3
'
'NOTE: Value will wrap around in some cases
' creating an unwanted effect, but I'm
' too lazy/tired to fix that now.
'
DEFINT A-Z
'$DYNAMIC
DECLARE FUNCTION BlendP2P% (r1%, g1%, b1%, r2%, g2%, b2%, bmap%()) 'fastest
DECLARE FUNCTION Blend% (start%, ir%, ig%, ib%, bmap%()) 'average, useful
DECLARE FUNCTION BlendC2C% (origcol%, blendcol%, bmap%()) 'slow, easiest
CLS : SCREEN 13
'Load blendermap
DIM SHARED BlenderMap(255) AS INTEGER
OPEN "blender.map" FOR INPUT AS #1
FOR a = 0 TO 255
INPUT #1, BlenderMap(a)
NEXT
CLOSE #1
FUNCTION Blend% (start, ir, ig, ib, bmap())
nb = start \ 64 + ib
IF nb > 3 THEN nb = 3
s = start MOD 64
nr = s \ 8 + ir
IF nr > 7 THEN nr = 7
s = s MOD 8
ng = s + ig
IF ng > 7 THEN ng = 7
Blend% = bmap(nr * 8 + ng + nb * 64)
END FUNCTION
FUNCTION BlendC2C (origcol, blendcol, bmap())
nb = origcol \ 64 + blendcol \ 64
IF nb > 3 THEN nb = 3
s = origcol MOD 64
s2 = blendcol MOD 64
nr = s \ 8 + s2 \ 8
IF nr > 7 THEN nr = 7
s = s MOD 8
s2 = s2 MOD 8
ng = s + s2
IF ng > 7 THEN ng = 7
BlendC2C% = bmap(nr * 8 + ng + nb * 64)
END FUNCTION
FUNCTION BlendP2P% (r1, g1, b1, r2, g2, b2, bmap())
nb = b1 + b2
IF nb > 3 THEN nb = 3
nr = r1 + r2
IF nr > 7 THEN nr = 7
ng = g1 + g2
IF ng > 7 THEN ng = 7
BlendP2P% = bmap(nr * 8 + ng + nb * 64)
END FUNCTION
Blender.Map:
Code:
000, 004, 008, 012, 016, 020, 024, 028, 032, 036, 040, 044, 048, 052, 056, 060, 064, 068, 072, 076, 080, 084, 088, 092, 096, 100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144, 148, 152, 156, 160, 164, 168, 172, 176, 180, 184, 188, 192, 196, 200, 204, 208, 212, 216, 220, 224, 228, 232, 236, 240, 244, 248, 252
001, 005, 009, 013, 017, 021, 025, 029, 033, 037, 041, 045, 049, 053, 057, 061, 065, 069, 073, 077, 081, 085, 089, 093, 097, 101, 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, 145, 149, 153, 157, 161, 165, 169, 173, 177, 181, 185, 189, 193, 197, 201, 205, 209, 213, 217, 221, 225, 229, 233, 237, 241, 245, 249, 253
002, 006, 010, 014, 018, 022, 026, 030, 034, 038, 042, 046, 050, 054, 058, 062, 066, 070, 074, 078, 082, 086, 090, 094, 098, 102, 106, 110, 114, 118, 122, 126, 130, 134, 138, 142, 146, 150, 154, 158, 162, 166, 170, 174, 178, 182, 186, 190, 194, 198, 202, 206, 210, 214, 218, 222, 226, 230, 234, 238, 242, 246, 250, 254
003, 007, 011, 015, 019, 023, 027, 031, 035, 039, 043, 047, 051, 055, 059, 063, 067, 071, 075, 079, 083, 087, 091, 095, 099, 103, 107, 111, 115, 119, 123, 127, 131, 135, 139, 143, 147, 151, 155, 159, 163, 167, 171, 175, 179, 183, 187, 191, 195, 199, 203, 207, 211, 215, 219, 223, 227, 231, 235, 239, 243, 247, 251, 255
This is only for the windows default 8bit palette, it will only produce "good" results if you actually load a BMP with the standard palette included (pretty much any 256 color BMP saved with MS Paint)