Example #1
0
static Boolean GetDeviceGammaRampGD (GDHandle hGD, Ptr pRamp)
{
	GammaTblPtr		pTableGammaTemp = NULL;
	long 			indexChan, indexEntry;
	OSErr			err;
	
	if (pRamp)															
	{
		err = GetGammaTable (hGD, &pTableGammaTemp);					
		if ((noErr == err) && pTableGammaTemp)							
		{															
			
			unsigned char * pEntry = (unsigned char *) &pTableGammaTemp->gFormulaData + pTableGammaTemp->gFormulaSize; 
			short bytesPerEntry = (pTableGammaTemp->gDataWidth + 7) / 8; 
			short shiftRightValue = pTableGammaTemp->gDataWidth - 8; 	 
			short channels = pTableGammaTemp->gChanCnt;	
			short entries = pTableGammaTemp->gDataCnt;									
			if (3 == channels)											
			{															
				for (indexChan = 0; indexChan < channels; indexChan++)
					for (indexEntry = 0; indexEntry < 256; indexEntry++)
						*((unsigned char *) pRamp + (indexChan * 256) + indexEntry) = 
						  *(pEntry + indexChan * entries * bytesPerEntry + indexEntry * entries * bytesPerEntry / 256) >> shiftRightValue;
			}
			else														
			{
				for (indexChan = 0; indexChan < 768; indexChan += 256)	
					for (indexEntry = 0; indexEntry < 256; indexEntry++) 
						*((unsigned char *) pRamp + indexChan + indexEntry) = 
						  *(pEntry + indexEntry * entries * bytesPerEntry / 256) >> shiftRightValue;
			}
			return true;
		}
Example #2
0
static Boolean GetDeviceGammaRampGD (GDHandle hGD, Ptr pRamp)
{
	GammaTblPtr		pTableGammaTemp = NULL;
	long 			indexChan, indexEntry;
	OSErr			err;
	
	if (pRamp)															/* ensure pRamp is allocated */
	{
		err = GetGammaTable (hGD, &pTableGammaTemp);					/* get a pointer to the current gamma */
		if ((noErr == err) && pTableGammaTemp)							/* if successful */
		{															
			/* fill ramp */
			unsigned char * pEntry = (unsigned char *) &pTableGammaTemp->gFormulaData + pTableGammaTemp->gFormulaSize; /* base of table */
			short bytesPerEntry = (pTableGammaTemp->gDataWidth + 7) / 8; /* size, in bytes, of the device table entries */
			short shiftRightValue = pTableGammaTemp->gDataWidth - 8; 	 /* number of right shifts device -> ramp */
			short channels = pTableGammaTemp->gChanCnt;	
			short entries = pTableGammaTemp->gDataCnt;									
			if (3 == channels)											/* RGB format */
			{															/* note, this will create runs of entries if dest. is bigger (not linear interpolate) */
				for (indexChan = 0; indexChan < channels; indexChan++)
					for (indexEntry = 0; indexEntry < 256; indexEntry++)
						*((unsigned char *) pRamp + (indexChan * 256) + indexEntry) = 
						  *(pEntry + indexChan * entries * bytesPerEntry + indexEntry * entries * bytesPerEntry / 256) >> shiftRightValue;
			}
			else														/* single channel format */
			{
				for (indexChan = 0; indexChan < 768; indexChan += 256)	/* repeat for all 3 channels (step by ramp size) */
					for (indexEntry = 0; indexEntry < 256; indexEntry++) /* for all entries set vramp value */
						*((unsigned char *) pRamp + indexChan + indexEntry) = 
						  *(pEntry + indexEntry * entries * bytesPerEntry / 256) >> shiftRightValue;
			}
			return true;
		}
Example #3
0
static Ptr GetDeviceGamma (GDHandle hGD)
{
	GammaTblPtr		pTableGammaDevice = NULL;
	GammaTblPtr		pTableGammaReturn = NULL;	
	OSErr			err;
	
	err = GetGammaTable (hGD, &pTableGammaDevice);					
	if ((noErr == err) && pTableGammaDevice)						
		pTableGammaReturn = (GammaTblPtr) CopyGammaTable (pTableGammaDevice); 

	return (Ptr) pTableGammaReturn;
}
Example #4
0
static Ptr GetDeviceGamma (GDHandle hGD)
{
	GammaTblPtr		pTableGammaDevice = NULL;
	GammaTblPtr		pTableGammaReturn = NULL;	
	OSErr			err;
	
	err = GetGammaTable (hGD, &pTableGammaDevice);					/* get a pointer to the devices table */
	if ((noErr == err) && pTableGammaDevice)						/* if succesful */
		pTableGammaReturn = (GammaTblPtr) CopyGammaTable (pTableGammaDevice); /* copy to global */

	return (Ptr) pTableGammaReturn;
}