summaryrefslogtreecommitdiff
path: root/osframework/source/SexyAppFramework/MI_GetRLAlphaData.inc
blob: 2dcf3ec656405764b58ba7983725a15daf00113a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
{		
	
	uchar* aWPtr = mRLAlphaData;
	
	if (mWidth==1)
	{
		memset(aWPtr,1,mHeight);
	}
	else
	{
		for (int aRow = 0; aRow < mHeight; aRow++)			
		{
			int aRCount = 1;
			int aRLCount = 1;

			int anAVal = NEXT_SRC_COLOR >> 24;
			int aLastAClass = (anAVal == 0) ? 0 : (anAVal == 255) ? 1 : 2;

			while (aRCount < mWidth)
			{
				aRCount++;				

				anAVal = NEXT_SRC_COLOR >> 24;
				int aThisAClass = (anAVal == 0) ? 0 : (anAVal == 255) ? 1 : 2;

				if ((aThisAClass != aLastAClass) || (aRCount == mWidth))
				{
					if (aThisAClass == aLastAClass)
						aRLCount++;

					for (int i = aRLCount; i > 0; i--)
					{
						if (i >= 255)
							*aWPtr++ = 255;
						else
							*aWPtr++ = i;
					}					

					if ((aRCount == mWidth) && (aThisAClass != aLastAClass))
						*aWPtr++ = 1;

					aLastAClass = aThisAClass;
					aRLCount = 1;
				}
				else
				{
					aRLCount++;
				}
			}
		}
	}
}