View Single Post
Old 15 June 2017, 12:25   #8
chocsplease
Registered User
 
Join Date: Dec 2016
Location: london
Posts: 178
Many thanks for the replies - yes the compile works but I have really had to fiddle with it.

Anyway I have now hit a very odd problem to do with how the Amiga assigns colours on a screen with more than 4.

I'm running a 32 colour Workbench, but the Shell will only use 8 of these (0 - 7). I thought that it would simply use the first 8, since this would be the most obvious. HA! Wrong.

My WB Palette prefs are as follows -

Code:
Colour number  Red    Green    Blue
0                   155    155       155
1                   255    255       255
2                   0       0          0
3                   80     120       160
4                   238    68        68
5                   85      221      85
6                   0        68       221
7                   238     153     0
Now OK it does not actually number them but my code is reporting the following

Code:
Colour number  Red    Green    Blue
0                   155    155       155
1                   255    255       255
2                   0       0          0
3                   80     120       160
4                   120    120       120
5                   175    175       175
6                   170    145       125
7                   255    170       150
In short every colour from 4 onwards is different

Here's an exert of the code I'm using, not pretty but it should work (I think)

Code:
struct Screen *screen;
unsigned char screenName[] = "Workbench";
unsigned long colorTable[256 *3 ];
struct ViewPort *viewPort;
struct ColorMap *colorMap;
unsigned long red,green,blue;

screen = LockPubScreen(screenName);
	if (screen) /*locked the screen so we can now read info */
	{
		viewPort = &screen->ViewPort;
		colorMap = viewPort->ColorMap;
		GetRGB32(colorMap,0,colorMap->Count, colorTable);
		
		UnlockPubScreen(NULL,screen);
		numcolours=colorMap->Count;
	}
	if (numcolours>2) /*don't bother for failed or 2 colur screen*/	
	{
		for (i=0;i<numcolours;i++)
		{
			red = colorTable[i * 3 + 0] >> 24 ;
			green = colorTable[i * 3 +1] >> 24;
			blue = colorTable[i * 3 +2] >> 24;
		
			/*find reddest*/
			if ((red >= red_r) && ((green <= red_g) || (blue <= red_b))) 
			{
				colour_red=i;
				red_r=red;red_g=green;red_b=blue;
			}
			/*find greenest*/
			if ((green >= green_g) && ((red <= green_r) || (blue <= green_b)))
			{
				colour_green=i;
				green_r=red;green_g=green;green_b=blue;
			}
			/*find blueest - eventually yellow */
			if ((blue >= blue_b) && (red <= blue_r) && ((red <=blue_r) || (green <= blue_g)))
			{
				colour_blue=i;
				blue_r=red;blue_g=green;blue_b=blue;
			}
               }
	}
I wanted to have the code display the %used in a different colour depending on how full the disk was, green ish for less than 60%, yellowish for 61% to 90% and reddish for 90+%.

I worked out some code that finds the most red, green etc colour but it fails as its not seeing the same numbers as the system is actually using and I have no idea how to get it to do so.

Anyone got any ideas on this?

Last edited by chocsplease; 15 June 2017 at 12:36.
chocsplease is offline  
 
Page generated in 0.04505 seconds with 11 queries