Notifications
Clear all

[Closed] Bitmap Magic Number


 try(destroydialog rampRol) catch()
 rollout rampRol "Gradient" width:270 height:30
 (
 	bitmap bm width:260 height:20 pos:[4,5]
 	
 	on rampRol open do
 	(
 		local bmp = bitmap 256 16
 		cols = for k=0 to 255 collect 
 		(
 			c = black
 			c.v = k
 			c
 		) 
 		for y=0 to 15 do setPixels bmp [0,y] cols
 		bm.bitmap = bmp
 	)
 )
 createdialog rampRol bgcolor:red
 

why is COLOR 240 240 240 transparent, and is there any way to solve the issue?

14 Replies

Sorry… I tried but I dont get it, when I open the bitmap in VFB using “display bm.bitmap” and all alpha values are 1…

That is curious indeed.
Unless you really want the sunken edge, you could use an imgTag instead. In there you can control the color value to be treated as transparent.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

sunken edge is not a problem. imgTag control draws the same bitmap ~5 times slower than bitmap control

 lo1

no issue on max 2009.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

that’s right. it happens since 2010, after they added dark scheme as default.

why is 240?

that’s crazy. tested on 2011 with light scheme and it’s broken here too. it seems to only be a problem if all 3 rgb values are set to 240. so 240 240 241 works just fine…

exactly… 240 is a magic number, as i said.

2 Replies
(@gravey)
Joined: 11 months ago

Posts: 0

240 in binary is 11110000

is this relevant? no idea

(@denist)
Joined: 11 months ago

Posts: 0

i don’t know how it can help but:
240 = 53+59+61+67 (sum of 4 consecutive prime numbers)
240 = 17+19+23+31+37+41+43 (sum of 7 consecutive prime numbers)
any other clue?

I think the answer is 42

Here is a surprising twist – it might not be Autodesk’s fault!

I copied the code and run it in Max 2012 – it looked GOOD!

So I tried to figure out what is different in my setup.
Well, due to the nature of my work (creating screenshots for documentation), I tend to run the Classic Windows color scheme in Window 7.
So I switched to the Win 7 default Air setup and got the transparent color 240!

So it happens only when windows is running its native color scheme, but not in classic mode.

Some Googling shows that the number 240 has a special meaning in some cases, not sure if it is relevant, but…

A master palette built this way can be filled with up to 8R×8G×4B = 256 colors, but this does not leave space in the palette for reserved colors, color indices that the program could use for special purposes. It is more general to use only 6R×6G×6B = 216 (as in the Web colors case), 6R×8G×5B = 240 or 6R×7G×6B = 252, which leave room for some reserved colors.

Then, when loading the mosaic of image thumbnails (or other heterogeneous images), the program simply maps every original indexed color pixel to its most approximated in the master palette (after dumping this into the hardware color registers), and writes the result in the video buffer. Here is a sample of a simple mosaic of the four image thumbnails using a master palette of 240 RGB arranged colors plus 16 additional intermediate shades of gray; all images are put together without a significant loss of color accuracy:

http://en.wikipedia.org/wiki/Palette_(computing)

So it is quite possible that Microsoft is using a 240 colors palette and assuming color 240 as special, but it could be totally irrelevant…

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

i don’t blame on Autodesk. it’s not their fault. i had many years free of this problem… thanks! i have many other controls that work… just work… thanks! and i can safely use all other 16777215 colors!

Ah… I also tested on 2012 using Classic theme… that’s why I didnt get it :d